diff --git a/.github/.keepalive b/.github/.keepalive deleted file mode 100644 index ec35ce4..0000000 --- a/.github/.keepalive +++ /dev/null @@ -1 +0,0 @@ -2024-01-01T02:52:10.010Z diff --git a/NOTICE b/NOTICE index f7aca1b..e6e7482 100644 --- a/NOTICE +++ b/NOTICE @@ -1 +1 @@ -Copyright (c) 2016-2023 The Stdlib Authors. +Copyright (c) 2016-2024 The Stdlib Authors. diff --git a/dist/index.js b/dist/index.js index 955ea81..7c427a2 100644 --- a/dist/index.js +++ b/dist/index.js @@ -1,13 +1,13 @@ -"use strict";var s=function(e,r){return function(){return r||e((r={exports:{}}).exports,r),r.exports}};var c=s(function(ae,S){S.exports={objectMode:!1,encoding:null,sep:"\n",dir:1}});var b=s(function(ne,m){ -var T=require('@stdlib/assert-is-plain-object/dist'),u=require('@stdlib/assert-has-own-property/dist'),z=require('@stdlib/assert-is-boolean/dist').isPrimitive,k=require('@stdlib/assert-is-nonnegative-number/dist').isPrimitive,g=require('@stdlib/assert-is-string/dist').isPrimitive,N=require('@stdlib/assert-is-function/dist'),t=require('@stdlib/error-tools-fmtprodmsg/dist');function W(e,r){return T(r)?u(r,"sep")&&(e.sep=r.sep,!g(e.sep))?new TypeError(t('1M92W',"sep",e.sep)):u(r,"objectMode")&&(e.objectMode=r.objectMode,!z(e.objectMode))?new TypeError(t('1M92o',"objectMode",e.objectMode)):u(r,"encoding")&&(e.encoding=r.encoding,!g(e.encoding)&&e.encoding!==null)?new TypeError(t('1M97n',"encoding",e.encoding)):u(r,"highWaterMark")&&(e.highWaterMark=r.highWaterMark,!k(e.highWaterMark))?new TypeError(t('1M94k',"highWaterMark",e.highWaterMark)):u(r,"serialize")&&(e.serialize=r.serialize,!N(e.serialize))?new TypeError(t('1M96p',"serialize",e.serialize)):u(r,"dir")&&(e.dir=r.dir,e.dir!==1&&e.dir!==-1)?new TypeError(t('1M92v',"dir",e.dir)):null:new TypeError(t('1M92V',r));}m.exports=W -});var q=s(function(se,y){ -var A=require("debug"),F=A("from-array-stream");y.exports=F -});var l=s(function(ue,w){ -var _=require("readable-stream").Readable,V=require('@stdlib/assert-is-collection/dist'),B=require('@stdlib/assert-is-error/dist'),J=require('@stdlib/assert-is-buffer/dist'),p=require('@stdlib/error-tools-fmtprodmsg/dist'),P=require('@stdlib/object-assign/dist'),R=require('@stdlib/utils-inherit/dist'),f=require('@stdlib/utils-define-nonenumerable-property/dist'),a=require('@stdlib/utils-define-nonenumerable-read-only-property/dist'),h=require('@stdlib/buffer-from-string/dist'),C=require('@stdlib/buffer-ctor/dist'),I=require('@stdlib/utils-next-tick/dist'),L=c(),D=b(),o=q();function G(){var e,r,i;if(!this._destroyed)for(e=!0;e;){if(r=null,this._i+=1,this._i>this._src.length)return o("Finished iteration."),this.push(null);i=this._src[this._idx],o("Value: %s. Idx: %d. Iter: %d.",JSON.stringify(i),this._idx,this._i),this._idx+=this._stride,this._objectMode===!1&&(i=this._serialize(i),typeof i=="string"?this._i===1?i=h(i):i=h(this._sep+i):J(i)?this._i>1&&(i=C.concat([h(this._sep),i])):r=new Error(p('1M9A9',i))),r?this.emit("error",r):e=this.push(i)}}function U(e){var r;if(this._destroyed)return o("Attempted to destroy an already destroyed stream."),this;return r=this,this._destroyed=!0,I(i),this;function i(){e&&(o("Stream was destroyed due to an error. Error: %s.",B(e)?e.message:JSON.stringify(e)),r.emit("error",e)),o("Closing the stream..."),r.emit("close")}}function n(e,r){var i,d;if(!(this instanceof n))return arguments.length>1?new n(e,r):new n(e);if(!V(e))throw new TypeError(p('1M92O',e));if(i=P({},L),arguments.length>1&&(d=D(i,r),d))throw d;return o("Creating a readable stream configured with the following options: %s.",JSON.stringify(i)),_.call(this,i),f(this,"_destroyed",!1),a(this,"_objectMode",i.objectMode),a(this,"_sep",i.sep),a(this,"_serialize",i.serialize||JSON.stringify),a(this,"_src",e),a(this,"_stride",i.dir),f(this,"_i",0),f(this,"_idx",i.dir===1?0:e.length-1),this}R(n,_);a(n.prototype,"_read",G);a(n.prototype,"destroy",U);w.exports=n -});var j=s(function(oe,M){ -var H=require('@stdlib/assert-is-plain-object/dist'),K=require('@stdlib/error-tools-fmtprodmsg/dist'),Q=require('@stdlib/object-assign/dist'),X=l();function Y(e,r){var i;if(arguments.length>1){if(i=r,!H(i))throw new TypeError(K('1M92V',i));i=Q({},r)}else i={};return i.objectMode=!0,new X(e,i)}M.exports=Y -});var E=s(function(de,O){ -var Z=require('@stdlib/object-assign/dist'),$=l();function ee(e){var r;return arguments.length?r=Z({},e):r={},i;function i(d){return new $(d,r)}}O.exports=ee -});var x=require('@stdlib/utils-define-nonenumerable-read-only-property/dist'),v=l(),re=j(),ie=E();x(v,"objectMode",re);x(v,"factory",ie);module.exports=v; +"use strict";var s=function(e,r){return function(){return r||e((r={exports:{}}).exports,r),r.exports}};var c=s(function(se,S){S.exports={objectMode:!1,encoding:null,sep:"\n",dir:1}});var b=s(function(ue,m){ +var T=require('@stdlib/assert-is-plain-object/dist'),u=require('@stdlib/assert-has-own-property/dist'),z=require('@stdlib/assert-is-boolean/dist').isPrimitive,k=require('@stdlib/assert-is-nonnegative-number/dist').isPrimitive,g=require('@stdlib/assert-is-string/dist').isPrimitive,N=require('@stdlib/assert-is-function/dist'),t=require('@stdlib/error-tools-fmtprodmsg/dist');function V(e,r){return T(r)?u(r,"sep")&&(e.sep=r.sep,!g(e.sep))?new TypeError(t('1M92W',"sep",e.sep)):u(r,"objectMode")&&(e.objectMode=r.objectMode,!z(e.objectMode))?new TypeError(t('1M92o',"objectMode",e.objectMode)):u(r,"encoding")&&(e.encoding=r.encoding,!g(e.encoding)&&e.encoding!==null)?new TypeError(t('1M97n',"encoding",e.encoding)):u(r,"highWaterMark")&&(e.highWaterMark=r.highWaterMark,!k(e.highWaterMark))?new TypeError(t('1M94k',"highWaterMark",e.highWaterMark)):u(r,"serialize")&&(e.serialize=r.serialize,!N(e.serialize))?new TypeError(t('1M96p',"serialize",e.serialize)):u(r,"dir")&&(e.dir=r.dir,e.dir!==1&&e.dir!==-1)?new TypeError(t('1M92v',"dir",e.dir)):null:new TypeError(t('1M92V',r));}m.exports=V +});var q=s(function(oe,y){ +var W=require("debug"),A=W("from-array-stream");y.exports=A +});var l=s(function(de,w){ +var _=require("readable-stream").Readable,F=require('@stdlib/assert-is-collection/dist'),B=require('@stdlib/assert-is-error/dist'),J=require('@stdlib/assert-is-buffer/dist'),p=require('@stdlib/error-tools-fmtprodmsg/dist'),P=require('@stdlib/object-assign/dist'),R=require('@stdlib/utils-inherit/dist'),f=require('@stdlib/utils-define-nonenumerable-property/dist'),a=require('@stdlib/utils-define-nonenumerable-read-only-property/dist'),h=require('@stdlib/buffer-from-string/dist'),C=require('@stdlib/buffer-ctor/dist'),I=require('@stdlib/utils-next-tick/dist'),L=c(),D=b(),o=q();function G(){var e,r,i;if(!this._destroyed)for(e=!0;e;){if(r=null,this._i+=1,this._i>this._src.length)return o("Finished iteration."),this.push(null);i=this._src[this._idx],o("Value: %s. Idx: %d. Iter: %d.",JSON.stringify(i),this._idx,this._i),this._idx+=this._stride,this._objectMode===!1&&(i=this._serialize(i),typeof i=="string"?this._i===1?i=h(i):i=h(this._sep+i):J(i)?this._i>1&&(i=C.concat([h(this._sep),i])):r=new Error(p('1M9A9',i))),r?this.emit("error",r):e=this.push(i)}}function U(e){var r;if(this._destroyed)return o("Attempted to destroy an already destroyed stream."),this;return r=this,this._destroyed=!0,I(i),this;function i(){e&&(o("Stream was destroyed due to an error. Error: %s.",B(e)?e.message:JSON.stringify(e)),r.emit("error",e)),o("Closing the stream..."),r.emit("close")}}function n(e,r){var i,d;if(!(this instanceof n))return arguments.length>1?new n(e,r):new n(e);if(!F(e))throw new TypeError(p('1M92O',e));if(i=P({},L),arguments.length>1&&(d=D(i,r),d))throw d;return o("Creating a readable stream configured with the following options: %s.",JSON.stringify(i)),_.call(this,i),f(this,"_destroyed",!1),a(this,"_objectMode",i.objectMode),a(this,"_sep",i.sep),a(this,"_serialize",i.serialize||JSON.stringify),a(this,"_src",e),a(this,"_stride",i.dir),f(this,"_i",0),f(this,"_idx",i.dir===1?0:e.length-1),this}R(n,_);a(n.prototype,"_read",G);a(n.prototype,"destroy",U);w.exports=n +});var M=s(function(le,j){ +var H=require('@stdlib/assert-is-plain-object/dist'),K=require('@stdlib/error-tools-fmtprodmsg/dist'),Q=require('@stdlib/object-assign/dist'),X=l();function Y(e,r){var i;if(arguments.length>1){if(i=r,!H(i))throw new TypeError(K('1M92V',i));i=Q({},r)}else i={};return i.objectMode=!0,new X(e,i)}j.exports=Y +});var E=s(function(fe,O){ +var Z=require('@stdlib/assert-is-plain-object/dist'),$=require('@stdlib/error-tools-fmtprodmsg/dist'),ee=require('@stdlib/object-assign/dist'),re=l();function ie(e){var r;if(arguments.length){if(!Z(e))throw new TypeError($('1M92V',e));r=ee({},e)}else r={};return i;function i(d){return new re(d,r)}}O.exports=ie +});var x=require('@stdlib/utils-define-nonenumerable-read-only-property/dist'),v=l(),te=M(),ae=E();x(v,"objectMode",te);x(v,"factory",ae);module.exports=v; /** @license Apache-2.0 */ //# sourceMappingURL=index.js.map diff --git a/dist/index.js.map b/dist/index.js.map index be37d59..f599207 100644 --- a/dist/index.js.map +++ b/dist/index.js.map @@ -1,7 +1,7 @@ { "version": 3, "sources": ["../lib/defaults.json", "../lib/validate.js", "../lib/debug.js", "../lib/main.js", "../lib/object_mode.js", "../lib/factory.js", "../lib/index.js"], - "sourcesContent": ["{\n\t\"objectMode\": false,\n\t\"encoding\": null,\n\t\"sep\": \"\\n\",\n\t\"dir\": 1\n}\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nvar isObject = require( '@stdlib/assert-is-plain-object' );\nvar hasOwnProp = require( '@stdlib/assert-has-own-property' );\nvar isBoolean = require( '@stdlib/assert-is-boolean' ).isPrimitive;\nvar isNonNegative = require( '@stdlib/assert-is-nonnegative-number' ).isPrimitive;\nvar isString = require( '@stdlib/assert-is-string' ).isPrimitive;\nvar isFunction = require( '@stdlib/assert-is-function' );\nvar format = require( '@stdlib/string-format' );\n\n\n// MAIN //\n\n/**\n* Validates function options.\n*\n* @private\n* @param {Object} opts - destination object\n* @param {Options} options - function options\n* @param {string} [options.sep] - separator used to join streamed data\n* @param {boolean} [options.objectMode] - specifies whether a stream should operate in object mode\n* @param {(string|null)} [options.encoding] - specifies how `Buffer` objects should be decoded to `strings`\n* @param {NonNegativeNumber} [options.highWaterMark] - specifies the maximum number of bytes to store in the internal buffer before pausing streaming\n* @param {Function} [options.serialize] - custom serialization function\n* @param {integer} [options.dir] - iteration direction\n* @returns {(Error|null)} null or an error object\n*\n* @example\n* var opts = {};\n* var options = {\n* 'objectMode': true\n* };\n* var err = validate( opts, options );\n* if ( err ) {\n* throw err;\n* }\n*/\nfunction validate( opts, options ) {\n\tif ( !isObject( options ) ) {\n\t\treturn new TypeError( format( 'invalid argument. Options argument must be an object. Value: `%s`.', options ) );\n\t}\n\tif ( hasOwnProp( options, 'sep' ) ) {\n\t\topts.sep = options.sep;\n\t\tif ( !isString( opts.sep ) ) {\n\t\t\treturn new TypeError( format( 'invalid option. `%s` option must be a string. Option: `%s`.', 'sep', opts.sep ) );\n\t\t}\n\t}\n\tif ( hasOwnProp( options, 'objectMode' ) ) {\n\t\topts.objectMode = options.objectMode;\n\t\tif ( !isBoolean( opts.objectMode ) ) {\n\t\t\treturn new TypeError( format( 'invalid option. `%s` option must be a boolean. Option: `%s`.', 'objectMode', opts.objectMode ) );\n\t\t}\n\t}\n\tif ( hasOwnProp( options, 'encoding' ) ) {\n\t\topts.encoding = options.encoding;\n\t\tif ( !isString( opts.encoding ) && opts.encoding !== null ) {\n\t\t\treturn new TypeError( format( 'invalid option. `%s` option must be a string or null. Option: `%s`.', 'encoding', opts.encoding ) );\n\t\t}\n\t}\n\tif ( hasOwnProp( options, 'highWaterMark' ) ) {\n\t\topts.highWaterMark = options.highWaterMark;\n\t\tif ( !isNonNegative( opts.highWaterMark ) ) {\n\t\t\treturn new TypeError( format( 'invalid option. `%s` option must be a nonnegative number. Option: `%s`.', 'highWaterMark', opts.highWaterMark ) );\n\t\t}\n\t}\n\tif ( hasOwnProp( options, 'serialize' ) ) {\n\t\topts.serialize = options.serialize;\n\t\tif ( !isFunction( opts.serialize ) ) {\n\t\t\treturn new TypeError( format( 'invalid option. `%s` option must be a function. Option: `%s`.', 'serialize', opts.serialize ) );\n\t\t}\n\t}\n\tif ( hasOwnProp( options, 'dir' ) ) {\n\t\topts.dir = options.dir;\n\t\tif ( opts.dir !== 1 && opts.dir !== -1 ) {\n\t\t\treturn new TypeError( format( 'invalid option. `%s` option must be either `1` or `-1`. Option: `%s`.', 'dir', opts.dir ) );\n\t\t}\n\t}\n\treturn null;\n}\n\n\n// EXPORTS //\n\nmodule.exports = validate;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nvar logger = require( 'debug' );\n\n\n// MAIN //\n\nvar debug = logger( 'from-array-stream' );\n\n\n// EXPORTS //\n\nmodule.exports = debug;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nvar Readable = require( 'readable-stream' ).Readable;\nvar isCollection = require( '@stdlib/assert-is-collection' );\nvar isError = require( '@stdlib/assert-is-error' );\nvar isBuffer = require( '@stdlib/assert-is-buffer' );\nvar format = require( '@stdlib/string-format' );\nvar assign = require( '@stdlib/object-assign' );\nvar inherit = require( '@stdlib/utils-inherit' );\nvar setNonEnumerable = require( '@stdlib/utils-define-nonenumerable-property' );\nvar setNonEnumerableReadOnly = require( '@stdlib/utils-define-nonenumerable-read-only-property' );\nvar string2buffer = require( '@stdlib/buffer-from-string' );\nvar Buffer = require( '@stdlib/buffer-ctor' ); // TODO: replace Buffer.concat usage with stdlib pkg\nvar nextTick = require( '@stdlib/utils-next-tick' );\nvar DEFAULTS = require( './defaults.json' );\nvar validate = require( './validate.js' );\nvar debug = require( './debug.js' );\n\n\n// FUNCTIONS //\n\n/**\n* Implements the `_read` method.\n*\n* @private\n* @param {number} size - number (of bytes) to read\n* @returns {void}\n*/\nfunction read() {\n\t/* eslint-disable no-invalid-this */\n\tvar FLG;\n\tvar err;\n\tvar v;\n\n\tif ( this._destroyed ) {\n\t\treturn;\n\t}\n\tFLG = true;\n\twhile ( FLG ) {\n\t\terr = null;\n\n\t\tthis._i += 1;\n\t\tif ( this._i > this._src.length ) {\n\t\t\tdebug( 'Finished iteration.' );\n\t\t\treturn this.push( null );\n\t\t}\n\t\tv = this._src[ this._idx ];\n\t\tdebug( 'Value: %s. Idx: %d. Iter: %d.', JSON.stringify( v ), this._idx, this._i );\n\n\t\tthis._idx += this._stride;\n\t\tif ( this._objectMode === false ) {\n\t\t\tv = this._serialize( v );\n\t\t\tif ( typeof v === 'string' ) {\n\t\t\t\tif ( this._i === 1 ) {\n\t\t\t\t\tv = string2buffer( v );\n\t\t\t\t} else {\n\t\t\t\t\tv = string2buffer( this._sep+v );\n\t\t\t\t}\n\t\t\t} else if ( isBuffer( v ) ) {\n\t\t\t\tif ( this._i > 1 ) {\n\t\t\t\t\tv = Buffer.concat( [ string2buffer( this._sep ), v ] );\n\t\t\t\t}\n\t\t\t} else {\n\t\t\t\terr = new Error( format( 'invalid operation. Serialization function must return a string or Buffer. Value: `%s`.', v ) );\n\t\t\t}\n\t\t}\n\t\tif ( err ) {\n\t\t\tthis.emit( 'error', err );\n\t\t} else {\n\t\t\tFLG = this.push( v );\n\t\t}\n\t}\n\n\t/* eslint-enable no-invalid-this */\n}\n\n/**\n* Gracefully destroys a stream, providing backward compatibility.\n*\n* @private\n* @param {(string|Object|Error)} [error] - error\n* @returns {ArrayStream} Stream instance\n*/\nfunction destroy( error ) {\n\t/* eslint-disable no-invalid-this */\n\tvar self;\n\tif ( this._destroyed ) {\n\t\tdebug( 'Attempted to destroy an already destroyed stream.' );\n\t\treturn this;\n\t}\n\tself = this;\n\tthis._destroyed = true;\n\n\tnextTick( close );\n\n\treturn this;\n\n\t/**\n\t* Closes a stream.\n\t*\n\t* @private\n\t*/\n\tfunction close() {\n\t\tif ( error ) {\n\t\t\tdebug( 'Stream was destroyed due to an error. Error: %s.', ( isError( error ) ) ? error.message : JSON.stringify( error ) );\n\t\t\tself.emit( 'error', error );\n\t\t}\n\t\tdebug( 'Closing the stream...' );\n\t\tself.emit( 'close' );\n\t}\n\n\t/* eslint-enable no-invalid-this */\n}\n\n\n// MAIN //\n\n/**\n* Stream constructor for generating a readable stream from an array-like object.\n*\n* @constructor\n* @param {Collection} src - source array-like object\n* @param {Options} [options] - stream options\n* @param {boolean} [options.objectMode=false] - specifies whether the stream should operate in object mode\n* @param {(string|null)} [options.encoding=null] - specifies how `Buffer` objects should be decoded to strings\n* @param {NonNegativeNumber} [options.highWaterMark] - specifies the maximum number of bytes to store in an internal buffer before pausing streaming\n* @param {string} [options.sep='\\n'] - separator used to join streamed data\n* @param {Function} [options.serialize] - custom serialization function\n* @param {integer} [options.dir=1] - iteration direction\n* @throws {TypeError} first argument must be an array-like object\n* @throws {TypeError} options argument must be an object\n* @throws {TypeError} must provide valid options\n* @returns {ArrayStream} Stream instance\n*\n* @example\n* var inspectStream = require( '@stdlib/streams-node-inspect-sink' );\n* var Float64Array = require( '@stdlib/array-float64' );\n* var randu = require( '@stdlib/random-base-randu' );\n*\n* function log( chunk ) {\n* console.log( chunk.toString() );\n* }\n*\n* var arr = new Float64Array( 10 );\n* var i;\n* for ( i = 0; i < arr.length; i++ ) {\n* arr[ i ] = randu();\n* }\n*\n* var stream = new ArrayStream( arr );\n*\n* stream.pipe( inspectStream( log ) );\n*/\nfunction ArrayStream( src, options ) {\n\tvar opts;\n\tvar err;\n\tif ( !( this instanceof ArrayStream ) ) {\n\t\tif ( arguments.length > 1 ) {\n\t\t\treturn new ArrayStream( src, options );\n\t\t}\n\t\treturn new ArrayStream( src );\n\t}\n\tif ( !isCollection( src ) ) {\n\t\tthrow new TypeError( format( 'invalid argument. First argument must be an array-like object. Value: `%s`.', src ) );\n\t}\n\topts = assign( {}, DEFAULTS );\n\tif ( arguments.length > 1 ) {\n\t\terr = validate( opts, options );\n\t\tif ( err ) {\n\t\t\tthrow err;\n\t\t}\n\t}\n\t// Make the stream a readable stream:\n\tdebug( 'Creating a readable stream configured with the following options: %s.', JSON.stringify( opts ) );\n\tReadable.call( this, opts );\n\n\t// Destruction state:\n\tsetNonEnumerable( this, '_destroyed', false );\n\n\t// Cache whether the stream is operating in object mode:\n\tsetNonEnumerableReadOnly( this, '_objectMode', opts.objectMode );\n\n\t// Cache the separator:\n\tsetNonEnumerableReadOnly( this, '_sep', opts.sep );\n\n\t// Define the serialization function:\n\tsetNonEnumerableReadOnly( this, '_serialize', opts.serialize || JSON.stringify );\n\n\t// Cache the data source:\n\tsetNonEnumerableReadOnly( this, '_src', src );\n\n\t// Cache the array \"stride\":\n\tsetNonEnumerableReadOnly( this, '_stride', opts.dir );\n\n\t// Initialize an iteration counter:\n\tsetNonEnumerable( this, '_i', 0 );\n\n\t// Initialize the source index (pointer):\n\tsetNonEnumerable( this, '_idx', ( opts.dir === 1 ) ? 0 : src.length-1 );\n\n\treturn this;\n}\n\n/*\n* Inherit from the `Readable` prototype.\n*/\ninherit( ArrayStream, Readable );\n\n/**\n* Implements the `_read` method.\n*\n* @private\n* @name _read\n* @memberof ArrayStream.prototype\n* @type {Function}\n* @param {number} size - number (of bytes) to read\n* @returns {void}\n*/\nsetNonEnumerableReadOnly( ArrayStream.prototype, '_read', read );\n\n/**\n* Gracefully destroys a stream, providing backward compatibility.\n*\n* @name destroy\n* @memberof ArrayStream.prototype\n* @type {Function}\n* @param {(string|Object|Error)} [error] - error\n* @returns {ArrayStream} Stream instance\n*/\nsetNonEnumerableReadOnly( ArrayStream.prototype, 'destroy', destroy );\n\n\n// EXPORTS //\n\nmodule.exports = ArrayStream;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nvar isObject = require( '@stdlib/assert-is-plain-object' );\nvar format = require( '@stdlib/string-format' );\nvar assign = require( '@stdlib/object-assign' );\nvar ArrayStream = require( './main.js' );\n\n\n// MAIN //\n\n/**\n* Returns an \"objectMode\" readable stream from an array-like object.\n*\n* @param {Collection} src - source array-like object\n* @param {Options} [options] - stream options\n* @param {(string|null)} [options.encoding=null] - specifies how `Buffer` objects should be decoded to `strings`\n* @param {NonNegativeNumber} [options.highWaterMark] - specifies the maximum number of objects to store in an internal buffer before pausing streaming\n* @param {integer} [options.dir=1] - iteration direction\n* @throws {TypeError} first argument must be an array-like object\n* @throws {TypeError} options argument must be an object\n* @throws {TypeError} must provide valid options\n* @returns {ArrayStream} Stream instance\n*\n* @example\n* var inspectStream = require( '@stdlib/streams-node-inspect-sink' );\n* var Float64Array = require( '@stdlib/array-float64' );\n* var randu = require( '@stdlib/random-base-randu' );\n*\n* function log( v ) {\n* console.log( v );\n* }\n*\n* var arr = new Float64Array( 10 );\n* var i;\n* for ( i = 0; i < arr.length; i++ ) {\n* arr[ i ] = randu();\n* }\n*\n* var stream = objectMode( arr );\n*\n* stream.pipe( inspectStream.objectMode( log ) );\n*/\nfunction objectMode( src, options ) {\n\tvar opts;\n\tif ( arguments.length > 1 ) {\n\t\topts = options;\n\t\tif ( !isObject( opts ) ) {\n\t\t\tthrow new TypeError( format( 'invalid argument. Options argument must be an object. Value: `%s`.', opts ) );\n\t\t}\n\t\topts = assign( {}, options );\n\t} else {\n\t\topts = {};\n\t}\n\topts.objectMode = true;\n\treturn new ArrayStream( src, opts );\n}\n\n\n// EXPORTS //\n\nmodule.exports = objectMode;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nvar assign = require( '@stdlib/object-assign' );\nvar ArrayStream = require( './main.js' );\n\n\n// MAIN //\n\n/**\n* Returns a function for creating readable streams from array-like objects.\n*\n* @param {Options} [options] - stream options\n* @param {boolean} [options.objectMode=false] - specifies whether a stream should operate in object mode\n* @param {(string|null)} [options.encoding=null] - specifies how `Buffer` objects should be decoded to `strings`\n* @param {NonNegativeNumber} [options.highWaterMark] - specifies the maximum number of bytes to store in an internal buffer before pausing streaming\n* @param {string} [options.sep='\\n'] - separator used to join streamed data\n* @param {Function} [options.serialize] - custom serialization function\n* @param {integer} [options.dir=1] - iteration direction\n* @returns {Function} stream factory\n*\n* @example\n* var Float64Array = require( '@stdlib/array-float64' );\n* var randu = require( '@stdlib/random-base-randu' );\n*\n* var arr = new Float64Array( 10 );\n* var i;\n* for ( i = 0; i < arr.length; i++ ) {\n* arr[ i ] = randu();\n* }\n*\n* var opts = {\n* 'sep': ',',\n* 'objectMode': false,\n* 'encoding': 'utf8',\n* 'highWaterMark': 64\n* };\n*\n* var createStream = factory( opts );\n*\n* // Create 10 identically configured streams...\n* var streams = [];\n* for ( i = 0; i < 10; i++ ) {\n* streams.push( createStream( arr ) );\n* }\n*/\nfunction factory( options ) {\n\tvar opts;\n\tif ( arguments.length ) {\n\t\topts = assign( {}, options );\n\t} else {\n\t\topts = {};\n\t}\n\treturn createStream;\n\n\t/**\n\t* Returns a readable stream from an array-like object.\n\t*\n\t* @private\n\t* @param {Collection} src - source array-like object\n\t* @throws {TypeError} must provide an array-like object\n\t* @throws {TypeError} options argument must be an object\n\t* @throws {TypeError} must provide valid options\n\t* @returns {ArrayStream} Stream instance\n\t*/\n\tfunction createStream( src ) {\n\t\treturn new ArrayStream( src, opts );\n\t}\n}\n\n\n// EXPORTS //\n\nmodule.exports = factory;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n/**\n* Create a readable stream from an array-like object.\n*\n* @module @stdlib/streams-node-from-array\n*\n* @example\n* var inspectStream = require( '@stdlib/streams-node-inspect-sink' );\n* var Float64Array = require( '@stdlib/array-float64' );\n* var randu = require( '@stdlib/random-base-randu' );\n* var arrayStream = require( '@stdlib/streams-node-from-array' );\n*\n* function log( chunk ) {\n* console.log( chunk.toString() );\n* }\n*\n* var arr = new Float64Array( 10 );\n* var i;\n* for ( i = 0; i < arr.length; i++ ) {\n* arr[ i ] = randu();\n* }\n*\n* var stream = arrayStream( arr );\n*\n* stream.pipe( inspectStream( log ) );\n*\n* @example\n* var Float64Array = require( '@stdlib/array-float64' );\n* var randu = require( '@stdlib/random-base-randu' );\n* var arrayStream = require( '@stdlib/streams-node-from-array' );\n*\n* var arr = new Float64Array( 10 );\n* var i;\n* for ( i = 0; i < arr.length; i++ ) {\n* arr[ i ] = randu();\n* }\n*\n* var opts = {\n* 'sep': ',',\n* 'objectMode': false,\n* 'encoding': 'utf8',\n* 'highWaterMark': 64\n* };\n*\n* var createStream = arrayStream.factory( opts );\n*\n* // Create 10 identically configured streams...\n* var streams = [];\n* for ( i = 0; i < 10; i++ ) {\n* streams.push( createStream( arr ) );\n* }\n*\n* @example\n* var inspectStream = require( '@stdlib/streams-node-inspect-sink' );\n* var Float64Array = require( '@stdlib/array-float64' );\n* var randu = require( '@stdlib/random-base-randu' );\n* var arrayStream = require( '@stdlib/streams-node-from-array' );\n*\n* function log( v ) {\n* console.log( v );\n* }\n*\n* var arr = new Float64Array( 10 );\n* var i;\n* for ( i = 0; i < arr.length; i++ ) {\n* arr[ i ] = randu();\n* }\n*\n* var stream = arrayStream.objectMode( arr );\n*\n* stream.pipe( inspectStream.objectMode( log ) );\n*/\n\n\n// MODULES //\n\nvar setReadOnly = require( '@stdlib/utils-define-nonenumerable-read-only-property' );\nvar main = require( './main.js' );\nvar objectMode = require( './object_mode.js' );\nvar factory = require( './factory.js' );\n\n\n// MAIN //\n\nsetReadOnly( main, 'objectMode', objectMode );\nsetReadOnly( main, 'factory', factory );\n\n\n// EXPORTS //\n\nmodule.exports = main;\n"], - "mappings": "uGAAA,IAAAA,EAAAC,EAAA,SAAAC,GAAAC,EAAA,CAAAA,EAAA,SACC,WAAc,GACd,SAAY,KACZ,IAAO,KACP,IAAO,CACR,ICLA,IAAAC,EAAAC,EAAA,SAAAC,GAAAC,EAAA,cAsBA,IAAIC,EAAW,QAAS,gCAAiC,EACrDC,EAAa,QAAS,iCAAkC,EACxDC,EAAY,QAAS,2BAA4B,EAAE,YACnDC,EAAgB,QAAS,sCAAuC,EAAE,YAClEC,EAAW,QAAS,0BAA2B,EAAE,YACjDC,EAAa,QAAS,4BAA6B,EACnDC,EAAS,QAAS,uBAAwB,EA6B9C,SAASC,EAAUC,EAAMC,EAAU,CAClC,OAAMT,EAAUS,CAAQ,EAGnBR,EAAYQ,EAAS,KAAM,IAC/BD,EAAK,IAAMC,EAAQ,IACd,CAACL,EAAUI,EAAK,GAAI,GACjB,IAAI,UAAWF,EAAQ,8DAA+D,MAAOE,EAAK,GAAI,CAAE,EAG5GP,EAAYQ,EAAS,YAAa,IACtCD,EAAK,WAAaC,EAAQ,WACrB,CAACP,EAAWM,EAAK,UAAW,GACzB,IAAI,UAAWF,EAAQ,+DAAgE,aAAcE,EAAK,UAAW,CAAE,EAG3HP,EAAYQ,EAAS,UAAW,IACpCD,EAAK,SAAWC,EAAQ,SACnB,CAACL,EAAUI,EAAK,QAAS,GAAKA,EAAK,WAAa,MAC7C,IAAI,UAAWF,EAAQ,sEAAuE,WAAYE,EAAK,QAAS,CAAE,EAG9HP,EAAYQ,EAAS,eAAgB,IACzCD,EAAK,cAAgBC,EAAQ,cACxB,CAACN,EAAeK,EAAK,aAAc,GAChC,IAAI,UAAWF,EAAQ,0EAA2E,gBAAiBE,EAAK,aAAc,CAAE,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UAAU,OACdA,EAAOJ,EAAQ,CAAC,EAAGG,CAAQ,EAE3BC,EAAO,CAAC,EAEFC,EAYP,SAASA,EAAcC,EAAM,CAC5B,OAAO,IAAIL,EAAaK,EAAKF,CAAK,CACnC,CACD,CAKAL,EAAO,QAAUG,KCGjB,IAAIK,EAAc,QAAS,uDAAwD,EAC/EC,EAAO,IACPC,GAAa,IACbC,GAAU,IAKdH,EAAaC,EAAM,aAAcC,EAAW,EAC5CF,EAAaC,EAAM,UAAWE,EAAQ,EAKtC,OAAO,QAAUF", - "names": ["require_defaults", "__commonJSMin", "exports", "module", "require_validate", "__commonJSMin", "exports", "module", "isObject", "hasOwnProp", "isBoolean", "isNonNegative", "isString", "isFunction", "format", "validate", "opts", "options", "require_debug", "__commonJSMin", "exports", "module", "logger", "debug", "require_main", "__commonJSMin", "exports", "module", "Readable", "isCollection", "isError", "isBuffer", "format", "assign", "inherit", "setNonEnumerable", "setNonEnumerableReadOnly", "string2buffer", "Buffer", "nextTick", "DEFAULTS", "validate", "debug", "read", "FLG", "err", "v", "destroy", "error", "self", "close", "ArrayStream", "src", "options", "opts", "require_object_mode", "__commonJSMin", "exports", "module", "isObject", "format", "assign", "ArrayStream", "objectMode", "src", "options", "opts", "require_factory", "__commonJSMin", "exports", "module", "assign", "ArrayStream", "factory", "options", "opts", "createStream", "src", "setReadOnly", "main", "objectMode", "factory"] + "sourcesContent": ["{\n\t\"objectMode\": false,\n\t\"encoding\": null,\n\t\"sep\": \"\\n\",\n\t\"dir\": 1\n}\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nvar isObject = require( '@stdlib/assert-is-plain-object' );\nvar hasOwnProp = require( '@stdlib/assert-has-own-property' );\nvar isBoolean = require( '@stdlib/assert-is-boolean' ).isPrimitive;\nvar isNonNegative = require( '@stdlib/assert-is-nonnegative-number' ).isPrimitive;\nvar isString = require( '@stdlib/assert-is-string' ).isPrimitive;\nvar isFunction = require( '@stdlib/assert-is-function' );\nvar format = require( '@stdlib/string-format' );\n\n\n// MAIN //\n\n/**\n* Validates function options.\n*\n* @private\n* @param {Object} opts - destination object\n* @param {Options} options - function options\n* @param {string} [options.sep] - separator used to join streamed data\n* @param {boolean} [options.objectMode] - specifies whether a stream should operate in object mode\n* @param {(string|null)} [options.encoding] - specifies how `Buffer` objects should be decoded to `strings`\n* @param {NonNegativeNumber} [options.highWaterMark] - specifies the maximum number of bytes to store in the internal buffer before pausing streaming\n* @param {Function} [options.serialize] - custom serialization function\n* @param {integer} [options.dir] - iteration direction\n* @returns {(Error|null)} null or an error object\n*\n* @example\n* var opts = {};\n* var options = {\n* 'objectMode': true\n* };\n* var err = validate( opts, options );\n* if ( err ) {\n* throw err;\n* }\n*/\nfunction validate( opts, options ) {\n\tif ( !isObject( options ) ) {\n\t\treturn new TypeError( format( 'invalid argument. Options argument must be an object. Value: `%s`.', options ) );\n\t}\n\tif ( hasOwnProp( options, 'sep' ) ) {\n\t\topts.sep = options.sep;\n\t\tif ( !isString( opts.sep ) ) {\n\t\t\treturn new TypeError( format( 'invalid option. `%s` option must be a string. Option: `%s`.', 'sep', opts.sep ) );\n\t\t}\n\t}\n\tif ( hasOwnProp( options, 'objectMode' ) ) {\n\t\topts.objectMode = options.objectMode;\n\t\tif ( !isBoolean( opts.objectMode ) ) {\n\t\t\treturn new TypeError( format( 'invalid option. `%s` option must be a boolean. Option: `%s`.', 'objectMode', opts.objectMode ) );\n\t\t}\n\t}\n\tif ( hasOwnProp( options, 'encoding' ) ) {\n\t\topts.encoding = options.encoding;\n\t\tif ( !isString( opts.encoding ) && opts.encoding !== null ) {\n\t\t\treturn new TypeError( format( 'invalid option. `%s` option must be a string or null. Option: `%s`.', 'encoding', opts.encoding ) );\n\t\t}\n\t}\n\tif ( hasOwnProp( options, 'highWaterMark' ) ) {\n\t\topts.highWaterMark = options.highWaterMark;\n\t\tif ( !isNonNegative( opts.highWaterMark ) ) {\n\t\t\treturn new TypeError( format( 'invalid option. `%s` option must be a nonnegative number. Option: `%s`.', 'highWaterMark', opts.highWaterMark ) );\n\t\t}\n\t}\n\tif ( hasOwnProp( options, 'serialize' ) ) {\n\t\topts.serialize = options.serialize;\n\t\tif ( !isFunction( opts.serialize ) ) {\n\t\t\treturn new TypeError( format( 'invalid option. `%s` option must be a function. Option: `%s`.', 'serialize', opts.serialize ) );\n\t\t}\n\t}\n\tif ( hasOwnProp( options, 'dir' ) ) {\n\t\topts.dir = options.dir;\n\t\tif ( opts.dir !== 1 && opts.dir !== -1 ) {\n\t\t\treturn new TypeError( format( 'invalid option. `%s` option must be either `1` or `-1`. Option: `%s`.', 'dir', opts.dir ) );\n\t\t}\n\t}\n\treturn null;\n}\n\n\n// EXPORTS //\n\nmodule.exports = validate;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nvar logger = require( 'debug' );\n\n\n// MAIN //\n\nvar debug = logger( 'from-array-stream' );\n\n\n// EXPORTS //\n\nmodule.exports = debug;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nvar Readable = require( 'readable-stream' ).Readable;\nvar isCollection = require( '@stdlib/assert-is-collection' );\nvar isError = require( '@stdlib/assert-is-error' );\nvar isBuffer = require( '@stdlib/assert-is-buffer' );\nvar format = require( '@stdlib/string-format' );\nvar assign = require( '@stdlib/object-assign' );\nvar inherit = require( '@stdlib/utils-inherit' );\nvar setNonEnumerable = require( '@stdlib/utils-define-nonenumerable-property' );\nvar setNonEnumerableReadOnly = require( '@stdlib/utils-define-nonenumerable-read-only-property' );\nvar string2buffer = require( '@stdlib/buffer-from-string' );\nvar Buffer = require( '@stdlib/buffer-ctor' ); // TODO: replace Buffer.concat usage with stdlib pkg\nvar nextTick = require( '@stdlib/utils-next-tick' );\nvar DEFAULTS = require( './defaults.json' );\nvar validate = require( './validate.js' );\nvar debug = require( './debug.js' );\n\n\n// FUNCTIONS //\n\n/**\n* Implements the `_read` method.\n*\n* @private\n* @param {number} size - number (of bytes) to read\n* @returns {void}\n*/\nfunction read() {\n\t/* eslint-disable no-invalid-this */\n\tvar FLG;\n\tvar err;\n\tvar v;\n\n\tif ( this._destroyed ) {\n\t\treturn;\n\t}\n\tFLG = true;\n\twhile ( FLG ) {\n\t\terr = null;\n\n\t\tthis._i += 1;\n\t\tif ( this._i > this._src.length ) {\n\t\t\tdebug( 'Finished iteration.' );\n\t\t\treturn this.push( null );\n\t\t}\n\t\tv = this._src[ this._idx ];\n\t\tdebug( 'Value: %s. Idx: %d. Iter: %d.', JSON.stringify( v ), this._idx, this._i );\n\n\t\tthis._idx += this._stride;\n\t\tif ( this._objectMode === false ) {\n\t\t\tv = this._serialize( v );\n\t\t\tif ( typeof v === 'string' ) {\n\t\t\t\tif ( this._i === 1 ) {\n\t\t\t\t\tv = string2buffer( v );\n\t\t\t\t} else {\n\t\t\t\t\tv = string2buffer( this._sep+v );\n\t\t\t\t}\n\t\t\t} else if ( isBuffer( v ) ) {\n\t\t\t\tif ( this._i > 1 ) {\n\t\t\t\t\tv = Buffer.concat( [ string2buffer( this._sep ), v ] );\n\t\t\t\t}\n\t\t\t} else {\n\t\t\t\terr = new Error( format( 'invalid operation. Serialization function must return a string or Buffer. Value: `%s`.', v ) );\n\t\t\t}\n\t\t}\n\t\tif ( err ) {\n\t\t\tthis.emit( 'error', err );\n\t\t} else {\n\t\t\tFLG = this.push( v );\n\t\t}\n\t}\n\n\t/* eslint-enable no-invalid-this */\n}\n\n/**\n* Gracefully destroys a stream, providing backward compatibility.\n*\n* @private\n* @param {(string|Object|Error)} [error] - error\n* @returns {ArrayStream} Stream instance\n*/\nfunction destroy( error ) {\n\t/* eslint-disable no-invalid-this */\n\tvar self;\n\tif ( this._destroyed ) {\n\t\tdebug( 'Attempted to destroy an already destroyed stream.' );\n\t\treturn this;\n\t}\n\tself = this;\n\tthis._destroyed = true;\n\n\tnextTick( close );\n\n\treturn this;\n\n\t/**\n\t* Closes a stream.\n\t*\n\t* @private\n\t*/\n\tfunction close() {\n\t\tif ( error ) {\n\t\t\tdebug( 'Stream was destroyed due to an error. Error: %s.', ( isError( error ) ) ? error.message : JSON.stringify( error ) );\n\t\t\tself.emit( 'error', error );\n\t\t}\n\t\tdebug( 'Closing the stream...' );\n\t\tself.emit( 'close' );\n\t}\n\n\t/* eslint-enable no-invalid-this */\n}\n\n\n// MAIN //\n\n/**\n* Stream constructor for generating a readable stream from an array-like object.\n*\n* @constructor\n* @param {Collection} src - source array-like object\n* @param {Options} [options] - stream options\n* @param {boolean} [options.objectMode=false] - specifies whether the stream should operate in object mode\n* @param {(string|null)} [options.encoding=null] - specifies how `Buffer` objects should be decoded to strings\n* @param {NonNegativeNumber} [options.highWaterMark] - specifies the maximum number of bytes to store in an internal buffer before pausing streaming\n* @param {string} [options.sep='\\n'] - separator used to join streamed data\n* @param {Function} [options.serialize] - custom serialization function\n* @param {integer} [options.dir=1] - iteration direction\n* @throws {TypeError} first argument must be an array-like object\n* @throws {TypeError} options argument must be an object\n* @throws {TypeError} must provide valid options\n* @returns {ArrayStream} Stream instance\n*\n* @example\n* var inspectStream = require( '@stdlib/streams-node-inspect-sink' );\n* var Float64Array = require( '@stdlib/array-float64' );\n* var randu = require( '@stdlib/random-base-randu' );\n*\n* function log( chunk ) {\n* console.log( chunk.toString() );\n* }\n*\n* var arr = new Float64Array( 10 );\n* var i;\n* for ( i = 0; i < arr.length; i++ ) {\n* arr[ i ] = randu();\n* }\n*\n* var stream = new ArrayStream( arr );\n*\n* stream.pipe( inspectStream( log ) );\n*/\nfunction ArrayStream( src, options ) {\n\tvar opts;\n\tvar err;\n\tif ( !( this instanceof ArrayStream ) ) {\n\t\tif ( arguments.length > 1 ) {\n\t\t\treturn new ArrayStream( src, options );\n\t\t}\n\t\treturn new ArrayStream( src );\n\t}\n\tif ( !isCollection( src ) ) {\n\t\tthrow new TypeError( format( 'invalid argument. First argument must be an array-like object. Value: `%s`.', src ) );\n\t}\n\topts = assign( {}, DEFAULTS );\n\tif ( arguments.length > 1 ) {\n\t\terr = validate( opts, options );\n\t\tif ( err ) {\n\t\t\tthrow err;\n\t\t}\n\t}\n\t// Make the stream a readable stream:\n\tdebug( 'Creating a readable stream configured with the following options: %s.', JSON.stringify( opts ) );\n\tReadable.call( this, opts );\n\n\t// Destruction state:\n\tsetNonEnumerable( this, '_destroyed', false );\n\n\t// Cache whether the stream is operating in object mode:\n\tsetNonEnumerableReadOnly( this, '_objectMode', opts.objectMode );\n\n\t// Cache the separator:\n\tsetNonEnumerableReadOnly( this, '_sep', opts.sep );\n\n\t// Define the serialization function:\n\tsetNonEnumerableReadOnly( this, '_serialize', opts.serialize || JSON.stringify );\n\n\t// Cache the data source:\n\tsetNonEnumerableReadOnly( this, '_src', src );\n\n\t// Cache the array \"stride\":\n\tsetNonEnumerableReadOnly( this, '_stride', opts.dir );\n\n\t// Initialize an iteration counter:\n\tsetNonEnumerable( this, '_i', 0 );\n\n\t// Initialize the source index (pointer):\n\tsetNonEnumerable( this, '_idx', ( opts.dir === 1 ) ? 0 : src.length-1 );\n\n\treturn this;\n}\n\n/*\n* Inherit from the `Readable` prototype.\n*/\ninherit( ArrayStream, Readable );\n\n/**\n* Implements the `_read` method.\n*\n* @private\n* @name _read\n* @memberof ArrayStream.prototype\n* @type {Function}\n* @param {number} size - number (of bytes) to read\n* @returns {void}\n*/\nsetNonEnumerableReadOnly( ArrayStream.prototype, '_read', read );\n\n/**\n* Gracefully destroys a stream, providing backward compatibility.\n*\n* @name destroy\n* @memberof ArrayStream.prototype\n* @type {Function}\n* @param {(string|Object|Error)} [error] - error\n* @returns {ArrayStream} Stream instance\n*/\nsetNonEnumerableReadOnly( ArrayStream.prototype, 'destroy', destroy );\n\n\n// EXPORTS //\n\nmodule.exports = ArrayStream;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nvar isObject = require( '@stdlib/assert-is-plain-object' );\nvar format = require( '@stdlib/string-format' );\nvar assign = require( '@stdlib/object-assign' );\nvar ArrayStream = require( './main.js' );\n\n\n// MAIN //\n\n/**\n* Returns an \"objectMode\" readable stream from an array-like object.\n*\n* @param {Collection} src - source array-like object\n* @param {Options} [options] - stream options\n* @param {(string|null)} [options.encoding=null] - specifies how `Buffer` objects should be decoded to `strings`\n* @param {NonNegativeNumber} [options.highWaterMark] - specifies the maximum number of objects to store in an internal buffer before pausing streaming\n* @param {integer} [options.dir=1] - iteration direction\n* @throws {TypeError} first argument must be an array-like object\n* @throws {TypeError} options argument must be an object\n* @throws {TypeError} must provide valid options\n* @returns {ArrayStream} Stream instance\n*\n* @example\n* var inspectStream = require( '@stdlib/streams-node-inspect-sink' );\n* var Float64Array = require( '@stdlib/array-float64' );\n* var randu = require( '@stdlib/random-base-randu' );\n*\n* function log( v ) {\n* console.log( v );\n* }\n*\n* var arr = new Float64Array( 10 );\n* var i;\n* for ( i = 0; i < arr.length; i++ ) {\n* arr[ i ] = randu();\n* }\n*\n* var stream = objectMode( arr );\n*\n* stream.pipe( inspectStream.objectMode( log ) );\n*/\nfunction objectMode( src, options ) {\n\tvar opts;\n\tif ( arguments.length > 1 ) {\n\t\topts = options;\n\t\tif ( !isObject( opts ) ) {\n\t\t\tthrow new TypeError( format( 'invalid argument. Options argument must be an object. Value: `%s`.', opts ) );\n\t\t}\n\t\topts = assign( {}, options );\n\t} else {\n\t\topts = {};\n\t}\n\topts.objectMode = true;\n\treturn new ArrayStream( src, opts );\n}\n\n\n// EXPORTS //\n\nmodule.exports = objectMode;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nvar isObject = require( '@stdlib/assert-is-plain-object' );\nvar format = require( '@stdlib/string-format' );\nvar assign = require( '@stdlib/object-assign' );\nvar ArrayStream = require( './main.js' );\n\n\n// MAIN //\n\n/**\n* Returns a function for creating readable streams from array-like objects.\n*\n* @param {Options} [options] - stream options\n* @param {boolean} [options.objectMode=false] - specifies whether a stream should operate in object mode\n* @param {(string|null)} [options.encoding=null] - specifies how `Buffer` objects should be decoded to `strings`\n* @param {NonNegativeNumber} [options.highWaterMark] - specifies the maximum number of bytes to store in an internal buffer before pausing streaming\n* @param {string} [options.sep='\\n'] - separator used to join streamed data\n* @param {Function} [options.serialize] - custom serialization function\n* @param {integer} [options.dir=1] - iteration direction\n* @throws {TypeError} options argument must be an object\n* @returns {Function} stream factory\n*\n* @example\n* var Float64Array = require( '@stdlib/array-float64' );\n* var randu = require( '@stdlib/random-base-randu' );\n*\n* var arr = new Float64Array( 10 );\n* var i;\n* for ( i = 0; i < arr.length; i++ ) {\n* arr[ i ] = randu();\n* }\n*\n* var opts = {\n* 'sep': ',',\n* 'objectMode': false,\n* 'encoding': 'utf8',\n* 'highWaterMark': 64\n* };\n*\n* var createStream = factory( opts );\n*\n* // Create 10 identically configured streams...\n* var streams = [];\n* for ( i = 0; i < 10; i++ ) {\n* streams.push( createStream( arr ) );\n* }\n*/\nfunction factory( options ) {\n\tvar opts;\n\tif ( arguments.length ) {\n\t\tif ( !isObject( options ) ) {\n\t\t\tthrow new TypeError( format( 'invalid argument. Options argument must be an object. Value: `%s`.', options ) );\n\t\t}\n\t\topts = assign( {}, options );\n\t} else {\n\t\topts = {};\n\t}\n\treturn createStream;\n\n\t/**\n\t* Returns a readable stream from an array-like object.\n\t*\n\t* @private\n\t* @param {Collection} src - source array-like object\n\t* @throws {TypeError} must provide an array-like object\n\t* @throws {TypeError} options argument must be an object\n\t* @throws {TypeError} must provide valid options\n\t* @returns {ArrayStream} Stream instance\n\t*/\n\tfunction createStream( src ) {\n\t\treturn new ArrayStream( src, opts );\n\t}\n}\n\n\n// EXPORTS //\n\nmodule.exports = factory;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n/**\n* Create a readable stream from an array-like object.\n*\n* @module @stdlib/streams-node-from-array\n*\n* @example\n* var inspectStream = require( '@stdlib/streams-node-inspect-sink' );\n* var Float64Array = require( '@stdlib/array-float64' );\n* var randu = require( '@stdlib/random-base-randu' );\n* var arrayStream = require( '@stdlib/streams-node-from-array' );\n*\n* function log( chunk ) {\n* console.log( chunk.toString() );\n* }\n*\n* var arr = new Float64Array( 10 );\n* var i;\n* for ( i = 0; i < arr.length; i++ ) {\n* arr[ i ] = randu();\n* }\n*\n* var stream = arrayStream( arr );\n*\n* stream.pipe( inspectStream( log ) );\n*\n* @example\n* var Float64Array = require( '@stdlib/array-float64' );\n* var randu = require( '@stdlib/random-base-randu' );\n* var arrayStream = require( '@stdlib/streams-node-from-array' );\n*\n* var arr = new Float64Array( 10 );\n* var i;\n* for ( i = 0; i < arr.length; i++ ) {\n* arr[ i ] = randu();\n* }\n*\n* var opts = {\n* 'sep': ',',\n* 'objectMode': false,\n* 'encoding': 'utf8',\n* 'highWaterMark': 64\n* };\n*\n* var createStream = arrayStream.factory( opts );\n*\n* // Create 10 identically configured streams...\n* var streams = [];\n* for ( i = 0; i < 10; i++ ) {\n* streams.push( createStream( arr ) );\n* }\n*\n* @example\n* var inspectStream = require( '@stdlib/streams-node-inspect-sink' );\n* var Float64Array = require( '@stdlib/array-float64' );\n* var randu = require( '@stdlib/random-base-randu' );\n* var arrayStream = require( '@stdlib/streams-node-from-array' );\n*\n* function log( v ) {\n* console.log( v );\n* }\n*\n* var arr = new Float64Array( 10 );\n* var i;\n* for ( i = 0; i < arr.length; i++ ) {\n* arr[ i ] = randu();\n* }\n*\n* var stream = arrayStream.objectMode( arr );\n*\n* stream.pipe( inspectStream.objectMode( log ) );\n*/\n\n\n// MODULES //\n\nvar setReadOnly = require( '@stdlib/utils-define-nonenumerable-read-only-property' );\nvar main = require( './main.js' );\nvar objectMode = require( './object_mode.js' );\nvar factory = require( './factory.js' );\n\n\n// MAIN //\n\nsetReadOnly( main, 'objectMode', objectMode );\nsetReadOnly( main, 'factory', factory );\n\n\n// EXPORTS //\n\nmodule.exports = main;\n"], + "mappings": "uGAAA,IAAAA,EAAAC,EAAA,SAAAC,GAAAC,EAAA,CAAAA,EAAA,SACC,WAAc,GACd,SAAY,KACZ,IAAO,KACP,IAAO,CACR,ICLA,IAAAC,EAAAC,EAAA,SAAAC,GAAAC,EAAA,cAsBA,IAAIC,EAAW,QAAS,gCAAiC,EACrDC,EAAa,QAAS,iCAAkC,EACxDC,EAAY,QAAS,2BAA4B,EAAE,YACnDC,EAAgB,QAAS,sCAAuC,EAAE,YAClEC,EAAW,QAAS,0BAA2B,EAAE,YACjDC,EAAa,QAAS,4BAA6B,EACnDC,EAAS,QAAS,uBAAwB,EA6B9C,SAASC,EAAUC,EAAMC,EAAU,CAClC,OAAMT,EAAUS,CAAQ,EAGnBR,EAAYQ,EAAS,KAAM,IAC/BD,EAAK,IAAMC,EAAQ,IACd,CAACL,EAAUI,EAAK,GAAI,GACjB,IAAI,UAAWF,EAAQ,8DAA+D,MAAOE,EAAK,GAAI,CAAE,EAG5GP,EAAYQ,EAAS,YAAa,IACtCD,EAAK,WAAaC,EAAQ,WACrB,CAACP,EAAWM,EAAK,UAAW,GACzB,IAAI,UAAWF,EAAQ,+DAAgE,aAAcE,EAAK,UAAW,CAAE,EAG3HP,EAAYQ,EAAS,UAAW,IACpCD,EAAK,SAAWC,EAAQ,SACnB,CAACL,EAAUI,EAAK,QAAS,GAAKA,EAAK,WAAa,MAC7C,IAAI,UAAWF,EAAQ,sEAA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AAK,CACnC,CAKAR,EAAO,QAAUK,IChFjB,IAAAI,EAAAC,EAAA,SAAAC,GAAAC,EAAA,cAsBA,IAAIC,EAAW,QAAS,gCAAiC,EACrDC,EAAS,QAAS,uBAAwB,EAC1CC,GAAS,QAAS,uBAAwB,EAC1CC,GAAc,IA2ClB,SAASC,GAASC,EAAU,CAC3B,IAAIC,EACJ,GAAK,UAAU,OAAS,CACvB,GAAK,CAACN,EAAUK,CAAQ,EACvB,MAAM,IAAI,UAAWJ,EAAQ,qEAAsEI,CAAQ,CAAE,EAE9GC,EAAOJ,GAAQ,CAAC,EAAGG,CAAQ,CAC5B,MACCC,EAAO,CAAC,EAET,OAAOC,EAYP,SAASA,EAAcC,EAAM,CAC5B,OAAO,IAAIL,GAAaK,EAAKF,CAAK,CACnC,CACD,CAKAP,EAAO,QAAUK,KCHjB,IAAIK,EAAc,QAAS,uDAAwD,EAC/EC,EAAO,IACPC,GAAa,IACbC,GAAU,IAKdH,EAAaC,EAAM,aAAcC,EAAW,EAC5CF,EAAaC,EAAM,UAAWE,EAAQ,EAKtC,OAAO,QAAUF", + "names": ["require_defaults", "__commonJSMin", "exports", "module", "require_validate", "__commonJSMin", "exports", "module", "isObject", "hasOwnProp", "isBoolean", "isNonNegative", "isString", "isFunction", "format", "validate", "opts", "options", "require_debug", "__commonJSMin", "exports", "module", "logger", "debug", "require_main", "__commonJSMin", "exports", "module", "Readable", "isCollection", "isError", "isBuffer", "format", "assign", "inherit", "setNonEnumerable", "setNonEnumerableReadOnly", "string2buffer", "Buffer", "nextTick", "DEFAULTS", "validate", "debug", "read", "FLG", "err", "v", "destroy", "error", "self", "close", "ArrayStream", "src", "options", "opts", "require_object_mode", "__commonJSMin", "exports", "module", "isObject", "format", "assign", "ArrayStream", "objectMode", "src", "options", "opts", "require_factory", "__commonJSMin", "exports", "module", "isObject", "format", "assign", "ArrayStream", "factory", "options", "opts", "createStream", "src", "setReadOnly", "main", "objectMode", "factory"] } diff --git a/docs/types/index.d.ts b/docs/types/index.d.ts index 2cf8b35..5be1c2d 100644 --- a/docs/types/index.d.ts +++ b/docs/types/index.d.ts @@ -78,9 +78,9 @@ interface Constructor { * @returns Stream instance * * @example - * var inspectStream = require( `@stdlib/streams/node/inspect-sink` ); - * var Float64Array = require( `@stdlib/array/float64` ); - * var randu = require( `@stdlib/random/base/randu` ); + * var inspectStream = require( '@stdlib/streams-node-inspect-sink' ); + * var Float64Array = require( '@stdlib/array-float64' ); + * var randu = require( '@stdlib/random-base-randu' ); * * function log( chunk ) { * console.log( chunk.toString() ); @@ -114,9 +114,9 @@ interface Constructor { * @returns Stream instance * * @example - * var inspectStream = require( `@stdlib/streams/node/inspect-sink` ); - * var Float64Array = require( `@stdlib/array/float64` ); - * var randu = require( `@stdlib/random/base/randu` ); + * var inspectStream = require( '@stdlib/streams-node-inspect-sink' ); + * var Float64Array = require( '@stdlib/array-float64' ); + * var randu = require( '@stdlib/random-base-randu' ); * * function log( chunk ) { * console.log( chunk.toString() ); @@ -147,8 +147,8 @@ interface Constructor { * @returns stream factory * * @example - * var Float64Array = require( `@stdlib/array/float64` ); - * var randu = require( `@stdlib/random/base/randu` ); + * var Float64Array = require( '@stdlib/array-float64' ); + * var randu = require( '@stdlib/random-base-randu' ); * * var arr = new Float64Array( 10 ); * var i; @@ -185,9 +185,9 @@ interface Constructor { * @returns Stream instance * * @example - * var inspectStream = require( `@stdlib/streams/node/inspect-sink` ); - * var Float64Array = require( `@stdlib/array/float64` ); - * var randu = require( `@stdlib/random/base/randu` ); + * var inspectStream = require( '@stdlib/streams-node-inspect-sink' ); + * var Float64Array = require( '@stdlib/array-float64' ); + * var randu = require( '@stdlib/random-base-randu' ); * * function log( v ) { * console.log( v ); @@ -215,9 +215,9 @@ interface Constructor { * @returns stream instance * * @example -* var inspectStream = require( `@stdlib/streams/node/inspect-sink` ); -* var Float64Array = require( `@stdlib/array/float64` ); -* var randu = require( `@stdlib/random/base/randu` ); +* var inspectStream = require( '@stdlib/streams-node-inspect-sink' ); +* var Float64Array = require( '@stdlib/array-float64' ); +* var randu = require( '@stdlib/random-base-randu' ); * * function log( chunk ) { * console.log( chunk.toString() ); @@ -235,8 +235,8 @@ interface Constructor { * stream.pipe( inspectStream( log ) ); * * @example -* var Float64Array = require( `@stdlib/array/float64` ); -* var randu = require( `@stdlib/random/base/randu` ); +* var Float64Array = require( '@stdlib/array-float64' ); +* var randu = require( '@stdlib/random-base-randu' ); * * var arr = new Float64Array( 10 ); * var i; @@ -260,9 +260,9 @@ interface Constructor { * } * * @example -* var inspectStream = require( `@stdlib/streams/node/inspect-sink` ); -* var Float64Array = require( `@stdlib/array/float64` ); -* var randu = require( `@stdlib/random/base/randu` ); +* var inspectStream = require( '@stdlib/streams-node-inspect-sink' ); +* var Float64Array = require( '@stdlib/array-float64' ); +* var randu = require( '@stdlib/random-base-randu' ); * * function log( v ) { * console.log( v ); diff --git a/lib/factory.js b/lib/factory.js index b6eb829..bf3d665 100644 --- a/lib/factory.js +++ b/lib/factory.js @@ -20,6 +20,8 @@ // MODULES // +var isObject = require( '@stdlib/assert-is-plain-object' ); +var format = require( '@stdlib/string-format' ); var assign = require( '@stdlib/object-assign' ); var ArrayStream = require( './main.js' ); @@ -36,6 +38,7 @@ var ArrayStream = require( './main.js' ); * @param {string} [options.sep='\n'] - separator used to join streamed data * @param {Function} [options.serialize] - custom serialization function * @param {integer} [options.dir=1] - iteration direction +* @throws {TypeError} options argument must be an object * @returns {Function} stream factory * * @example @@ -66,6 +69,9 @@ var ArrayStream = require( './main.js' ); function factory( options ) { var opts; if ( arguments.length ) { + if ( !isObject( options ) ) { + throw new TypeError( format( 'invalid argument. Options argument must be an object. Value: `%s`.', options ) ); + } opts = assign( {}, options ); } else { opts = {};