open-index/open-npm huggingface dataset:
npm package: @pelevesque/matrix-transformers
Description: A collection of matrix transformation algorithms.
Author: Pierre-Emmanuel Lévesque
Latest version: 0.0.5

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

# matrix-transformers

A collection of matrix transformation algorithms.

## Node Repository

https://www.npmjs.com/package/@pelevesque/matrix-transformers

## Installation

`npm install @pelevesque/matrix-transformers`

## Tests

Command                      | Description
---------------------------- | ------------
`npm test` or `npm run test` | All Tests Below
`npm run cover`              | Standard Style
`npm run standard`           | Coverage
`npm run unit`               | Unit Tests

## Usage

### Requiring the Module

```js
const matrixTransformers = require('@pelevesque/matrix-transformers')
```

### Requiring a Particular Transformation

```js
const rotateMatrixClockwise = require('@pelevesque/matrix-transformers').rotate90
```

### Available Transformations

- rotate90
- rotate180
- rotate270
- reflectHorizontally
- reflectVertically

### Examples

```js
const matrix = [
  [1, 2, 3],
  [4, 5, 6],
  [7, 8, 9]
]
const transformed = matrixTransformers.reflectHorizontally(matrix)

// result
transformed = [
  [3, 2, 1],
  [6, 5, 4],
  [9, 8, 7]
]
```

```js
const matrix = [
  [1, 2],
  [3, 4],
  [5, 6]
]
const transformed = matrixTransformers.rotate270(matrix)

// result
transformed = [
  [2, 4, 6],
  [1, 3, 5]
]
```
npm package: @pelevesque/numeric-code
Description: Tool for working with a custom numeric code system.
Author: Pierre-Emmanuel Lévesque
Latest version: 0.0.3

