@stdlib/iter

Standard library iterator utilities.

https://github.com/stdlib-js/iter

Science Score: 44.0%

This score indicates how likely this project is to be science-related based on various indicators:

  • CITATION.cff file
    Found CITATION.cff file
  • codemeta.json file
    Found codemeta.json file
  • .zenodo.json file
    Found .zenodo.json file
  • DOI references
  • Academic publication links
  • Committers with academic emails
  • Institutional organization owner
  • JOSS paper metadata
  • Scientific vocabulary similarity
    Low similarity (14.2%) to scientific vocabulary

Keywords

iter iterate iteration iterator iterators javascript node node-js nodejs stdlib util utilities utility utils
Last synced: 6 months ago · JSON representation ·

Repository

Standard library iterator utilities.

Basic Info
  • Host: GitHub
  • Owner: stdlib-js
  • License: apache-2.0
  • Language: JavaScript
  • Default Branch: main
  • Size: 7.32 MB
Statistics
  • Stars: 4
  • Watchers: 3
  • Forks: 0
  • Open Issues: 0
  • Releases: 0
Topics
iter iterate iteration iterator iterators javascript node node-js nodejs stdlib util utilities utility utils
Created almost 5 years ago · Last pushed 6 months ago
Metadata Files
Readme Changelog Contributing License Code of conduct Citation Security

README.md

About stdlib...

We believe in a future in which the web is a preferred environment for numerical computation. To help realize this future, we've built stdlib. stdlib is a standard library, with an emphasis on numerical and scientific computation, written in JavaScript (and C) for execution in browsers and in Node.js.

The library is fully decomposable, being architected in such a way that you can swap out and mix and match APIs and functionality to cater to your exact preferences and use cases.

When you use stdlib, you can be absolutely certain that you are using the most thorough, rigorous, well-written, studied, documented, tested, measured, and high-quality code out there.

To join us in bringing numerical computing to the web, get started by checking us out on GitHub, and please consider financially supporting stdlib. We greatly appreciate your continued support!

Iterators

NPM version Build Status Coverage Status <!-- dependencies -->

Iterator utilities.

## Installation ```bash npm install @stdlib/iter ``` Alternatively, - To load the package in a website via a `script` tag without installation and bundlers, use the [ES Module][es-module] available on the [`esm`][esm-url] branch (see [README][esm-readme]). - If you are using Deno, visit the [`deno`][deno-url] branch (see [README][deno-readme] for usage intructions). - For use in Observable, or in browser/node environments, use the [Universal Module Definition (UMD)][umd] build available on the [`umd`][umd-url] branch (see [README][umd-readme]). The [branches.md][branches-url] file summarizes the available branches and displays a diagram illustrating their relationships. To view installation and usage instructions specific to each branch build, be sure to explicitly navigate to the respective README files on each branch, as linked to above.
## Usage ```javascript var ns = require( '@stdlib/iter' ); ``` #### ns Namespace containing iterator utilities. ```javascript var objectKeys = require( '@stdlib/utils/keys' ); var keys = objectKeys( ns ); // e.g., returns [ 'iterAny', 'iterAnyBy', ... ] ```
- [`iterAdvance( iterator[, n] )`][@stdlib/iter/advance]: advance an iterator. - [`iterAnyBy( iterator, predicate[, thisArg] )`][@stdlib/iter/any-by]: test whether at least one iterated value passes a test implemented by a predicate function. - [`iterAny( iterator )`][@stdlib/iter/any]: test whether at least one iterated value is truthy. - [`iterConcat( iter0, ...iterator )`][@stdlib/iter/concat]: create an iterator which iterates over the values of two or more iterators. - [`iterConstant( value[, options] )`][@stdlib/iter/constant]: create an iterator which always returns the same value. - [`iterCounter( iterator )`][@stdlib/iter/counter]: create an iterator which iteratively computes the number of iterated values. - [`iterDatespace( start, stop[, N][, options] )`][@stdlib/iter/datespace]: create an iterator which returns evenly spaced dates over a specified interval. - [`iterDedupeBy( iterator, [limit,] fcn )`][@stdlib/iter/dedupe-by]: create an iterator which removes consecutive values that resolve to the same value according to a provided function. - [`iterDedupe( iterator[, limit] )`][@stdlib/iter/dedupe]: create an iterator which removes consecutive duplicated values. - [`iterEmpty()`][@stdlib/iter/empty]: create an empty iterator. - [`iterEveryBy( iterator, predicate[, thisArg] )`][@stdlib/iter/every-by]: test whether every iterated value passes a test implemented by a predicate function. - [`iterEvery( iterator )`][@stdlib/iter/every]: test whether all iterated values are truthy. - [`iterFill( iterator, value[, begin[, end]] )`][@stdlib/iter/fill]: create an iterator which replaces all values from a provided iterator from a start index to an end index with a static value. - [`iterFilterMap( iterator, fcn[, thisArg] )`][@stdlib/iter/filter-map]: create an iterator which both filters and maps the values of another iterator. - [`iterFilter( iterator, predicate[, thisArg] )`][@stdlib/iter/filter]: create an iterator which filters the values of another iterator according to a predicate function. - [`iterFirst( iterator )`][@stdlib/iter/first]: return the first iterated value. - [`iterFlow( methods )`][@stdlib/iter/flow]: create a fluent interface for chaining together iterator methods. - [`iterForEach( iterator, fcn[, thisArg] )`][@stdlib/iter/for-each]: create an iterator which invokes a function for each iterated value before returning the iterated value. - [`iterHead( iterator, n )`][@stdlib/iter/head]: create an iterator which returns the first `n` values of a provided iterator. - [`iterIncrspace( start, stop[, increment] )`][@stdlib/iter/incrspace]: create an iterator which returns evenly spaced numbers according to a specified increment. - [`iterIntersectionByHash( iter0, ...iterator, hashFcn[, thisArg] )`][@stdlib/iter/intersection-by-hash]: create an iterator which returns the intersection of two or more iterators according to a hash function. - [`iterIntersection( iter0, ...iterator )`][@stdlib/iter/intersection]: create an iterator which returns the intersection of two or more iterators. - [`iterLast( iterator )`][@stdlib/iter/last]: consume an entire iterator and return the last iterated value. - [`iterLength( iterator )`][@stdlib/iter/length]: return an iterator's length. - [`iterLinspace( start, stop[, N] )`][@stdlib/iter/linspace]: create an iterator which returns evenly spaced numbers over a specified interval. - [`iterLogspace( start, stop[, N][, options] )`][@stdlib/iter/logspace]: create an iterator which returns evenly spaced numbers over a specified interval. - [`iterMap( iterator, fcn[, thisArg] )`][@stdlib/iter/map]: create an iterator which invokes a function for each iterated value. - [`iterMapN( iter0, ...iterator, fcn[, thisArg] )`][@stdlib/iter/mapn]: create an iterator which transforms iterated values from two or more iterators by applying the iterated values as arguments to a provided function. - [`iterNoneBy( iterator, predicate[, thisArg] )`][@stdlib/iter/none-by]: test whether every iterated value fails a test implemented by a predicate function. - [`iterNone( iterator )`][@stdlib/iter/none]: test whether all iterated values are falsy. - [`iterNth( iterator, n )`][@stdlib/iter/nth]: return the nth iterated value. - [`iterThunk( iterFcn[, ...args] )`][@stdlib/iter/pipeline-thunk]: create an iterator "thunk". - [`iterPipeline( iterFcn0[, ...iterFcn] )`][@stdlib/iter/pipeline]: create an iterator pipeline. - [`iterPop( iterator[, clbk[, thisArg]] )`][@stdlib/iter/pop]: create an iterator which skips the last value of a provided iterator. - [`iterPush( iterator, ...items )`][@stdlib/iter/push]: create an iterator which appends additional values to the end of a provided iterator. - [`iterReject( iterator, predicate[, thisArg] )`][@stdlib/iter/reject]: create an iterator which rejects the values of another iterator according to a predicate function. - [`iterReplicateBy( iterator, fcn[, thisArg] )`][@stdlib/iter/replicate-by]: create an iterator which replicates each iterated value according to a provided function. - [`iterReplicate( iterator, n )`][@stdlib/iter/replicate]: create an iterator which replicates each iterated value a specified number of times. - [`iterShift( iterator[, clbk[, thisArg]] )`][@stdlib/iter/shift]: create an iterator which skips the first value of a provided iterator. - [`iterSlice( iterator[, begin[, end]] )`][@stdlib/iter/slice]: create an iterator which returns a subsequence of iterated values from a provided iterator. - [`iterSomeBy( iterator, n, predicate[, thisArg] )`][@stdlib/iter/some-by]: test whether at least `n` iterated values pass a test implemented by a predicate function. - [`iterSome( iterator, n )`][@stdlib/iter/some]: test whether at least `n` iterated values are truthy. - [`iterStep( start, increment[, N] )`][@stdlib/iter/step]: create an iterator which returns a sequence of numbers according to a specified increment. - [`iterStridedBy( iterator, fcn[, offset[, eager]][, thisArg] )`][@stdlib/iter/strided-by]: create an iterator which steps according to a provided callback function. - [`iterStrided( iterator, stride[, offset[, eager]] )`][@stdlib/iter/strided]: create an iterator which steps by a specified amount. - [`iterator2arrayviewRight( iterator, dest[, begin[, end]][, mapFcn[, thisArg]] )`][@stdlib/iter/to-array-view-right]: fill an array-like object view from right to left with values returned from an iterator. - [`iterator2arrayview( iterator, dest[, begin[, end]][, mapFcn[, thisArg]] )`][@stdlib/iter/to-array-view]: fill an array-like object view with values returned from an iterator. - [`iterUnion( iter0, ...iterator )`][@stdlib/iter/union]: create an iterator which returns the union of two or more iterators. - [`iterUniqueByHash( iterator, hashFcn[, thisArg] )`][@stdlib/iter/unique-by-hash]: create an iterator which returns unique values according to a hash function. - [`iterUniqueBy( iterator, predicate[, thisArg] )`][@stdlib/iter/unique-by]: create an iterator which returns unique values according to a predicate function. - [`iterUnique( iterator )`][@stdlib/iter/unique]: create an iterator which returns unique values. - [`iterUnitspace( start[, stop] )`][@stdlib/iter/unitspace]: create an iterator which returns numbers incremented by `1`. - [`iterUnshift( iterator, ...items )`][@stdlib/iter/unshift]: create an iterator which prepends values to the beginning of a provided iterator. - [`whileEach( iterator, predicate, fcn[, thisArg] )`][@stdlib/iter/while-each]: create an iterator which, while a test condition is true, invokes a function for each iterated value before returning the iterated value.
## Examples ```javascript var objectKeys = require( '@stdlib/utils/keys' ); var uncapitalize = require( '@stdlib/string/uncapitalize' ); var replace = require( '@stdlib/string/replace' ); var contains = require( '@stdlib/assert/contains' ); var randu = require( '@stdlib/random/iter/randu' ); var ns = require( '@stdlib/iter' ); // Create a fluent interface for chaining together iterator operations... // Retrieve all the iterator utility names: var keys = objectKeys( ns ); // Define a list of utilities to exclude from the fluent API: var exclude = [ 'iterFlow', 'iterPipeline', 'iterThunk' ]; // Map each utility name to a fluent interface method... var methods = {}; var key; var k; var i; for ( i = 0; i < keys.length; i++ ) { key = keys[ i ]; if ( contains( exclude, key ) ) { continue; } k = uncapitalize( replace( key, /^iter/, '' ) ); methods[ k ] = ns[ key ]; } // Create a fluent interface: var FluentIterator = ns.iterFlow( methods ); // Create a new fluent interface iterator: var it1 = new FluentIterator( randu() ); // Define a predicate function for filtering values: function predicate( v ) { return ( v > 0.25 && v < 0.75 ); } // Define a function which transforms iterated values: function transform( v ) { return v * 10.0; } // Define a function to be invoked for each iterated value: function log( v ) { console.log( v ); } // Chain together a sequence of operations: var it2 = it1.filter( predicate ) .map( transform ) .head( 10 ) .forEach( log ); // Perform manual iteration... var v; while ( true ) { v = it2.next(); if ( v.done ) { break; } } ```
* * * ## Notice This package is part of [stdlib][stdlib], a standard library for JavaScript and Node.js, with an emphasis on numerical and scientific computing. The library provides a collection of robust, high performance libraries for mathematics, statistics, streams, utilities, and more. For more information on the project, filing bug reports and feature requests, and guidance on how to develop [stdlib][stdlib], see the main project [repository][stdlib]. #### Community [![Chat][chat-image]][chat-url] --- ## License See [LICENSE][stdlib-license]. ## Copyright Copyright © 2016-2025. The Stdlib [Authors][stdlib-authors].

