1.0.3 • Published 2 years ago

@hckrnews/store v1.0.3

Weekly downloads
-
License
LGPL-2.1
Repository
github
Last release
2 years ago

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