Skip to content

Latest commit

 

History

7 Commits

Folders and files

NameName
Last commit message
Last commit date
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

KeyMirrorPlus

This library allows you to create constants by just defining the key in the constant. The library will create the values same as the constant. This library also supports creation of multi-level constants. This work has been inspired from bloody-keymirror and mirrorkey

Build Status

Installation

$ npm install keymirrorplus

Require

var keyMirrorPlus = require("keymirrorplus")

API

keyMirrorPlus(object) > mirroredObject

It takes an object or an array of strings and creates a new object having original object's keys and value would be the same as the key

Usage

Following are couple use cases for KeyMirrorPlus

Single-Level

var constants = keyMirrorPlus({
  GET_DATA : null,
  RECEIVED_DATA : null
});

console.log(constants.GET_DATA); // "GET_DATA"

Multi-Level

var constants ={
    FOO : "FOO",
    BAR : "BAR",
    BAZ : "BAZ",
    XYZ: {
      ABC : "ABC",
      JKL: "JKL"
    }
  };

console.log(constants.XYZ); // {"ABC":"ABC", "JKL":"JKL"}
console.log(constants.XYZ.ABC); // "ABC"

Credits

Inspiration from:

License

MIT

About

Mirror Keys for creating nested constants easily for JavaScript projects

Resources

Stars

1 star

Watchers

1 watching

Forks

Releases

Packages

Contributors

Languages