# xorderedlist

> A useful tool for managing array of object

Latest version **0.0.15** (published 2018-04-24) · MIT license · 0 weekly downloads

## Install

```sh
npm install xorderedlist
pnpm add xorderedlist
yarn add xorderedlist
bun add xorderedlist
```

## Health

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

Positive: no vulnerabilities.

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

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 0.0.15 |
| Published | 2018-04-24 |
| First published | 2018-04-20 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 0 |
| Unpacked size | 35.5 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 3 |
| Author | daiyanze |
| Maintainers | daiyanze |
| Keywords | orderedlist, orderedlist.js, list, map, database, array, store |

## Links

- npm: https://www.npmjs.com/package/xorderedlist
- Repository: https://github.com/daiyanze/OrderedList
- Homepage: https://github.com/daiyanze/OrderedList#readme
- Issues: https://github.com/daiyanze/OrderedList/issues
- npm.io page: https://npm.io/package/xorderedlist

## Recent versions

- 0.0.15 (latest) — 2018-04-24
- 0.0.14 — 2018-04-24
- 0.0.13 — 2018-04-24
- 0.0.12 — 2018-04-23
- 0.0.11 — 2018-04-23
- 0.0.10 — 2018-04-20
- 0.0.9 — 2018-04-20
- 0.0.8 — 2018-04-20
- 0.0.7 — 2018-04-20
- 0.0.6 — 2018-04-20
- 0.0.5 — 2018-04-20

## README

# XOrderedList
[![Build Status](https://travis-ci.org/daiyanze/XOrderedList.svg?branch=master)](https://travis-ci.org/daiyanze/XOrderedList)
[![npm version](https://badge.fury.io/js/xorderedlist.svg)](https://badge.fury.io/js/xorderedlist)

A useful tool to manage array of object.


### Introduction
Sometimes it would be a headache to maintain and to manipulate an array of object. ListStore is just a `Map` wrapper Object that enhances the original `Map` object. It looks like a small "database" which will help you manage arrays in a rather comfortable way.

### How to use it

install
```
npm install xorderedlist
```

example
```javascript
import OrderedList from 'xorderedlist'

const list = new OrderedList([{ id: 1, name: 'one' }])
console.log(list.size) // 1

list.push([{ id: 2, name: 'two' }])

list.unshift([{ id: 0, name: 'zero' }])

list.update([{ id: 1, name: 'update one'}])

list.insertOne({id: 1.5, name: 'one point five' }, 1)

list.delete([2])

list.findOne(0)

list.findList([1, 2])

list.mutate((orderedList) => {
  return orderedList.values.map(v => {
    v.name = 'mutate ' + v.name
  })
})
```

### APIs 
##### Properties
| Name          | Type              | default   |
| ------------- |:----------------- |:----------|
| data          | Map               | []        |
| idAttr        | String            | 'id'      |
| values        | Array             | []        |
| keys          | Array             | []        |
| size          | number            | []        |
| length        | number            | []        |
| first         | Object/undefined  | undefined |
| last          | Object/undefined  | undefined |

##### Methods
| Name          | argument           | return | description  |
| ------------- |:-------------------|:-------|:-------------|
| findOne       | id: Any            | Object | Same to Map.get. Query one result from list |
| findList      | idList: Array      | Object | Query results |
| insertOne     | obj: Object        | this   | Insert data after the given id of the list |
| unshift       | arrOfObject: Array | this   | Add data to the start of list |
| push          | arrOfObject: Array | this   | Add data at the end of list |
| update        | arrOfObject: Array | this   | Update the given data |
| delete        | idList: Array      | this   | Delete data by the given id list |
| mutate        | callback: Function, argument: Object | Array | change the data by your own method. Support one extra argument |

### License
MIT

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