libj-object-search
v1.1.0
Published
This is used to search in objects' properties
Downloads
1
Readme
libj-object-search
Part of libj tools
This is used to search in objects' properties
Usage (npm)
npm install libj-object-search
import { searchObjects } from 'libj-object-search'
var list = [
{ name: 'ali', family: 'farahi' },
{ name: 'monir', family: 'marahi' },
{ name: 'hasan', family: 'farahmanesh' },
]
it('all properties', function () {
var res = searchObjects('arahi', list)
assert.deepEqual(res, [
{ name: 'ali', family: 'farahi' },
{ name: 'monir', family: 'marahi' },
])
})
it('name with no results : arahi', function () {
var res = searchObjects('arahi', list, ['name'])
assert.deepEqual(res, [])
})
it('family: arahi', function () {
var res = searchObjects('arahi', list, ['family'])
assert.deepEqual(res, [
{ name: 'ali', family: 'farahi' },
{ name: 'monir', family: 'marahi' },
])
})
it('family : farah', function () {
var res = searchObjects('farah', list, ['family'])
assert.deepEqual(res, [
{ name: 'ali', family: 'farahi' },
{ name: 'hasan', family: 'farahmanesh' },
])
})
Test
- Run this in a separate command line to start node server
node server.js
- Run one of the following to re-create bundles
npm test
npm run dev
npm run dev:watch
- Navigate to http://localhost:3000
Build
npm run build
npm run build:watch