constant-enum

creates a frozen object with matching keys and values

Usage no npm install needed!

<script type="module">
  import constantEnum from 'https://cdn.skypack.dev/constant-enum';
</script>

README

Build Status"> constant-enum

Generates a frozen object with matching keys and values

Installation

$ npm install constant-enum

Usage

var en = require('constant-enum');
en('MON', 'TUES', 'WEDS');
// or
en.apply(null, ['MON', 'TUES', 'WEDS']);
// results in ->
{
  MON: 'MON',
  TUES: 'TUES',
  WEDS: 'WEDS'
}

Why?

We found this pattern helpful when implementing Facebook's Flux architecture. We use this pattern as an alterative to the one demonstrated in the Flux TodoMVC example.