Security News
Node.js EOL Versions CVE Dubbed the "Worst CVE of the Year" by Security Experts
Critics call the Node.js EOL CVE a misuse of the system, sparking debate over CVE standards and the growing noise in vulnerability databases.
check-object-key
Advanced tools
Standardized way to check an objects key, setting defaults, timing out etc.
npm i check-object-key
Load up library like so:
'use strict';
const checkKey = require('check-object-key');
const obj = {'foo': 'bar'};
checkKey({
'obj': obj,
'objectKey': 'foo'
}, function (err) {
if (err) throw err;
// If no error, key exists
});
const obj = {};
checkKey({
'obj': obj,
'objectKey': 'foo',
'default': 'blut'
}, function (err, warning) {
if (err) throw err;
console.log(obj.foo); // "blut"
console.log(warning); // obj["foo"] is not set, setting default: "blut"
});
const obj = {'foo': 'nein'};
checkKey({
'obj': obj,
'objectKey': 'foo',
'validValues': ['ja', 'yes', 'da']
}, function (err) {
if (err) throw err; // This should throw an error, since "nein" is not in the validValues array
});
const obj = {};
checkKey({
'obj': obj,
'objectKey': 'foo'
}, function (err) {
if (err) throw err;
// No error is thrown, since obj.foo is set in the async operation below
});
someAsyncThingie(function (err, someValue) {
if (err) throw err;
obj.foo = someValue;
});
options.obj: object - Object to have its keys checked
options.objectKey: string - object key name
options.default: any - The default value if it does not exist
options.defaultLabel: string - What to print in the log as the default value (will default to "default" if it is a string)
options.retries: integer - used internally. Set to 10+ to have the method immediately set the default value or fail if the key does not exist
FAQs
Checking a thing
We found that check-object-key demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 3 open source maintainers collaborating on the project.
Did you know?
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.
Security News
Critics call the Node.js EOL CVE a misuse of the system, sparking debate over CVE standards and the growing noise in vulnerability databases.
Security News
cURL and Go security teams are publicly rejecting CVSS as flawed for assessing vulnerabilities and are calling for more accurate, context-aware approaches.
Security News
Bun 1.2 enhances its JavaScript runtime with 90% Node.js compatibility, built-in S3 and Postgres support, HTML Imports, and faster, cloud-first performance.