Giter Site home page Giter Site logo

dahlia / aitertools Goto Github PK

View Code? Open in Web Editor NEW
17.0 2.0 0.0 128 KB

Well-tested utility functions dealing with async iterables

Home Page: https://jsr.io/@hongminhee/aitertools

License: GNU Lesser General Public License v3.0

TypeScript 99.89% Shell 0.11%
async-iterators deno itertools typescript

aitertools's Introduction

aitertools

Published on JSR Published on npm LGPL 3.0 GitHub Actions Codecov

This library provides a well-tested collection of small utility functions dealing with async iterables. You can think of it as .NET LINQ or Python aitertools for Deno & Node.js.

Functions

For the complete list of functions, see the complete API reference.

  • concat(...sources): Concatenate multiple async iterables into one.
  • take(source, count): Take the first count items from the source.
  • drop(source, count): Drop the first count items from the source.
  • takeWhile(source, predicate): Take items from the source while the predicate returns true.
  • dropWhile(source, predicate): Drop items from the source while the predicate returns true.
  • takeEnd(source, count): Take the last count items from the source.
  • dropEnd(source, count): Drop the last count items from the source.
  • map(mapper, ...sources): Apply the mapper to each item in the sources.
  • filter(predicate, ...sources): Filter items in the sources by the predicate.
  • reduce(reducer, source, initial?): Reduce the source to a single value by the reducer, optionally with the initial value.
  • tee(source, number): Effectively duplicate the source into number of async iterables.
  • groupBy(source, keySelector): Group items in the source by the keySelector.
  • unique(source, keySelector?): Eliminate duplicate items in the source, optionally by the keySelector.
  • range(start?, stop, step?): Generate a sequence of numbers from start to stop by step.
  • count(start?, step?): Generate a sequence of numbers from start by step infinitely.
  • cycle(source): Cycle the source infinitely.
  • repeat(value, times?): Repeat the value for times times, or infinitely if times is not specified.
  • fromIterable(source): Convert an iterable to an async iterable.
  • toArray(source): Convert an async iterable to an array.
  • toSet(source): Convert an async iterable to a Set.
  • toMap(source, keySelector, valueSelector?): Convert an async iterable to a Map.
  • assertStreams(actual, expected, msg?): Asset that an async iterable actual is equal to an array expected.
  • assertStreamStartsWith(actual, expected, msg?): Asset that an async iterable actual (which is possibly infinite) starts with an array expected.

Usage

In Deno:

$ deno add @hongminhee/aitertools
import * as aitertools from "@hongminhee/aitertools";

In Node.js:

$ npm add aitertools
import * as aitertools from "aitertools";

Changelog

See CHANGES.md file. Note that unreleased versions are also available on JSR for Deno:

deno add @hongminhee/aitertools@0.6.0-dev.36+9aa783c

โ€ฆ and on npm with dev tag for Node.js:

$ npm add aitertools@dev

aitertools's People

Contributors

dahlia avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.