Owner

  • Name: stdlib
  • Login: stdlib-js
  • Kind: organization

Standard library for JavaScript.

Citation (CITATION.cff)

cff-version: 1.2.0
title: stdlib
message: >-
  If you use this software, please cite it using the
  metadata from this file.

type: software

authors:
  - name: The Stdlib Authors
    url: https://github.com/stdlib-js/stdlib/graphs/contributors

repository-code: https://github.com/stdlib-js/stdlib
url: https://stdlib.io

abstract: |
  Standard library for JavaScript and Node.js.

keywords:
  - JavaScript
  - Node.js
  - TypeScript
  - standard library
  - scientific computing
  - numerical computing
  - statistical computing

license: Apache-2.0 AND BSL-1.0

date-released: 2016

GitHub Events

Total
  • Push event: 74
  • Create event: 8
Last Year
  • Push event: 74
  • Create event: 8

Committers

Last synced: 8 months ago

All Time
  • Total Commits: 140
  • Total Committers: 1
  • Avg Commits per committer: 140.0
  • Development Distribution Score (DDS): 0.0
Past Year
  • Commits: 36
  • Committers: 1
  • Avg Commits per committer: 36.0
  • Development Distribution Score (DDS): 0.0
Top Committers
Name Email Commits
stdlib-bot n****y@s****o 140
Committer Domains (Top 20 + Academic)

Issues and Pull Requests

Last synced: 8 months ago

All Time
  • Total issues: 0
  • Total pull requests: 0
  • Average time to close issues: N/A
  • Average time to close pull requests: N/A
  • Total issue authors: 0
  • Total pull request authors: 0
  • Average comments per issue: 0
  • Average comments per pull request: 0
  • Merged pull requests: 0
  • Bot issues: 0
  • Bot pull requests: 0
Past Year
  • Issues: 0
  • Pull requests: 0
  • Average time to close issues: N/A
  • Average time to close pull requests: N/A
  • Issue authors: 0
  • Pull request authors: 0
  • Average comments per issue: 0
  • Average comments per pull request: 0
  • Merged pull requests: 0
  • Bot issues: 0
  • Bot pull requests: 0
Top Authors
Issue Authors
Pull Request Authors
Top Labels
Issue Labels
Pull Request Labels

Packages

  • Total packages: 1
  • Total downloads:
    • npm 15,562 last-month
  • Total dependent packages: 7
  • Total dependent repositories: 19
  • Total versions: 21
  • Total maintainers: 4
npmjs.org: @stdlib/iter

Standard iterator utilities.

  • Homepage: https://stdlib.io
  • License: Apache-2.0
  • Latest release: 0.3.3
    published over 1 year ago
  • Versions: 21
  • Dependent Packages: 7
  • Dependent Repositories: 19
  • Downloads: 15,562 Last month
Rankings
Downloads: 1.1%
Dependent packages count: 2.8%
Dependent repos count: 2.8%
Average: 6.9%
Stargazers count: 12.2%
Forks count: 15.4%
Funding
  • type: opencollective
  • url: https://opencollective.com/stdlib
Last synced: 6 months ago

Dependencies

