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(>2) mixin.

Params

  1. quantifier*-String|Number

    The quantifier to generate

  2. settings{}TFromQuantifierSettings

    Some settings to configure your array generation

Return

  1. -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

  1. max*-Number

    The maximum wanted when using > and >= quantifiers

  2. value*-Function

    A function that take the current index and that MUST return the value wanted in the generated array