Package Exports
- obj-key-count
This package does not declare an exports field, so the exports above have been automatically detected and optimized by JSPM instead. If any package subpath is missing, it is recommended to post an issue to the original package (obj-key-count) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.
Readme
obj-key-count
A fast way to check if the object has a specific number of properties.
This is not using the Object.keys(obj).length
method but iterates a part of object until it reaches the specified count. π
βοΈ Installation
$ npm i --save obj-key-count
π Example
const objKeysCount = require("obj-key-count");
console.log(objKeysCount({}, 0));
// => true
console.log(objKeysCount({ foo: 42}, 1, true));
// => "foo"
console.log(objKeysCount({}, 1));
// => false
console.log(objKeysCount({ foo: 42, bar: "baz" }, 2));
// => true
π Documentation
objKeysCount(obj, count, sendKey)
Checks if the provided object contains a specifc number of keys.
Params
- Object
obj
: The input object. - Number
count
: The expected number of object keys. - Boolean
sendKey
: Iftrue
, the key will be returned as value. Use this when you want to check for one key and you want to use the key name.
Return
- Boolean
true
if the object has the specified number of keys,false
otherwise.
π How to contribute
Have an idea? Found a bug? See how to contribute.
π° Donations
Another way to support the development of my open-source modules is to set up a recurring donation, via Patreon. π
PayPal donations are appreciated too! Each dollar helps.
Thanks! β€οΈ
π« Where is this library used?
If you are using this library in one of your projects, add it in this list. β¨
xml-jsonify
βA liberal XML to JSON converter.