UNPKG

@stdlib/esm

Version:

ES module distribution for Stdlib, a standard library for JavaScript and Node.js.

3 lines 3.99 kB
// This file is a part of stdlib. License is Apache-2.0: http://www.apache.org/licenses/LICENSE-2.0 import e from"./../../utils/define-nonenumerable-read-only-property.js";import t from"./../../vendor/process.js";import i from"./../../vendor/readable-stream.js";import o from"./../../buffer/from-string.js";import n from"./../../utils/copy.js";import r from"./../../utils/inherit.js";import s from"./../../buffer/ctor.js";import a from"./../../utils/define-nonenumerable-property.js";import p from"./../../assert/is-plain-object.js";import d from"./../../assert/has-own-property.js";import l from"./../../assert/is-boolean.js";import m from"./../../assert/is-nonnegative-number.js";import c from"./../../assert/is-string.js";import h from"./../../vendor/debug.js";var u=!1,f=null,b=!1,g=!1,j="\n",v={objectMode:u,encoding:f,allowHalfOpen:b,readableObjectMode:g,sep:j},w=p,y=d,O=l.isPrimitive,M=m.isPrimitive,_=c.isPrimitive;function E(e,t){return w(t)?y(t,"sep")&&(e.sep=t.sep,!_(e.sep))?new TypeError("invalid option. `sep` option must be a primitive string. Option: `"+e.sep+"`."):y(t,"objectMode")&&(e.objectMode=t.objectMode,!O(e.objectMode))?new TypeError("invalid option. `objectMode` option must be a primitive boolean. Option: `"+e.objectMode+"`."):y(t,"readableObjectMode")&&(e.readableObjectMode=t.readableObjectMode,!O(e.readableObjectMode))?new TypeError("invalid option. `readableObjectMode` option must be a primitive boolean. Option: `"+e.readableObjectMode+"`."):y(t,"encoding")&&(e.encoding=t.encoding,!_(e.encoding))?new TypeError("invalid option. `encoding` option must be a primitive string. Option: `"+e.encoding+"`."):y(t,"allowHalfOpen")&&(e.allowHalfOpen=t.allowHalfOpen,!O(e.allowHalfOpen))?new TypeError("invalid option. `allowHalfOpen` option must be a primitive boolean. Option: `"+e.allowHalfOpen+"`."):y(t,"highWaterMark")&&(e.highWaterMark=t.highWaterMark,!M(e.highWaterMark))?new TypeError("invalid option. `highWaterMark` option must be a nonnegative number. Option: `"+e.highWaterMark+"`."):null:new TypeError("invalid argument. Options must be an object. Value: `"+t+"`.")}var T=h,k=T("join-stream"),H=i.Transform,x=o,S=n,W=r,C=s,P=a,V=e,J=v,N=E,A=k;function F(e,t,i){var o;this._idx+=1,A("Received a new chunk. Chunk: %s. Encoding: %s. Index: %d.",e.toString(),t,this._idx),"utf8"===this._encoding?this._init?e=this._sep+e:this._init=!0:this._init?(e=new C(e,t),o=this._sep.length+e.length,e=(e=C.concat([this._sep,e],o)).toString(this._encoding)):this._init=!0,this.push(e,this._encoding),i()}function I(e){A("Flushing the stream..."),e()}function R(e){var i;return this._destroyed?(A("Attempted to destroy an already destroyed stream."),this):(i=this,this._destroyed=!0,t.nextTick((function(){e&&(A("Stream was destroyed due to an error. Error: %s.",JSON.stringify(e)),i.emit("error",e));A("Closing the stream..."),i.emit("close")})),this)}function q(e){var t,i;if(!(this instanceof q))return arguments.length?new q(e):new q;if(t=S(J),arguments.length&&(i=N(t,e)))throw i;return t.writableObjectMode=!0,t.decodeStrings=!1,A("Creating a transform stream configured with the following options: %s.",JSON.stringify(t)),H.call(this,t),P(this,"_destroyed",!1),V(this,"_encoding",null===t.encoding?"utf8":t.encoding),"utf8"!==this._encoding&&(t.sep=x(t.sep,this._encoding)),V(this,"_sep",t.sep),P(this,"_init",!1),P(this,"_idx",-1),this}W(q,H),V(q.prototype,"_transform",F),V(q.prototype,"_flush",I),V(q.prototype,"destroy",R);var z=p,B=n,D=q;function G(e){var t;if(arguments.length){if(!z(e))throw new TypeError("invalid argument. Options argument must be an object. Value: `"+e+"`.");t=B(e)}else t={};return t.objectMode=!0,new D(t)}var K=p,L=n,Q=q;function U(e){var t;if(arguments.length){if(!K(e))throw new TypeError("invalid argument. Options argument must be an object. Value: `"+e+"`.");t=L(e)}else t={};return i;function i(){return new Q(t)}}var X=e,Y=q,Z=G,$=U;X(Y,"objectMode",Z),X(Y,"factory",$);export default Y; //# sourceMappingURL=join.js.map