# to-item

> converts object to one item of given set

Latest version **2.0.2** (published 2023-02-21) · MIT license · 0 weekly downloads

## Install

```sh
npm install to-item
pnpm add to-item
yarn add to-item
bun add to-item
```

## Health

**Score 15/100 (F)** — status: abandoned.

Positive: no vulnerabilities.

Warnings: low downloads; no types; no esm support.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 2.0.2 |
| Published | 2023-02-21 |
| First published | 2021-05-07 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 0 |
| Unpacked size | 8.6 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 1 |
| Author | pavlikm |
| Maintainers | pavlikm |
| Keywords | string, array, object, convert, map, set, routing, hash |

## Links

- npm: https://www.npmjs.com/package/to-item
- Repository: https://github.com/pavlikm/to-item
- Homepage: https://github.com/pavlikm/to-item#readme
- Issues: https://github.com/pavlikm/to-item/issues
- npm.io page: https://npm.io/package/to-item

## Alternatives

- [express-promise-router](https://npm.io/package/express-promise-router.md) — 736.1K weekly downloads
- [next-usequerystate](https://npm.io/package/next-usequerystate.md) — 29.8K weekly downloads
- [@bitkyc08/opencodex](https://npm.io/package/@bitkyc08/opencodex.md) — 4.6K weekly downloads
- [lynkr](https://npm.io/package/lynkr.md) — 575 weekly downloads
- [baremetal.js](https://npm.io/package/baremetal.js.md) — 42 weekly downloads

## Recent versions

- 2.0.2 (latest) — 2023-02-21
- 2.0.1 — 2022-04-04
- 2.0.0 — 2021-09-30
- 1.0.9 — 2021-08-18
- 1.0.8 — 2021-05-14
- 1.0.7 — 2021-05-13
- 1.0.6 — 2021-05-13
- 1.0.5 — 2021-05-12
- 1.0.4 — 2021-05-11
- 1.0.3 — 2021-05-10
- 1.0.2 — 2021-05-07
- 1.0.1 — 2021-05-07
- 1.0.0 — 2021-05-07

## README

[![CodeQL](https://github.com/pavlikm/to-item/actions/workflows/codeql-analysis.yml/badge.svg)](https://github.com/pavlikm/to-item/actions/workflows/codeql-analysis.yml)
![Coverage](https://github.com/pavlikm/to-item/raw/master/public/badge.svg)

# 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:
```javascript
require('to-item');

"Some String".toItem([10, 15, 20]);  //15
```
Run A-B test. Based of given cookie run one of method:
```javascript
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:
```javascript
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:
```javascript
require('to-item');

let tip = (new Date()).getDay().toItem(arrayOfDailyTips);

```
... and many other use cases ;)

---
_Source: https://npm.io/package/to-item · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
