filename stringlengths 20 188 | language stringclasses 3
values | AST-segments stringlengths 0 204k |
|---|---|---|
pratsatya_uqt-serverside-nft-ops_node_modules_stream-transform_dist_iife_sync.js | javascript | if we have no data yet |
pratsatya_uqt-serverside-nft-ops_node_modules_stream-transform_dist_iife_sync.js | javascript | we can stand some
// more bytes. This is to work around cases where hwm=0 |
pratsatya_uqt-serverside-nft-ops_node_modules_stream-transform_dist_iife_sync.js | javascript | // such as the repl. Also |
pratsatya_uqt-serverside-nft-ops_node_modules_stream-transform_dist_iife_sync.js | javascript | if the push() triggered a
// readable event |
pratsatya_uqt-serverside-nft-ops_node_modules_stream-transform_dist_iife_sync.js | javascript | and the user called read(largeNumber) such that
// needReadable was set |
pratsatya_uqt-serverside-nft-ops_node_modules_stream-transform_dist_iife_sync.js | javascript | then we ought to push more |
pratsatya_uqt-serverside-nft-ops_node_modules_stream-transform_dist_iife_sync.js | javascript | so that another
// 'readable' event will be triggered.
function needMoreData(state) {
return !state.ended && (state.needReadable || state.length < state.highWaterMark || state.length === 0);
}
// backwards compatibility.
Readable.prototype.setEncoding = function (enc) {
this._readableState.decoder = ... |
pratsatya_uqt-serverside-nft-ops_node_modules_stream-transform_dist_iife_sync.js | javascript | so please take care when making
// changes to the function body.
function howMuchToRead(n |
pratsatya_uqt-serverside-nft-ops_node_modules_stream-transform_dist_iife_sync.js | javascript | state) {
if (n <= 0 || state.length === 0 && state.ended) return 0;
if (state.objectMode) return 1;
if (n !== n) {
// Only flow one buffer at a time
if (state.flowing && state.length) return state.buffer.head.data.length;else return state.length;
}
// If we're asking for more than the cu... |
pratsatya_uqt-serverside-nft-ops_node_modules_stream-transform_dist_iife_sync.js | javascript | then raise the hwm.
if (n > state.highWaterMark) state.highWaterMark = computeNewHighWaterMark(n);
if (n <= state.length) return n;
// Don't have enough
if (!state.ended) {
state.needReadable = true;
return 0;
}
return state.length;
}
// you can override either this method |
pratsatya_uqt-serverside-nft-ops_node_modules_stream-transform_dist_iife_sync.js | javascript | or the async _read(n) below.
Readable.prototype.read = function (n) {
debug('read' |
pratsatya_uqt-serverside-nft-ops_node_modules_stream-transform_dist_iife_sync.js | javascript | n);
n = parseInt(n |
pratsatya_uqt-serverside-nft-ops_node_modules_stream-transform_dist_iife_sync.js | javascript | 10);
var state = this._readableState;
var nOrig = n;
if (n !== 0) state.emittedReadable = false;
// if we're doing read(0) to trigger a readable event |
pratsatya_uqt-serverside-nft-ops_node_modules_stream-transform_dist_iife_sync.js | javascript | but we
// already have a bunch of data in the buffer |
pratsatya_uqt-serverside-nft-ops_node_modules_stream-transform_dist_iife_sync.js | javascript | then just trigger
// the 'readable' event and move on.
if (n === 0 && state.needReadable && (state.length >= state.highWaterMark || state.ended)) {
debug('read: emitReadable' |
pratsatya_uqt-serverside-nft-ops_node_modules_stream-transform_dist_iife_sync.js | javascript | state.length |
pratsatya_uqt-serverside-nft-ops_node_modules_stream-transform_dist_iife_sync.js | javascript | state.ended);
if (state.length === 0 && state.ended) endReadable(this);else emitReadable(this);
return null;
}
n = howMuchToRead(n |
pratsatya_uqt-serverside-nft-ops_node_modules_stream-transform_dist_iife_sync.js | javascript | state);
// if we've ended |
pratsatya_uqt-serverside-nft-ops_node_modules_stream-transform_dist_iife_sync.js | javascript | and we're now clear |
pratsatya_uqt-serverside-nft-ops_node_modules_stream-transform_dist_iife_sync.js | javascript | then finish it up.
if (n === 0 && state.ended) {
if (state.length === 0) endReadable(this);
return null;
}
// All the actual chunk generation logic needs to be
// *below* the call to _read. The reason is that in certain
// synthetic stream cases |
pratsatya_uqt-serverside-nft-ops_node_modules_stream-transform_dist_iife_sync.js | javascript | such as passthrough streams |
pratsatya_uqt-serverside-nft-ops_node_modules_stream-transform_dist_iife_sync.js | javascript | _read
// may be a completely synchronous operation which may change
// the state of the read buffer |
pratsatya_uqt-serverside-nft-ops_node_modules_stream-transform_dist_iife_sync.js | javascript | providing enough data when
// before there was *not* enough.
//
// So |
pratsatya_uqt-serverside-nft-ops_node_modules_stream-transform_dist_iife_sync.js | javascript | the steps are:
// 1. Figure out what the state of things will be after we do
// a read from the buffer.
//
// 2. If that resulting state will trigger a _read |
pratsatya_uqt-serverside-nft-ops_node_modules_stream-transform_dist_iife_sync.js | javascript | then call _read.
// Note that this may be asynchronous |
pratsatya_uqt-serverside-nft-ops_node_modules_stream-transform_dist_iife_sync.js | javascript | or synchronous. Yes |
pratsatya_uqt-serverside-nft-ops_node_modules_stream-transform_dist_iife_sync.js | javascript | it is
// deeply ugly to write APIs this way |
pratsatya_uqt-serverside-nft-ops_node_modules_stream-transform_dist_iife_sync.js | javascript | but that still doesn't mean
// that the Readable class should behave improperly |
pratsatya_uqt-serverside-nft-ops_node_modules_stream-transform_dist_iife_sync.js | javascript | as streams are
// designed to be sync/async agnostic.
// Take note if the _read call is sync or async (ie |
pratsatya_uqt-serverside-nft-ops_node_modules_stream-transform_dist_iife_sync.js | javascript | if the read call
// has returned yet) |
pratsatya_uqt-serverside-nft-ops_node_modules_stream-transform_dist_iife_sync.js | javascript | so that we know whether or not it's safe to emit
// 'readable' etc.
//
// 3. Actually pull the requested chunks out of the buffer and return.
// if we need a readable event |
pratsatya_uqt-serverside-nft-ops_node_modules_stream-transform_dist_iife_sync.js | javascript | then we need to do some reading.
var doRead = state.needReadable;
debug('need readable' |
pratsatya_uqt-serverside-nft-ops_node_modules_stream-transform_dist_iife_sync.js | javascript | doRead);
// if we currently have less than the highWaterMark |
pratsatya_uqt-serverside-nft-ops_node_modules_stream-transform_dist_iife_sync.js | javascript | then also read some
if (state.length === 0 || state.length - n < state.highWaterMark) {
doRead = true;
debug('length less than watermark' |
pratsatya_uqt-serverside-nft-ops_node_modules_stream-transform_dist_iife_sync.js | javascript | doRead);
}
// however |
pratsatya_uqt-serverside-nft-ops_node_modules_stream-transform_dist_iife_sync.js | javascript | if we've ended |
pratsatya_uqt-serverside-nft-ops_node_modules_stream-transform_dist_iife_sync.js | javascript | then there's no point |
pratsatya_uqt-serverside-nft-ops_node_modules_stream-transform_dist_iife_sync.js | javascript | and if we're already
// reading |
pratsatya_uqt-serverside-nft-ops_node_modules_stream-transform_dist_iife_sync.js | javascript | then it's unnecessary.
if (state.ended || state.reading) {
doRead = false;
debug('reading or ended' |
pratsatya_uqt-serverside-nft-ops_node_modules_stream-transform_dist_iife_sync.js | javascript | doRead);
} else if (doRead) {
debug('do read');
state.reading = true;
state.sync = true;
// if the length is currently zero |
pratsatya_uqt-serverside-nft-ops_node_modules_stream-transform_dist_iife_sync.js | javascript | then we *need* a readable event.
if (state.length === 0) state.needReadable = true;
// call internal read method
this._read(state.highWaterMark);
state.sync = false;
// If _read pushed data synchronously |
pratsatya_uqt-serverside-nft-ops_node_modules_stream-transform_dist_iife_sync.js | javascript | then `reading` will be false |
pratsatya_uqt-serverside-nft-ops_node_modules_stream-transform_dist_iife_sync.js | javascript | // and we need to re-evaluate how much data we can return to the user.
if (!state.reading) n = howMuchToRead(nOrig |
pratsatya_uqt-serverside-nft-ops_node_modules_stream-transform_dist_iife_sync.js | javascript | state);
}
var ret;
if (n > 0) ret = fromList(n |
pratsatya_uqt-serverside-nft-ops_node_modules_stream-transform_dist_iife_sync.js | javascript | state);else ret = null;
if (ret === null) {
state.needReadable = true;
n = 0;
} else {
state.length -= n;
}
if (state.length === 0) {
// If we have nothing in the buffer |
pratsatya_uqt-serverside-nft-ops_node_modules_stream-transform_dist_iife_sync.js | javascript | then we want to know
// as soon as we *do* get something into the buffer.
if (!state.ended) state.needReadable = true;
// If we tried to read() past the EOF |
pratsatya_uqt-serverside-nft-ops_node_modules_stream-transform_dist_iife_sync.js | javascript | then emit end on the next tick.
if (nOrig !== n && state.ended) endReadable(this);
}
if (ret !== null) this.emit('data' |
pratsatya_uqt-serverside-nft-ops_node_modules_stream-transform_dist_iife_sync.js | javascript | ret);
return ret;
};
function chunkInvalid(state |
pratsatya_uqt-serverside-nft-ops_node_modules_stream-transform_dist_iife_sync.js | javascript | chunk) {
var er = null;
if (!isBuffer$1(chunk) && typeof chunk !== 'string' && chunk !== null && chunk !== undefined && !state.objectMode) {
er = new TypeError('Invalid non-string/buffer chunk');
}
return er;
}
function onEofChunk(stream |
pratsatya_uqt-serverside-nft-ops_node_modules_stream-transform_dist_iife_sync.js | javascript | state) {
if (state.ended) return;
if (state.decoder) {
var chunk = state.decoder.end();
if (chunk && chunk.length) {
state.buffer.push(chunk);
state.length += state.objectMode ? 1 : chunk.length;
}
}
state.ended = true;
// emit 'readable' now to make sure it gets p... |
pratsatya_uqt-serverside-nft-ops_node_modules_stream-transform_dist_iife_sync.js | javascript | because this can trigger
// another read() call => stack overflow. This way |
pratsatya_uqt-serverside-nft-ops_node_modules_stream-transform_dist_iife_sync.js | javascript | it might trigger
// a nextTick recursion warning |
pratsatya_uqt-serverside-nft-ops_node_modules_stream-transform_dist_iife_sync.js | javascript | but that's not so bad.
function emitReadable(stream) {
var state = stream._readableState;
state.needReadable = false;
if (!state.emittedReadable) {
debug('emitReadable' |
pratsatya_uqt-serverside-nft-ops_node_modules_stream-transform_dist_iife_sync.js | javascript | state.flowing);
state.emittedReadable = true;
if (state.sync) nextTick(emitReadable_ |
pratsatya_uqt-serverside-nft-ops_node_modules_stream-transform_dist_iife_sync.js | javascript | stream);else emitReadable_(stream);
}
}
function emitReadable_(stream) {
debug('emit readable');
stream.emit('readable');
flow(stream);
}
// at this point |
pratsatya_uqt-serverside-nft-ops_node_modules_stream-transform_dist_iife_sync.js | javascript | the user has presumably seen the 'readable' event |
pratsatya_uqt-serverside-nft-ops_node_modules_stream-transform_dist_iife_sync.js | javascript | // and called read() to consume some data. that may have triggered
// in turn another _read(n) call |
pratsatya_uqt-serverside-nft-ops_node_modules_stream-transform_dist_iife_sync.js | javascript | in which case reading = true if
// it's in progress.
// However |
pratsatya_uqt-serverside-nft-ops_node_modules_stream-transform_dist_iife_sync.js | javascript | if we're not ended |
pratsatya_uqt-serverside-nft-ops_node_modules_stream-transform_dist_iife_sync.js | javascript | or reading |
pratsatya_uqt-serverside-nft-ops_node_modules_stream-transform_dist_iife_sync.js | javascript | and the length < hwm |
pratsatya_uqt-serverside-nft-ops_node_modules_stream-transform_dist_iife_sync.js | javascript | // then go ahead and try to read some more preemptively.
function maybeReadMore(stream |
pratsatya_uqt-serverside-nft-ops_node_modules_stream-transform_dist_iife_sync.js | javascript | state) {
if (!state.readingMore) {
state.readingMore = true;
nextTick(maybeReadMore_ |
pratsatya_uqt-serverside-nft-ops_node_modules_stream-transform_dist_iife_sync.js | javascript | stream |
pratsatya_uqt-serverside-nft-ops_node_modules_stream-transform_dist_iife_sync.js | javascript | state);
}
}
function maybeReadMore_(stream |
pratsatya_uqt-serverside-nft-ops_node_modules_stream-transform_dist_iife_sync.js | javascript | state) {
var len = state.length;
while (!state.reading && !state.flowing && !state.ended && state.length < state.highWaterMark) {
debug('maybeReadMore read 0');
stream.read(0);
if (len === state.length)
// didn't get any data |
pratsatya_uqt-serverside-nft-ops_node_modules_stream-transform_dist_iife_sync.js | javascript | stop spinning.
break;else len = state.length;
}
state.readingMore = false;
}
// abstract method. to be overridden in specific implementation classes.
// call cb(er |
pratsatya_uqt-serverside-nft-ops_node_modules_stream-transform_dist_iife_sync.js | javascript | data) where data is <= n in length.
// for virtual (non-string |
pratsatya_uqt-serverside-nft-ops_node_modules_stream-transform_dist_iife_sync.js | javascript | non-buffer) streams |
pratsatya_uqt-serverside-nft-ops_node_modules_stream-transform_dist_iife_sync.js | javascript | "length" is somewhat
// arbitrary |
pratsatya_uqt-serverside-nft-ops_node_modules_stream-transform_dist_iife_sync.js | javascript | and perhaps not very meaningful.
Readable.prototype._read = function (n) {
this.emit('error' |
pratsatya_uqt-serverside-nft-ops_node_modules_stream-transform_dist_iife_sync.js | javascript | new Error('not implemented'));
};
Readable.prototype.pipe = function (dest |
pratsatya_uqt-serverside-nft-ops_node_modules_stream-transform_dist_iife_sync.js | javascript | pipeOpts) {
var src = this;
var state = this._readableState;
switch (state.pipesCount) {
case 0:
state.pipes = dest;
break;
case 1:
state.pipes = [state.pipes |
pratsatya_uqt-serverside-nft-ops_node_modules_stream-transform_dist_iife_sync.js | javascript | dest];
break;
default:
state.pipes.push(dest);
break;
}
state.pipesCount += 1;
debug('pipe count=%d opts=%j' |
pratsatya_uqt-serverside-nft-ops_node_modules_stream-transform_dist_iife_sync.js | javascript | state.pipesCount |
pratsatya_uqt-serverside-nft-ops_node_modules_stream-transform_dist_iife_sync.js | javascript | pipeOpts);
var doEnd = (!pipeOpts || pipeOpts.end !== false);
var endFn = doEnd ? onend : cleanup;
if (state.endEmitted) nextTick(endFn);else src.once('end' |
pratsatya_uqt-serverside-nft-ops_node_modules_stream-transform_dist_iife_sync.js | javascript | endFn);
dest.on('unpipe' |
pratsatya_uqt-serverside-nft-ops_node_modules_stream-transform_dist_iife_sync.js | javascript | onunpipe);
function onunpipe(readable) {
debug('onunpipe');
if (readable === src) {
cleanup();
}
}
function onend() {
debug('onend');
dest.end();
}
// when the dest drains |
pratsatya_uqt-serverside-nft-ops_node_modules_stream-transform_dist_iife_sync.js | javascript | it reduces the awaitDrain counter
// on the source. This would be more elegant with a .once()
// handler in flow() |
pratsatya_uqt-serverside-nft-ops_node_modules_stream-transform_dist_iife_sync.js | javascript | but adding and removing repeatedly is
// too slow.
var ondrain = pipeOnDrain(src);
dest.on('drain' |
pratsatya_uqt-serverside-nft-ops_node_modules_stream-transform_dist_iife_sync.js | javascript | ondrain);
var cleanedUp = false;
function cleanup() {
debug('cleanup');
// cleanup event handlers once the pipe is broken
dest.removeListener('close' |
pratsatya_uqt-serverside-nft-ops_node_modules_stream-transform_dist_iife_sync.js | javascript | onclose);
dest.removeListener('finish' |
pratsatya_uqt-serverside-nft-ops_node_modules_stream-transform_dist_iife_sync.js | javascript | onfinish);
dest.removeListener('drain' |
pratsatya_uqt-serverside-nft-ops_node_modules_stream-transform_dist_iife_sync.js | javascript | ondrain);
dest.removeListener('error' |
pratsatya_uqt-serverside-nft-ops_node_modules_stream-transform_dist_iife_sync.js | javascript | onerror);
dest.removeListener('unpipe' |
pratsatya_uqt-serverside-nft-ops_node_modules_stream-transform_dist_iife_sync.js | javascript | onunpipe);
src.removeListener('end' |
pratsatya_uqt-serverside-nft-ops_node_modules_stream-transform_dist_iife_sync.js | javascript | onend);
src.removeListener('end' |
pratsatya_uqt-serverside-nft-ops_node_modules_stream-transform_dist_iife_sync.js | javascript | cleanup);
src.removeListener('data' |
pratsatya_uqt-serverside-nft-ops_node_modules_stream-transform_dist_iife_sync.js | javascript | ondata);
cleanedUp = true;
// if the reader is waiting for a drain event from this
// specific writer |
pratsatya_uqt-serverside-nft-ops_node_modules_stream-transform_dist_iife_sync.js | javascript | then it would cause it to never start
// flowing again.
// So |
pratsatya_uqt-serverside-nft-ops_node_modules_stream-transform_dist_iife_sync.js | javascript | if this is awaiting a drain |
pratsatya_uqt-serverside-nft-ops_node_modules_stream-transform_dist_iife_sync.js | javascript | then we just call it now.
// If we don't know |
pratsatya_uqt-serverside-nft-ops_node_modules_stream-transform_dist_iife_sync.js | javascript | then assume that we are waiting for one.
if (state.awaitDrain && (!dest._writableState || dest._writableState.needDrain)) ondrain();
}
// If the user pushes more data while we're writing to dest then we'll end up
// in ondata again. However |
pratsatya_uqt-serverside-nft-ops_node_modules_stream-transform_dist_iife_sync.js | javascript | we only want to increase awaitDrain once because
// dest will only emit one 'drain' event for the multiple writes.
// => Introduce a guard on increasing awaitDrain.
var increasedAwaitDrain = false;
src.on('data' |
pratsatya_uqt-serverside-nft-ops_node_modules_stream-transform_dist_iife_sync.js | javascript | ondata);
function ondata(chunk) {
debug('ondata');
increasedAwaitDrain = false;
var ret = dest.write(chunk);
if (false === ret && !increasedAwaitDrain) {
// If the user unpiped during `dest.write()` |
pratsatya_uqt-serverside-nft-ops_node_modules_stream-transform_dist_iife_sync.js | javascript | it is possible
// to get stuck in a permanently paused state if that write
// also returned false.
// => Check whether `dest` is still a piping destination.
if ((state.pipesCount === 1 && state.pipes === dest || state.pipesCount > 1 && indexOf(state.pipes |
pratsatya_uqt-serverside-nft-ops_node_modules_stream-transform_dist_iife_sync.js | javascript | dest) !== -1) && !cleanedUp) {
debug('false write response |
pratsatya_uqt-serverside-nft-ops_node_modules_stream-transform_dist_iife_sync.js | javascript | pause' |
pratsatya_uqt-serverside-nft-ops_node_modules_stream-transform_dist_iife_sync.js | javascript | src._readableState.awaitDrain);
src._readableState.awaitDrain++;
increasedAwaitDrain = true;
}
src.pause();
}
}
// if the dest has an error |
pratsatya_uqt-serverside-nft-ops_node_modules_stream-transform_dist_iife_sync.js | javascript | then stop piping into it.
// however |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.