# gen_const

> A simple utility for generating constant object with a string contains keys

Latest version **0.0.3** (published 2015-04-24) · 0 weekly downloads

> **Deprecated.** This package is deprecated.

## Install

```sh
npm install gen_const
pnpm add gen_const
yarn add gen_const
bun add gen_const
```

## Health

**Score 10/100 (F)** — status: deprecated.

Negative: deprecated.

## Facts

| | |
|---|---|
| Version | 0.0.3 |
| Published | 2015-04-24 |
| First published | 2015-04-24 |
| Weekly downloads | 0 |
| TypeScript types | none |
| Module format | CommonJS |
| Node | >=0.4 |
| Dependencies | 0 |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 4 |
| Author | Gelin Luo |
| Maintainers | greenlaw110 |
| Keywords | enum, const |

## Links

- npm: https://www.npmjs.com/package/gen_const
- Repository: https://github.com/greenlaw110/constjs
- Issues: https://github.com/greenlaw110/constjs/issues
- npm.io page: https://npm.io/package/gen_const

## Recent versions

- 0.0.3 (latest) — 2015-04-24
- 0.0.2 — 2015-04-24
- 0.0.1 — 2015-04-24

## README

gen_const
=========

Create a constant object with key names specified in String or object

This simple tool extends `keyMirror` from ReactJS in a way that it accept more varieties of input to specify the constant keys

Usage
-----

`npm install gen_const`

```javascript
var genConst = require('gen_enum');
var COLORS = genConst("blue red");
var myColor = COLORS.blue;
console.log(myColor); // output blue
```

Input:  `"key1 key2 ..."`

Note, other than `space` keys could also be separated by `,`, `;` and `:`

Output: 

```
{
    key1: 'key1',
    key2: 'key2'
}
```

Input variations
-----------------

Instead of a string of keys sepated by separators specified above, it can use another two variaions of input to specify keys:

```javascript

// use array of strings to specify keys
var Color = genConst("blue", "red");
var myColor = Color.blue; // 'blue'

// use object to specify keys
var WeekDay = genConst({
    Monday: null,
    Tuesday: null
})
var myDay = WeekDay.Monday; // 'Monday'
```

---
_Source: https://npm.io/package/gen_const · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
