3.0.0 • Published 7 years ago

mmle-namespace v3.0.0

Weekly downloads
3
License
MIT
Repository
github
Last release
7 years ago

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'
3.0.0

7 years ago

2.1.1

7 years ago

2.1.0

7 years ago

2.0.0

7 years ago

1.0.1

7 years ago

1.0.0

7 years ago