ifonly
v2.2.0
Published
ifonly is function that checks if your object have only and only specific properties you passed.
Readme
ifonly
ifonly is function that checks if your object have only and only specific properties you passed.
It works in both node and client-side applications.
Example
var obj;
obj = { a: 'a'};
console.log(only(obj, ['a'])); // true because only 'a' property is present
obj = { a: 'a', b: 'b', c: 'c' };
console.log(only(obj, ['a', 'b'])); // false because 'c' property is present
obj = { a: 'a' };
console.log(ifonly(obj, ['a', 'b'])); // false because 'b' does not exist
obj = { a: 'a', b: 'b', c: 'c' };
console.log(only(obj, ['a', 'b'], ['c'])); // true because 'c' property is ignored
obj = { a: '', b: 'b', c: '' };
console.log(only(obj, ['b'])); // true because 'a' and 'c' properties are empty
obj = { a: [], b: 'b', c: {} };
console.log(only(obj, ['b'])); // true because 'a' and 'c' properties are empty