[![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'
```
npm package: @pelevesque/paginate
Description: Makes useful calculations for creating website pagination links.
Author: Pierre-Emmanuel Lévesque
Latest version: 0.1.1

[build-badge]:    https://travis-ci.org/pelevesque-node/paginate.svg?branch=master
[build]:          https://travis-ci.org/pelevesque-node/paginate
[coverage-badge]: https://coveralls.io/repos/github/pelevesque-node/paginate/badge.svg?branch=master
[coverage]:       https://coveralls.io/github/pelevesque-node/paginate?branch=master
[standard-badge]: https://img.shields.io/badge/code_style-standard-brightgreen.svg
[standard]:       https://standardjs.com
[mit-badge]:      https://img.shields.io/badge/License-MIT-yellow.svg
[mit]:            http://opensource.org/licenses/MIT

[![][build-badge]][build]
[![][coverage-badge]][coverage]
[![][standard-badge]][standard]
[![][mit-badge]][mit]

# paginate

Makes useful calculations for creating website pagination links.

## Node Repository

https://www.npmjs.com/package/@pelevesque/paginate

## Installation

`npm install @pelevesque/paginate`

## Tests

Command                      | Description
---------------------------- | ----------------------
`npm test` or `npm run test` | standardx + unit tests
`npm run cover`              | unit tests + coverage
`npm run standardx`          | standardx
`npm run unit`               | unit tests

## Usage

```js
const paginate = require('@pelevesque/paginate')
```

```js
const numLinks = 10 // number of links to others pages
const currentPage = 3
const numItemsPerPage = 10
const numItems = 300
const url = 'http://www.localhost.com/?page='

const paginateObject = paginate(numLinks, currentPage, numItemsPerPage, numItems, url)

// result
paginateObject = {
  numLinks: 10,
  currentPage: 3,
  numItemsPerPage: 10,
  numItems: 300,
  url: 'www.localhost.com/?page=',
  links: [
    { page: 1,  active: false, url: 'www.localhost.com/?page=1'  },
    { page: 2,  active: false, url: 'www.localhost.com/?page=2'  },
    { page: 3,  active: true,  url: 'www.localhost.com/?page=3'  },
    { page: 4,  active: false, url: 'www.localhost.com/?page=4'  },
    { page: 5,  active: false, url: 'www.localhost.com/?page=5'  },
    { page: 6,  active: false, url: 'www.localhost.com/?page=6'  },
    { page: 7,  active: false, url: 'www.localhost.com/?page=7'  },
    { page: 8,  active: false, url: 'www.localhost.com/?page=8'  },
    { page: 9,  active: false, url: 'www.localhost.com/?page=9'  },
    { page: 10, active: false, url: 'www.localhost.com/?page=10' },
  ],
  firstPageLink: 1,
  lastPageLink: 10,
  firstPage: 1,
  lastPage: 30,
  numPreviousPages: 2,
  numFollowingPages: 27,
}
```

## Integration with Adonis.js

https://github.com/adonisjs/core/discussions/1381

## Copyright

Copyright (c) 2018-2020, Pierre-Emmanuel Lévesque

## License

MIT

<div align="center">
  <sub>Built with ❤︎ by <a href="https://github.com/pelevesque">Pierre-Emmanuel Lévesque</a></sub>
</div>
npm package: @pelevesque/permutate
Description: Permutates elements. Same as https://www.npmjs.com/package/permutater, but with the addition of filtering offsets.
Author: Pierre-Emmanuel Lévesque
Latest version: 1.0.0

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

# permutate

Permutates elements. Same as https://www.npmjs.com/package/permutater, but with the addition of filtering unique sets.

When `removeOffsets` is set with an integer `>` 0, `removeOffsets` is run with the integer as the step to use.

@see https://www.npmjs.com/package/@pelevesque/remove-offsets for more details.

## Node Repository

[https://www.npmjs.com/package/@pelevesque/permutate](https://www.npmjs.com/package/@pelevesque/permutate)

## Installation

`npm install @pelevesque/permutate`

## Tests

### Standard Style & Unit Tests

`npm test`

### Unit Tests & Coverage

`npm run cover`

## Usage

```js
const permutate = require('@pelevesque/permutate');
```

```js
permutate({
  characters: 'abcdefghijklmnopqrstuvwxyz0123456789'.split(''),
  length: 3
})
// ['aaa', 'aab', 'aac' ... '997', '998', '999'].length = 46656
```

```js
permutate({
  characters: '1.23'.split('.'),
  length: 2
})
// ['11', '123', '231', '2323']
```

```js
permutate({
  charactersAt: {
    0: ['0', '1', '2']
  },
  characters: 'abcdefghijklmnopqrstuvwxyz'.split(''),
  length: 2
})
// ['0a', '0b', '0c' ... '2x', '2y', '2z'].length = 78
```

```js
permutate({
  charactersAt: {
    0: ['a', 'b'],
    1: ['-']
  },
  characters: 'abcdefghijklmnopqrstuvwxyz'.split(''),
  length: 3
})
// ['a-a', 'a-b', 'a-c' ... 'b-x', 'b-y', 'b-z'].length = 52
```

```js
permutate({
  characters: 'abcdefghijklmnopqrstuvwxyz0123456789'.split(''),
  length: 5,
  limit: 30
})
// ['fn6p3', 'x83na', '3v20r' ... ].length = 30
```

```js
permutate({
  characters: 'abcdefghijklmnopqrstuvwxyz0123456789'.split(''),
  length: 8,
})
// out of memory
```

```js
permutate({
  characters: '123'.split(''),
  length: 3,
  removeOffsets: 1 // indicates the step to use when removing offsets
})
// [
//   '111', '112', '113', '122', '123', '132', '133',
//   '222', '223', '233',
//   '333'
// ]
```

```js
permutate({
  characters: '123'.split(''),
  length: 3,
  removeOffsets: 2 // indicates the step to use when removing offsets
})
// [
//   '111', '112', '113', '122', '123', '132', '133',
//   '211', '212', '213', '222', '223', '233',
//   '311', '312', '313', '322', '323', '333'
// ]
```
npm package: @pelevesque/remove-duplicates
Description: Removes and returns duplicates from an array.
Author: Pierre-Emmanuel Lévesque
Latest version: 1.0.1

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

# remove-duplicates

Removes and returns duplicates from an array.

## Node Repository

https://www.npmjs.com/package/@pelevesque/remove-duplicates

## Installation

`npm install @pelevesque/remove-duplicates`

## Tests

### Standard Style & Unit Tests

`npm test`

### Unit Tests & Coverage

`npm run cover`

## Usage

#### Requiring

```js
const removeDuplicates = require('@pelevesque/remove-duplicates')
```

#### Basic

```js
const arr = [
  'd131dd02c5e6eec4', // a
  '55ad340609f4b302',
  'd8823e3156348f5b', // b
  'd131dd02c5e6eec4', // a
  'd8823e3156348f5b', // b
  '551111111114b302', // c
  '551111111114b302'  // c
]
const duplicates = removeDuplicates(arr)
/*
arr = [
  'd131dd02c5e6eec4',
  '55ad340609f4b302',
  'd8823e3156348f5b',
  '551111111114b302'
]
duplicates = [
  'd131dd02c5e6eec4',
  'd8823e3156348f5b',
  '551111111114b302'
]
*/
```

#### OnlyKeepElementsWithoutDuplicates Option

When setting the `onlyKeepElementsWithoutDuplicates` to true, only elements that
have no duplicates are kept.

```js
const arr = [
  'd131dd02c5e6eec4', // a
  '55ad340609f4b302',
  'd8823e3156348f5b', // b
  'd131dd02c5e6eec4', // a
  'd8823e3156348f5b', // b
  '551111111114b302', // c
  '551111111114b302'  // c
]
const opts = { onlyKeepElementsWithoutDuplicates: true }
const duplicates = removeDuplicates(arr, opts)
/*
arr = [
  '55ad340609f4b302'
]
duplicates = [
  'd131dd02c5e6eec4',
  'd8823e3156348f5b',
  'd131dd02c5e6eec4',
  'd8823e3156348f5b',
  '551111111114b302',
  '551111111114b302'
]
*/
```

#### Remove option

With the remove option set to false, duplicates are still returned, but nothing is
removed from the original array.

```js
const arr = [
  'd131dd02c5e6eec4', // a
  '55ad340609f4b302',
  'd8823e3156348f5b', // b
  'd131dd02c5e6eec4', // a
  'd8823e3156348f5b', // b
  '551111111114b302', // c
  '551111111114b302'  // c
]
const opts = { remove: false }
const duplicates = removeDuplicates(arr, opts)
/*
arr = [
  'd131dd02c5e6eec4',
  '55ad340609f4b302',
  'd8823e3156348f5b',
  'd131dd02c5e6eec4',
  'd8823e3156348f5b',
  '551111111114b302',
  '551111111114b302'
]
duplicates = [
  'd131dd02c5e6eec4',
  'd8823e3156348f5b',
  '551111111114b302'
]
*/
```
npm package: @pelevesque/remove-offsets
Description: Removes and returns offsetted strings from an array.
Author: Pierre-Emmanuel Lévesque
Latest version: 1.0.5

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

# remove-offsets

Removes and returns offsetted strings from an array.

## Node Repository

https://www.npmjs.com/package/@pelevesque/remove-offsets

## Installation

`npm install @pelevesque/remove-offsets`

## Tests

Command                      | Description
---------------------------- | ------------
`npm test` or `npm run test` | All Tests Below
`npm run cover`              | Standard Style
`npm run standard`           | Coverage
`npm run unit`               | Unit Tests

## Usage

### Parameters

```js
arr     (required)
options (optional) default = { step: 1, remove: true }
```

### Requiring

```js
const removeOffsets = require('@pelevesque/remove-offsets')
```

### Basic

```js
const arr = [
  'abcdef',
  '123456',
  'defabc', // 0
  'apple',
  '234561', // 1
  'banana',
  '456123', // 1
  'panama',
  'amapan' // 7
]
const offsets = removeOffsets(arr)
/*
arr = [
  'abcdef',
  '123456',
  'apple',
  'banana',
  'panama'
]
offsets = [
  'defabc',
  '234561',
  '456123',
  'amapan'
]
*/
```

### Step Option

```js
// Only check for offsets every 4 steps
const arr = [
  '123456789',
  'aaaabbbbb',
  'abbbbbaaa',
  'bbbbbaaaa', // 1
  '234567891', // 0
  '678912345', // 0
  '912345678'
]
const offsets = removeOffsets(arr, { step: 4 })
/*
arr = [
  '123456789',
  'aaaabbbbb',
  'abbbbbaaa',
  '912345678'
]
offsets = [
  'bbbbbaaaa',
  '234567891',
  '678912345'
]
*/
```

### Remove Option

With the remove option set to false, offsets are still returned, but nothing is
removed from the original array.

```js
// Only check for offsets every 4 steps
const arr = [
  '123456789',
  'aaaabbbbb',
  'abbbbbaaa',
  'bbbbbaaaa', // 1
  '234567891', // 0
  '678912345', // 0
  '912345678'
]
const offsets = removeOffsets(arr, { step: 4, remove: false })
/*
arr = [
  '123456789',
  'aaaabbbbb',
  'abbbbbaaa',
  'bbbbbaaaa',
  '234567891',
  '678912345',
  '912345678'
]
offsets = [
  'bbbbbaaaa',
  '234567891',
  '678912345'
]
*/
```
npm package: @pelevesque/remove-palindromes
Description: Removes and returns palindromes from an array.
Author: Pierre-Emmanuel Lévesque
Latest version: 1.0.3

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

# remove-palindromes

Removes and returns palindromes from an array.

## Node Repository

https://www.npmjs.com/package/@pelevesque/remove-palindromes

## Installation

`npm install @pelevesque/remove-palindromes`

## Tests

Command                      | Description
---------------------------- | ------------
`npm test` or `npm run test` | All Tests Below
`npm run cover`              | Standard Style
`npm run standard`           | Coverage
`npm run unit`               | Unit Tests

## Usage

### Parameters

```js
arr     (required)
options (optional) default = { groupBy: 1, pivotMustBePalindromic: false, remove: true }
```

### Requiring

```js
const removePalindromes = require('@pelevesque/remove-palindromes')
```

### Basic

```js
const arr = [
  '12321',
  'abcdef',
  '1221',
  'aaaaa'
]
const palindromes = removePalindromes(arr)
/*
arr = [
  'abcdef'
]
palindromes = [
  '12321',
  '1221',
  'aaaaa'
]
*/
```

### GroupBy Option

```js
const arr = [
  'aaabbb12bbbaaa',
  '123bbb321',
  '12321',
  '12345',
  '123bcdbcd123',
  '123ccc123',
  'abcdef',
  '123aaa343aaa123'
]
const opts = { groupBy: 3 }
const palindromes = removePalindromes(arr, opts)
/*
arr = [
  '123bbb321',
  '12321',
  '12345',
  'abcdef'
]
palindromes = [
  'aaabbb12bbbaaa',
  '123bcdbcd123',
  '123ccc123',
  '123aaa343aaa123'
]
*/
```

### PivotMustBePalindromic Option

```js
const arr = [
  'aaabbb12bbbaaa',
  '123bbb321',
  '12321',
  '12345',
  '123bcdbcd123',
  '123ccc123',
  'abcdef',
  '123aaa343aaa123'
]
const opts = { groupBy: 3, pivotMustBePalindromic: true }
const palindromes = removePalindromes(arr, opts)
/*
arr = [
  'aaabbb12bbbaaa',
  '123bbb321',
  '12321',
  '12345',
  'abcdef'
]
palindromes = [
  '123bcdbcd123',
  '123ccc123',
  '123aaa343aaa123'
]
*/
```

### Remove Option

With the remove option set to false, palindromes are still returned, but nothing is
removed from the original array.

```js
const arr = [
  'aaabbb12bbbaaa',
  '123bbb321',
  '12321',
  '12345',
  '123bcdbcd123',
  '123ccc123',
  'abcdef',
  '123aaa343aaa123'
]
const opts = { groupBy: 3, pivotMustBePalindromic: true, remove: false }
const palindromes = removePalindromes(arr, opts)
/*
arr = [
  'aaabbb12bbbaaa',
  '123bbb321',
  '12321',
  '12345',
  '123bcdbcd123',
  '123ccc123',
  'abcdef',
  '123aaa343aaa123'
]
palindromes = [
  '123bcdbcd123',
  '123ccc123',
  '123aaa343aaa123'
]
*/
```
npm package: @pelevesque/scale-number
Description: Scales a number within a range.
Author: Pierre-Emmanuel Lévesque
Latest version: 0.0.7

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

# scale-number

Scales a number within a range.

## Node Repository

https://www.npmjs.com/package/@pelevesque/scale-number

## Installation

`npm install @pelevesque/scale-number`

## Tests

Command                      | Description
---------------------------- | ------------
`npm test` or `npm run test` | All Tests Below
`npm run cover`              | Standard Style
`npm run standard`           | Coverage
`npm run unit`               | Unit Tests

## Usage

```js
const scaleNumber = require('@pelevesque/scale-number')
```

```js
const num = 10
const oldRangeMin = 0
const oldRangeMax = 100
const newRangeMin = 0
const newRangeMax = 1000
const result = scaleNumber(num, oldRangeMin, oldRangeMax, newRangeMin, newRangeMax)
// result === 100
```
npm package: @pelevesque/sort-object-keys
Description: Sorts an object by keys.
Author: Pierre-Emmanuel Lévesque
Latest version: 0.0.5

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

# sort-object-keys

Sorts an object by keys.

## Node Repository

https://www.npmjs.com/package/@pelevesque/sort-object-keys

## Installation

`npm install @pelevesque/sort-object-keys`

## Tests

Command                      | Description
---------------------------- | ------------
`npm test` or `npm run test` | All Tests Below
`npm run cover`              | Standard Style
`npm run standard`           | Coverage
`npm run unit`               | Unit Tests

## Usage

```js
const sortObjectKeys = require('@pelevesque/sort-object-keys')
```

```js
const unsorted = {3: 3, 1: 1, 2: 2, 0: 0}
const result = sortObjectKeys(unsorted)
// result === {0: 0, 1: 1, 2: 2, 3: 3}
```
npm package: @pelevesque/sort-string
Description: Sorts a string alphanumerically.
Author: Pierre-Emmanuel Lévesque
Latest version: 0.0.6

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

# sort-string

Sorts a string alphanumerically.

## Node Repository

https://www.npmjs.com/package/@pelevesque/sort-string

## Installation

`npm install @pelevesque/sort-string`

## Tests

Command                      | Description
---------------------------- | ------------
`npm test` or `npm run test` | All Tests Below
`npm run cover`              | Standard Style
`npm run standard`           | Coverage
`npm run unit`               | Unit Tests

## Usage

```js
const sortString = require('@pelevesque/sort-string')
```

```js
const str = '321bca321'
const result = sortString(str)
// result === '112233abc'
```
npm package: @pelevesque/substitute-chars
Description: Substitutes chars in a string.
Author: Pierre-Emmanuel Lévesque
Latest version: 0.0.3

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

# substitute-chars

Substitutes chars in a string.

## Node Repository

https://www.npmjs.com/package/@pelevesque/substitute-chars

## Installation

`npm install @pelevesque/substitute-chars`

## Tests

### Standard Style & Unit Tests

`npm test`

### Unit Tests & Coverage

`npm run cover`

## Usage

```js
const substituteChars = require('@pelevesque/substitute-chars')
const str = 'abbcabcc'
const substitutions = [
  ['a', '1'],
  ['b', '2'],
  ['c', '3']
]
const result = substituteChars(str, substitutions)
// result === '12231233'
```
npm package: @pelevesque/substitute-substrings
Description: Substitutes substrings.
Author: Pierre-Emmanuel Lévesque
Latest version: 0.0.1

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

# substitute-substrings

Substitutes substrings.

## Node Repository

https://www.npmjs.com/package/@pelevesque/substitute-substrings

## Installation

`npm install @pelevesque/substitute-substrings`

## Tests

### Standard Style & Unit Tests

`npm test`

### Unit Tests & Coverage

`npm run cover`

## Usage

### Requiring

```js
const substituteSubstrings = require('@pelevesque/substitute-substrings')
```

### Single Substitution

```js
const str = 'abbc'
const substitutions = ['b', '2']
const result = substituteSubstrings(str, substitutions)
// result === 'a22c'
```

Substrings are not swapped like with https://github.com/pelevesque/swap-substrings

```js
const str = 'ac'
const substitutions = ['a', 'c']
const result = substituteSubstrings(str, substitutions)
// result === 'cc'
```

### Multiple Substitutions

```js
const str = 'abbcabcc'
const substitutions = [
  ['a', '1'],
  ['b', '2'],
  ['c', '3']
]
const result = substituteSubstrings(str, substitutions)
// result === '12231233'
```

```js
const str = 'a long stormy night and a little boy named jim'
const substitutions = [
  ['a ', 'the '],
  ['night', 'day'],
  ['jim', 'oscar'],
  ['long', 'short'],
  ['little', 'very tall']
]
const result = substituteSubstrings(str, substitutions)
// result === 'the short stormy day and the very tall boy named oscar'
```
npm package: @pelevesque/sum-digits
Description: Sums the digits in a string with a powerful substrings->digits feature.
Author: Pierre-Emmanuel Lévesque
Latest version: 0.0.10

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

# sum-digits

Sums the digits in a string with a powerful substrings->digits feature.

## Node Repository

https://www.npmjs.com/package/@pelevesque/sum-digits

## Installation

`npm install @pelevesque/sum-digits`

## Tests

Command                      | Description
---------------------------- | ------------
`npm test` or `npm run test` | All Tests Below
`npm run cover`              | Standard Style
`npm run standard`           | Coverage
`npm run unit`               | Unit Tests

## Usage

### Parameters

```js
str     (required)
options (optional) default = { substringsToDigits = null, sumPlainDigits = true }
```

### Examples

```js
const sumDigits = require('@pelevesque/sum-digits')
```

```js
// normal summing
sumDigits('1234') // 10
```

```js
// ignores non numeric characters
sumDigits('1a2!3_4.') // 10
```

```js
// you can provide a hash table of substrings to digits
const substringsToDigits = { a: 1, b: 2, c: 3 }
sumDigits('1a2b3ca', { substringsToDigits: substringsToDigits }) // 13
```

```js
// substrings can be of any length
const substringsToDigits = { '1p': 1000, panama: 100, nam: 10, 2: 1 }
sumDigits('1panama2', { substringsToDigits: substringsToDigits }) // 1114
```

```js
// you can bypass plain digit summing and only use substringsToDigits summing
const substringsToDigits = { '1p': 1000, panama: 100, nam: 10, 2: 1 }
sumDigits('1panama2', { substringsToDigits: substringsToDigits, sumPlainDigits: false}) // 1111
```
npm package: @pelevesque/supersubstr
Description: Like Javascript's substr, but with wrapping and reversed substrings.
Author: Pierre-Emmanuel Lévesque
Latest version: 1.0.3

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

# supersubstr

Like Javascript's substr, but with wrapping and reversed substrings.

## Node Repository

https://www.npmjs.com/package/@pelevesque/supersubstr

## Installation

`npm install @pelevesque/supersubstr`

## Tests

Command                      | Description
---------------------------- | ------------
`npm test` or `npm run test` | All Tests Below
`npm run cover`              | Standard Style
`npm run standard`           | Coverage
`npm run unit`               | Unit Tests

## Usage

### Parameters

```js
str     (required)
options (optional) default = { startIndex = 0, length, reverse = false }
```

### Examples

```js
const supersubstr = require('@pelevesque/supersubstr')
```

```js
const str = '12345'
const result = supersubstr(str, { startIndex: 1 })
// result === '2345'
```

```js
const str = '12345'
const result = supersubstr(str, { startIndex: 2, length: 10, reverse: true })
// result === '3215432154'
```
npm package: @pelevesque/swap-chars
Description: Swaps two characters in a string.
Author: Pierre-Emmanuel Lévesque
Latest version: 0.0.4

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

# swap-chars

Swaps two characters in a string.

## Node Repository

https://www.npmjs.com/package/@pelevesque/swap-chars

## Installation

`npm install @pelevesque/swap-chars`

## Tests

### Standard Style & Unit Tests

`npm test`

### Unit Tests & Coverage

`npm run cover`

## Usage

```js
const swapChars = require('@pelevesque/swap-chars')
const string = 'bad bed led lad'
const result = swapChars(string, 'a', 'e')
// result === 'bed bad lad led'
```
npm package: @pelevesque/swap-substrings
Description: Swaps substrings.
Author: Pierre-Emmanuel Lévesque
Latest version: 1.0.3

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

# swap-substrings

Swaps substrings.

## Node Repository

https://www.npmjs.com/package/@pelevesque/swap-substrings

## Installation

`npm install @pelevesque/swap-substrings`

## Tests

Command                      | Description
---------------------------- | ------------
`npm test` or `npm run test` | All Tests Below
`npm run cover`              | Standard Style
`npm run standard`           | Coverage
`npm run unit`               | Unit Tests

## Usage

### Requiring

```js
const swapSubstrings = require('@pelevesque/swap-substrings')
```

### Swap Substrings

```js
const str = 'bad bed led lad'
const swaps = ['a', 'e']
const result = swapSubstrings(str, swaps)
// result === 'bed bad lad led'
```

```js
const str = 'dog treats for dogs, cat treats for cats'
const swaps = ['dog', 'cat']
const result = swapSubstrings(str, swaps)
// result === 'cat treats for cats, dog treats for dogs'
```

### Swap Many Substring Pairs

```js
const str = 'a fairly large man says oh oh oh to the bird'
const swaps = [
  ['a ', 'the '],
  ['man', 'bird'],
  ['large', 'small'],
  ['oh', 'tweet']
]
const result = swapSubstrings(str, swaps)
// result === 'the fairly small bird says tweet tweet tweet to a man'
```

### Substitute Substrings (Replacement is not in the String)

```js
const str = 'I like hamsters'
const swaps = ['hamsters', 'squirrels']
const result = swapSubstrings(str, swaps)
// result === 'I like squirrels'
```
npm package: @pelevesque/wrap-number
Description: Wraps a number inside a range.
Author: Pierre-Emmanuel Lévesque
Latest version: 0.0.5

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

# wrap-number

Wraps a number inside a range.

## Node Repository

https://www.npmjs.com/package/@pelevesque/wrap-number

## Installation

`npm install @pelevesque/wrap-number`

## Tests

Command                      | Description
---------------------------- | ------------
`npm test` or `npm run test` | All Tests Below
`npm run cover`              | Standard Style
`npm run standard`           | Coverage
`npm run unit`               | Unit Tests

## Usage

```js
const wrapNumber = require('@pelevesque/wrap-number')
```

```js
const num = 11
const rangeMin = -10
const rangeMax = 10
const result = wrapNumber(num, rangeMin, rangeMax)
// result === -10
```