Socket
Book a DemoInstallSign in
Socket

keys-length

Package Overview
Dependencies
Maintainers
1
Versions
1
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

keys-length

Get the length of the keys on an object. Much faster than Object.keys()

latest
Source
npmnpm
Version
0.1.0
Version published
Maintainers
1
Created
Source

keys-length NPM version

Get the length of the keys on an object. Much faster than Object.keys()

If you need the length of an object's properties, excluding prototype properties, use object-length

Install

Install with npm

npm i keys-length --save

Usage

var len = require('keys-length');

len({a: 'b', c: 'd', e: 'f'});
//=> 3
  • expand-object: Expand a string into a JavaScript object using a simple notation.
  • object-length: Get the length of an object's properties, excluding prototype properties. Works with dontEnum bugs.

Comparison to Object.keys()

#1: 2 keys
  'for-in loop' x 24,570,016 ops/sec ±0.65% (93 runs sampled)
  'Object.keys()' x 3,840,164 ops/sec ±0.62% (97 runs sampled)

#2: 5 keys
  'for-in loop' x 22,487,684 ops/sec ±0.83% (91 runs sampled)
  'Object.keys()' x 3,169,150 ops/sec ±0.59% (97 runs sampled)

#3: 10 keys
  'for-in loop' x 20,201,512 ops/sec ±1.06% (94 runs sampled)
  'Object.keys()' x 2,519,700 ops/sec ±0.62% (94 runs sampled)

#4: 52 keys
  'for-in loop' x 10,519,640 ops/sec ±0.61% (97 runs sampled)
  'Object.keys()' x 791,094 ops/sec ±0.63% (94 runs sampled)

Running tests

Install dev dependencies:

npm i -d && npm test

Contributing

Pull requests and stars are always welcome. For bugs and feature requests, please create an issue

Author

Jon Schlinkert

License

Copyright (c) 2015 Jon Schlinkert Released under the MIT license.

This file was generated by verb-cli on May 12, 2015.

FAQs

Package last updated on 12 May 2015

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts