
Security News
OpenClaw Skill Marketplace Emerges as Active Malware Vector
Security researchers report widespread abuse of OpenClaw skills to deliver info-stealing malware, exposing a new supply chain risk as agent ecosystems scale.
Easily get, set, stub values of a field in a JavaScript object.
I got tired of doing this:
var port = cfg && cfg.env && cfg.env.prod && cfg.env.prod.port
now...
var field = require('field')
var port = field.get(cfg, 'env.prod.port')
or if you prefer ":"...
var field = require('field')
var port = field.get(config, 'env:prod:port')
I also got tired of writing long stubs:
var stub = {
window: {
localStorage: {
getItem: function () {
return 'data'
},
length: 1
}
}
}
now...
var field = require('field')
var stub = {}
field(stub, 'window:localStorage.getItem', function () { return 'data' })
field(stub, 'window:localStorage.length', 1)
npm i --save field
Gets the property value of the object. Returns undefined if it does not exist.
var field = require('field')
var dbPort = field.get(config, 'environment:production:port')
Sets the property value of the object. Returns the old value. If the field does not exist
then it returns undefined and creates the object chain and sets the value.
var field = require('field')
var database = {}
console.log(field.get(database, 'production.port'))
// => undefined
// will return undefined since it never existed before
field.set(database, 'production.port', 27017)
console.log(database.production.port)
// => 27017
var field = require('field')
var bigObject = {
host: {
url: 'http://myserver.com'
}
/*
... some big object ...
*/
};
bigObject.get = field.get.bind(bigObject)
bigObject.set = field.set.bind(bigObject)
console.log(bigObject.get('host.url'))
// => 'http://myserver.com'
(MIT License)
Copyright 2015, JP Richardson
FAQs
Easily set, get, stub values of a field in a JavaScript object.
We found that field demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer 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
Security researchers report widespread abuse of OpenClaw skills to deliver info-stealing malware, exposing a new supply chain risk as agent ecosystems scale.

Security News
Claude Opus 4.6 has uncovered more than 500 open source vulnerabilities, raising new considerations for disclosure, triage, and patching at scale.

Research
/Security News
Malicious dYdX client packages were published to npm and PyPI after a maintainer compromise, enabling wallet credential theft and remote code execution.