3.0.3 • Published 3 years ago

@thebespokepixel/n-selector v3.0.3

Weekly downloads
45
License
MIT
Repository
github
Last release
3 years ago

@thebespokepixel/n-selector

Smart multi-gang enumerator with global, namespaced event emission for node.js.

Publishing Status

npm Libraries.io
Travis Rollup

Development Status

Travis Libraries.io
Snyk Code-Climate Code-Climate Coverage

Documentation/Help

Inch.io Twitter

Usage

Think of n-selector as an endlessly extendable multi-way n-gang switch.

Firstly, it allows the selection of a position by the position of an option in a primary index and then returns a value or an array of all the options that fall under that position.

Secondly, it allows selection by a simple scalar value (0.0 to 1.0) and can return a value or an array of the options at that position.

       0.00 ... 0.25 ... 0.50 ... 0.75 ... 1.00
        |--------|--------|--------|--------|
Primary |    One    |    Two    |   Three   |
Gang +1 |    Red    |   Green   |    Blue   |
Gang +2 |       One       |       Two       |

select('one') - returns ['One', 'Red', 'One']
select(2) - returns ['Two', 'Green', 'One']
position(0.75) - returns ['Three', 'Blue', 'Two']

Installation

npm install --save @thebespokepixel/n-selector

Examples

import {createSelector} from '@thebespokepixel/n-selector'

const matrix = createSelector(['one', 'two', 'three'], 0)

matrix.select(0) - returns 'one'
matrix.position(0.5) - returns 'two'

Documentation

Full documentation can be found at https://thebespokepixel.github.io/n-selector/

3.0.3

3 years ago

3.0.2

3 years ago

3.0.1

3 years ago

3.0.0

3 years ago

2.0.2

4 years ago

2.0.1

4 years ago

2.0.0

4 years ago

1.0.5

5 years ago

1.0.4

5 years ago

1.0.3

5 years ago

1.0.2

5 years ago

1.0.1

5 years ago

1.0.0

5 years ago

0.2.3

5 years ago

0.2.2

5 years ago

0.2.1

6 years ago

0.2.0

6 years ago

0.1.3

7 years ago

0.1.2

7 years ago

0.1.1

8 years ago

0.1.0

8 years ago