Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
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 files and put them in a frozen object

  • 0.1.2
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
2
increased by100%
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 which defines two ACCOUNT.TYPEs, USER and ADMIN:

[{
    "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

JSON Setup

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

Comments

Comments are useful for authors of the source JSON but are ignored otherwise.

Sequence

Sequence is used for ordering properties in UI.

Example

node example/demo.js

TODO

  • validate JSON to match this pattern upon injestion

Keywords

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

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc