js-itertools
js-itertools copied to clipboard
:hammer_and_wrench: Python's iterable and iterator library for JavaScript
:hammer_and_wrench:
js-itertools

© xkcd.com
Python's iterable and iterator library for JavaScript. Parent is js-library.
:warning: Depending on your environment, the code may require
regeneratorRuntime
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 ...
:newspaper: Description
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.
:deciduous_tree: Hierarchy
The packages are released under multiple npm @scopes.
Extra features are marked with a *
.
@iterable-iterator
-
@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
-
@combinatorics/n-combinations
:combinations
,_combinations*
-
@combinatorics/n-multicombinations
:combinations_with_replacement
asmulticombinations
,_multicombinations*
-
@combinatorics/n-permutations
:permutations
,_permutations*
@set-theory
-
@set-theory/cartesian-product
:product
,diagonal*
-
@set-theory/closure
:closure*
:link: More references in Python and JavaScript
- http://mochi.github.io/mochikit/doc/html/MochiKit/Iter.html
- https://github.com/cweider/js-itertools
- http://itertoolsjs.com
- https://github.com/thegoleffect/node-itertools
- http://rfw.name/sloth.js
- https://github.com/lodash/lodash
- https://github.com/StreetStrider/aux.js