Skip to content

syrflover/iterator-helper

Repository files navigation

Iterator Helper

github actions npm version

Iterator Helper used AsyncIterator

Contents

Installation

Node

npm install @syrflover/iterator

Deno

Install master branch (as latest)

deno install https://raw.githubusercontent.com/syrflover/iterator-helper/master/mod.ts

Fetch specified version

deno install https://raw.githubusercontent.com/syrflover/iterator-helper/v0.4.1/mod.ts

Usage

Use constructor

// in browser or node
import { iterator } from '@syrflover/iterator';

// in deno
import { iterator } from 'https://raw.githubusercontent.com/syrflover/iterator-helper/master/mod.ts';

iterator([1, 2, 3, 4, 5, 6])
    .filter((e) => e % 2 === 0)
    .map((e) => e + 1)
    .sum()
    .then((r) => logger.info(r)); // 15

Use ArrayLike.prototype.iter

// in browser or node
import '@syrflover/iterator/dist/types/global';

// in deno
import 'https://raw.githubusercontent.com/syrflover/iterator-helper/master/deno/types/global.ts';

[1, 2, 3, 4, 5, 6]
    .iter()
    .filter((e) => e % 2 === 0)
    .map((e) => e + 1)
    .sum()
    .then((r) => logger.info(r)); // 15

List of supported ArrayLike.prototype.iter

  • String
  • Array
  • Int8Array
  • Int16Array
  • Int32Array
  • Uint8Array
  • Uint8ClampedArray
  • Uint16Array
  • Uint32Array
  • Float32Array
  • Float64Array

Path of internal modules

src
├── mod.ts
├── lib
│   ├── compare
│   │   └── mod.ts
│   ├── iterable
│   │   └── mod.ts
│   └── utils
│       └── mod.ts
├── methods
│   └── mod.ts
└── types
    ├── global.ts
    ├── mod.ts
    ├── functions
    │   └── mod.ts
    └── guards
        └── mod.ts

Document

Not Ready

Releases

Github Releases

References