name-space
v2.0.0
Published
namespace `ns.set(obj, 'user.name', 'nimo')` `ns.get(obj, 'user.name')` // "nimo" or undefined
Downloads
4
Readme
name-space
namespace set get
Install
npm install name-space --save
# <script src="https://pkgzip.com/?name-space" ></script>
get
var ns = require('name-space')
var people = {
user: {
name: 'nimo'
}
}
ns.get(people, 'user.name')
// nimo
set
var ns = require('name-space')
var people = {}
ns.set(people, 'user.name', 'nimo')
console.log(people)
/*
{
user: {
name: 'nimo'
}
}
*/
replaced object
var ns = require('name-space')
var people = {
user: 'abc'
}
ns.set(people, 'user.name', 'nimo')
console.log(people)
/*
node_modules/name-space: set(obj, "user.name", value); obj. is a string
This value will be replaced by the object
{ user: { name: 'nimo' } }
*/
Development
npm run test
# npm run test:ci