Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

missing-keys

Package Overview
Dependencies
Maintainers
1
Versions
5
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

missing-keys - npm Package Compare versions

Comparing version 0.1.3 to 0.1.4

LICENSE

64

index.js
/*global require, module*/
/*!
* key-validator <https://github.com/tobiasoberrauch/key-validator>
* missing-keys <https://github.com/tobiasoberrauch/missing-keys>
*

@@ -11,30 +11,40 @@ * Copyright (c) 2015, Tobias Oberrauch.

/**
*
* @param object
* @param expectedKeys
* @returns {Array.<T>|*}
*/
function missingKeys(object, expectedKeys) {
var actualKeys = Object.keys(object);
return expectedKeys.filter(function (expectedKey) {
return actualKeys.indexOf(expectedKey) === -1;
});
}
(function (factory) {
if (typeof module === "object" && typeof module.exports === "object") {
module.exports = factory();
}
else if (typeof window === "object") {
window.missingKeys = factory();
}
}(function () {
/**
*
* @param {object} object
* @param {string|object} expectedKeys
* @returns {Array.<T>|*}
*/
function missingKeys(object, expectedKeys) {
expectedKeys = Object.prototype.toString.call(expectedKeys) === '[object Array]' ? expectedKeys : [expectedKeys];
var actualKeys = Object.keys(object);
return expectedKeys.filter(function (expectedKey) {
return actualKeys.indexOf(expectedKey) === -1;
});
}
/**
* @type {missingKeys}
*/
missingKeys.get = missingKeys;
/**
* @type {missingKeys}
*/
missingKeys.get = missingKeys;
/**
*
* @param object
* @param expectedKeys
* @returns {boolean}
*/
missingKeys.has = function (object, expectedKeys) {
return missingKeys(object, expectedKeys).length > 0;
};
/**
*
* @param {object} object
* @param {string|object} expectedKeys
* @returns {boolean}
*/
missingKeys.has = function (object, expectedKeys) {
return missingKeys(object, expectedKeys).length > 0;
};
module.exports = missingKeys;
return missingKeys;
}));
{
"name": "missing-keys",
"description": "Return missing keys if the given object hasn't all required keys.",
"version": "0.1.3",
"version": "0.1.4",
"homepage": "https://github.com/tobiasoberrauch/missing-keys",

@@ -20,3 +20,5 @@ "author": "Tobias Oberrauch <tobias.oberrauch@grolba.com> (https://github.com/tobiasoberrauch)",

"scripts": {
"test": "mocha"
"test": "mocha",
"publish": "npm publish",
"browserify": "browserify index.js -o browser.js"
},

@@ -23,0 +25,0 @@ "devDependencies": {

SocketSocket SOC 2 Logo

Product

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

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc