Various helper functions for working with object and arrays
npm install obj-helper
var oh = require('obj-helper');
var obj = {
name: 'Luke',
age: 19,
druid: 'R2D2'
}
var objSize = oh.size(obj); // returns 3
var obj = {
name: 'Luke',
age: 19,
druid: 'R2D2'
}
var lukeToStr = oh.objtoStr(obj); // returns luke19R2D2
var obj = {
name: 'Luke',
age: 19,
druid: 'R2D2'
}
var obj2 = {
name: 'Luke',
age: 19,
druid: 'R2D2'
}
var objsEqual = oh.compare(obj,obj2); // returns true
var rebels = [
{
name: 'Han',
job: 'Smuggler',
age: 29
},
{
name: 'Leia',
job: 'Princess',
age: 19
},
{
name: 'Chewbacca',
job: 'Pilot',
age: 200
}
];
oh.indexOfObj(rebels, {
name: 'Chewbacca',
job: 'Pilot',
age: 200
}); // returns 2