2.2.0 • Published 10 years ago

ifonly v2.2.0

Weekly downloads
5
License
MIT
Repository
github
Last release
10 years ago

ifonly

Build Status

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
2.2.0

10 years ago

2.1.0

10 years ago

2.0.1

10 years ago

2.0.0

10 years ago

1.1.0

10 years ago

1.0.0

11 years ago