Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/syrflover/iterator-helper
Iterator Helper for TypeScript
https://github.com/syrflover/iterator-helper
async async-iterator deno iterator node nodejs typescript
Last synced: 4 months ago
JSON representation
Iterator Helper for TypeScript
- Host: GitHub
- URL: https://github.com/syrflover/iterator-helper
- Owner: syrflover
- License: mit
- Created: 2019-10-22T14:25:38.000Z (over 5 years ago)
- Default Branch: master
- Last Pushed: 2021-05-20T14:57:32.000Z (over 3 years ago)
- Last Synced: 2024-09-19T01:40:07.316Z (5 months ago)
- Topics: async, async-iterator, deno, iterator, node, nodejs, typescript
- Language: TypeScript
- Homepage:
- Size: 1.03 MB
- Stars: 4
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# Iterator Helper
[![github actions](https://github.com/syrflover/iterator-helper/workflows/test/badge.svg)](https://github.com/syrflover/iterator-helper/actions?query=workflow%3Atest+)
[![npm version](https://img.shields.io/npm/v/@syrflover/iterator?label=npm%20version)](https://www.npmjs.com/package/@syrflover/iterator)Iterator Helper used `AsyncIterator`
## Contents
- [Installation](#installation)
- [Usage](#usage)
- [Path of internal modules](#path-of-internal-modules)
- [TypeDoc](#typedoc)
- [Releases](#releases)
- [References](#references)## Installation
### Node
```bash
npm install @syrflover/iterator
```### Deno
Install master branch (as latest)
```bash
deno install https://raw.githubusercontent.com/syrflover/iterator-helper/master/mod.ts
```Fetch specified version
```bash
deno install https://raw.githubusercontent.com/syrflover/iterator-helper/v0.4.1/mod.ts
```## Usage
### Use constructor
```typescript
// 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
```typescript
// 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
```txt
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](https://github.com/syrflover/iterator-helper/releases)
## References
- https://github.com/tc39/proposal-iterator-helpers
- https://doc.rust-lang.org/stable/std/iter/trait.Iterator.html
- https://hackage.haskell.org/package/base-4.12.0.0/docs/Data-List.html