package.json npm
  • @stdlib/bench github:stdlib-js/bench development
  • @stdlib/complex github:stdlib-js/complex development
  • @stdlib/random github:stdlib-js/random development
  • @stdlib/simulate github:stdlib-js/simulate development
  • @stdlib/strided github:stdlib-js/strided development
  • istanbul ^0.4.1 development
  • proxyquire ^2.0.0 development
  • tap-spec 5.x.x development
  • tape git+https://github.com/kgryte/tape.git#fix/globby development
  • @stdlib/array github:stdlib-js/array#main
  • @stdlib/assert github:stdlib-js/assert#main
  • @stdlib/constants github:stdlib-js/constants#main
  • @stdlib/math github:stdlib-js/math#main
  • @stdlib/string github:stdlib-js/string#main
  • @stdlib/symbol github:stdlib-js/symbol#main
  • @stdlib/types github:stdlib-js/types#main
  • @stdlib/utils github:stdlib-js/utils#main
.github/workflows/benchmark.yml actions
  • actions/checkout v3 composite
  • actions/setup-node v3 composite
.github/workflows/cancel.yml actions
  • styfle/cancel-workflow-action 0.11.0 composite
.github/workflows/close_pull_requests.yml actions
  • superbrothers/close-pull-request v3 composite
.github/workflows/examples.yml actions
  • actions/checkout v3 composite
  • actions/setup-node v3 composite
.github/workflows/npm_downloads.yml actions
  • actions/checkout v3 composite
  • actions/setup-node v3 composite
  • actions/upload-artifact v3 composite
  • distributhor/workflow-webhook v3 composite
.github/workflows/productionize.yml actions
  • act10ns/slack v1 composite
  • actions/checkout v3 composite
  • actions/setup-node v3 composite
  • stdlib-js/bundle-action main composite
  • stdlib-js/transform-errors-action main composite
.github/workflows/publish.yml actions
  • JS-DevTools/npm-publish v1 composite
  • act10ns/slack v1 composite
  • actions/checkout v3 composite
  • actions/setup-node v3 composite
  • styfle/cancel-workflow-action 0.11.0 composite
.github/workflows/test.yml actions
  • act10ns/slack v1 composite
  • actions/checkout v3 composite
  • actions/setup-node v3 composite
.github/workflows/test_bundles.yml actions
  • act10ns/slack v1 composite
  • actions/checkout v3 composite
  • actions/setup-node v3 composite
  • denoland/setup-deno v1 composite
.github/workflows/test_coverage.yml actions
  • act10ns/slack v1 composite
  • actions/checkout v3 composite
  • actions/setup-node v3 composite
  • codecov/codecov-action v3 composite
  • distributhor/workflow-webhook v3 composite
.github/workflows/test_install.yml actions
  • act10ns/slack v1 composite
  • actions/checkout v3 composite
  • actions/setup-node v3 composite
advance/package.json npm
any/package.json npm
any-by/package.json npm
concat/package.json npm
constant/package.json npm
counter/package.json npm
datespace/package.json npm
dedupe/package.json npm
dedupe-by/package.json npm
empty/package.json npm
every/package.json npm
every-by/package.json npm
fill/package.json npm
filter/package.json npm
filter-map/package.json npm
first/package.json npm
flow/package.json npm
for-each/package.json npm
head/package.json npm
incrspace/package.json npm
intersection/package.json npm
intersection-by-hash/package.json npm
last/package.json npm
length/package.json npm
linspace/package.json npm
logspace/package.json npm
map/package.json npm
mapn/package.json npm
none/package.json npm
none-by/package.json npm
nth/package.json npm
pipeline/package.json npm
pipeline-thunk/package.json npm
pop/package.json npm
push/package.json npm
reject/package.json npm
replicate/package.json npm
replicate-by/package.json npm
shift/package.json npm
slice/package.json npm
some/package.json npm
some-by/package.json npm
step/package.json npm
strided/package.json npm
strided-by/package.json npm
to-array-view/package.json npm
to-array-view-right/package.json npm
union/package.json npm
unique/package.json npm
unique-by/package.json npm
unique-by-hash/package.json npm
unitspace/package.json npm
unshift/package.json npm
while-each/package.json npm
until-each/package.json npm
do-while-each/package.json npm
do-until-each/package.json npm