JSPM

  • ESM via JSPM
  • ES Module Entrypoint
  • Export Map
  • Keywords
  • License
  • Repository URL
  • TypeScript Types
  • README
  • Created
  • Published
  • Downloads 7
  • Score
    100M100P100Q44305F
  • License MIT

Make My Life Easier - namespace

Package Exports

  • mmle-namespace

This package does not declare an exports field, so the exports above have been automatically detected and optimized by JSPM instead. If any package subpath is missing, it is recommended to post an issue to the original package (mmle-namespace) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.

Readme

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'