https://github.com/eidellev/nahman
https://github.com/eidellev/nahman
Last synced: 11 months ago
JSON representation
- Host: GitHub
- URL: https://github.com/eidellev/nahman
- Owner: eidellev
- Created: 2019-02-12T08:32:38.000Z (over 7 years ago)
- Default Branch: master
- Last Pushed: 2019-02-17T09:15:01.000Z (over 7 years ago)
- Last Synced: 2025-06-22T22:46:42.355Z (about 1 year ago)
- Language: JavaScript
- Size: 283 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# Nahman
---
**NOTE:** _This library was conceived as an exercise, using functional programming, TDD and rollup.js._
A small utility library for converting arrays into a "stepped arrays".
A stepped array is an array where each member is a sub-array of the original, the first member is `[1]`, the second is `[1 ➜ 2]` and the last member is `[1 ➜ n]`.
For an example, if our input is `[1, 2, 3, 4]`, our output will be:
```
[
[1],
[1, 2],
[1, 2, 3]
[1, 2, 3, 4]
]
```
## Installation
```
npm i --save @eidellev/nahman
# or
yarn add @eidellev/nahman
```
## Usage
```javascript
import nahman from '@eidellev/nahman';
// or
const nahman = require('@eidellev/nahman');
nahman.toSteps([1, 2, 3, 4]);
nahman.toStepsRight([1, 2, 3, 4]);
```
## Methods
- `toSteps` - Converts an array into a stepped array
- `toStepsRight` - Converts an array into a stepped array from right to left, e.g:
```
[1, 2, 3, 4] ➜ [[1, 2, 3, 4], [1, 2, 3], [2, 3], [3]]
```