Installations
npm install @stdlib/streams-node-from-circular-array
Developer Guide
Typescript
Yes
Module System
CommonJS
Min. Node Version
>=0.10.0
Node Version
16.20.2
NPM Version
8.19.4
Score
67.2
Supply Chain
82.3
Quality
81.5
Maintenance
100
Vulnerability
87.6
License
Releases
Unable to fetch releases
Contributors
Unable to fetch Contributors
Languages
JavaScript (100%)
Love this project? Help keep it running — sponsor us today! 🚀
Developer
Download Statistics
Total Downloads
4,464
Last Day
2
Last Week
21
Last Month
97
Last Year
912
GitHub Statistics
Apache-2.0 License
2 Stars
61 Commits
3 Watchers
5 Branches
11 Contributors
Updated on Dec 01, 2024
Bundle Size
59.46 kB
Minified
15.67 kB
Minified + Gzipped
Sponsor this package
Package Meta Information
Latest Version
0.2.2
Package Id
@stdlib/streams-node-from-circular-array@0.2.2
Unpacked Size
87.84 kB
Size
17.26 kB
File Count
16
NPM Version
8.19.4
Node Version
16.20.2
Published on
Jul 28, 2024
Total Downloads
Cumulative downloads
Total Downloads
4,464
Last Day
0%
2
Compared to previous day
Last Week
-8.7%
21
Compared to previous week
Last Month
11.5%
97
Compared to previous month
Last Year
-33%
912
Compared to previous year
Daily Downloads
Weekly Downloads
Monthly Downloads
Yearly Downloads
Dependencies
21
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!
Circular Array Stream
Create a readable stream from a circular array-like object.
Installation
1npm install @stdlib/streams-node-from-circular-array
Usage
1var circularArrayStream = require( '@stdlib/streams-node-from-circular-array' );
circularArrayStream( src[, options] )
Returns a readable stream from an array-like object
which repeatedly iterates over a provided value's elements.
1var inspectStream = require( '@stdlib/streams-node-inspect-sink' ); 2 3var iStream; 4var stream; 5var count; 6 7function log( chunk ) { 8 console.log( chunk.toString() ); 9 count += 1; 10 if ( count === 20 ) { 11 stream.destroy(); 12 } 13} 14 15stream = circularArrayStream( [ 1, 2, 3, 4 ] ); 16iStream = inspectStream( log ); 17 18count = 0; 19stream.pipe( iStream );
The function accepts the following options
:
- objectMode: specifies whether a stream should operate in objectMode. Default:
false
. - encoding: specifies how
Buffer
objects should be decoded tostrings
. Default:null
. - highWaterMark: specifies the maximum number of bytes to store in an internal buffer before pausing streaming.
- sep: separator used to join streamed data. This option is only applicable when a stream is not in objectMode. Default:
'\n'
. - serialize: custom serialization function. This option is only applicable when a stream is not in objectMode.
- iter: number of iterations. Default:
1e308
. - dir: iteration direction. If set to
-1
, the stream iterates over elements from right-to-left. Default:1
.
To set stream options
,
1var opts = { 2 'objectMode': true, 3 'encoding': 'utf8', 4 'highWaterMark': 64 5}; 6 7var stream = circularArrayStream( [ 1, 2, 3, 4 ], opts );
By default, the returned stream is an infinite stream (i.e., never ends). To limit the number of streamed values, set the iter
option.
1var inspectStream = require( '@stdlib/streams-node-inspect-sink' ); 2 3function log( chunk ) { 4 console.log( chunk.toString() ); 5} 6 7var opts = { 8 'iter': 10 9}; 10var stream = circularArrayStream( [ 1, 2, 3, 4 ], opts ); 11var iStream = inspectStream( log ); 12 13stream.pipe( iStream );
By default, when not operating in objectMode, a returned stream delineates individual values using a newline character. To specify an alternative separator, set the sep
option.
1var inspectStream = require( '@stdlib/streams-node-inspect-sink' ); 2 3function log( chunk ) { 4 console.log( chunk.toString() ); 5} 6 7var stream = circularArrayStream( [ 1, 2, 3, 4 ], { 8 'sep': ',', 9 'iter': 10 10}); 11 12var iStream = inspectStream( log ); 13 14stream.pipe( iStream );
By default, when not operating in objectMode, a returned stream serializes values as JSON strings. To specify custom serialization behavior (either to a string
or Buffer
), set the serialize
option.
1var inspectStream = require( '@stdlib/streams-node-inspect-sink' ); 2 3function serialize( v ) { 4 return 'v::' + v.toString(); 5} 6 7function log( chunk ) { 8 console.log( chunk.toString() ); 9} 10 11var stream = circularArrayStream( [ 1, 2, 3, 4 ], { 12 'serialize': serialize, 13 'iter': 10 14}); 15 16var iStream = inspectStream( log ); 17 18stream.pipe( iStream );
circularArrayStream.factory( [options] )
Returns a function
for creating readable streams from array-like objects.
1var opts = { 2 'objectMode': true, 3 'encoding': 'utf8', 4 'highWaterMark': 64 5}; 6 7var createStream = circularArrayStream.factory( opts ); 8 9var stream1 = createStream( [ 1, 2, 3, 4 ] ); 10var stream2 = createStream( [ 5, 6, 7, 8 ] ); 11// ...
The method accepts the same options
as circularArrayStream()
.
circularArrayStream.objectMode( src[, options] )
This method is a convenience function to create streams which always operate in objectMode.
1var inspectStream = require( '@stdlib/streams-node-inspect-sink' ); 2 3function log( v ) { 4 console.log( v ); 5} 6 7var opts = { 8 'iter': 10 9}; 10var stream = circularArrayStream.objectMode( [ 1, 2, 3, 4 ], opts ); 11 12opts = { 13 'objectMode': true 14}; 15var iStream = inspectStream( opts, log ); 16 17stream.pipe( iStream );
This method accepts the same options
as circularArrayStream()
; however, the method will always override the objectMode
option in options
.
Notes
- In
objectMode
,null
is a reserved value. If anarray
containsnull
values (e.g., as a means to encode missing values), the stream will prematurely end. Consider an alternative encoding or filternull
values prior to invocation. - In binary mode, if an
array
containsundefined
values, the stream will emit an error. Consider providing a custom serialization function or filteringundefined
values prior to invocation.
Examples
1var inspectStream = require( '@stdlib/streams-node-inspect-sink' ); 2var randu = require( '@stdlib/random-base-randu' ); 3var Float64Array = require( '@stdlib/array-float64' ); 4var circularArrayStream = require( '@stdlib/streams-node-from-circular-array' ); 5 6function log( v ) { 7 console.log( v.toString() ); 8} 9 10// Create an array containing uniformly distributed pseudorandom numbers: 11var arr = new Float64Array( 10 ); 12 13var i; 14for ( i = 0; i < arr.length; i++ ) { 15 arr[ i ] = randu(); 16} 17 18// Convert the array to a stream: 19var opts = { 20 'objectMode': true, 21 'iter': arr.length * 3 22}; 23var stream = circularArrayStream( arr, opts ); 24 25// Create a writable stream for inspecting stream data: 26opts = { 27 'objectMode': true 28}; 29var iStream = inspectStream( opts, log ); 30 31// Begin data flow: 32stream.pipe( iStream );
See Also
@stdlib/streams-node/from-array
: create a readable stream from an array-like object.@stdlib/streams-node/from-iterator
: create a readable stream from an iterator.@stdlib/streams-node/from-strided-array
: create a readable stream from a strided array-like object.
Notice
This package is part of 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, see the main project repository.
Community
License
See LICENSE.
Copyright
Copyright © 2016-2024. The Stdlib Authors.

