Security News
tea.xyz Spam Plagues npm and RubyGems Package Registries
Tea.xyz, a crypto project aimed at rewarding open source contributions, is once again facing backlash due to an influx of spam packages flooding public package registries.
args2object
Advanced tools
Readme
Node/JavaScript library to access an item in an object structure given function arguments as path.
$ npm install args2object
Take the browserified file at dist/args2object.bundle.js
and include it in your HTML:
<script src='js/args2object.bundle.js'></script>
The browserified file exports the window.args2object
function.
var args2object = require('args2object'); // if Node
var myObject = {
a: true,
b: false,
c: 'hello',
d: {
d1: 'foo',
d2: [1,2,3,4]
},
true: {
false: 0,
bar: null
}
};
var getter = args2object(myObject);
getter('a'); // => true
getter('b'); // => false
getter('c'); // => 'hello'
getter('d','d1'); // => 'foo'
getter('d','d2'); // => [1,2,3,4]
getter(true,false); // => 0
getter(true,'bar'); // => null
getter('a','a1'); // => undefined
getter('a','a1','a11'); // => undefined
getter('e'); // => undefined
getter('e','e1'); // => undefined
getter(null,true,false); // => undefined
getter(); // => the full object
var getter = args2object(myObject, {failOnNotFound: true});
getter('a','a1'); // => throws an Error exception
getter('a','a1','a11'); // => throws an Error exception
getter('e'); // => throws an Error exception
getter('e','e1'); // => throws an Error exception
getter(false); // => throws an Error exception
getter = args2object(object, options)
{Object|Function}
object: The object to handle.{Object}
options (optional):
{Boolean}
failOnNotFound: Whether to throw an Error
if the searched path does not exist in the object structure (default: false
).Returns a getter
function.
getter(a,b,c)
Retrieve the value at object[a][b][c]
.
If the path does not exist it returns undefined
(or throws an Error
if options.failOnNotFound
is set).
Copyright (c) 2014 Iñaki Baz Castillo Licensed under the MIT license.
FAQs
Node/JavaScript library to access an item in an object structure given function arguments as path.
The npm package args2object receives a total of 3 weekly downloads. As such, args2object popularity was classified as not popular.
We found that args2object 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
Tea.xyz, a crypto project aimed at rewarding open source contributions, is once again facing backlash due to an influx of spam packages flooding public package registries.
Security News
As cyber threats become more autonomous, AI-powered defenses are crucial for businesses to stay ahead of attackers who can exploit software vulnerabilities at scale.
Security News
UnitedHealth Group disclosed that the ransomware attack on Change Healthcare compromised protected health information for millions in the U.S., with estimated costs to the company expected to reach $1 billion.