Socket
Book a DemoInstallSign in
Socket

constantly

Package Overview
Dependencies
Maintainers
1
Versions
5
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

constantly

Parse constant definition files and put them into a frozen object

0.1.4
latest
Source
npmnpm
Version published
Weekly downloads
0
Maintainers
1
Weekly downloads
 
Created
Source

Constantly

Take flat constants files and turn their properties into a read-only object.

Usage

Given an example.json structure like this:

[{
    "feature": "ACCOUNT",
    "category": "TYPE",
    "property": "USER",
    "comment": "A regular user that can login and do normal things",
    "value": 100,
    "sequence": 0
},
{
    "feature": "ACCOUNT",
    "category": "TYPE",
    "property": "ADMIN",
    "comment": "User which is an administrator",
    "value": 200,
    "sequence": 0
}]

We can get the value of those constants like so:

var constantly = require('constantly');
var path = require('path');

var $C = constantly(require(path.resolve('example.json'))); //pass it real JSON

var admin = $C.ACCOUNT.TYPE.ADMIN.value; //200
var user = $C.ACCOUNT.TYPE.USER.value; //100

JSON Format

You are required to define a feature, category, and property to “namespace” each constant.

Comment

Comments are useful for authors of the source JSON, but are ignored upon converting into an object.

Sequence

Sequence is used for ordering properties in UI.

Example

node example/demo.js

TODO

  • validate JSON to match the prescribed pattern upon injestion

Keywords

constant

FAQs

Package last updated on 10 May 2015

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

About

Packages

Stay in touch

Get open source security insights delivered straight into your inbox.

  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc

U.S. Patent No. 12,346,443 & 12,314,394. Other pending.