Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
.filter(Boolean).map(function (entry) {
if (entry === '-') {
var s = process.stdin;
if (typeof s.read === 'function') return s;
// only needed for 0.8, remove at some point later:
var rs = Readable().wrap(s);
s.resume();
return rs;
}
return path.resolve(process.cwd(), entry);
});
var stream = require('readable-stream')
var encode = require('./encode')
var decode = require('./decode')
var bufferAlloc = require('buffer-alloc')
var buf = bufferAlloc(32 * 1024)
var source = new stream.Readable()
var sent = 0
source._read = function () {
if (sent > 5 * 1024 * 1024 * 1024) return source.push(null)
sent += buf.length
source.push(buf)
}
// silly benchmark that allows me to look for opts/deopts
var s = source.pipe(encode()).pipe(decode())
var now = Date.now()
s.resume()
s.on('end', function () {
var delta = Date.now() - now
exports.combine = function(writable, readable) {
if (!isStream.isWritable(writable)) {
throw new Error('The first stream must be writable.');
}
if (!isStream.isReadable(readable)) {
throw new Error('The last stream must be readable.');
}
if (writable === readable) {
throw new Error('The two streams must not be === to each other.');
// ... because it would lead to a bunch of special cases related to duplicate calls
}
// convert node 0.8 readable to 0.10 readable stream
if (typeof readable.read !== 'function') {
readable = new Readable().wrap(readable);
}
var stream = exports.duplex.obj(function(chunk, enc, done) {
if (!writable.writable) {
return done(); // if the stream has already ended, stop writing to it
}
// Node 0.8.x writable streams do not accept the third parameter, done
var ok = writable.write(chunk, enc);
if (ok) {
done();
} else {
writable.once('drain', done);
}
}, forwardRead);
writable.once('finish', function() { stream.end(); });
function evalInAfterEffects(fn, args){
var ID = ++UID
var debugInfo
if (exports.debug){
debugInfo = {
ID:ID,
}
console.warn('evalInAfterEffects', debugInfo, {
name:evalInAfterEffects,
fn:fn,
args:args
})
}
var readable = new Readable
readable._read = function(size){
readable._read = noop
if (exports.debug) console.warn('_read', debugInfo)
var script = functionToExtendScript(fn, args)
var cliArgs = []
cliArgs.push("-e", 'on run argv')
cliArgs.push("-e", 'with timeout of 600 seconds')
cliArgs.push("-e", 'tell application "' + evalInAfterEffects.getName() + '" to DoScript (item 1 of argv)')
cliArgs.push("-e", 'end timeout')
cliArgs.push("-e", 'end run')
cliArgs.push(script)
if (exports.debug) console.log('script `%s`', script)
function getStreamFromBuffer(string) {
var stream = new Stream.Readable();
stream._read = function() {
stream.push(new Buffer(string));
stream._read = stream.push.bind(stream, null);
};
return stream;
}
function wrap (tr, opts) {
if (typeof tr.read === 'function') return tr
return new Readable(opts).wrap(tr)
}
function wrapStream (s) {
if (typeof s.read === 'function') return s
else return (new Readable).wrap(s)
}
function createArrayStream(arr) {
let i = 0;
const l = arr.length;
return new stream.Readable({
objectMode: true,
read() {
this.push(i < l ? arr[i++] : null);
}
});
}
store: function (file, destination, zip) {
var writer;
if (file.uncompressedSize === 0) {
writer = touch.bind(null, destination);
} else if (file.uncompressedSize <= zip.chunkSize) {
writer = function () {
return zip.getBuffer(file._offset, file._offset + file.uncompressedSize)
.then(function (buffer) {
return writeFile(destination, buffer, { mode: file.mode });
});
};
} else {
var input = new stream.Readable();
input.wrap(fs.createReadStream(zip.filename, {start: file._offset, end: file._offset + file.uncompressedSize - 1}));
writer = pipePromise.bind(null, input, destination, { mode: file.mode });
}
return mkdir(path.dirname(destination))
.then(writer)
.then(function () {
return {stored: file.path};
});
},
deflate: function (file, destination, zip) {
export function stringToReadable(s: string) {
const result = new stream.Readable();
result.push(s);
result.push(null);
return result;
}