1
0
mirror of https://github.com/musix-org/musix-oss synced 2025-07-01 17:03:38 +00:00
This commit is contained in:
MatteZ02
2019-10-10 16:43:04 +03:00
parent 6f6ac8a6fa
commit 50b9bed483
9432 changed files with 1988816 additions and 167 deletions

1
node_modules/bun/.npmignore generated vendored Normal file
View File

@ -0,0 +1 @@
node_modules

6
node_modules/bun/.travis.yml generated vendored Normal file
View File

@ -0,0 +1,6 @@
language: node_js
node_js:
- "0.6"
- "0.8"
- "0.10"
- "0.11"

104
node_modules/bun/README.md generated vendored Normal file
View File

@ -0,0 +1,104 @@
bun ![build status][build_status]
===
We've all pondered, "But what do I do with it?" The answer is universal: Wrap it
in a bun! **bun** wraps a series of streams into a single
`stream.Duplex`-compliant unit.
A Possible And Likely Scenario
------------------------------
Say you have an existing module with an implentation like this
```js
// my-transport.js
encryptor.pipe(compressor).pipe(socket).pipe(decompressor).pipe(decryptor);
```
Totally believable, right? Now each time someone wants to use your module, you
have to do something like this
```js
// too much work!
client.pipe(encryptor)
.pipe(compressor)
.pipe(socket)
.pipe(decompressor)
.pipe(decryptor)
.pipe(client);
```
Gross! Puke! This is horribly inconvenient and ugly for the end user! Let's look
at a **better solution**
```js
// defined in my-transport.js
var bun = require("bun");
module.service = function(socket) {
return bun([encryptor, compressor, socket, decompressor, decryptor]);
});
// used in client
var transport = require("./my-transport");
client.pipe(transport.service(socket)).pipe(client);
```
Hot cross buns! **bun** is amazing!
Example
-------
```js
var stream = require("stream"),
bun = require("bun");
// stream generator
var createStream = function createStream(id) {
var s = new stream.Transform({encoding: "utf8"});
s._transform = function _transform(str, encoding, done) {
this.push("(" + id + " " + str + ")");
done();
};
return s;
};
// create some streams
var streams = ["G", "O", "D"].map(function(id) {
return createStream(id);
});
// wrap the streams in a bun!
var hotdog = bun(streams);
// connect hotdog to stdout
hotdog.pipe(process.stdout);
// use the hotdog
hotdog.write("in a bun"); // (D (O (G in a bun)))
```
Buns are convenient, edible, and keep your hands clean! Use **bun**!
API
---
**bun**
```js
var service = bun(streams, [options]);
```
* _streams_ - An array of `stream` objects.
* _options_ - An object specifying options. (options are optional)
Options:
* _bubbleErrors_ - Bubble "error" events from wrapped streams up to the outer
stream, giving you an easy way to aggregate and react to all the errors
emitted by them in one place. Default is `true`.
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
[build_status]: https://travis-ci.org/naomik/bun.png

27
node_modules/bun/example.js generated vendored Normal file
View File

@ -0,0 +1,27 @@
#!/usr/bin/env node
var stream = require("readable-stream"),
bun = require("./lib/bun");
// stream generator
var createStream = function createStream(id) {
var s = new stream.Transform({encoding: "utf8"});
s._transform = function _transform(str, encoding, done) {
this.push("(" + id + " " + str + ")");
done();
};
return s;
};
// create some streams
var streams = ["G", "O", "D"].map(function(id) {
return createStream(id);
});
// wrap the streams in a bun!
var hotdog = bun(streams);
// connect hotdog to stdout
hotdog.pipe(process.stdout);
// use the hotdog
hotdog.write("in a bun"); // (D (O (G in a bun)))

92
node_modules/bun/lib/bun.js generated vendored Normal file
View File

