Socket
Socket
Sign inDemoInstall

jsprim

Package Overview
Dependencies
3
Maintainers
1
Versions
29
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

Comparing version 1.2.2 to 1.3.0

5

CHANGES.md

@@ -7,2 +7,7 @@ # Changelog

## v1.3.0 (2016-06-22)
* #14 add safer version of hasOwnProperty()
* #15 forEachKey() should ignore inherited properties
## v1.2.2 (2015-10-15)

@@ -9,0 +14,0 @@

14

lib/jsprim.js

@@ -18,2 +18,3 @@ /*

exports.isEmpty = isEmpty;
exports.hasKey = hasKey;
exports.forEachKey = forEachKey;

@@ -126,6 +127,15 @@ exports.pluck = pluck;

function hasKey(obj, key)
{
mod_assert.equal(typeof (key), 'string');
return (Object.prototype.hasOwnProperty.call(obj, key));
}
function forEachKey(obj, callback)
{
for (var key in obj)
callback(key, obj[key]);
for (var key in obj) {
if (hasKey(obj, key)) {
callback(key, obj[key]);
}
}
}

@@ -132,0 +142,0 @@

2

package.json
{
"name": "jsprim",
"version": "1.2.2",
"version": "1.3.0",
"description": "utilities for primitive JavaScript types",

@@ -5,0 +5,0 @@ "main": "./lib/jsprim.js",

@@ -22,10 +22,19 @@ # jsprim: utilities for primitive JavaScript types

### hasKey(obj, key)
Returns true if the given object has an enumerable, non-inherited property
called `key`. [For information on enumerability and ownership of properties, see
the MDN
documentation.](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Enumerability_and_ownership_of_properties)
### forEachKey(obj, callback)
Like Array.forEach, but iterates properties of an object rather than elements
of an array. Equivalent to:
Like Array.forEach, but iterates enumerable, owned properties of an object
rather than elements of an array. Equivalent to:
for (var key in obj)
callback(key, obj[key]);
for (var key in obj) {
if (Object.prototype.hasOwnProperty.call(obj, key)) {
callback(key, obj[key]);
}
}

@@ -32,0 +41,0 @@

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc