© xkcd.com
Python's iterable and iterator library for JavaScript. Parent is js-library.
⚠️ Depending on your environment, the code may requireregeneratorRuntime
to be defined, for instance by importing regenerator-runtime/runtime.
import {cycle} from '@iterable-iterator/cycle';
import {chain} from '@iterable-iterator/chain';
cycle( chain( [ 0 , 1 , 2 ] , [ 3 , 4 , 5 ] ) ) ; // 0 1 2 3 4 5 0 1 ...
The goal of this project is to make (the parts that interest me of) the following python constructs/idioms/libraries available in JavaScript under the .
iter
,next
,StopIteration
,list
,sorted
,map
,zip
,filter
,sum
,any
,all
,min
,max
- itertools
- itertools recipes
- more-itertools
- cardinality
reduce
The corresponding software library used to be released as a monolith. It has since been split up into multiple packages.
The packages are released under multiple npm @scopes.
Extra features are marked with a *
.
@iterable-iterator/cardinality
:isEmpty
,count
, ...@iterable-iterator/chain
:chain
,chain.from_iterable
as_chain
@iterable-iterator/consume
:consume(it, n)
asconsume
,consume(it)
asexhaust
@iterable-iterator/convolution
:convolve
asconvolution
,_convolution*
@iterable-iterator/count
:count
@iterable-iterator/cycle
:cycle
,ncycles
asncycle
@iterable-iterator/filter
:filter
,filtertrue
,filterfalse
,compress
@iterable-iterator/group
:group
,groupby
,by*
@iterable-iterator/iter
:iter
@iterable-iterator/list
:list
@iterable-iterator/map
:map
(:warning: unary only),starmap
,pick
@iterable-iterator/next
:next
,StopIteration
,_next*
@iterable-iterator/range
:range
@iterable-iterator/reduce
:reduce
,sum
,any
,all
,some
,min
,max
@iterable-iterator/repeat
:repeat
,nrepeat
@iterable-iterator/reversed
:reversed
@iterable-iterator/round-robin
:roundRobin
@iterable-iterator/select
:first
,last
,nth*
(:sparkles: supports negative indices)@iterable-iterator/slice
:take
(also aliased tohead
),drop
,trunc
,tail
,takewhile
,dropwhile
,islice
asslice
@iterable-iterator/sorted
:sorted
@iterable-iterator/tee
:tee
@iterable-iterator/window
:window*
@iterable-iterator/zip
:zip
,zip_longest
asziplongest
,enumerate
@combinatorics/n-combinations
:combinations
,_combinations*
@combinatorics/n-multicombinations
:combinations_with_replacement
asmulticombinations
,_multicombinations*
@combinatorics/n-permutations
:permutations
,_permutations*
@set-theory/cartesian-product
:product
,diagonal*
@set-theory/closure
:closure*