All Projects → TomerAberbach → betterator

TomerAberbach / betterator

Licence: Apache-2.0 license
💯 A better sync and async iterator API.

Programming Languages

typescript
32286 projects

Projects that are alternatives of or similar to betterator

iterum
Handling iterables like lazy arrays.
Stars: ✭ 28 (-50.88%)
Mutual labels:  iterator, iterable
iterative
Functions for working with iterators in JavaScript and TypeScript
Stars: ✭ 16 (-71.93%)
Mutual labels:  iterator, iterable
Scandir
Better directory iterator and faster os.walk(), now in the Python 3.5 stdlib
Stars: ✭ 471 (+726.32%)
Mutual labels:  iterator
Libdict
C library of key-value data structures.
Stars: ✭ 234 (+310.53%)
Mutual labels:  iterator
Rubico
[a]synchronous functional programming
Stars: ✭ 133 (+133.33%)
Mutual labels:  iterator
Linq In Rust
Language Integrated Query in Rust.
Stars: ✭ 48 (-15.79%)
Mutual labels:  iterator
Mir Algorithm
Dlang Core Library
Stars: ✭ 143 (+150.88%)
Mutual labels:  iterator
Tbox
🎁 A glib-like multi-platform c library
Stars: ✭ 3,800 (+6566.67%)
Mutual labels:  iterator
oh-my-design-patterns
🎨 Record the articles and code I wrote while learning design patterns
Stars: ✭ 33 (-42.11%)
Mutual labels:  iterator
Gkvdb
[mirror] Go语言开发的基于DRH(Deep-Re-Hash)深度哈希分区算法的高性能高可用Key-Value嵌入式事务数据库。基于纯Go语言实现,具有优异的跨平台性,良好的高可用及文件IO复用设计,高效的底层数据库文件操作性能,支持原子操作、批量操作、事务操作、多表操作、多表事务、随机遍历等特性。
Stars: ✭ 109 (+91.23%)
Mutual labels:  iterator
Php Pdo Mysql Class
A PHP MySQL PDO class similar to the the Python MySQLdb, which supports iterator and parameter binding when using "WHERE IN" statement.
Stars: ✭ 213 (+273.68%)
Mutual labels:  iterator
Gods
GoDS (Go Data Structures). Containers (Sets, Lists, Stacks, Maps, Trees), Sets (HashSet, TreeSet, LinkedHashSet), Lists (ArrayList, SinglyLinkedList, DoublyLinkedList), Stacks (LinkedListStack, ArrayStack), Maps (HashMap, TreeMap, HashBidiMap, TreeBidiMap, LinkedHashMap), Trees (RedBlackTree, AVLTree, BTree, BinaryHeap), Comparators, Iterators, …
Stars: ✭ 10,883 (+18992.98%)
Mutual labels:  iterator
Resumablefunctions.jl
C# style generators a.k.a. semi-coroutines for Julia.
Stars: ✭ 82 (+43.86%)
Mutual labels:  iterator
Rolling
Computationally efficient rolling window iterators for Python (including sum, min/max, median and more...)
Stars: ✭ 158 (+177.19%)
Mutual labels:  iterator
Finder
The Finder component finds files and directories via an intuitive fluent interface.
Stars: ✭ 7,840 (+13654.39%)
Mutual labels:  iterator
Staticvec
Implements a fixed-capacity stack-allocated Vec alternative backed by an array, using const generics.
Stars: ✭ 236 (+314.04%)
Mutual labels:  iterator
Tstl
TypeScript-STL (Standard Template Library, migrated from C++)
Stars: ✭ 397 (+596.49%)
Mutual labels:  iterator
Easyiterator
🏃 Iterators made easy! Zero cost abstractions for designing and using C++ iterators.
Stars: ✭ 107 (+87.72%)
Mutual labels:  iterator
Designpatterns
🔑Elements of Reusable Object-Oriented Software🔓is a software engineering book describing software design patterns. The book's authors are Erich Gamma, Richard Helm, Ralph Johnson and John Vlissides with a foreword by Grady Booch.
Stars: ✭ 134 (+135.09%)
Mutual labels:  iterator
AsyncIterator
An asynchronous iterator library for advanced object pipelines in JavaScript
Stars: ✭ 43 (-24.56%)
Mutual labels:  iterator

betterator

A better sync and async iterator API.

Features

  • Intuitive: easy to use hasNext and getNext methods
  • Familiar: lots of other programming languages use the same API
  • Tiny: ~400 bytes minzipped
  • Awesome Name: you have to admit it's pretty rad 😎

Install

$ npm i betterator

Usage

import { Betterator, AsyncBetterator } from 'betterator'

const slothActivities = [`sleeping`, `eating`, `climbing`]

// Or `new Betterator(slothActivities[Symbol.iterator]())`
const iterator = Betterator.fromIterable(slothActivities)

while (iterator.hasNext()) {
  console.log(iterator.getNext())
}
//=> sleeping
//=> eating
//=> climbing

try {
  iterator.getNext()
} catch (e) {
  console.log(e.message)
}
//=> Doesn't have next

console.log(iterator.getNextOr(() => `being lazy`))
//=> being lazy

const asyncSlothActivities = (async function* () {
  yield* slothActivities
})()

// Or `new AsyncBetterator(slothActivities[Symbol.asyncIterator]())`
const asyncIterator = AsyncBetterator.fromAsyncIterable(asyncSlothActivities)

while (await asyncIterator.hasNext()) {
  console.log(await asyncIterator.getNext())
}
//=> sleeping
//=> eating
//=> climbing

try {
  await asyncIterator.getNext()
} catch (e) {
  console.log(e.message)
}
//=> Doesn't have next

const delay = timeout => new Promise(resolve => setTimeout(resolve, timeout))
console.log(
  await asyncIterator.getNextOr(() => delay(10).then(() => `being lazy`)),
)
//=> being lazy

See the type definitions for more documentation.

Contributing

Stars are always welcome!

For bugs and feature requests, please create an issue.

For pull requests, please read the contributing guidelines.

License

Apache 2.0

This is not an official Google product.

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].