@hckrnews/store

[![NPM version][npm-image]][npm-url] [![Build Status][travis-image]][travis-url] [![Coveralls Status][coveralls-image]][coveralls-url] [![Scrutinizer Code Quality][scrutinizer-image]][scrutinizer-url]

Usage no npm install needed!

<script type="module">
  import hckrnewsStore from 'https://cdn.skypack.dev/@hckrnews/store';
</script>

README

Create store search results

NPM version Build Status Coveralls Status Scrutinizer Code Quality

Installation

npm install @hckrnews/store or yarn add @hckrnews/store

Test the package

npm run test or yarn test

Usage

import Store from '../store.js'

const testStore = new Store()

testStore.addItem({ id: 42, value: 1 })
testStore.addItem({ id: 43, value: 2 })
testStore.updateItem({ id: 42, value: 3 }, 'id')
testStore.removeItem({ id: 42 }, 'id')

const result = testStore.search({ page: 0, size: 10 })

testStore.totalCount() // 1

result.count() // 1 
result.totalCount() // 1 
result.valueOf() // [{ id: 43, value: 2 }]
result.items // [{ id: 43, value: 2 }]
result.from // 0
result.size // 10
result.page // 0