2.0.2 • Published 1 year ago

to-item v2.0.2

Weekly downloads
-
License
MIT
Repository
github
Last release
1 year ago

CodeQL Coverage

to-item

to-item is polyfil for mapping any javascript Object to one item of given set, which can be again any Object.

Instalation

npm install to-item

Test

npm run test

Usage

Basic usage for mapping any object (for example string) to one item of given set:

require('to-item');

"Some String".toItem([10, 15, 20]);  //15

Run A-B test. Based of given cookie run one of method:

require('to-item');

let funcA = function(){
    console.log("function A");
}
let funcB = function(){
    console.log("function B");
}
cookieValue.toItem([funcA, funcB])();

Get random IP from pool:

require('to-item');

let host = Math.random().toItem(['10.0.0.120', '10.0.0.121', '10.0.0.122']);

Get tip of the day:

require('to-item');

let tip = (new Date()).getDay().toItem(arrayOfDailyTips);

... and many other use cases ;)

2.0.2

1 year ago

2.0.1

2 years ago

2.0.0

3 years ago

1.0.9

3 years ago

1.0.8

3 years ago

1.0.7

3 years ago

1.0.6

3 years ago

1.0.5

3 years ago

1.0.4

3 years ago

1.0.3

3 years ago

1.0.2

3 years ago

1.0.1

3 years ago

1.0.0

3 years ago