shared
utils
string
object
is
extension
js
tracking
string
dom
when
selection
position
iframe
event
scroll
console
node
string
project
fs
console
fromQuantifier
Type:Function
Status:stable
Platform:jsnode
@blackbyte.sugar.shared.array
This function allows you to generate an array from a certain passed quantifier like “2”, “<10”, “>10”, “9-12”, etc…
This is useful to create arrays that are depending on user-friendly quantifier and it’s used for example in the
s-postcss-sugar-plugin for the @s.lod(&gt;2) mixin.
Params
- quantifier*-String|Number
The quantifier to generate
- settings{}TFromQuantifierSettings
Some settings to configure your array generation
Return
- -Array
The generated array
Example
import { fromQuantifier } from '@blackbyte/sugar/array'
fromQuantifier(3); // => [0,1,2]
fromQuantifier('3-5'); // => [3,4,5]
fromQuantifier('3-6', {
value(i) => `c-${i}`
}); // => ['c-3','c-4','c-5','c-6']Settings
- max*-Number
The maximum wanted when using > and >= quantifiers
- value*-Function
A function that take the current index and that MUST return the value wanted in the generated array
Author
- Olivier Bosselolivier.bossel@gmail.comhttps://blackbyte.space