No vulnerabilities found.
Reason
no binaries found in the repo
Reason
no dangerous workflow patterns detected
Reason
0 existing vulnerabilities detected
Reason
license file detected
Details
- Info: project has a license file: LICENSE:0
- Info: FSF or OSI recognized license: Apache License 2.0: LICENSE:0
Reason
security policy file detected
Details
- Info: security policy file detected: SECURITY.md:1
- Info: Found linked content: SECURITY.md:1
- Warn: One or no descriptive hints of disclosure, vulnerability, and/or timelines in security policy
- Info: Found text in security policy: SECURITY.md:1
Reason
dependency not pinned by hash detected -- score normalized to 3
Details
- Warn: third-party GitHubAction not pinned by hash: .github/workflows/productionize.yml:275: update your workflow using https://app.stepsecurity.io/secureworkflow/stdlib-js/streams-node-from-circular-array/productionize.yml/main?enable=pin
- Warn: third-party GitHubAction not pinned by hash: .github/workflows/productionize.yml:449: update your workflow using https://app.stepsecurity.io/secureworkflow/stdlib-js/streams-node-from-circular-array/productionize.yml/main?enable=pin
- Warn: third-party GitHubAction not pinned by hash: .github/workflows/productionize.yml:457: update your workflow using https://app.stepsecurity.io/secureworkflow/stdlib-js/streams-node-from-circular-array/productionize.yml/main?enable=pin
- Warn: third-party GitHubAction not pinned by hash: .github/workflows/productionize.yml:623: update your workflow using https://app.stepsecurity.io/secureworkflow/stdlib-js/streams-node-from-circular-array/productionize.yml/main?enable=pin
- Warn: third-party GitHubAction not pinned by hash: .github/workflows/productionize.yml:85: update your workflow using https://app.stepsecurity.io/secureworkflow/stdlib-js/streams-node-from-circular-array/productionize.yml/main?enable=pin
- Warn: npmCommand not pinned by hash: .github/workflows/benchmark.yml:58
- Warn: npmCommand not pinned by hash: .github/workflows/benchmark.yml:58
- Warn: npmCommand not pinned by hash: .github/workflows/benchmark.yml:58
- Warn: npmCommand not pinned by hash: .github/workflows/examples.yml:58
- Warn: npmCommand not pinned by hash: .github/workflows/examples.yml:58
- Warn: npmCommand not pinned by hash: .github/workflows/examples.yml:58
- Warn: npmCommand not pinned by hash: .github/workflows/productionize.yml:436
- Warn: npmCommand not pinned by hash: .github/workflows/productionize.yml:436
- Warn: npmCommand not pinned by hash: .github/workflows/productionize.yml:436
- Warn: npmCommand not pinned by hash: .github/workflows/productionize.yml:617
- Warn: npmCommand not pinned by hash: .github/workflows/productionize.yml:617
- Warn: npmCommand not pinned by hash: .github/workflows/productionize.yml:617
- Warn: npmCommand not pinned by hash: .github/workflows/productionize.yml:157
- Warn: npmCommand not pinned by hash: .github/workflows/productionize.yml:157
- Warn: npmCommand not pinned by hash: .github/workflows/productionize.yml:157
- Warn: npmCommand not pinned by hash: .github/workflows/productionize.yml:165
- Warn: npmCommand not pinned by hash: .github/workflows/productionize.yml:269
- Warn: npmCommand not pinned by hash: .github/workflows/productionize.yml:269
- Warn: npmCommand not pinned by hash: .github/workflows/productionize.yml:269
- Warn: npmCommand not pinned by hash: .github/workflows/test.yml:76
- Warn: npmCommand not pinned by hash: .github/workflows/test.yml:76
- Warn: npmCommand not pinned by hash: .github/workflows/test.yml:76
- Warn: npmCommand not pinned by hash: .github/workflows/test.yml:83
- Warn: npmCommand not pinned by hash: .github/workflows/test_bundles.yml:72
- Warn: npmCommand not pinned by hash: .github/workflows/test_coverage.yml:67
- Warn: npmCommand not pinned by hash: .github/workflows/test_coverage.yml:67
- Warn: npmCommand not pinned by hash: .github/workflows/test_coverage.yml:67
- Warn: npmCommand not pinned by hash: .github/workflows/test_coverage.yml:74
- Warn: npmCommand not pinned by hash: .github/workflows/test_install.yml:75
- Warn: npmCommand not pinned by hash: .github/workflows/test_install.yml:75
- Warn: npmCommand not pinned by hash: .github/workflows/test_install.yml:75
- Warn: npmCommand not pinned by hash: .github/workflows/test_published_package.yml:93
- Info: 33 out of 33 GitHub-owned GitHubAction dependencies pinned
- Info: 19 out of 24 third-party GitHubAction dependencies pinned
- Info: 0 out of 32 npmCommand dependencies pinned
Reason
1 commit(s) and 0 issue activity found in the last 90 days -- score normalized to 0
Reason
Found 0/30 approved changesets -- score normalized to 0
Reason
no effort to earn an OpenSSF best practices badge detected
Reason
project is not fuzzed
Details
- Warn: no fuzzer integrations found
Reason
no SAST tool detected
Details
- Warn: no pull requests merged into dev branch
Reason
detected GitHub workflow tokens with excessive permissions
Details
- Warn: no topLevel permission defined: .github/workflows/benchmark.yml:1
- Warn: no topLevel permission defined: .github/workflows/cancel.yml:1
- Warn: no topLevel permission defined: .github/workflows/close_pull_requests.yml:1
- Warn: no topLevel permission defined: .github/workflows/examples.yml:1
- Warn: no topLevel permission defined: .github/workflows/npm_downloads.yml:1
- Warn: no topLevel permission defined: .github/workflows/productionize.yml:1
- Warn: no topLevel permission defined: .github/workflows/publish.yml:1
- Warn: no topLevel permission defined: .github/workflows/test.yml:1
- Warn: no topLevel permission defined: .github/workflows/test_bundles.yml:1
- Warn: no topLevel permission defined: .github/workflows/test_coverage.yml:1
- Warn: no topLevel permission defined: .github/workflows/test_install.yml:1
- Warn: no topLevel permission defined: .github/workflows/test_published_package.yml:1
- Info: no jobLevel write permissions found
Reason
branch protection not enabled on development/release branches
Details
- Warn: branch protection not enabled for branch 'main'
Score
4.2
/10
Last Scanned on 2025-02-10
The Open Source Security Foundation is a cross-industry collaboration to improve the security of open source software (OSS). The Scorecard provides security health metrics for open source projects.
Learn MoreOther packages similar to @stdlib/streams-node-from-circular-array
@taktikorg/unde-animi-omnis
<p align="center"> <a href="https://www.npmjs.com/package/@taktikorg/unde-animi-omnis"><img src="https://img.shields.io/npm/v/@taktikorg/unde-animi-omnis"></a> <a href=""><img src="https://img.shields.io/github/actions/workflow/status/RemiMyrset/@taktikor
@womorg/recusandae-eveniet-quos
<!-- markdownlint-disable MD024 MD034 MD033 -->
@devtea2026/odio-corrupti-illo-delectus
@womorg/adipisci-enim-illum
[](https://www.npmjs.com/package/@womorg/adipisci-enim-illum)