A convenient lib to manipulate object in JavaScript arrays.
Explore the docs »
View Demo
·
Report Bug
·
Request Feature
Convenient functions to query and change objects in a JavaScript array. It is useful to manipulate local storages mirroring a server database.
$ npm i array-simple-query --save
import * as ASQ from 'array-simple-query';
const books = [{ 'id': 1, 'title': 'English course', 'author': {first_name: 'Joe', last_name:'Doe'}, 'year': 2009 },
{ 'id': 2, 'title': 'Italian course', 'author': {first_name: 'Pinco', last_name:'Pallino'}, 'year': 2010 },
{ 'id': 3, 'title': 'German course', 'author': {first_name: 'Max', last_name:'Musterman'}, 'year': 2009 },
{ 'id': 4, 'title': 'Portugues course', 'author': {first_name: 'Ciclano', last_name:'Silva'}, 'year': 2010 }];
// simple query
const englishBook = ASQ.getObject(books, {'title':'English course'});
//nested query
const pallinosBook = ASQ.getObject(books, {'author.last_name':'Pallino'});
//negation
const nonGermanBooks = ASQ.filterObjects(books,{'!title': 'German course'});
//deletion
const positionOfDeletedElements = ASQ.deleteObjects(books, {'year': 2009});
This package is in development.
This project is licensed under the MIT License
Generated using TypeDoc