@ -0,0 +1,92 @@
var stream = require("readable-stream");
var BunWrapper = function BunWrapper(options) {
options = options || {};
if (Array.isArray(options)) {
options = {streams: options};
}
options.objectMode = true;
stream.Duplex.call(this, options);
var self = this;
// grab a copy of the streams array
this._streams = (options.streams || []).slice();
// we need at least one stream to do things
if (this._streams.length === 0) {
this._streams.push(new stream.PassThrough({objectMode: true}));
}
// default: true
this._bubbleErrors = (typeof options.bubbleErrors === "undefined") || !!options.bubbleErrors;
// error bubbling! yay!
if (this._bubbleErrors) {
for (var i=0;i<this._streams.length;++i) {
this._streams[i].on("error", function(e) {
return self.emit("error", e);
});
}
}
// 0 -> 1, 1 -> 2, ..., n-1 -> n
for (var i=0;i<this._streams.length-1;++i) {
this._streams[i].pipe(this._streams[i+1]);
}
// these might actually be the same. that's ok.
this._first = this._streams[0];
this._last = this._streams[this._streams.length-1];
// .on("data") is supported again in 0.11 and has always worked in 0.10
this._last.on("data", function(e) {
if (!self.push(e)) {
self._last.pause();
}
});
// this is the readable side of our pipe ending
this._last.on("end", function() {
self.push(null);
});
// and here's the writable side finishing
this._first.on("finish", function() {
self.end();
});
// proxy through the .end() action
this.on("finish", function() {
self._first.end();
});
};
BunWrapper.prototype = Object.create(stream.Duplex.prototype, {constructor: {value: BunWrapper}});
BunWrapper.prototype._write = function _write(input, encoding, done) {
this._first.write(input, done);
};
BunWrapper.prototype._read = function _read(n) {
this._last.resume();
};
// factory function
var bun = module.exports = function bun(options, streams) {
if (Array.isArray(options)) {
var tmp = streams;
streams = options;
options = tmp;
}
options = options || {};
options.streams = options.streams || streams;
return new BunWrapper(options);
};
bun.BunWrapper = BunWrapper;

61
node_modules/bun/package.json generated vendored Normal file
View File

@ -0,0 +1,61 @@
{
"_from": "bun@^0.0.12",
"_id": "bun@0.0.12",
"_inBundle": false,
"_integrity": "sha512-Toms18J9DqnT+IfWkwxVTB2EaBprHvjlMWrTIsfX4xbu3ZBqVBwrERU0em1IgtRe04wT+wJxMlKHZok24hrcSQ==",
"_location": "/bun",
"_phantomChildren": {},
"_requested": {
"type": "range",
"registry": true,
"raw": "bun@^0.0.12",
"name": "bun",
"escapedName": "bun",
"rawSpec": "^0.0.12",
"saveSpec": null,
"fetchSpec": "^0.0.12"
},
"_requiredBy": [
"/@google-cloud/firestore"
],
"_resolved": "https://registry.npmjs.org/bun/-/bun-0.0.12.tgz",
"_shasum": "d54fae69f895557f275423bc14b404030b20a5fc",
"_spec": "bun@^0.0.12",
"_where": "C:\\Users\\matia\\Documents\\GitHub\\FutoX-Musix\\node_modules\\@google-cloud\\firestore",
"author": {
"name": "naomik",
"email": "naomi@fknsrs.biz"
},
"bugs": {
"url": "https://github.com/naomik/bun/issues"
},
"bundleDependencies": false,
"dependencies": {
"readable-stream": "~1.0.32"
},
"deprecated": false,
"description": "A useful container for streams",
"devDependencies": {
"mocha": "~1.11.0"
},
"engines": {
"node": ">=0.10.12"
},
"homepage": "https://github.com/naomik/bun#readme",
"keywords": [
"stream",
"streams2",
"bun"
],
"license": "BSD",
"main": "lib/bun.js",
"name": "bun",
"repository": {
"type": "git",
"url": "git://github.com/naomik/bun.git"
},
"scripts": {
"test": "mocha -R tap"
},
"version": "0.0.12"
}

447
node_modules/bun/test/bun_test.js generated vendored Normal file
View File

