Software: Apache/2.4.41 (Ubuntu). PHP/8.0.30 uname -a: Linux apirnd 5.4.0-204-generic #224-Ubuntu SMP Thu Dec 5 13:38:28 UTC 2024 x86_64 uid=33(www-data) gid=33(www-data) groups=33(www-data) Safe-mode: OFF (not secure) /var/www/html/node-red/node_modules/stream-via/lib/ drwxr-xr-x | |
| Viewing file: Select action/file-type: 'use strict'
var Transform = require('stream').Transform
var util = require('util')
/**
* @module stream-via
*/
module.exports = via
via.async = viaAsync
/**
* @param {module:stream-via~throughFunction} - a function to process each chunk
* @param [options] {object} - passed to the returned stream constructor
* @return {external:Duplex}
* @alias module:stream-via
*/
function via (throughFunction, options) {
options = options || {}
var stream = Transform(options)
stream._transform = function (chunk, enc, done) {
if (chunk) {
try {
this.push(throughFunction(chunk, enc))
} catch (err) {
stream.emit('error', err)
}
}
done()
}
/* node 0.10 polyfil */
if (!options.objectMode) {
if (options.readableObjectMode) stream._readableState.objectMode = true
if (options.writableObjectMode) stream._writableState.objectMode = true
}
return stream
}
/**
* @param {module:stream-via~throughFunction} - a function to process each chunk
* @param [options] {object} - passed to the returned stream constructor
* @return {external:Duplex}
* @alias module:stream-via.async
*/
function viaAsync (throughFunction, options) {
var stream = Transform(options)
stream._transform = function (chunk, enc, done) {
if (chunk) {
try {
throughFunction(chunk, enc, function (err, returnValue) {
if (err) {
stream.emit('error', err)
} else {
stream.push(returnValue)
}
done()
})
} catch (err) {
stream.emit('error', err)
done()
}
}
}
return stream
}
/**
* @external Duplex
* @see https://nodejs.org/api/stream.html#stream_class_stream_duplex
*/
/**
* @typedef throughFunction
* @type function
* @param chunk {buffer|string}
* @param enc {string}
* @param done {function} - only used in `via.async`, call it like so: `done(err, returnValue)`.
*/
|
:: Command execute :: | |
--[ c99shell v. 2.5 [PHP 8 Update] [24.05.2025] | Generation time: 0.0045 ]-- |