Current Dev State

This commit is contained in:
Tim Lorsbach
2025-06-23 20:13:54 +02:00
parent b4f9bb277d
commit ded50edaa2
22617 changed files with 4345095 additions and 174 deletions

View File

@ -0,0 +1,47 @@
# end-of-stream
A node module that calls a callback when a readable/writable/duplex stream has completed or failed.
npm install end-of-stream
## Usage
Simply pass a stream and a callback to the `eos`.
Both legacy streams and streams2 are supported.
``` js
var eos = require('end-of-stream');
eos(readableStream, function(err) {
if (err) return console.log('stream had an error or closed early');
console.log('stream has ended');
});
eos(writableStream, function(err) {
if (err) return console.log('stream had an error or closed early');
console.log('stream has finished');
});
eos(duplexStream, function(err) {
if (err) return console.log('stream had an error or closed early');
console.log('stream has ended and finished');
});
eos(duplexStream, {readable:false}, function(err) {
if (err) return console.log('stream had an error or closed early');
console.log('stream has ended but might still be writable');
});
eos(duplexStream, {writable:false}, function(err) {
if (err) return console.log('stream had an error or closed early');
console.log('stream has ended but might still be readable');
});
eos(readableStream, {error:false}, function(err) {
// do not treat emit('error', err) as a end-of-stream
});
```
## License
MIT

61
static/js/ketcher2/node_modules/end-of-stream/index.js generated vendored Normal file
View File

@ -0,0 +1,61 @@
var once = require('once');
var noop = function() {};
var isRequest = function(stream) {
return stream.setHeader && typeof stream.abort === 'function';
};
var eos = function(stream, opts, callback) {
if (typeof opts === 'function') return eos(stream, null, opts);
if (!opts) opts = {};
callback = once(callback || noop);
var ws = stream._writableState;
var rs = stream._readableState;
var readable = opts.readable || (opts.readable !== false && stream.readable);
var writable = opts.writable || (opts.writable !== false && stream.writable);
var onlegacyfinish = function() {
if (!stream.writable) onfinish();
};
var onfinish = function() {
writable = false;
if (!readable) callback();
};
var onend = function() {
readable = false;
if (!writable) callback();
};
var onclose = function() {
if (readable && !(rs && rs.ended)) return callback(new Error('premature close'));
if (writable && !(ws && ws.ended)) return callback(new Error('premature close'));
};
var onrequest = function() {
stream.req.on('finish', onfinish);
};
if (isRequest(stream)) {
stream.on('complete', onfinish);
stream.on('abort', onclose);
if (stream.req) onrequest();
else stream.on('request', onrequest);
} else if (writable && !ws) { // legacy streams
stream.on('end', onlegacyfinish);
stream.on('close', onlegacyfinish);
}
stream.on('end', onend);
stream.on('finish', onfinish);
if (opts.error !== false) stream.on('error', callback);
stream.on('close', onclose);
return stream;
};
module.exports = eos;

View File

@ -0,0 +1,15 @@
The ISC License
Copyright (c) Isaac Z. Schlueter and Contributors
Permission to use, copy, modify, and/or distribute this software for any
purpose with or without fee is hereby granted, provided that the above
copyright notice and this permission notice appear in all copies.
THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR
IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.

View File

@ -0,0 +1,51 @@
# once
Only call a function once.
## usage
```javascript
var once = require('once')
function load (file, cb) {
cb = once(cb)
loader.load('file')
loader.once('load', cb)
loader.once('error', cb)
}
```
Or add to the Function.prototype in a responsible way:
```javascript
// only has to be done once
require('once').proto()
function load (file, cb) {
cb = cb.once()
loader.load('file')
loader.once('load', cb)
loader.once('error', cb)
}
```
Ironically, the prototype feature makes this module twice as
complicated as necessary.
To check whether you function has been called, use `fn.called`. Once the
function is called for the first time the return value of the original
function is saved in `fn.value` and subsequent calls will continue to
return this value.
```javascript
var once = require('once')
function load (cb) {
cb = once(cb)
var stream = createStream()
stream.once('data', cb)
stream.once('end', function () {
if (!cb.called) cb(new Error('not found'))
})
}
```

View File

@ -0,0 +1,21 @@
var wrappy = require('wrappy')
module.exports = wrappy(once)
once.proto = once(function () {
Object.defineProperty(Function.prototype, 'once', {
value: function () {
return once(this)
},
configurable: true
})
})
function once (fn) {
var f = function () {
if (f.called) return f.value
f.called = true
return f.value = fn.apply(this, arguments)
}
f.called = false
return f
}

View File

