Backend half

This commit is contained in:
2025-07-11 19:56:28 +02:00
parent fa868e7c1d
commit 8600fa7c1d
19426 changed files with 3750448 additions and 8108 deletions
+20
View File
@@ -0,0 +1,20 @@
sauce_connect: true
loopback: airtap.local
browsers:
- name: chrome
version: latest
- name: firefox
# extended support releases 52, 60, 68
version: [52, 60, 68, latest]
- name: safari
version: 9..latest
- name: iphone
version: latest
- name: ie
version: 9..latest
- name: microsoftedge
version: 13..latest
browserify:
- plugin: ./test/use-stream.js
- require: tape
expose: tape
+12
View File
@@ -0,0 +1,12 @@
# These are supported funding model platforms
github: # Replace with up to 4 GitHub Sponsors-enabled usernames e.g., [user1, user2]
patreon: # Replace with a single Patreon username
open_collective: # Replace with a single Open Collective username
ko_fi: # Replace with a single Ko-fi username
tidelift: npm/stream-browserify
community_bridge: # Replace with a single Community Bridge project-name e.g., cloud-foundry
liberapay: # Replace with a single Liberapay username
issuehunt: # Replace with a single IssueHunt username
otechie: # Replace with a single Otechie username
custom: # Replace with up to 4 custom sponsorship URLs e.g., ['link1', 'link2']
+24
View File
@@ -0,0 +1,24 @@
os: linux
dist: bionic
language: node_js
jobs:
include:
- name: Run browser tests with airtap
node_js: stable
script: npm run test:browsers
addons:
sauce_connect: true
hosts:
- airtap.local
- name: Test on stable Node.js
node_js: stable
- name: Test on Node.js 12.x
node_js: 12
- name: Test on Node.js 10.x
node_js: 10
- name: Test on Node.js 8.x
node_js: 8
- name: Test on Node.js 6.x
node_js: 6
- name: Test on Node.js 4.x
node_js: 4
+8
View File
@@ -0,0 +1,8 @@
# stream-browserify change log
All notable changes to this project will be documented in this file.
This project adheres to [Semantic Versioning](http://semver.org/).
## 3.0.0
* Upgrade to `readable-stream` 3. For breaking changes, see the [readable-stream notes](https://github.com/nodejs/readable-stream#version-3xx).
+20
View File
@@ -0,0 +1,20 @@
MIT License
Copyright (c) James Halliday
Permission is hereby granted, free of charge, to any person obtaining a copy of
this software and associated documentation files (the "Software"), to deal in
the Software without restriction, including without limitation the rights to
use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
the Software, and to permit persons to whom the Software is furnished to do so,
subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+129
View File
@@ -0,0 +1,129 @@
// Copyright Joyent, Inc. and other Node contributors.
//
// Permission is hereby granted, free of charge, to any person obtaining a
// copy of this software and associated documentation files (the
// "Software"), to deal in the Software without restriction, including
// without limitation the rights to use, copy, modify, merge, publish,
// distribute, sublicense, and/or sell copies of the Software, and to permit
// persons to whom the Software is furnished to do so, subject to the
// following conditions:
//
// The above copyright notice and this permission notice shall be included
// in all copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
// OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN
// NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
// DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
// OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE
// USE OR OTHER DEALINGS IN THE SOFTWARE.
module.exports = Stream;
var EE = require('events').EventEmitter;
var inherits = require('inherits');
inherits(Stream, EE);
Stream.Readable = require('readable-stream/lib/_stream_readable.js');
Stream.Writable = require('readable-stream/lib/_stream_writable.js');
Stream.Duplex = require('readable-stream/lib/_stream_duplex.js');
Stream.Transform = require('readable-stream/lib/_stream_transform.js');
Stream.PassThrough = require('readable-stream/lib/_stream_passthrough.js');
Stream.finished = require('readable-stream/lib/internal/streams/end-of-stream.js')
Stream.pipeline = require('readable-stream/lib/internal/streams/pipeline.js')
// Backwards-compat with node 0.4.x
Stream.Stream = Stream;
// old-style streams. Note that the pipe method (the only relevant
// part of this class) is overridden in the Readable class.
function Stream() {
EE.call(this);
}
Stream.prototype.pipe = function(dest, options) {
var source = this;
function ondata(chunk) {
if (dest.writable) {
if (false === dest.write(chunk) && source.pause) {
source.pause();
}
}
}
source.on('data', ondata);
function ondrain() {
if (source.readable && source.resume) {
source.resume();
}
}
dest.on('drain', ondrain);
// If the 'end' option is not supplied, dest.end() will be called when
// source gets the 'end' or 'close' events. Only dest.end() once.
if (!dest._isStdio && (!options || options.end !== false)) {
source.on('end', onend);
source.on('close', onclose);
}
var didOnEnd = false;
function onend() {
if (didOnEnd) return;
didOnEnd = true;
dest.end();
}
function onclose() {
if (didOnEnd) return;
didOnEnd = true;
if (typeof dest.destroy === 'function') dest.destroy();
}
// don't leave dangling pipes when there are errors.
function onerror(er) {
cleanup();
if (EE.listenerCount(this, 'error') === 0) {
throw er; // Unhandled stream error in pipe.
}
}
source.on('error', onerror);
dest.on('error', onerror);
// remove all the event listeners that were added.
function cleanup() {
source.removeListener('data', ondata);
dest.removeListener('drain', ondrain);
source.removeListener('end', onend);
source.removeListener('close', onclose);
source.removeListener('error', onerror);
dest.removeListener('error', onerror);
source.removeListener('end', cleanup);
source.removeListener('close', cleanup);
dest.removeListener('close', cleanup);
}
source.on('end', cleanup);
source.on('close', cleanup);
dest.on('close', cleanup);
dest.emit('pipe', source);
// Allow for unix-like usage: A.pipe(B).pipe(C)
return dest;
};
+54
View File
@@ -0,0 +1,54 @@
{
"name": "stream-browserify",
"version": "3.0.0",
"description": "the stream module from node core for browsers",
"main": "index.js",
"dependencies": {
"inherits": "~2.0.4",
"readable-stream": "^3.5.0"
},
"devDependencies": {
"airtap": "^1.0.2",
"safe-buffer": "^5.1.2",
"tape": "^4.13.0",
"through": "^2.3.8"
},
"scripts": {
"test": "node test",
"test:browsers": "airtap -- test/index.js"
},
"repository": {
"type": "git",
"url": "git://github.com/browserify/stream-browserify.git"
},
"homepage": "https://github.com/browserify/stream-browserify",
"keywords": [
"stream",
"browser",
"browserify"
],
"author": {
"name": "James Halliday",
"email": "mail@substack.net",
"url": "http://substack.net"
},
"license": "MIT",
"testling": {
"files": "test/*.js",
"browsers": [
"ie/8..latest",
"firefox/3.5",
"firefox/10",
"firefox/nightly",
"chrome/10",
"chrome/latest",
"chrome/canary",
"opera/12..latest",
"opera/next",
"safari/5.1..latest",
"ipad/6.0..latest",
"iphone/6.0..latest",
"android-browser/4.2..latest"
]
}
}
+32
View File
@@ -0,0 +1,32 @@
# stream-browserify
the stream module from node core, for browsers!
This module uses [`readable-stream`](https://github.com/nodejs/readable-stream), with additions for compatibility with npm packages that use old Node.js stream APIs.
[![build status](https://secure.travis-ci.org/browserify/stream-browserify.svg?branch=master)](http://travis-ci.org/browserify/stream-browserify)
## Install
You usually do not have to install `stream-browserify` yourself! If your code runs in Node.js, `stream` is built in, or `readable-stream` can be used. If your code runs in the browser, bundlers like [browserify](https://github.com/browserify/browserify) also include the `stream-browserify` module.
But if none of those apply, with [npm](https://npmjs.org) do:
```bash
npm install stream-browserify
```
## API
Consult the node core
[documentation on streams](http://nodejs.org/docs/latest/api/stream.html).
## Browser Support
Cross-browser testing generously provided by [Sauce Labs](https://saucelabs.com).
[![Sauce Test Status](https://saucelabs.com/browser-matrix/stream-browserify.svg)](https://saucelabs.com/u/stream-browserify)
## License
[MIT](./LICENSE)
+10
View File
@@ -0,0 +1,10 @@
# Security Policy
## Supported Versions
Only the latest major version is supported at any given time.
## Reporting a Vulnerability
To report a security vulnerability, please use the
[Tidelift security contact](https://tidelift.com/security).
Tidelift will coordinate the fix and disclosure.
+33
View File
@@ -0,0 +1,33 @@
var path = require('path');
var test = require('tape');
var Buffer = require('safe-buffer').Buffer;
var Writable = require('..').Writable;
var inherits = require('inherits');
inherits(TestWritable, Writable);
function TestWritable(opt) {
if (!(this instanceof TestWritable))
return new TestWritable(opt);
Writable.call(this, opt);
this._written = [];
}
TestWritable.prototype._write = function(chunk, encoding, cb) {
this._written.push(chunk);
cb();
};
var buf = Buffer.from([ 88 ]);
test('.writable writing ArrayBuffer', function(t) {
var writable = new TestWritable();
writable.write(buf);
writable.end();
t.equal(writable._written.length, 1);
t.equal(writable._written[0].toString(), 'X')
t.end()
});
+2
View File
@@ -0,0 +1,2 @@
require('./buf');
require('./pipeline');
+38
View File
@@ -0,0 +1,38 @@
var test = require('tape');
var pipeline = require('..').pipeline;
var stream = require('..');
var Buffer = require('safe-buffer').Buffer;
test('supports pipeline', function(t) {
t.plan(4);
var readable = new stream.Readable({
read: function () {
this.push(Buffer.from('chunk', 'ascii'));
}
});
var transform1 = new stream.Transform({
transform: function (chunk, enc, cb) {
cb(new Error('fail'));
}
});
var transform2 = new stream.PassThrough();
transform2.on('close', function () {
t.pass('transform2.close called');
});
var writable = new stream.Writable({
write: function (chunk, enc, cb) { cb(); }
});
writable.on('close', function () {
t.pass('writable.close called');
});
pipeline(
readable,
transform1,
transform2,
writable,
function(err) {
t.ok(err);
t.equal(err.message, 'fail');
});
});
@@ -0,0 +1,4 @@
// browserify plugin to swap out the `stream` builtin node shim with the stream-browserify version in this repo.
module.exports = function (b) {
b._mdeps.options.modules.stream = require.resolve('../index.js');
};