Zero Dependency Extension of Javascript Array class with record data handling capabilities
Note: Further information on recordarray.js.ie or recordarray.com
npm install recordarray
https://unpkg.com/recordarray/src/RecordArray.js
const RecordArray = require('recordarray');
const users = new RecordArray([
{id: 1, name: 'Admin', type: 'admin'},
{id: 2, name: 'Bob', type: 'guest'},
{id: 3, name: 'Sam', type: 'guest'}
]);
console.log( 'User with ID 1 = ', users.findOneByID(1).name );
// Output: "Admin"
console.log( 'Guest Users Reverse Alphabetically = ', users
.findBy('type', 'guest')
.sortBy('name','DESC')
.listValues('name')
.join(', ')
);
// Output: "Sam, Bob"
- compare
- compareRecords
As this class extends the base Array class it inherits all methods from that class, but may need these alternatives to work with an array of records via their fields.
- findBy
- findByID
- findByTag
- findOne
- findOneByID
- findOneByTag
- matchBy
- matchByID
- matchByTag
- unique
- uniqueBy
- clone
- toArray
- listValues
- getName
- getNameByTag
- indexBy
- indexByID
- indexByTag
- sortBy
- sortASC
- sortDESC
- extend
- merge
- create
- read
- update
- delete
- list