# @pelevesque/numeric-code

> Tool for working with a custom numeric code system.

Latest version **0.0.3** (published 2019-06-23) · MIT license · 0 weekly downloads

## Install

```sh
npm install @pelevesque/numeric-code
pnpm add @pelevesque/numeric-code
yarn add @pelevesque/numeric-code
bun add @pelevesque/numeric-code
```

## Health

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

Positive: no vulnerabilities.

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

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 0.0.3 |
| Published | 2019-06-23 |
| First published | 2018-08-01 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | none |
| Module format | CommonJS |
| Node | >=6.4.0 |
| Dependencies | 1 |
| Unpacked size | 9.6 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| Author | Pierre-Emmanuel Lévesque |
| Maintainers | pelevesque |
| Keywords | math, numeric, code, string |

## Links

- npm: https://www.npmjs.com/package/@pelevesque/numeric-code
- Repository: https://github.com/pelevesque/numeric-code
- Homepage: https://github.com/pelevesque/numeric-code#readme
- Issues: https://github.com/pelevesque/numeric-code/issues
- npm.io page: https://npm.io/package/@pelevesque/numeric-code

## Dependencies (1)

- [@pelevesque/substitute-substrings](https://npm.io/package/@pelevesque/substitute-substrings.md) ^0.0.1

## Alternatives

- [flatbuffers](https://npm.io/package/flatbuffers.md) — 6.0M weekly downloads
- [jwt-simple](https://npm.io/package/jwt-simple.md) — 259.5K weekly downloads
- [@exodus/patch-broken-hermes-typed-arrays](https://npm.io/package/@exodus/patch-broken-hermes-typed-arrays.md) — 28.5K weekly downloads
- [@native-to-anchor/buffer-layout](https://npm.io/package/@native-to-anchor/buffer-layout.md) — 12.2K weekly downloads
- [binary-parser-encoder](https://npm.io/package/binary-parser-encoder.md) — 5.3K weekly downloads

## Recent versions

- 0.0.3 (latest) — 2019-06-23
- 0.0.2 — 2019-05-30
- 0.0.1 — 2018-08-01

## README

[![Build Status](https://travis-ci.org/pelevesque/numeric-code.svg?branch=master)](https://travis-ci.org/pelevesque/numeric-code)
[![Coverage Status](https://coveralls.io/repos/github/pelevesque/numeric-code/badge.svg?branch=master)](https://coveralls.io/github/pelevesque/numeric-code?branch=master)
[![JavaScript Style Guide](https://img.shields.io/badge/code_style-standard-brightgreen.svg)](https://standardjs.com)

# numeric-code

Tool for working with a custom numeric code system.

The numeric code is made up of digits from `1` to `9` inclusively. `0` and any
other symbol can be included, but will be ignored when processing.

Ex: `091230/129830`

This numeric code system can be used to denote positions of elements in a game
using `0` for empty spaces.

For example, we could use this code `00210/00211/00210/00211/00200` to denote a
the following go position on a 5 x 5 board. The numbers `1` and `2` could denote
the black and white stone colors. We could then obtain a canonicalization or a
randomization of the position using this module.

0 0 2 1 0  
0 0 2 1 1  
0 0 2 1 0  
0 0 2 1 1  
0 0 2 0 0  

## Node Repository

https://www.npmjs.com/package/@pelevesque/numeric-code

## Installation

`npm install @pelevesque/numeric-code`

## Tests

### Standard Style & Unit Tests

`npm test`

### Unit Tests & Coverage

`npm run cover`

## Methods

- `canonicalize` canonicalizes a numeric code
- `randomize` randomizes a numeric code

## Usage

### Initialization

#### Requiring the Entire Module

```js
const numericCode = require('@pelevesque/numeric-code')
```

#### Requiring a Specific Method

```js
const numericCode = require('@pelevesque/numeric-code').canonicalize
```

### Canonicalize

Canonicalizing the numeric code does two things:

1. The code is flattened to avoid jumps between digits.  
2. The code is ordered chronologically.

```js
const str = '008213/923480'
const result = numericCode.canonicalize(str)
// result === '001234/524610'
```

### Randomize

Randomizing the numeric code does two things:

1. The code is flattened to avoid jumps between digits.  
2. The code is ordered randomly.

```js
const str = '008213/923480'
const result = numericCode.randomize(str)
// result === '004312/532640'
```

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