@ -0,0 +1,66 @@
{
"_from": "once@~1.3.0",
"_id": "once@1.3.3",
"_inBundle": false,
"_integrity": "sha1-suJhVXzkwxTsgwTz+oJmPkKXyiA=",
"_location": "/end-of-stream/once",
"_phantomChildren": {},
"_requested": {
"type": "range",
"registry": true,
"raw": "once@~1.3.0",
"name": "once",
"escapedName": "once",
"rawSpec": "~1.3.0",
"saveSpec": null,
"fetchSpec": "~1.3.0"
},
"_requiredBy": [
"/end-of-stream"
],
"_resolved": "https://registry.npmjs.org/once/-/once-1.3.3.tgz",
"_shasum": "b2e261557ce4c314ec8304f3fa82663e4297ca20",
"_spec": "once@~1.3.0",
"_where": "/home/manfred/enviPath/ketcher2/ketcher/node_modules/end-of-stream",
"author": {
"name": "Isaac Z. Schlueter",
"email": "i@izs.me",
"url": "http://blog.izs.me/"
},
"bugs": {
"url": "https://github.com/isaacs/once/issues"
},
"bundleDependencies": false,
"dependencies": {
"wrappy": "1"
},
"deprecated": false,
"description": "Run a function exactly one time",
"devDependencies": {
"tap": "^1.2.0"
},
"directories": {
"test": "test"
},
"files": [
"once.js"
],
"homepage": "https://github.com/isaacs/once#readme",
"keywords": [
"once",
"function",
"one",
"single"
],
"license": "ISC",
"main": "once.js",
"name": "once",
"repository": {
"type": "git",
"url": "git://github.com/isaacs/once.git"
},
"scripts": {
"test": "tap test/*.js"
},
"version": "1.3.3"
}

View File

@ -0,0 +1,61 @@
{
"_from": "end-of-stream@~0.1.5",
"_id": "end-of-stream@0.1.5",
"_inBundle": false,
"_integrity": "sha1-jhdyBsPICDfYVjLouTWd/osvbq8=",
"_location": "/end-of-stream",
"_phantomChildren": {
"wrappy": "1.0.2"
},
"_requested": {
"type": "range",
"registry": true,
"raw": "end-of-stream@~0.1.5",
"name": "end-of-stream",
"escapedName": "end-of-stream",
"rawSpec": "~0.1.5",
"saveSpec": null,
"fetchSpec": "~0.1.5"
},
"_requiredBy": [
"/orchestrator"
],
"_resolved": "https://registry.npmjs.org/end-of-stream/-/end-of-stream-0.1.5.tgz",
"_shasum": "8e177206c3c80837d85632e8b9359dfe8b2f6eaf",
"_spec": "end-of-stream@~0.1.5",
"_where": "/home/manfred/enviPath/ketcher2/ketcher/node_modules/orchestrator",
"author": {
"name": "Mathias Buus",
"email": "mathiasbuus@gmail.com"
},
"bugs": {
"url": "https://github.com/mafintosh/end-of-stream/issues"
},
"bundleDependencies": false,
"dependencies": {
"once": "~1.3.0"
},
"deprecated": false,
"description": "Call a callback when a readable/writable/duplex stream has completed or failed.",
"homepage": "https://github.com/mafintosh/end-of-stream",
"keywords": [
"stream",
"streams",
"callback",
"finish",
"close",
"end",
"wait"
],
"license": "MIT",
"main": "index.js",
"name": "end-of-stream",
"repository": {
"type": "git",
"url": "git://github.com/mafintosh/end-of-stream.git"
},
"scripts": {
"test": "node test.js"
},
"version": "0.1.5"
}

59
static/js/ketcher2/node_modules/end-of-stream/test.js generated vendored Normal file
View File

@ -0,0 +1,59 @@
var assert = require('assert');
var eos = require('./index');
var expected = 6;
var fs = require('fs');
var net = require('net');
var ws = fs.createWriteStream('/dev/null');
eos(ws, function(err) {
expected--;
assert(!!err);
if (!expected) process.exit(0);
});
ws.close();
var rs = fs.createReadStream('/dev/random');
eos(rs, function(err) {
expected--;
assert(!!err);
if (!expected) process.exit(0);
});
rs.close();
var rs = fs.createReadStream(__filename);
eos(rs, function(err) {
expected--;
assert(!err);
if (!expected) process.exit(0);
});
rs.pipe(fs.createWriteStream('/dev/null'));
var socket = net.connect(50000);
eos(socket, function(err) {
expected--;
assert(!!err);
if (!expected) process.exit(0);
});
var server = net.createServer(function(socket) {
eos(socket, function() {
expected--;
if (!expected) process.exit(0);
});
socket.destroy();
}).listen(30000, function() {
var socket = net.connect(30000);
eos(socket, function() {
expected--;
if (!expected) process.exit(0);
});
});
setTimeout(function() {
assert(expected === 0);
process.exit(0);
}, 1000);