npm

Share private packages across your team with npm Orgs, now with simplified billing via the aws marketplace!Learn more »

mmle-namespace

3.0.0 • Public • Published

mmle-namespace

Make My Life Easier when manipulate with namespace

Usage

Node

npm install mmle-namespace --save-dev

Browser

└── dist
    └── mmle-namespace.js

API

namespace(obj, path, value, [allowOverwrite])

Setter.

var cats = {};
 
var name = namespace(cats, 'yellow.small.happy', 'paul');
console.log(cats); // { 'yellow': { 'small': { 'happy': 'paul' } } }
console.log(name); // 'paul'
 
 
// when the namespace is already existed
var name = namespace(cats, 'yellow.small.happy', 'thammin');
// throw error
 
 
// overwrite the existing namespace
var name = namespace(cats, 'yellow.small.happy', 'thammin', true);
console.log(cats); // { 'yellow': { 'small': { 'happy': 'thammin' } } }
console.log(name); // 'thammin'

namespace(obj, path)

Getter.

var cats = {
  yellow: {
    small: {
      happy: 'thammin'
    }
  }
};
 
var name = namespace(cats, 'yellow.small.happy');
console.log(name); // 'thammin'

install

npm i mmle-namespace

Downloadsweekly downloads

6

version

3.0.0

license

MIT

homepage

github.com

repository

Gitgithub

last publish

collaborators

  • avatar
Report a vulnerability