JSPM

  • ESM via JSPM
  • ES Module Entrypoint
  • Export Map
  • Keywords
  • License
  • Repository URL
  • TypeScript Types
  • README
  • Created
  • Published
  • Downloads 73
  • Score
    100M100P100Q71172F
  • License MIT

A fast way to check if the object has a specific number of properties.

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

Patreon PayPal AMA Version Downloads Get help on Codementor

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: If true, 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. ✨

πŸ“œ License

MIT © Ionică Bizău