This repository has been archived by the owner on Oct 28, 2021. It is now read-only.
-
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
0 parents
commit 50f22c3
Showing
62 changed files
with
2,733 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
root = true | ||
|
||
[*] | ||
insert_final_newline = true | ||
indent_size = 2 | ||
indent_style = tab | ||
tab_width = 2 | ||
trim_trailing_whitespace = true | ||
|
||
[*.md] | ||
indent_style = space |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
# User-specific files | ||
*.vs | ||
*.user | ||
|
||
# Package Managers | ||
node_modules | ||
npm-debug.log | ||
|
||
# Build Artifacts | ||
*.lock.json | ||
*-lock.json | ||
*.cache |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
## 1.0.0 | ||
|
||
* Initial release! |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
MIT License | ||
|
||
Copyright (c) 2020 roydukkey | ||
|
||
Permission is hereby granted, free of charge, to any person obtaining a copy | ||
of this software and associated documentation files (the "Software"), to deal | ||
in the Software without restriction, including without limitation the rights | ||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell | ||
copies of the Software, and to permit persons to whom the Software is | ||
furnished to do so, subject to the following conditions: | ||
|
||
The above copyright notice and this permission notice shall be included in all | ||
copies or substantial portions of the Software. | ||
|
||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR | ||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, | ||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE | ||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER | ||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, | ||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE | ||
SOFTWARE. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,104 @@ | ||
# sass-list | ||
|
||
[![Release Version](https://img.shields.io/npm/v/sass-list.svg)](https://www.npmjs.com/package/sass-list) | ||
[![License](https://img.shields.io/badge/License-MIT-blue.svg)](https://opensource.org/licenses/MIT) | ||
|
||
This Sass module is for advanced list functions. | ||
|
||
## Install | ||
|
||
Install the package: | ||
|
||
```bash | ||
npm install sass-list | ||
``` | ||
|
||
Use the package like any other Sass module: | ||
|
||
```scss | ||
@use 'sass-list'; | ||
``` | ||
|
||
Depending on your setup, you may need to use the module by its full path: | ||
|
||
```scss | ||
// This is only an example | ||
@use '../node_modules/sass-list'; | ||
``` | ||
|
||
## Public API | ||
|
||
<dl> | ||
<dt><code><a href="//github.com/roydukkey/sass-module-list/tree/master/src/list/_concat.sass">concat ( $values... [, $separator] [, $bracketed] )</a></code></dt> | ||
<dd>Merges two or more lists into a new list.</dd> | ||
|
||
<dt><a href="//github.com/roydukkey/sass-module-list/tree/master/src/list/_distinct.sass"><code>distinct ( $list [, $separator] )</code></a></dt> | ||
<dd>Creates a new list with all distinct items from a list.</dd> | ||
|
||
<dt><a href="//github.com/roydukkey/sass-module-list/tree/master/src/list/_every.sass"><code>every ( $list, $predicate [, $args...] )</code></a></dt> | ||
<dd>Tests whether all items in a list satisfy the test implemented by the specified function.</dd> | ||
|
||
<dt><a href="//github.com/roydukkey/sass-module-list/tree/master/src/list/_filter.sass"><code>filter ( $list, $predicate [, $separator] [, $args...] )</code></a></dt> | ||
<dd>Creates a new list with all item from a list that satisfy the test implemented by the specified function.</dd> | ||
|
||
<dt><a href="//github.com/roydukkey/sass-module-list/tree/master/src/list/_find.sass"><code>find ( $list, $predicate [, $args...] )</code></a></dt> | ||
<dd>Returns the value of the first element from a list that satisfies the test implemented by the specified function.</dd> | ||
|
||
<dt><a href="//github.com/roydukkey/sass-module-list/tree/master/src/list/_find-nth.sass"><code>find-nth ( $list, $predicate [, $args...] )</code></a></dt> | ||
<dd>Returns the index of the first item from a list that satisfies the test implemented by the specified function; otherwise, 0 is returned, indicating that no item satisfies the test.</dd> | ||
|
||
<dt><a href="//github.com/roydukkey/sass-module-list/tree/master/src/list/_flat.sass"><code>flat ( $list [, $separator] )</code></a></dt> | ||
<dd>Creates a new list with all sub-list items concatenated into it recursively up to a specified depth.</dd> | ||
|
||
<dt><a href="//github.com/roydukkey/sass-module-list/tree/master/src/list/_includes.sass"><code>includes ( $list, $value [, $start-at] )</code></a></dt> | ||
<dd>Determines whether a list includes a certain value among its items, returning true or false as appropriate.</dd> | ||
|
||
<dt><a href="//github.com/roydukkey/sass-module-list/tree/master/src/list/_index.sass"><code>index ( $list [, $from-index] )</code></a></dt> | ||
<dd>Returns the first index at which a specified item can be found in a list; otherwise, 0 is returned, indicating that the item is not present.</dd> | ||
|
||
<dt><a href="//github.com/roydukkey/sass-module-list/tree/master/src/list/_insert-nth.sass"><code>insert-nth ( $list, $index, $value )</code></a></dt> | ||
<dd>Returns a copy of a list with the specified value inserted into the list at a given index.</dd> | ||
|
||
<dt><a href="//github.com/roydukkey/sass-module-list/tree/master/src/list/_join.sass"><code>join ( $list [, $glue] )</code></a></dt> | ||
<dd>Concatenates all of the items in an list to a string, separated by the list's separator or a specified glue string. If the list has only one item, then that item will be returned without using the glue.</dd> | ||
|
||
<dt><a href="//github.com/roydukkey/sass-module-list/tree/master/src/list/_last-index.sass"><code>last-index ( $list [, $from-index] )</code></a></dt> | ||
<dd>Returns the last index at which a specified item can be found in a list; otherwise, 0 is returned, indicating that the item is not present. The list is searched backwards, starting at a given index when specified.</dd> | ||
|
||
<dt><a href="//github.com/roydukkey/sass-module-list/tree/master/src/list/_map.sass"><code>map ( $list, $transformer [, $args...] )</code></a></dt> | ||
<dd>Creates a new list populated with the results of calling a specified function on every item in a list.</dd> | ||
|
||
<dt><a href="//github.com/roydukkey/sass-module-list/tree/master/src/list/_prepend.sass"><code>prepend ( $list, $value [, $separator] )</code></a></dt> | ||
<dd>Returns a copy of a list with the specified value added to the beginning.</dd> | ||
|
||
<dt><a href="//github.com/roydukkey/sass-module-list/tree/master/src/list/_reduce-right.sass"><code>reduce-right ( $list, $transformer [, $initial-value] [, $args...] )</code></a></dt> | ||
<dd>Reduces a list to a single value as the product of calling a specified function on every item in a list, starting with the last item to the first.</dd> | ||
|
||
<dt><a href="//github.com/roydukkey/sass-module-list/tree/master/src/list/_reduce.sass"><code>reduce ( $list, $transformer [, $initial-value] [, $args...] )</code></a></dt> | ||
<dd>Reduces a list to a single value as the product of calling a specified function on every item in a list.</dd> | ||
|
||
<dt><a href="//github.com/roydukkey/sass-module-list/tree/master/src/list/_remove.sass"><code>remove ( $list, $value )</code></a></dt> | ||
<dd>Returns a copy of a list without the specified value.</dd> | ||
|
||
<dt><a href="//github.com/roydukkey/sass-module-list/tree/master/src/list/_remove-nth.sass"><code>remove-nth ( $list, $index )</code></a></dt> | ||
<dd>Returns a copy of a list without the value at a given index.</dd> | ||
|
||
<dt><a href="//github.com/roydukkey/sass-module-list/tree/master/src/list/_replace.sass"><code>replace ( $list, $value )</code></a></dt> | ||
<dd>Reverses a list in place. The first item becomes the last, and the last item becomes the first.</dd> | ||
|
||
<dt><a href="//github.com/roydukkey/sass-module-list/tree/master/src/list/_reverse.sass"><code>reverse ( $list )</code></a></dt> | ||
<dd>Reverses a list in place. The first item becomes the last, and the last item becomes the first.</dd> | ||
|
||
<dt><a href="//github.com/roydukkey/sass-module-list/tree/master/src/list/_slice.sass"><code>slice ( $list, $start-at [, $end-at] [, $separator] )</code></a></dt> | ||
<dd>Extracts a portion of a list into a new list selected from a starting index through a ending index.</dd> | ||
|
||
<dt><a href="//github.com/roydukkey/sass-module-list/tree/master/src/list/_some.sass"><code>some ( $list, $predicate [, $args...] )</code></a></dt> | ||
<dd>Tests whether at least one item in a list satisfies the test implemented by the specified function.</dd> | ||
|
||
<dt><a href="//github.com/roydukkey/sass-module-list/tree/master/src/list/_sort.sass"><code>sort ( $list, $compare )</code></a></dt> | ||
<dd>Sorts the items of a list in place. The default sort order is ascending, built upon converting the items into strings, then comparing their sequences of UTF-16 code units values.</dd> | ||
|
||
<dt><a href="//github.com/roydukkey/sass-module-list/tree/master/src/list/_to-string.sass"><code>to-string ( $list )</code></a></dt> | ||
<dd>Returns a string representing the specified list and its items.</dd> | ||
|
||
</dl> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
// Copyright (c) roydukkey. All rights reserved. | ||
// Licensed under the MIT. See LICENSE file in the project root for full license information. | ||
//// | ||
/// @author roydukkey | ||
/// @group api | ||
//// | ||
@forward 'src' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
{ | ||
"name": "sass-list", | ||
"description": "This Sass module is for advanced list functions.", | ||
"version": "1.0.0", | ||
"author": "roydukkey", | ||
"license": "MIT", | ||
"repository": { | ||
"type": "git", | ||
"url": "git+https://github.com/roydukkey/sass-module-list.git" | ||
}, | ||
"homepage": "https://github.com/roydukkey/sass-module-list#readme", | ||
"bugs": { | ||
"url": "https://github.com/roydukkey/sass-module-list/issues" | ||
}, | ||
"keywords": [ | ||
"sass", | ||
"scss", | ||
"dart-sass", | ||
"list", | ||
"array", | ||
"slice" | ||
], | ||
"dependencies": { | ||
"sass": "^1.23.0" | ||
}, | ||
"devDependencies": { | ||
"jest": "^25.1.0", | ||
"sass-true": "^5.0.0" | ||
}, | ||
"main": "./index.sass", | ||
"scripts": { | ||
"test": "jest" | ||
}, | ||
"jest": { | ||
"testEnvironment": "node" | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
// Copyright (c) roydukkey. All rights reserved. | ||
// Licensed under the MIT. See LICENSE file in the project root for full license information. | ||
//// | ||
/// @author roydukkey | ||
//// | ||
@forward 'list/concat' | ||
@forward 'list/distinct' | ||
@forward 'list/every' | ||
@forward 'list/filter' | ||
@forward 'list/find-nth' | ||
@forward 'list/find' | ||
@forward 'list/flat' | ||
@forward 'list/includes' | ||
@forward 'list/index' | ||
@forward 'list/insert-nth' | ||
@forward 'list/join' | ||
@forward 'list/last-index' | ||
@forward 'list/map' | ||
@forward 'list/prepend' | ||
@forward 'list/reduce-right' | ||
@forward 'list/reduce' | ||
@forward 'list/remove-nth' | ||
@forward 'list/remove' | ||
@forward 'list/replace' | ||
@forward 'list/reverse' | ||
@forward 'list/slice' | ||
@forward 'list/some' | ||
@forward 'list/sort' | ||
@forward 'list/to-string' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,61 @@ | ||
// Copyright (c) roydukkey. All rights reserved. | ||
// Licensed under the MIT. See LICENSE file in the project root for full license information. | ||
//// | ||
/// @author roydukkey | ||
/// @group internal | ||
//// | ||
@use 'sass:meta' | ||
@use 'sass:string' | ||
@use '../list/join' | ||
|
||
|
||
/// | ||
/// The name of the function issuing the error. | ||
/// | ||
/// @type {String} | ||
/// | ||
$function: null | ||
|
||
|
||
/// | ||
/// Structures an error message stating an issue with one or more parameters. | ||
/// | ||
/// @param {String} $value - The message which describes the issue. | ||
/// @param {ArgList} $params - The names of the parameters for which there is an issue. | ||
/// @return {String} | ||
/// | ||
/// @access private | ||
/// @requires $function | ||
/// @requires join.join | ||
/// | ||
@function param($message, $params...) | ||
$params: join.join($params, ', $') | ||
@return string.unquote('$#{$params}: #{$message} for `#{$function}()`.') | ||
|
||
|
||
/// | ||
/// Gets an error message stating that a parameter received the wrong type. | ||
/// | ||
/// @param {String} $param - The name of the parameter which has received the wrong type. | ||
/// @param {*} $value - The value which was received. | ||
/// @param {String} $type - The type which is expected. | ||
/// @return {String} | ||
/// | ||
/// @access public | ||
/// @require param | ||
/// | ||
@function type($param, $value, $type) | ||
@return param('`#{meta.inspect($value)}` is not a #{string.unquote($type)}', $param) | ||
|
||
|
||
/// | ||
/// Gets an error message stating that a selector parameter received the wrong value. | ||
/// | ||
/// @return {String} | ||
/// | ||
/// @access public | ||
/// @require param | ||
/// | ||
@function separator() | ||
@return param('Must be "space", "comma", or "auto"', 'separator') |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
// Copyright (c) roydukkey. All rights reserved. | ||
// Licensed under the MIT. See LICENSE file in the project root for full license information. | ||
//// | ||
/// @author roydukkey | ||
//// | ||
@forward 'exception' as exception-* | ||
@forward 'list' | ||
@forward 'param' as param-* |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
// Copyright (c) roydukkey. All rights reserved. | ||
// Licensed under the MIT. See LICENSE file in the project root for full license information. | ||
//// | ||
/// @author roydukkey | ||
/// @group internal | ||
//// | ||
@use 'sass:list' | ||
|
||
|
||
/// | ||
/// Initialise a new list matching the bracket style of another list. | ||
/// | ||
/// @param {List} $list - The list to match. | ||
/// @return {List} | ||
/// | ||
/// @access public | ||
/// | ||
@function init($list) | ||
@return if(list.is-bracketed($list), [], ()) | ||
|
||
|
||
/// | ||
/// Returns a copy of a list with the specified value inserted into the list at a given index. | ||
/// | ||
/// @param {List} $list - The list to which the value is to be inserted. | ||
/// @param {Number} $index - The index at which the value is to be inserted. | ||
/// @param {*} $value - The value which is to be inserted. | ||
/// @param {String} $separator [auto] - The type of separator to be used by the copied list. | ||
/// @return {List} | ||
/// | ||
/// @access public | ||
/// | ||
@function insert-nth($list, $index, $value, $separator: list.separator($list)) | ||
$result: init($list) | ||
|
||
@for $n from 1 through list.length($list) | ||
|
||
@if $n == $index | ||
$result: list.append($result, $value, $separator) | ||
|
||
$result: list.append($result, list.nth($list, $n)) | ||
|
||
@return $result |
Oops, something went wrong.