Skip to content

Commit

Permalink
Merge pull request #231 from krypton225/functions
Browse files Browse the repository at this point in the history
feat(functions-list): ✨ add merge function to merge any list…
  • Loading branch information
krypton225 committed Dec 10, 2023
2 parents adc05f4 + 2d9cb72 commit 644d593
Show file tree
Hide file tree
Showing 2 changed files with 65 additions and 0 deletions.
6 changes: 6 additions & 0 deletions src/functions/list/_index.scss
Original file line number Diff line number Diff line change
Expand Up @@ -41,3 +41,9 @@
// * the centered element in the list from a given one.
// @see get-centered-element-list
@forward "get-centered-element-list";

// * forwarding the "merge" module.
// * The "merge" module likely contains a function to get
// * the centered element in the list from a given one.
// @see merge
@forward "merge";
59 changes: 59 additions & 0 deletions src/functions/list/_merge.scss
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
@charset "UTF-8";

// @description
// * merge function.
// * This function merges lists together and return all in a one list.

// @access private

// @version 1.0.0

// @author Khaled Mohamed

// @license MIT

// @repository: https://github.com/krypton225/sass-pire

// @namespace list

// @module list/merge

// @dependencies:
// * - list.join (SASS function).
// * - flatten-list (function).

// @param {List} $list...
// * A group of lists that may contain nested lists.

// @throw {Exception}
// * Throws an exception if the provided parameter is not a lists.

// @example
// * .example {
// * content: merge((2, 4, 5, (12, 5, 6)), (22, 38), (44, ((323))));
// * }

// @output
// * .example {
// * content: 2 4 5 12 5 6 22 38 44 323;
// * }

// @return {List} - Returns a merged list.

@use "sass:list";
@use "./flatten-list" as func;

@function merge($lists...) {
$merged-list: ();

@each $value in $lists {
@if type-of($value) != list {
@error "merge function only accepts lists.";
}

$flatten-one-list: func.flatten($value);
$merged-list: list.join($merged-list, $flatten-one-list, space);
}

@return $merged-list;
}

0 comments on commit 644d593

Please sign in to comment.