Socket
Book a DemoInstallSign in
Socket

mkconstants

Package Overview
Dependencies
Maintainers
1
Versions
4
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

mkconstants

A utility function for recursively building an object of constants.

latest
Source
npmnpm
Version
0.0.4
Version published
Maintainers
1
Created
Source
mkconstants
===========

If you're building up a nested object of constants, for use with things like
facebook/Flux, it's handy to have a function that can process said object
and return something that can be compared upon. Also, namespaced on a per-
app basis.

So, for instance:

    mkconstants('ProductsApp', {
      ActionTypes: {
        Product: {
          RECEIVE_RAW_INSTANCE: null
        }
      },
      PayloadSources: {
        SERVER_ACTION: null,
        VIEW_ACTION: null
      }
    });

Would output:
  
    {
      ActionTypes: {
        Product: {
          RECEIVE_RAW_INSTANCE: 'ProductsApp.ActionTypes.Product.RECEIVE_RAW_INSTANCE'
        }
      },
      PayloadSources: {
        SERVER_ACTION: 'ProductsApp.PayloadSources.SERVER_ACTION',
        VIEW_ACTION: 'ProductsApp.PayloadSources.VIEW_ACTION'
      }
    }

These are not only unique, but also great for debugging purposes.

Keywords

constants

FAQs

Package last updated on 17 Jul 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