# constant-factory

> Stop rewriting the constant name in each entry use a factory for this job

Latest version **1.2.1** (published 2017-08-29) · MIT license · 0 weekly downloads

## Install

```sh
npm install constant-factory
pnpm add constant-factory
yarn add constant-factory
bun add constant-factory
```

## Health

**Score 15/100 (F)** — status: abandoned.

Positive: no vulnerabilities.

Warnings: low downloads; no types; no esm support.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 1.2.1 |
| Published | 2017-08-29 |
| First published | 2017-03-21 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 0 |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 1 |
| Author | Michael J. Zoidl |
| Maintainers | michaelzoidl |
| Keywords | constant, constant generator, react, redux, constant factory |

## Links

- npm: https://www.npmjs.com/package/constant-factory
- Repository: https://github.com/entwicklerstube/constant-factory
- Homepage: https://github.com/entwicklerstube/constant-factory#readme
- Issues: https://github.com/entwicklerstube/constant-factory/issues
- npm.io page: https://npm.io/package/constant-factory

## Alternatives

- [mobx-react](https://npm.io/package/mobx-react.md) — 2.8M weekly downloads
- [rc-tree](https://npm.io/package/rc-tree.md) — 2.6M weekly downloads
- [@react-oauth/google](https://npm.io/package/@react-oauth/google.md) — 1.3M weekly downloads
- [@wagmi/connectors](https://npm.io/package/@wagmi/connectors.md) — 877.0K weekly downloads
- [vee-validate](https://npm.io/package/vee-validate.md) — 836.4K weekly downloads

## Recent versions

- 1.2.1 (latest) — 2017-08-29
- 1.2.0 — 2017-08-29
- 1.1.0 — 2017-04-17
- 1.0.0 — 2017-03-21

## README

# Constant Factory

> Stop rewriting the constant name in each entry use a factory for this job

[![Zero Dependencies](https://img.shields.io/badge/zero-dependencies-brightgreen.svg)]()
[![Coverage Status](https://coveralls.io/repos/github/entwicklerstube/constant-factory/badge.svg?branch=master)](https://coveralls.io/github/entwicklerstube/constant-factory?branch=master)
[![Build Status](https://travis-ci.org/entwicklerstube/constant-factory.svg?branch=master)](https://travis-ci.org/entwicklerstube/constant-factory)
[![greenkeeper badge](https://badges.greenkeeper.io/entwicklerstube/constant-factory.svg)](https://greenkeeper.io/)

### Install
**npm**
```
npm install constant-factory --save-dev
```

**yarn**
```
yarn add constant-factory --dev
```

### Usage
```js
// normal
constant(CONSTANT_NAME<STRING>, CONSTANT_ENTRIES<ARRAY>)

// advanced
constant(CONSTANT_COLLETION<ARRAY>)
```

### Example
Before:
```js
export const MY_CONSTANT = {
  TODO: 'MY_CONSTANT_TODO',
  ISSUES: 'MY_CONSTANT_ISSUES',
}
```

Now:
```js
import c from 'constant-factory'

export const MY_CONSTANT = c('MY_CONSTANT', [
  'TODO',
  'ISSUES'
])

// returns
// {
//   TODO: 'MY_CONSTANT_TODO',
//   ISSUES: 'MY_CONSTANT_ISSUES'
// }
```

Advanced:
```js
import c from 'constant-factory'

export const { MY_CONSTANT, ANOTHER_CONSTANT } = c({
  'MY_CONSTANT': [
    'TODO', 'ISSUES'
  ],
  'ANOTHER_CONSTANT': [
    'DATES'
  ]
})

// returns
// {
//   MY_CONSTANT: {
//     TODO: 'MY_CONSTANT_TODO',
//     ISSUES: 'MY_CONSTANT_ISSUES'
//   },
//   ANOTHER_CONSTANT: {
//     DATES: 'ANOTHER_CONSTANT_DATES'
//   }
// }
```

Expert:
> Add additional subs in subs
```js
import c from 'constant-factory'

export const { MY_CONSTANT, ANOTHER_CONSTANT } = c({
  'MY_CONSTANT': [
    'TODO',
    {
      'STATUS': [
        'DONE',
        'OPEN',
      ]
    }
  ],
})

// returns
// {
//   MY_CONSTANT: {
//     TODO: 'MY_CONSTANT_TODO',
//     STATUS: [
//       'MY_CONSTANT_STATUS_DONE',
//       'MY_CONSTANT_STATUS_OPEN'
//     ]
//   }
// }
```

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