minobjs
minimal object manipulation
Contents
For now, the current implementation supports isEmpty
and merge
functions over objects
export interface IObjs {
merge(...items: any[]): any;
isEmpty(obj: any): boolean;
}
Example
loading the module
const { Objs } = require("minobjs");
const obj = new Objs();
isEmpty
console.log(obj.isEmpty({}));
console.log(obj.isEmpty({ a: 1 }));
merge
const obj1 = {
a: 1,
b: 2,
c: {
a: 1,
b: 2,
c: {
d: 1,
e: 2
}
}
};
const obj2 = {
a: 1,
b: 3,
c: {
a: 1,
b: 2,
c: {
d: 1,
e: 3
}
}
};
const obj3 = {
e: 7
};
const obj4 = {
e: 8,
f: 1
};
const result = obj.merge(obj1, obj2, obj3, obj4);
console.log(result);
Instalation
yarn add minobjs
npm install minobjs