@ -0,0 +1,447 @@
var stream = require("readable-stream");
var bun = require("..");
var assert = require("assert");
describe("bun", function() {
it("should be the best", function() {
var bun = "is the best";
assert.strictEqual(bun, "is the best");
});
it("should pass data through one stream", function(done) {
var uppercaser = new stream.Transform({objectMode: true});
uppercaser._transform = function _transform(input, encoding, done) {
this.push(input.toString().toUpperCase());
return done();
};
var stack = bun([uppercaser]);
stack.on("readable", function() {
var data = stack.read();
assert(typeof data === "string", "data should be a string");
assert(data === "HELLO", "data should be transformed correctly");
done();
});
stack.write("hello");
});
it("should pass data through two streams", function(done) {
var uppercaser = new stream.Transform({objectMode: true}),
underscorer = new stream.Transform({objectMode: true});
uppercaser._transform = function _transform(input, encoding, done) {
this.push(input.toString().toUpperCase());
return done();
};
underscorer._transform = function _transform(input, encoding, done) {
this.push(input.toString().split("").join("_"));
return done();
};
var stack = bun([uppercaser, underscorer]);
stack.on("readable", function() {
var data = stack.read();
assert(typeof data === "string", "data should be a string");
assert(data === "H_E_L_L_O", "data should be transformed correctly");
done();
});
stack.write("hello");
});
it("should finish correctly with no streams and no data written", function(done) {
var stack = bun([]);
stack.on("finish", function() {
done();
});
stack.end();
});
it("should finish correctly with one stream and no data written", function(done) {
var alice = new stream.PassThrough({objectMode: true});
var stack = bun([alice]);
stack.on("finish", function() {
done();
});
stack.end();
});
it("should finish correctly with two streams and no data written", function(done) {
var alice = new stream.PassThrough({objectMode: true}),
bob = new stream.PassThrough({objectMode: true});
var stack = bun([alice, bob]);
stack.on("finish", function() {
done();
});
stack.end();
});
it("should finish correctly with no streams and some data written", function(done) {
var stack = bun([]);
stack.on("finish", function() {
done();
});
stack.on("readable", function() {
var e;
while (e = stack.read()) {
}
});
stack.write("some data");
stack.end();
});
it("should finish correctly with one stream and some data written", function(done) {
var alice = new stream.PassThrough({objectMode: true});
var stack = bun([alice]);
stack.on("finish", function() {
done();
});
stack.on("readable", function() {
var e;
while (e = stack.read()) {
}
});
stack.write("some data");
stack.end();
});
it("should finish correctly with two streams and some data written", function(done) {
var alice = new stream.PassThrough({objectMode: true}),
bob = new stream.PassThrough({objectMode: true});
var stack = bun([alice, bob]);
stack.on("finish", function() {
done();
});
stack.on("readable", function() {
var e;
while (e = stack.read()) {
}
});
stack.write("some data");
stack.end();
});
it("should finish correctly when piped through with no streams and no data written", function(done) {
var input = new stream.PassThrough({objectMode: true});
var nowhere = new stream.Writable({objectMode: true});
nowhere._write = function _write(input, encoding, done) { return done(); };
var stack = bun([]);
stack.on("finish", function() {
done();
});
input.pipe(stack).pipe(nowhere);
input.end();
});
it("should finish correctly when piped through with one stream and no data written", function(done) {
var input = new stream.PassThrough({objectMode: true});
var nowhere = new stream.Writable({objectMode: true});
nowhere._write = function _write(input, encoding, done) { return done(); };
var alice = new stream.PassThrough({objectMode: true});
var stack = bun([alice]);
stack.on("finish", function() {
done();
});
input.pipe(stack).pipe(nowhere);
input.end();
});
it("should finish correctly when piped through with two streams and no data written", function(done) {
var input = new stream.PassThrough({objectMode: true});
var nowhere = new stream.Writable({objectMode: true});
nowhere._write = function _write(input, encoding, done) { return done(); };
var alice = new stream.PassThrough({objectMode: true}),
bob = new stream.PassThrough({objectMode: true});
var stack = bun([alice, bob]);
stack.on("finish", function() {
done();
});
input.pipe(stack).pipe(nowhere);
input.end();
});
it("should finish correctly when piped through with no streams and some data written", function(done) {
var input = new stream.PassThrough({objectMode: true});
var nowhere = new stream.Writable({objectMode: true});
nowhere._write = function _write(input, encoding, done) { return done(); };
var stack = bun([]);
stack.on("finish", function() {
done();
});
input.pipe(stack).pipe(nowhere);
input.write("hello");
input.end();
});
it("should finish correctly when piped through with one stream and some data written", function(done) {
var input = new stream.PassThrough({objectMode: true});
var nowhere = new stream.Writable({objectMode: true});
nowhere._write = function _write(input, encoding, done) { return done(); };
var alice = new stream.PassThrough({objectMode: true});
var stack = bun([alice]);
stack.on("finish", function() {
done();
});
input.pipe(stack).pipe(nowhere);
input.write("hello");
input.end();
});
it("should finish correctly when piped through with two streams and some data written", function(done) {
var input = new stream.PassThrough({objectMode: true});
var nowhere = new stream.Writable({objectMode: true});
nowhere._write = function _write(input, encoding, done) { return done(); };
var alice = new stream.PassThrough({objectMode: true}),
bob = new stream.PassThrough({objectMode: true});
var stack = bun([alice, bob]);
stack.on("finish", function() {
done();
});
input.pipe(stack).pipe(nowhere);
input.write("hello");
input.end();
});
it("should end correctly when piped through with no streams and no data written", function(done) {
var input = new stream.PassThrough({objectMode: true});
var nowhere = new stream.Writable({objectMode: true});
nowhere._write = function _write(input, encoding, done) { return done(); };
var stack = bun([]);
stack.on("end", function() {
done();
});
input.pipe(stack).pipe(nowhere);
input.push(null);
});
it("should end correctly when piped through with one stream and no data written", function(done) {
var input = new stream.PassThrough({objectMode: true});
var nowhere = new stream.Writable({objectMode: true});
nowhere._write = function _write(input, encoding, done) { return done(); };
var alice = new stream.PassThrough({objectMode: true});
var stack = bun([alice]);
stack.on("end", function() {
done();
});
input.pipe(stack).pipe(nowhere);
input.end();
});
it("should end correctly when piped through with two streams and no data written", function(done) {
var input = new stream.PassThrough({objectMode: true});
var nowhere = new stream.Writable({objectMode: true});
nowhere._write = function _write(input, encoding, done) { return done(); };
var alice = new stream.PassThrough({objectMode: true}),
bob = new stream.PassThrough({objectMode: true});
var stack = bun([alice, bob]);
stack.on("end", function() {
done();
});
input.pipe(stack).pipe(nowhere);
input.end();
});
it("should end correctly when piped through with no streams and some data written", function(done) {
var input = new stream.PassThrough({objectMode: true});
var nowhere = new stream.Writable({objectMode: true});
nowhere._write = function _write(input, encoding, done) { return done(); };
var stack = bun([]);
stack.on("end", function() {
done();
});
input.pipe(stack).pipe(nowhere);
input.write("hello");
input.end();
});
it("should end correctly when piped through with one stream and some data written", function(done) {
var input = new stream.PassThrough({objectMode: true});
var nowhere = new stream.Writable({objectMode: true});
nowhere._write = function _write(input, encoding, done) { return done(); };
var alice = new stream.PassThrough({objectMode: true});
var stack = bun([alice]);
stack.on("end", function() {
done();
});
input.pipe(stack).pipe(nowhere);
input.write("hello");
input.end();
});
it("should end correctly when piped through with two streams and some data written", function(done) {
var input = new stream.PassThrough({objectMode: true});
var nowhere = new stream.Writable({objectMode: true});
nowhere._write = function _write(input, encoding, done) { return done(); };
var alice = new stream.PassThrough({objectMode: true}),
bob = new stream.PassThrough({objectMode: true});
var stack = bun([alice, bob]);
stack.on("end", function() {
done();
});
input.pipe(stack).pipe(nowhere);
input.write("hello");
input.end();
});
it("should end wrapped streams correctly when ended", function(done) {
var alice = new stream.PassThrough({objectMode: true});
alice.on("finish", function() {
done();
});
var stack = bun([alice]);
stack.end();
});
it("should finish when wrapped streams finish", function(done) {
var alice = new stream.PassThrough({objectMode: true}),
outside = new stream.PassThrough({objectMode: true});
var stack = bun([alice]);
stack.on("finish", function() {
done();
});
outside.pipe(stack).pipe(outside);
alice.end();
});
it("should end when wrapped streams end", function(done) {
var alice = new stream.PassThrough({objectMode: true});
var nowhere = new stream.Writable({objectMode: true});
nowhere._write = function _write(input, encoding, done) { return done(); };
var stack = bun([alice]);
stack.on("end", function() {
done();
});
stack.pipe(nowhere);
alice.push(null);
});
it("should forward errors if bubbleErrors is not specified", function(done) {
var alice = new stream.PassThrough();
var stack = bun([alice]);
stack.on("error", function(err) {
return done();
});
alice.emit("error", Error("test error"));
});
it("should forward errors if bubbleErrors is true", function(done) {
var alice = new stream.PassThrough();
var stack = bun([alice], {bubbleErrors: true});
stack.on("error", function(err) {
return done();
});
alice.emit("error", Error("test error"));
});
it("should not forward errors if bubbleErrors is false", function(done) {
var alice = new stream.PassThrough();
var stack = bun([alice], {bubbleErrors: false});
var timeout = setTimeout(done, 10);
stack.on("error", function(err) {
clearTimeout(timeout);
return done(Error("shouldn't have bubbled the error"));
});
alice.on("error", function(err) {
// prevent uncaught error crash
});
alice.emit("error", Error("test error"));
});
});