Socket
Book a DemoInstallSign in
Socket

iterable-utils

Package Overview
Dependencies
Maintainers
1
Versions
3
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

iterable-utils

Iterable utils, such as `Tuple`, `Range`.

latest
npmnpm
Version
0.1.2
Version published
Weekly downloads
1
Maintainers
1
Weekly downloads
 
Created
Source

Iterable Utils

Iterable utils, such as Tuple, Range. (For ESNext)

Install

$ yarn add iterutils

Example

Tuple

import { Tuple } from 'iterable-utils';
let a = Tuple(1, 2, 3),
    // or:
    b = new Tuple(1, 2 ,3),
    // with types:
    c = Tuple<[number, string, bigint]>(1, "Hello", 9n),
    // from iterable
    d = Tuple.from([1,2,3]);

a.has(0); // return: true
a.has(3); // return: false

a.get(0); // return: 1
a.get(3); // return: undefined

[...a.get(1, 2)]; // return: [2, 3]
[...a.get(1, 4)]; // return: [2, 3]
[...d]; // return: [1, 2, 3]

[...d.concat(a)] // return: [1, 2, 3, 1, 2, 3]

Range

import { Range } from 'iterable-utils';
let a = Range(0, 5),
    // or:
    b = Range(0, 5, 1),
    c = new Range(0, 5);

[...a]; // return: [0, 1, 2, 3, 4, 5]

// example:
const arr = [1, 2, 4, 5];
for (const index of Range(0, arr.length - 1)) {
  console.log(arr[index]);
}

FAQs

Package last updated on 13 May 2021

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts