initial commit
This commit is contained in:
12
node_modules/browserify/.github/FUNDING.yml
generated
vendored
Normal file
12
node_modules/browserify/.github/FUNDING.yml
generated
vendored
Normal 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/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']
|
||||
23
node_modules/browserify/.travis.yml
generated
vendored
Normal file
23
node_modules/browserify/.travis.yml
generated
vendored
Normal file
@@ -0,0 +1,23 @@
|
||||
language: node_js
|
||||
node_js:
|
||||
- "10"
|
||||
- "9"
|
||||
- "8"
|
||||
- "6"
|
||||
- "4"
|
||||
- "iojs"
|
||||
- "0.12"
|
||||
- "0.10"
|
||||
- "0.8"
|
||||
- "0.6"
|
||||
before_install:
|
||||
# Old npm certs are untrusted https://github.com/npm/npm/issues/20191
|
||||
- 'if [ "${TRAVIS_NODE_VERSION}" = "0.6" ] || [ "${TRAVIS_NODE_VERSION}" = "0.8" ]; then export NPM_CONFIG_STRICT_SSL=false; fi'
|
||||
- 'nvm install-latest-npm'
|
||||
install:
|
||||
- 'if [ "${TRAVIS_NODE_VERSION}" = "0.6" ] || [ "${TRAVIS_NODE_VERSION}" = "0.9" ]; then nvm install --latest-npm 0.8 && npm install && nvm use "${TRAVIS_NODE_VERSION}"; else npm install; fi;'
|
||||
sudo: false
|
||||
matrix:
|
||||
fast_finish: true
|
||||
allow_failures:
|
||||
- node_js: "0.6"
|
||||
21
node_modules/browserify/LICENSE
generated
vendored
Normal file
21
node_modules/browserify/LICENSE
generated
vendored
Normal file
@@ -0,0 +1,21 @@
|
||||
MIT License
|
||||
|
||||
Copyright (c) 2010 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.
|
||||
27
node_modules/browserify/appveyor.yml
generated
vendored
Normal file
27
node_modules/browserify/appveyor.yml
generated
vendored
Normal file
@@ -0,0 +1,27 @@
|
||||
environment:
|
||||
matrix:
|
||||
- nodejs_version: "10"
|
||||
- nodejs_version: "9"
|
||||
- nodejs_version: "8"
|
||||
- nodejs_version: "6"
|
||||
- nodejs_version: "4"
|
||||
- nodejs_version: "0.12"
|
||||
- nodejs_version: "0.10"
|
||||
|
||||
# Install scripts. (runs after repo cloning)
|
||||
install:
|
||||
# Get the latest stable version of Node.js or io.js
|
||||
- ps: Install-Product node $env:nodejs_version
|
||||
# install modules
|
||||
- npm install
|
||||
|
||||
# Post-install test scripts.
|
||||
test_script:
|
||||
# Output useful info for debugging.
|
||||
- node --version
|
||||
- npm --version
|
||||
# run tests
|
||||
- npm test
|
||||
|
||||
# Don't actually build.
|
||||
build: off
|
||||
BIN
node_modules/browserify/assets/browserify.png
generated
vendored
Normal file
BIN
node_modules/browserify/assets/browserify.png
generated
vendored
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 60 KiB |
BIN
node_modules/browserify/assets/logo.png
generated
vendored
Normal file
BIN
node_modules/browserify/assets/logo.png
generated
vendored
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 31 KiB |
117
node_modules/browserify/bin/advanced.txt
generated
vendored
Normal file
117
node_modules/browserify/bin/advanced.txt
generated
vendored
Normal file
@@ -0,0 +1,117 @@
|
||||
Advanced Options:
|
||||
|
||||
--insert-globals, --ig, --fast [default: false]
|
||||
|
||||
Skip detection and always insert definitions for process, global,
|
||||
__filename, and __dirname.
|
||||
|
||||
benefit: faster builds
|
||||
cost: extra bytes
|
||||
|
||||
--insert-global-vars, --igv
|
||||
|
||||
Comma-separated list of global variables to detect and define.
|
||||
Default: __filename,__dirname,process,Buffer,global
|
||||
|
||||
--detect-globals, --dg [default: true]
|
||||
|
||||
Detect the presence of process, global, __filename, and __dirname and define
|
||||
these values when present.
|
||||
|
||||
benefit: npm modules more likely to work
|
||||
cost: slower builds
|
||||
|
||||
--ignore-missing, --im [default: false]
|
||||
|
||||
Ignore `require()` statements that don't resolve to anything.
|
||||
|
||||
--noparse=FILE
|
||||
|
||||
Don't parse FILE at all. This will make bundling much, much faster for giant
|
||||
libs like jquery or threejs.
|
||||
|
||||
--no-builtins
|
||||
|
||||
Turn off builtins. This is handy when you want to run a bundle in node which
|
||||
provides the core builtins.
|
||||
|
||||
--no-commondir
|
||||
|
||||
Turn off setting a commondir. This is useful if you want to preserve the
|
||||
original paths that a bundle was generated with.
|
||||
|
||||
--no-bundle-external
|
||||
|
||||
Turn off bundling of all external modules. This is useful if you only want
|
||||
to bundle your local files.
|
||||
|
||||
--bare
|
||||
|
||||
Alias for both --no-builtins, --no-commondir, and sets --insert-global-vars
|
||||
to just "__filename,__dirname". This is handy if you want to run bundles in
|
||||
node.
|
||||
|
||||
--no-browser-field, --no-bf
|
||||
|
||||
Turn off package.json browser field resolution. This is also handy if you
|
||||
need to run a bundle in node.
|
||||
|
||||
--transform-key
|
||||
|
||||
Instead of the default package.json#browserify#transform field to list
|
||||
all transforms to apply when running browserify, a custom field, like, e.g.
|
||||
package.json#browserify#production or package.json#browserify#staging
|
||||
can be used, by for example running:
|
||||
* `browserify index.js --transform-key=production > bundle.js`
|
||||
* `browserify index.js --transform-key=staging > bundle.js`
|
||||
|
||||
--node
|
||||
|
||||
Alias for --bare and --no-browser-field.
|
||||
|
||||
--full-paths
|
||||
|
||||
Turn off converting module ids into numerical indexes. This is useful for
|
||||
preserving the original paths that a bundle was generated with.
|
||||
|
||||
--deps
|
||||
|
||||
Instead of standard bundle output, print the dependency array generated by
|
||||
module-deps.
|
||||
|
||||
--no-dedupe
|
||||
|
||||
Turn off deduping.
|
||||
|
||||
--list
|
||||
|
||||
Print each file in the dependency graph. Useful for makefiles.
|
||||
|
||||
--extension=EXTENSION
|
||||
|
||||
Consider files with specified EXTENSION as modules, this option can used
|
||||
multiple times.
|
||||
|
||||
--global-transform=MODULE, -g MODULE
|
||||
|
||||
Use a transform module on all files after any ordinary transforms have run.
|
||||
|
||||
--plugin=MODULE, -p MODULE
|
||||
|
||||
Register MODULE as a plugin.
|
||||
|
||||
--preserve-symlinks
|
||||
|
||||
Preserves symlinks when resolving modules.
|
||||
|
||||
Passing arguments to transforms and plugins:
|
||||
|
||||
For -t, -g, and -p, you may use subarg syntax to pass options to the
|
||||
transforms or plugin function as the second parameter. For example:
|
||||
|
||||
-t [ foo -x 3 --beep ]
|
||||
|
||||
will call the `foo` transform for each applicable file by calling:
|
||||
|
||||
foo(file, { x: 3, beep: true })
|
||||
|
||||
260
node_modules/browserify/bin/args.js
generated
vendored
Normal file
260
node_modules/browserify/bin/args.js
generated
vendored
Normal file
@@ -0,0 +1,260 @@
|
||||
var browserify = require('../');
|
||||
var path = require('path');
|
||||
var spawn = require('child_process').spawn;
|
||||
var parseShell = require('shell-quote').parse;
|
||||
var insertGlobals = require('insert-module-globals');
|
||||
var duplexer = require('duplexer2');
|
||||
var subarg = require('subarg');
|
||||
var glob = require('glob');
|
||||
var Readable = require('readable-stream').Readable;
|
||||
var xtend = require('xtend');
|
||||
|
||||
module.exports = function (args, opts) {
|
||||
var argv = subarg(args, {
|
||||
'boolean': [
|
||||
'deps', 'pack', 'ig', 'dg', 'im', 'd', 'list', 'builtins',
|
||||
'commondir', 'bare', 'full-paths', 'bundle-external', 'bf',
|
||||
'node', 'preserve-symlinks'
|
||||
],
|
||||
string: [ 's', 'r', 'u', 'x', 't', 'i', 'o', 'e', 'c', 'it' ],
|
||||
alias: {
|
||||
ig: [ 'insert-globals', 'fast' ],
|
||||
dg: [ 'detect-globals', 'detectGlobals', 'dg' ],
|
||||
bf: [ 'browser-field', 'browserField' ],
|
||||
im: 'ignore-missing',
|
||||
it: 'ignore-transform',
|
||||
igv: 'insert-global-vars',
|
||||
d: 'debug',
|
||||
s: 'standalone',
|
||||
noParse: [ 'noparse' ],
|
||||
'full-paths': [ 'fullpaths', 'fullPaths' ],
|
||||
r: 'require',
|
||||
u: 'exclude',
|
||||
x: 'external',
|
||||
t: 'transform',
|
||||
i: 'ignore',
|
||||
o: 'outfile',
|
||||
e: 'entry',
|
||||
c: 'command',
|
||||
bare: 'bear'
|
||||
},
|
||||
'default': {
|
||||
ig: false,
|
||||
im: false,
|
||||
dg: true,
|
||||
d: false,
|
||||
builtins: true,
|
||||
commondir: true,
|
||||
'bundle-external': true,
|
||||
bf: true,
|
||||
dedupe: true,
|
||||
node: false
|
||||
}
|
||||
});
|
||||
|
||||
var entries = argv._.concat(argv.entry)
|
||||
.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 entry;
|
||||
});
|
||||
|
||||
if (argv.igv) {
|
||||
var insertGlobalVars = {};
|
||||
var wantedGlobalVars = argv.igv.split(',');
|
||||
Object.keys(insertGlobals.vars).forEach(function (x) {
|
||||
if (wantedGlobalVars.indexOf(x) === -1) {
|
||||
insertGlobalVars[x] = undefined;
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
var ignoreTransform = argv['ignore-transform'] || argv.it;
|
||||
var b = browserify(xtend({
|
||||
node: argv.node,
|
||||
bare: argv.bare,
|
||||
noParse: Array.isArray(argv.noParse) ? argv.noParse : [argv.noParse],
|
||||
extensions: [].concat(argv.extension).filter(Boolean).map(function (extension) {
|
||||
if (extension.charAt(0) != '.') {
|
||||
return '.' + extension;
|
||||
} else {
|
||||
return extension
|
||||
}
|
||||
}),
|
||||
ignoreTransform: [].concat(ignoreTransform).filter(Boolean),
|
||||
entries: entries,
|
||||
fullPaths: argv['full-paths'],
|
||||
builtins: argv.builtins === false ? false : undefined,
|
||||
commondir: argv.commondir === false ? false : undefined,
|
||||
bundleExternal: argv['bundle-external'],
|
||||
basedir: argv.basedir,
|
||||
browserField: argv.browserField,
|
||||
transformKey: argv['transform-key'] ? ['browserify', argv['transform-key']] : undefined,
|
||||
dedupe: argv['dedupe'],
|
||||
preserveSymlinks: argv['preserve-symlinks'],
|
||||
|
||||
detectGlobals: argv.detectGlobals,
|
||||
insertGlobals: argv['insert-globals'] || argv.ig,
|
||||
insertGlobalVars: insertGlobalVars,
|
||||
ignoreMissing: argv['ignore-missing'] || argv.im,
|
||||
debug: argv['debug'] || argv.d,
|
||||
standalone: argv['standalone'] || argv.s
|
||||
}, opts));
|
||||
function error (msg) {
|
||||
var e = new Error(msg);
|
||||
process.nextTick(function () { b.emit('error', e) });
|
||||
}
|
||||
b.argv = argv;
|
||||
[].concat(argv.p).concat(argv.plugin).filter(Boolean)
|
||||
.forEach(function (p) {
|
||||
var pf = p, pOpts = {};
|
||||
if (typeof p === 'object') {
|
||||
pf = p._.shift(), pOpts = p;
|
||||
}
|
||||
b.plugin(pf, pOpts);
|
||||
})
|
||||
;
|
||||
|
||||
[].concat(argv.ignore).filter(Boolean)
|
||||
.forEach(function (i) {
|
||||
b._pending ++;
|
||||
glob(i, function (err, files) {
|
||||
if (err) return b.emit('error', err);
|
||||
if (files.length === 0) {
|
||||
b.ignore(i);
|
||||
}
|
||||
else {
|
||||
files.forEach(function (file) { b.ignore(file) });
|
||||
}
|
||||
if (--b._pending === 0) b.emit('_ready');
|
||||
});
|
||||
})
|
||||
;
|
||||
|
||||
[].concat(argv.exclude).filter(Boolean)
|
||||
.forEach(function (u) {
|
||||
b.exclude(u);
|
||||
|
||||
b._pending ++;
|
||||
glob(u, function (err, files) {
|
||||
if (err) return b.emit('error', err);
|
||||
files.forEach(function (file) { b.exclude(file) });
|
||||
if (--b._pending === 0) b.emit('_ready');
|
||||
});
|
||||
})
|
||||
;
|
||||
|
||||
[].concat(argv.require).filter(Boolean)
|
||||
.forEach(function (r) {
|
||||
var xs = splitOnColon(r);
|
||||
b.require(xs[0], { expose: xs.length === 1 ? xs[0] : xs[1] })
|
||||
})
|
||||
;
|
||||
|
||||
// resolve any external files and add them to the bundle as externals
|
||||
[].concat(argv.external).filter(Boolean)
|
||||
.forEach(function (x) {
|
||||
var xs = splitOnColon(x);
|
||||
if (xs.length === 2) {
|
||||
add(xs[0], { expose: xs[1] });
|
||||
}
|
||||
else if (/\*/.test(x)) {
|
||||
b.external(x);
|
||||
glob(x, function (err, files) {
|
||||
files.forEach(function (file) {
|
||||
add(file, {});
|
||||
});
|
||||
});
|
||||
}
|
||||
else add(x, {});
|
||||
|
||||
function add (x, opts) {
|
||||
if (/^[\/.]/.test(x)) b.external(path.resolve(x), opts)
|
||||
else b.external(x, opts)
|
||||
}
|
||||
})
|
||||
;
|
||||
|
||||
[].concat(argv.transform)
|
||||
.filter(Boolean)
|
||||
.forEach(function (t) { addTransform(t) })
|
||||
;
|
||||
|
||||
[].concat(argv.g).concat(argv['global-transform'])
|
||||
.filter(Boolean)
|
||||
.forEach(function (t) {
|
||||
addTransform(t, { global: true });
|
||||
})
|
||||
;
|
||||
|
||||
function addTransform (t, opts) {
|
||||
if (typeof t === 'string' || typeof t === 'function') {
|
||||
b.transform(opts, t);
|
||||
}
|
||||
else if (t && typeof t === 'object') {
|
||||
if (!t._[0] || typeof t._[0] !== 'string') {
|
||||
return error(
|
||||
'expected first parameter to be a transform string'
|
||||
);
|
||||
}
|
||||
if (opts) Object.keys(opts).forEach(function (key) {
|
||||
t[key] = opts[key];
|
||||
});
|
||||
b.transform(t, t._.shift());
|
||||
}
|
||||
else error('unexpected transform of type ' + typeof t);
|
||||
}
|
||||
|
||||
[].concat(argv.command).filter(Boolean)
|
||||
.forEach(function (c) {
|
||||
var cmd = parseShell(c);
|
||||
b.transform(function (file) {
|
||||
var env = Object.keys(process.env).reduce(function (acc, key) {
|
||||
acc[key] = process.env[key];
|
||||
return acc;
|
||||
}, {});
|
||||
env.FILENAME = file;
|
||||
var ps = spawn(cmd[0], cmd.slice(1), { env: env });
|
||||
var error = '';
|
||||
ps.stderr.on('data', function (buf) { error += buf });
|
||||
|
||||
ps.on('exit', function (code) {
|
||||
if (code === 0) return;
|
||||
console.error([
|
||||
'error running source transform command: ' + c,
|
||||
error.split('\n').join('\n '),
|
||||
''
|
||||
].join('\n'));
|
||||
process.exit(1);
|
||||
});
|
||||
return duplexer(ps.stdin, ps.stdout);
|
||||
});
|
||||
})
|
||||
;
|
||||
|
||||
if (argv.standalone === '') {
|
||||
error('--standalone requires an export name argument');
|
||||
return b;
|
||||
}
|
||||
|
||||
return b;
|
||||
};
|
||||
|
||||
function splitOnColon (f) {
|
||||
var pos = f.lastIndexOf(':');
|
||||
if (pos == -1) {
|
||||
return [f]; // No colon
|
||||
} else {
|
||||
if ((/[a-zA-Z]:[\\/]/.test(f)) && (pos == 1)){
|
||||
return [f]; // Windows path and colon is part of drive name
|
||||
} else {
|
||||
return [f.slice(0, pos), f.slice(pos + 1)];
|
||||
}
|
||||
}
|
||||
}
|
||||
91
node_modules/browserify/bin/cmd.js
generated
vendored
Executable file
91
node_modules/browserify/bin/cmd.js
generated
vendored
Executable file
@@ -0,0 +1,91 @@
|
||||
#!/usr/bin/env node
|
||||
var fs = require('fs');
|
||||
var JSONStream = require('JSONStream');
|
||||
var through = require('through2');
|
||||
var mkdirp = require('mkdirp-classic');
|
||||
var path = require('path');
|
||||
|
||||
var b = require('./args')(process.argv.slice(2));
|
||||
process.stdout.on('error', process.exit);
|
||||
|
||||
if ((b.argv._[0] === 'help' && b.argv._[1]) === 'advanced'
|
||||
|| (b.argv.h || b.argv.help) === 'advanced') {
|
||||
return fs.createReadStream(__dirname + '/advanced.txt')
|
||||
.pipe(process.stdout)
|
||||
.on('close', function () { process.exit(1) })
|
||||
;
|
||||
}
|
||||
if (b.argv._[0] === 'help' || b.argv.h || b.argv.help
|
||||
|| (process.argv.length <= 2 && process.stdin.isTTY)) {
|
||||
return fs.createReadStream(__dirname + '/usage.txt')
|
||||
.pipe(process.stdout)
|
||||
.on('close', function () { process.exit(1) })
|
||||
;
|
||||
}
|
||||
if (b.argv.version) {
|
||||
return console.log(require('../package.json').version);
|
||||
}
|
||||
|
||||
b.on('error', errorExit);
|
||||
|
||||
if (b.argv.pack) {
|
||||
process.stdin.pipe(b.pack()).pipe(process.stdout);
|
||||
process.stdin.resume();
|
||||
return;
|
||||
}
|
||||
|
||||
if (b.argv.deps) {
|
||||
var stringify = JSONStream.stringify();
|
||||
stringify.pipe(process.stdout);
|
||||
b.pipeline.get('deps').push(through.obj(
|
||||
function (row, enc, next) { stringify.write(row); next() },
|
||||
function () { stringify.end() }
|
||||
));
|
||||
return b.bundle();
|
||||
}
|
||||
|
||||
if (b.argv.list) {
|
||||
b.pipeline.get('deps').push(through.obj(
|
||||
function (row, enc, next) {
|
||||
console.log(row.file || row.id);
|
||||
next()
|
||||
}
|
||||
));
|
||||
return b.bundle();
|
||||
}
|
||||
|
||||
var bundle = b.bundle();
|
||||
bundle.on('error', errorExit);
|
||||
bundle.on('end', successExit);
|
||||
|
||||
var tmpfile;
|
||||
var outfile = b.argv.o || b.argv.outfile;
|
||||
if (outfile) {
|
||||
mkdirp.sync(path.dirname(outfile));
|
||||
|
||||
// we'll output to a temp file within same filesystem, then atomically overwrite outfile once successful
|
||||
tmpfile = outfile + ".tmp-browserify-" + Math.random().toFixed(20).slice(2)
|
||||
bundle.pipe(fs.createWriteStream(tmpfile));
|
||||
}
|
||||
else {
|
||||
bundle.pipe(process.stdout);
|
||||
}
|
||||
|
||||
function errorExit(err) {
|
||||
if (tmpfile) fs.unlink(tmpfile, function (err) {
|
||||
if (err) /* no-op, we're already exiting unhappily… */;
|
||||
});
|
||||
if (err.stack) {
|
||||
console.error(err.stack);
|
||||
}
|
||||
else {
|
||||
console.error(String(err));
|
||||
}
|
||||
process.exit(1);
|
||||
}
|
||||
|
||||
function successExit() {
|
||||
if (tmpfile && outfile) fs.rename(tmpfile, outfile, function (err) {
|
||||
if (err) errorExit(err);
|
||||
});
|
||||
}
|
||||
34
node_modules/browserify/bin/usage.txt
generated
vendored
Normal file
34
node_modules/browserify/bin/usage.txt
generated
vendored
Normal file
@@ -0,0 +1,34 @@
|
||||
Usage: browserify [entry files] {OPTIONS}
|
||||
|
||||
Standard Options:
|
||||
|
||||
--outfile, -o Write the browserify bundle to this file.
|
||||
If unspecified, browserify prints to stdout.
|
||||
|
||||
--require, -r A module name or file to bundle.require()
|
||||
Optionally use a colon separator to set the target.
|
||||
|
||||
--entry, -e An entry point of your app
|
||||
|
||||
--ignore, -i Replace a file with an empty stub. Files can be globs.
|
||||
|
||||
--exclude, -u Omit a file from the output bundle. Files can be globs.
|
||||
|
||||
--external, -x Reference a file from another bundle. Files can be globs.
|
||||
|
||||
--transform, -t Use a transform module on top-level files.
|
||||
|
||||
--command, -c Use a transform command on top-level files.
|
||||
|
||||
--standalone -s Generate a UMD bundle for the supplied export name.
|
||||
This bundle works with other module systems and sets the name
|
||||
given as a window global if no module system is found.
|
||||
|
||||
--debug -d Enable source maps that allow you to debug your files
|
||||
separately.
|
||||
|
||||
--help, -h Show this message
|
||||
|
||||
For advanced options, type `browserify --help advanced`.
|
||||
|
||||
Specify a parameter.
|
||||
1393
node_modules/browserify/changelog.markdown
generated
vendored
Normal file
1393
node_modules/browserify/changelog.markdown
generated
vendored
Normal file
File diff suppressed because it is too large
Load Diff
78
node_modules/browserify/code-of-conduct.md
generated
vendored
Normal file
78
node_modules/browserify/code-of-conduct.md
generated
vendored
Normal file
@@ -0,0 +1,78 @@
|
||||
# Contributor Covenant Code of Conduct
|
||||
|
||||
## Our Pledge
|
||||
|
||||
In the interest of fostering an open and welcoming environment, we as
|
||||
contributors and maintainers pledge to making participation in our project and
|
||||
our community a harassment-free experience for everyone, regardless of age, body
|
||||
size, disability, ethnicity, gender identity and expression, level of experience,
|
||||
nationality, personal appearance, race, religion, or sexual identity and
|
||||
orientation.
|
||||
|
||||
## Our Standards
|
||||
|
||||
Examples of behavior that contributes to creating a positive environment
|
||||
include:
|
||||
|
||||
* Using welcoming and inclusive language
|
||||
* Being respectful of differing viewpoints and experiences
|
||||
* Gracefully accepting constructive criticism
|
||||
* Focusing on what is best for the community
|
||||
* Showing empathy towards other community members
|
||||
|
||||
Examples of unacceptable behavior by participants include:
|
||||
|
||||
* The use of sexualized language or imagery and unwelcome sexual attention or
|
||||
advances
|
||||
* Trolling, insulting/derogatory comments, and personal or political attacks
|
||||
* Public or private harassment
|
||||
* Publishing others' private information, such as a physical or electronic
|
||||
address, without explicit permission
|
||||
* Other conduct which could reasonably be considered inappropriate in a
|
||||
professional setting
|
||||
|
||||
## Our Responsibilities
|
||||
|
||||
Project maintainers are responsible for clarifying the standards of acceptable
|
||||
behavior and are expected to take appropriate and fair corrective action in
|
||||
response to any instances of unacceptable behavior.
|
||||
|
||||
Project maintainers have the right and responsibility to remove, edit, or
|
||||
reject comments, commits, code, wiki edits, issues, and other contributions
|
||||
that are not aligned to this Code of Conduct, or to ban temporarily or
|
||||
permanently any contributor for other behaviors that they deem inappropriate,
|
||||
threatening, offensive, or harmful.
|
||||
|
||||
## Scope
|
||||
|
||||
This Code of Conduct applies both within project spaces and in public spaces
|
||||
when an individual is representing the project or its community. Examples of
|
||||
representing a project or community include using an official project e-mail
|
||||
address, posting via an official social media account, or acting as an appointed
|
||||
representative at an online or offline event. Representation of a project may be
|
||||
further defined and clarified by project maintainers.
|
||||
|
||||
## Enforcement
|
||||
|
||||
Instances of abusive, harassing, or otherwise unacceptable behavior may be
|
||||
reported by contacting the project team at (any one or all of these):
|
||||
|
||||
* substack@gmail.com
|
||||
|
||||
All complaints will be reviewed and investigated and will result in a response
|
||||
that is deemed necessary and appropriate to the circumstances. The project team
|
||||
is obligated to maintain confidentiality with regard to the reporter of an
|
||||
incident. Further details of specific enforcement policies may be posted
|
||||
separately.
|
||||
|
||||
Project maintainers who do not follow or enforce the Code of Conduct in good
|
||||
faith may face temporary or permanent repercussions as determined by other
|
||||
members of the project's leadership.
|
||||
|
||||
## Attribution
|
||||
|
||||
This Code of Conduct is adapted from the [Contributor Covenant][homepage], version 1.4,
|
||||
available at [http://contributor-covenant.org/version/1/4][version]
|
||||
|
||||
[homepage]: http://contributor-covenant.org
|
||||
[version]: http://contributor-covenant.org/version/1/4/
|
||||
1
node_modules/browserify/example/api/browser/bar.js
generated
vendored
Normal file
1
node_modules/browserify/example/api/browser/bar.js
generated
vendored
Normal file
@@ -0,0 +1 @@
|
||||
module.exports = function (n) { return n * 3 };
|
||||
5
node_modules/browserify/example/api/browser/foo.js
generated
vendored
Normal file
5
node_modules/browserify/example/api/browser/foo.js
generated
vendored
Normal file
@@ -0,0 +1,5 @@
|
||||
var bar = require('./bar');
|
||||
|
||||
module.exports = function (n) {
|
||||
return n * bar(n);
|
||||
};
|
||||
2
node_modules/browserify/example/api/browser/main.js
generated
vendored
Normal file
2
node_modules/browserify/example/api/browser/main.js
generated
vendored
Normal file
@@ -0,0 +1,2 @@
|
||||
var foo = require('./foo');
|
||||
console.log(foo(5));
|
||||
4
node_modules/browserify/example/api/build.js
generated
vendored
Normal file
4
node_modules/browserify/example/api/build.js
generated
vendored
Normal file
@@ -0,0 +1,4 @@
|
||||
var browserify = require('browserify');
|
||||
var b = browserify();
|
||||
b.add('./browser/main.js');
|
||||
b.bundle().pipe(process.stdout);
|
||||
2
node_modules/browserify/example/multiple_bundles/beep.js
generated
vendored
Normal file
2
node_modules/browserify/example/multiple_bundles/beep.js
generated
vendored
Normal file
@@ -0,0 +1,2 @@
|
||||
var robot = require('./robot');
|
||||
console.log(robot('beep'));
|
||||
2
node_modules/browserify/example/multiple_bundles/boop.js
generated
vendored
Normal file
2
node_modules/browserify/example/multiple_bundles/boop.js
generated
vendored
Normal file
@@ -0,0 +1,2 @@
|
||||
var robot = require('./robot');
|
||||
console.log(robot('boop'));
|
||||
4
node_modules/browserify/example/multiple_bundles/build.sh
generated
vendored
Executable file
4
node_modules/browserify/example/multiple_bundles/build.sh
generated
vendored
Executable file
@@ -0,0 +1,4 @@
|
||||
#!/bin/bash
|
||||
browserify -r ./robot.js > static/common.js
|
||||
browserify -x ./robot.js beep.js > static/beep.js
|
||||
browserify -x ./robot.js boop.js > static/boop.js
|
||||
1
node_modules/browserify/example/multiple_bundles/robot.js
generated
vendored
Normal file
1
node_modules/browserify/example/multiple_bundles/robot.js
generated
vendored
Normal file
@@ -0,0 +1 @@
|
||||
module.exports = function (s) { return s.toUpperCase() + '!' };
|
||||
2
node_modules/browserify/example/multiple_bundles/static/beep.html
generated
vendored
Normal file
2
node_modules/browserify/example/multiple_bundles/static/beep.html
generated
vendored
Normal file
@@ -0,0 +1,2 @@
|
||||
<script src="common.js"></script>
|
||||
<script src="beep.js"></script>
|
||||
2
node_modules/browserify/example/multiple_bundles/static/boop.html
generated
vendored
Normal file
2
node_modules/browserify/example/multiple_bundles/static/boop.html
generated
vendored
Normal file
@@ -0,0 +1,2 @@
|
||||
<script src="common.js"></script>
|
||||
<script src="boop.js"></script>
|
||||
13
node_modules/browserify/example/source_maps/build.js
generated
vendored
Normal file
13
node_modules/browserify/example/source_maps/build.js
generated
vendored
Normal file
@@ -0,0 +1,13 @@
|
||||
var browserify = require('../..'),
|
||||
path = require('path'),
|
||||
fs = require('fs'),
|
||||
bundlePath = path.join(__dirname, 'js', 'build', 'bundle.js');
|
||||
|
||||
browserify()
|
||||
.require(require.resolve('./js/main.js'), {
|
||||
entry: true,
|
||||
debug: true
|
||||
})
|
||||
.bundle()
|
||||
.on('error', function (err) { console.error(err); })
|
||||
.pipe(fs.createWriteStream(bundlePath));
|
||||
4
node_modules/browserify/example/source_maps/build.sh
generated
vendored
Executable file
4
node_modules/browserify/example/source_maps/build.sh
generated
vendored
Executable file
@@ -0,0 +1,4 @@
|
||||
#!/bin/bash
|
||||
../../bin/cmd.js --debug -e ./js/main.js > js/build/bundle.js
|
||||
|
||||
echo bundle was generated with source maps, you can now open index.html
|
||||
11
node_modules/browserify/example/source_maps/index.html
generated
vendored
Normal file
11
node_modules/browserify/example/source_maps/index.html
generated
vendored
Normal file
@@ -0,0 +1,11 @@
|
||||
<!DOCTYPE html>
|
||||
<html>
|
||||
<head>
|
||||
<meta charset=utf-8 />
|
||||
<title></title>
|
||||
<script type="text/javascript" src="./js/build/bundle.js"></script>
|
||||
</head>
|
||||
<body>
|
||||
<p>Open your dev tools ;)</p>
|
||||
</body>
|
||||
</html>
|
||||
1
node_modules/browserify/example/source_maps/js/build/.npmignore
generated
vendored
Normal file
1
node_modules/browserify/example/source_maps/js/build/.npmignore
generated
vendored
Normal file
@@ -0,0 +1 @@
|
||||
!.gitignore
|
||||
28
node_modules/browserify/example/source_maps/js/build/bundle.js
generated
vendored
Normal file
28
node_modules/browserify/example/source_maps/js/build/bundle.js
generated
vendored
Normal file
@@ -0,0 +1,28 @@
|
||||
;(function(e,t,n,r){function i(r){if(!n[r]){if(!t[r]){if(e)return e(r);throw new Error("Cannot find module '"+r+"'")}var s=n[r]={exports:{}};t[r][0](function(e){var n=t[r][1][e];return i(n?n:e)},s,s.exports)}return n[r].exports}for(var s=0;s<r.length;s++)i(r[s]);return i})(typeof require!=="undefined"&&require,{1:[function(require,module,exports){
|
||||
console.log('main line 1');
|
||||
var foo = require('./foo.js');
|
||||
|
||||
foo();
|
||||
|
||||
},{"./foo.js":2}],2:[function(require,module,exports){
|
||||
console.log('foo line 1');
|
||||
var bar = require('./wunder/bar');
|
||||
|
||||
module.exports = function foo() {
|
||||
console.log('hello from foo line 5');
|
||||
bar();
|
||||
};
|
||||
|
||||
},{"./wunder/bar":3}],3:[function(require,module,exports){
|
||||
console.log('bar line 1');
|
||||
'use strict';
|
||||
|
||||
// this is a meaningless comment to add some lines
|
||||
|
||||
module.exports = function bar() {
|
||||
console.log('hello from bar line 7');
|
||||
};
|
||||
|
||||
},{}]},{},[1])
|
||||
//@ sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiIiwic291cmNlcyI6WyIvVXNlcnMvdGhsb3JlbnovZGV2L2pzL3Byb2plY3RzL2ZvcmtzL25vZGUtYnJvd3NlcmlmeS9leGFtcGxlL3NvdXJjZV9tYXBzL2pzL21haW4uanMiLCIvVXNlcnMvdGhsb3JlbnovZGV2L2pzL3Byb2plY3RzL2ZvcmtzL25vZGUtYnJvd3NlcmlmeS9leGFtcGxlL3NvdXJjZV9tYXBzL2pzL2Zvby5qcyIsIi9Vc2Vycy90aGxvcmVuei9kZXYvanMvcHJvamVjdHMvZm9ya3Mvbm9kZS1icm93c2VyaWZ5L2V4YW1wbGUvc291cmNlX21hcHMvanMvd3VuZGVyL2Jhci5qcyJdLCJuYW1lcyI6W10sIm1hcHBpbmdzIjoiO0FBQUE7QUFDQTtBQUNBO0FBQ0E7QUFDQTs7QUNKQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBOztBQ1BBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQSIsInNvdXJjZVJvb3QiOiJmaWxlOi8vbG9jYWxob3N0Iiwic291cmNlQ29udGVudCI6WyJjb25zb2xlLmxvZygnbWFpbiBsaW5lIDEnKTtcbnZhciBmb28gPSByZXF1aXJlKCcuL2Zvby5qcycpO1xuXG5mb28oKTtcbiIsImNvbnNvbGUubG9nKCdmb28gbGluZSAxJyk7XG52YXIgYmFyID0gcmVxdWlyZSgnLi93dW5kZXIvYmFyJyk7XG5cbm1vZHVsZS5leHBvcnRzID0gZnVuY3Rpb24gZm9vKCkge1xuICBjb25zb2xlLmxvZygnaGVsbG8gZnJvbSBmb28gbGluZSA1Jyk7XG4gIGJhcigpO1xufTtcbiIsImNvbnNvbGUubG9nKCdiYXIgbGluZSAxJyk7XG4ndXNlIHN0cmljdCc7XG5cbi8vIHRoaXMgaXMgYSBtZWFuaW5nbGVzcyBjb21tZW50IHRvIGFkZCBzb21lIGxpbmVzXG5cbm1vZHVsZS5leHBvcnRzID0gZnVuY3Rpb24gYmFyKCkge1xuICBjb25zb2xlLmxvZygnaGVsbG8gZnJvbSBiYXIgbGluZSA3Jyk7XG59O1xuIl19
|
||||
;
|
||||
7
node_modules/browserify/example/source_maps/js/foo.js
generated
vendored
Normal file
7
node_modules/browserify/example/source_maps/js/foo.js
generated
vendored
Normal file
@@ -0,0 +1,7 @@
|
||||
console.log('foo line 1');
|
||||
var bar = require('./wunder/bar');
|
||||
|
||||
module.exports = function foo() {
|
||||
console.log('hello from foo line 5');
|
||||
bar();
|
||||
};
|
||||
4
node_modules/browserify/example/source_maps/js/main.js
generated
vendored
Normal file
4
node_modules/browserify/example/source_maps/js/main.js
generated
vendored
Normal file
@@ -0,0 +1,4 @@
|
||||
console.log('main line 1');
|
||||
var foo = require('./foo.js');
|
||||
|
||||
foo();
|
||||
8
node_modules/browserify/example/source_maps/js/wunder/bar.js
generated
vendored
Normal file
8
node_modules/browserify/example/source_maps/js/wunder/bar.js
generated
vendored
Normal file
@@ -0,0 +1,8 @@
|
||||
console.log('bar line 1');
|
||||
'use strict';
|
||||
|
||||
// this is a meaningless comment to add some lines
|
||||
|
||||
module.exports = function bar() {
|
||||
console.log('hello from bar line 7');
|
||||
};
|
||||
876
node_modules/browserify/index.js
generated
vendored
Normal file
876
node_modules/browserify/index.js
generated
vendored
Normal file
@@ -0,0 +1,876 @@
|
||||
var path = require('path');
|
||||
var mdeps = require('module-deps');
|
||||
var depsSort = require('deps-sort');
|
||||
var bpack = require('browser-pack');
|
||||
var insertGlobals = require('insert-module-globals');
|
||||
var syntaxError = require('syntax-error');
|
||||
|
||||
var builtins = require('./lib/builtins.js');
|
||||
|
||||
var splicer = require('labeled-stream-splicer');
|
||||
var through = require('through2');
|
||||
var concat = require('concat-stream');
|
||||
|
||||
var inherits = require('inherits');
|
||||
var EventEmitter = require('events').EventEmitter;
|
||||
var xtend = require('xtend');
|
||||
var isArray = Array.isArray;
|
||||
var defined = require('defined');
|
||||
var hasOwn = require('hasown');
|
||||
var sanitize = require('htmlescape').sanitize;
|
||||
var shasum = require('shasum-object');
|
||||
|
||||
var bresolve = require('browser-resolve');
|
||||
var resolve = require('resolve');
|
||||
|
||||
var readonly = require('read-only-stream');
|
||||
|
||||
module.exports = Browserify;
|
||||
inherits(Browserify, EventEmitter);
|
||||
|
||||
var fs = require('fs');
|
||||
var path = require('path');
|
||||
var cachedPathRelative = require('cached-path-relative');
|
||||
|
||||
var paths = {
|
||||
empty: path.join(__dirname, 'lib/_empty.js')
|
||||
};
|
||||
|
||||
function Browserify (files, opts) {
|
||||
var self = this;
|
||||
if (!(this instanceof Browserify)) return new Browserify(files, opts);
|
||||
if (!opts) opts = {};
|
||||
|
||||
if (typeof files === 'string' || isArray(files) || isStream(files)) {
|
||||
opts = xtend(opts, { entries: [].concat(opts.entries || [], files) });
|
||||
}
|
||||
else opts = xtend(files, opts);
|
||||
|
||||
if (opts.node) {
|
||||
opts.bare = true;
|
||||
opts.browserField = false;
|
||||
}
|
||||
if (opts.bare) {
|
||||
opts.builtins = false;
|
||||
opts.commondir = false;
|
||||
if (opts.insertGlobalVars === undefined) {
|
||||
opts.insertGlobalVars = {}
|
||||
Object.keys(insertGlobals.vars).forEach(function (name) {
|
||||
if (name !== '__dirname' && name !== '__filename') {
|
||||
opts.insertGlobalVars[name] = undefined;
|
||||
}
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
self._options = opts;
|
||||
if (opts.noparse) opts.noParse = opts.noparse;
|
||||
|
||||
if (opts.basedir !== undefined && typeof opts.basedir !== 'string') {
|
||||
throw new Error('opts.basedir must be either undefined or a string.');
|
||||
}
|
||||
|
||||
opts.dedupe = opts.dedupe === false ? false : true;
|
||||
|
||||
self._external = [];
|
||||
self._exclude = [];
|
||||
self._ignore = [];
|
||||
self._expose = {};
|
||||
self._hashes = {};
|
||||
self._pending = 0;
|
||||
self._transformOrder = 0;
|
||||
self._transformPending = 0;
|
||||
self._transforms = [];
|
||||
self._entryOrder = 0;
|
||||
self._ticked = false;
|
||||
|
||||
var browserField = opts.browserField
|
||||
self._bresolve = browserField === false
|
||||
? function (id, opts, cb) {
|
||||
if (!opts.basedir) opts.basedir = path.dirname(opts.filename)
|
||||
resolve(id, opts, cb)
|
||||
}
|
||||
: typeof browserField === 'string'
|
||||
? function (id, opts, cb) {
|
||||
opts.browser = browserField
|
||||
bresolve(id, opts, cb)
|
||||
}
|
||||
: bresolve
|
||||
;
|
||||
self._syntaxCache = {};
|
||||
|
||||
var ignoreTransform = [].concat(opts.ignoreTransform).filter(Boolean);
|
||||
self._filterTransform = function (tr) {
|
||||
if (isArray(tr)) {
|
||||
return ignoreTransform.indexOf(tr[0]) === -1;
|
||||
}
|
||||
return ignoreTransform.indexOf(tr) === -1;
|
||||
};
|
||||
|
||||
self.pipeline = self._createPipeline(opts);
|
||||
|
||||
[].concat(opts.transform).filter(Boolean).filter(self._filterTransform)
|
||||
.forEach(function (tr) {
|
||||
self.transform(tr);
|
||||
});
|
||||
|
||||
[].concat(opts.entries).filter(Boolean).forEach(function (file) {
|
||||
self.add(file, { basedir: opts.basedir });
|
||||
});
|
||||
|
||||
[].concat(opts.require).filter(Boolean).forEach(function (file) {
|
||||
self.require(file, { basedir: opts.basedir });
|
||||
});
|
||||
|
||||
[].concat(opts.plugin).filter(Boolean).forEach(function (p) {
|
||||
self.plugin(p, { basedir: opts.basedir });
|
||||
});
|
||||
}
|
||||
|
||||
Browserify.prototype.require = function (file, opts) {
|
||||
var self = this;
|
||||
if (isArray(file)) {
|
||||
file.forEach(function (x) {
|
||||
if (typeof x === 'object') {
|
||||
self.require(x.file, xtend(opts, x));
|
||||
}
|
||||
else self.require(x, opts);
|
||||
});
|
||||
return this;
|
||||
}
|
||||
|
||||
if (!opts) opts = {};
|
||||
var basedir = defined(opts.basedir, self._options.basedir, process.cwd());
|
||||
var expose = opts.expose;
|
||||
if (file === expose && /^[\.]/.test(expose)) {
|
||||
expose = '/' + relativePath(basedir, expose);
|
||||
}
|
||||
if (expose === undefined && this._options.exposeAll) {
|
||||
expose = true;
|
||||
}
|
||||
if (expose === true) {
|
||||
expose = '/' + relativePath(basedir, file);
|
||||
}
|
||||
|
||||
if (isStream(file)) {
|
||||
self._pending ++;
|
||||
var order = self._entryOrder ++;
|
||||
file.pipe(concat(function (buf) {
|
||||
var filename = opts.file || file.file || path.join(
|
||||
basedir,
|
||||
'_stream_' + order + '.js'
|
||||
);
|
||||
var id = file.id || expose || filename;
|
||||
if (expose || opts.entry === false) {
|
||||
self._expose[id] = filename;
|
||||
}
|
||||
if (!opts.entry && self._options.exports === undefined) {
|
||||
self._bpack.hasExports = true;
|
||||
}
|
||||
var rec = {
|
||||
source: buf.toString('utf8'),
|
||||
entry: defined(opts.entry, false),
|
||||
file: filename,
|
||||
id: id
|
||||
};
|
||||
if (rec.entry) rec.order = order;
|
||||
if (rec.transform === false) rec.transform = false;
|
||||
self.pipeline.write(rec);
|
||||
|
||||
if (-- self._pending === 0) self.emit('_ready');
|
||||
}));
|
||||
return this;
|
||||
}
|
||||
|
||||
var row;
|
||||
if (typeof file === 'object') {
|
||||
row = xtend(file, opts);
|
||||
}
|
||||
else if (!opts.entry && isExternalModule(file)) {
|
||||
// external module or builtin
|
||||
row = xtend(opts, { id: expose || file, file: file });
|
||||
}
|
||||
else {
|
||||
row = xtend(opts, { file: path.resolve(basedir, file) });
|
||||
}
|
||||
|
||||
if (!row.id) {
|
||||
row.id = expose || row.file;
|
||||
}
|
||||
if (expose || !row.entry) {
|
||||
// Make this available to mdeps so that it can assign the value when it
|
||||
// resolves the pathname.
|
||||
row.expose = row.id;
|
||||
}
|
||||
|
||||
if (opts.external) return self.external(file, opts);
|
||||
if (row.entry === undefined) row.entry = false;
|
||||
|
||||
if (!row.entry && self._options.exports === undefined) {
|
||||
self._bpack.hasExports = true;
|
||||
}
|
||||
|
||||
if (row.entry) row.order = self._entryOrder ++;
|
||||
|
||||
if (opts.transform === false) row.transform = false;
|
||||
self.pipeline.write(row);
|
||||
return self;
|
||||
};
|
||||
|
||||
Browserify.prototype.add = function (file, opts) {
|
||||
var self = this;
|
||||
if (!opts) opts = {};
|
||||
if (isArray(file)) {
|
||||
file.forEach(function (x) { self.add(x, opts) });
|
||||
return this;
|
||||
}
|
||||
return this.require(file, xtend({ entry: true, expose: false }, opts));
|
||||
};
|
||||
|
||||
Browserify.prototype.external = function (file, opts) {
|
||||
var self = this;
|
||||
if (isArray(file)) {
|
||||
file.forEach(function (f) {
|
||||
if (typeof f === 'object') {
|
||||
self.external(f, xtend(opts, f));
|
||||
}
|
||||
else self.external(f, opts)
|
||||
});
|
||||
return this;
|
||||
}
|
||||
if (file && typeof file === 'object' && typeof file.bundle === 'function') {
|
||||
var b = file;
|
||||
self._pending ++;
|
||||
|
||||
var bdeps = {};
|
||||
var blabels = {};
|
||||
|
||||
b.on('label', function (prev, id) {
|
||||
self._external.push(id);
|
||||
|
||||
if (prev !== id) {
|
||||
blabels[prev] = id;
|
||||
self._external.push(prev);
|
||||
}
|
||||
});
|
||||
|
||||
b.pipeline.get('deps').push(through.obj(function (row, enc, next) {
|
||||
bdeps = xtend(bdeps, row.deps);
|
||||
this.push(row);
|
||||
next();
|
||||
}));
|
||||
|
||||
self.on('dep', function (row) {
|
||||
Object.keys(row.deps).forEach(function (key) {
|
||||
var prev = bdeps[key];
|
||||
if (prev) {
|
||||
var id = blabels[prev];
|
||||
if (id) {
|
||||
row.indexDeps[key] = id;
|
||||
}
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
b.pipeline.get('label').once('end', function () {
|
||||
if (-- self._pending === 0) self.emit('_ready');
|
||||
});
|
||||
return this;
|
||||
}
|
||||
|
||||
if (!opts) opts = {};
|
||||
var basedir = defined(opts.basedir, process.cwd());
|
||||
this._external.push(file);
|
||||
this._external.push('/' + relativePath(basedir, file));
|
||||
return this;
|
||||
};
|
||||
|
||||
Browserify.prototype.exclude = function (file, opts) {
|
||||
if (!opts) opts = {};
|
||||
if (isArray(file)) {
|
||||
var self = this;
|
||||
file.forEach(function(file) {
|
||||
self.exclude(file, opts);
|
||||
});
|
||||
return this;
|
||||
}
|
||||
var basedir = defined(opts.basedir, process.cwd());
|
||||
this._exclude.push(file);
|
||||
this._exclude.push('/' + relativePath(basedir, file));
|
||||
return this;
|
||||
};
|
||||
|
||||
Browserify.prototype.ignore = function (file, opts) {
|
||||
if (!opts) opts = {};
|
||||
if (isArray(file)) {
|
||||
var self = this;
|
||||
file.forEach(function(file) {
|
||||
self.ignore(file, opts);
|
||||
});
|
||||
return this;
|
||||
}
|
||||
var basedir = defined(opts.basedir, process.cwd());
|
||||
|
||||
// Handle relative paths
|
||||
if (file[0] === '.') {
|
||||
this._ignore.push(path.resolve(basedir, file));
|
||||
}
|
||||
else {
|
||||
this._ignore.push(file);
|
||||
}
|
||||
return this;
|
||||
};
|
||||
|
||||
Browserify.prototype.transform = function (tr, opts) {
|
||||
var self = this;
|
||||
if (typeof opts === 'function' || typeof opts === 'string') {
|
||||
tr = [ opts, tr ];
|
||||
}
|
||||
if (isArray(tr)) {
|
||||
opts = tr[1];
|
||||
tr = tr[0];
|
||||
}
|
||||
|
||||
//if the bundler is ignoring this transform
|
||||
if (typeof tr === 'string' && !self._filterTransform(tr)) {
|
||||
return this;
|
||||
}
|
||||
|
||||
function resolved () {
|
||||
self._transforms[order] = rec;
|
||||
-- self._pending;
|
||||
if (-- self._transformPending === 0) {
|
||||
self._transforms.forEach(function (transform) {
|
||||
self.pipeline.write(transform);
|
||||
});
|
||||
|
||||
if (self._pending === 0) {
|
||||
self.emit('_ready');
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (!opts) opts = {};
|
||||
opts._flags = '_flags' in opts ? opts._flags : self._options;
|
||||
|
||||
var basedir = defined(opts.basedir, this._options.basedir, process.cwd());
|
||||
var order = self._transformOrder ++;
|
||||
self._pending ++;
|
||||
self._transformPending ++;
|
||||
|
||||
var rec = {
|
||||
transform: tr,
|
||||
options: opts,
|
||||
global: opts.global
|
||||
};
|
||||
|
||||
if (typeof tr === 'string') {
|
||||
var topts = {
|
||||
basedir: basedir,
|
||||
paths: (self._options.paths || []).map(function (p) {
|
||||
return path.resolve(basedir, p);
|
||||
})
|
||||
};
|
||||
resolve(tr, topts, function (err, res) {
|
||||
if (err) return self.emit('error', err);
|
||||
rec.transform = res;
|
||||
resolved();
|
||||
});
|
||||
}
|
||||
else process.nextTick(resolved);
|
||||
return this;
|
||||
};
|
||||
|
||||
Browserify.prototype.plugin = function (p, opts) {
|
||||
if (isArray(p)) {
|
||||
opts = p[1];
|
||||
p = p[0];
|
||||
}
|
||||
if (!opts) opts = {};
|
||||
var basedir = defined(opts.basedir, this._options.basedir, process.cwd());
|
||||
if (typeof p === 'function') {
|
||||
p(this, opts);
|
||||
}
|
||||
else {
|
||||
var pfile = resolve.sync(String(p), { basedir: basedir })
|
||||
var f = require(pfile);
|
||||
if (typeof f !== 'function') {
|
||||
throw new Error('plugin ' + p + ' should export a function');
|
||||
}
|
||||
f(this, opts);
|
||||
}
|
||||
return this;
|
||||
};
|
||||
|
||||
Browserify.prototype._createPipeline = function (opts) {
|
||||
var self = this;
|
||||
if (!opts) opts = {};
|
||||
this._mdeps = this._createDeps(opts);
|
||||
this._mdeps.on('file', function (file, id) {
|
||||
pipeline.emit('file', file, id);
|
||||
self.emit('file', file, id);
|
||||
});
|
||||
this._mdeps.on('package', function (pkg) {
|
||||
pipeline.emit('package', pkg);
|
||||
self.emit('package', pkg);
|
||||
});
|
||||
this._mdeps.on('transform', function (tr, file) {
|
||||
pipeline.emit('transform', tr, file);
|
||||
self.emit('transform', tr, file);
|
||||
});
|
||||
|
||||
var dopts = {
|
||||
index: !opts.fullPaths && !opts.exposeAll,
|
||||
dedupe: opts.dedupe,
|
||||
expose: this._expose
|
||||
};
|
||||
this._bpack = bpack(xtend(opts, { raw: true }));
|
||||
|
||||
var pipeline = splicer.obj([
|
||||
'record', [ this._recorder() ],
|
||||
'deps', [ this._mdeps ],
|
||||
'json', [ this._json() ],
|
||||
'unbom', [ this._unbom() ],
|
||||
'unshebang', [ this._unshebang() ],
|
||||
'syntax', [ this._syntax() ],
|
||||
'sort', [ depsSort(dopts) ],
|
||||
'dedupe', [ this._dedupe() ],
|
||||
'label', [ this._label(opts) ],
|
||||
'emit-deps', [ this._emitDeps() ],
|
||||
'debug', [ this._debug(opts) ],
|
||||
'pack', [ this._bpack ],
|
||||
'wrap', []
|
||||
]);
|
||||
if (opts.exposeAll) {
|
||||
var basedir = defined(opts.basedir, process.cwd());
|
||||
pipeline.get('deps').push(through.obj(function (row, enc, next) {
|
||||
if (self._external.indexOf(row.id) >= 0) return next();
|
||||
if (self._external.indexOf(row.file) >= 0) return next();
|
||||
|
||||
if (isAbsolutePath(row.id)) {
|
||||
row.id = '/' + relativePath(basedir, row.file);
|
||||
}
|
||||
Object.keys(row.deps || {}).forEach(function (key) {
|
||||
row.deps[key] = '/' + relativePath(basedir, row.deps[key]);
|
||||
});
|
||||
this.push(row);
|
||||
next();
|
||||
}));
|
||||
}
|
||||
return pipeline;
|
||||
};
|
||||
|
||||
Browserify.prototype._createDeps = function (opts) {
|
||||
var self = this;
|
||||
var mopts = xtend(opts);
|
||||
var basedir = defined(opts.basedir, process.cwd());
|
||||
|
||||
// Let mdeps populate these values since it will be resolving file paths
|
||||
// anyway.
|
||||
mopts.expose = this._expose;
|
||||
mopts.extensions = [ '.js', '.json' ].concat(mopts.extensions || []);
|
||||
self._extensions = mopts.extensions;
|
||||
|
||||
mopts.transform = [];
|
||||
mopts.transformKey = defined(opts.transformKey, [ 'browserify', 'transform' ]);
|
||||
mopts.postFilter = function (id, file, pkg) {
|
||||
if (opts.postFilter && !opts.postFilter(id, file, pkg)) return false;
|
||||
if (self._external.indexOf(file) >= 0) return false;
|
||||
if (self._exclude.indexOf(file) >= 0) return false;
|
||||
|
||||
//filter transforms on module dependencies
|
||||
if (pkg && pkg.browserify && pkg.browserify.transform) {
|
||||
//In edge cases it may be a string
|
||||
pkg.browserify.transform = [].concat(pkg.browserify.transform)
|
||||
.filter(Boolean)
|
||||
.filter(self._filterTransform);
|
||||
}
|
||||
return true;
|
||||
};
|
||||
mopts.filter = function (id) {
|
||||
if (opts.filter && !opts.filter(id)) return false;
|
||||
if (self._external.indexOf(id) >= 0) return false;
|
||||
if (self._exclude.indexOf(id) >= 0) return false;
|
||||
if (opts.bundleExternal === false && isExternalModule(id)) {
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
};
|
||||
mopts.resolve = function (id, parent, cb) {
|
||||
if (self._ignore.indexOf(id) >= 0) return cb(null, paths.empty, {});
|
||||
|
||||
self._bresolve(id, parent, function (err, file, pkg) {
|
||||
if (file && self._ignore.indexOf(file) >= 0) {
|
||||
return cb(null, paths.empty, {});
|
||||
}
|
||||
if (file && self._ignore.length) {
|
||||
var nm = file.replace(/\\/g, '/').split('/node_modules/')[1];
|
||||
if (nm) {
|
||||
nm = nm.split('/')[0];
|
||||
if (self._ignore.indexOf(nm) >= 0) {
|
||||
return cb(null, paths.empty, {});
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (file) {
|
||||
var ex = '/' + relativePath(basedir, file);
|
||||
if (self._external.indexOf(ex) >= 0) {
|
||||
return cb(null, ex);
|
||||
}
|
||||
if (self._exclude.indexOf(ex) >= 0) {
|
||||
return cb(null, ex);
|
||||
}
|
||||
if (self._ignore.indexOf(ex) >= 0) {
|
||||
return cb(null, paths.empty, {});
|
||||
}
|
||||
}
|
||||
if (err) cb(err, file, pkg)
|
||||
else if (file) {
|
||||
if (opts.preserveSymlinks && parent.id !== self._mdeps.top.id) {
|
||||
return cb(err, path.resolve(file), pkg, file)
|
||||
}
|
||||
|
||||
fs.realpath(file, function (err, res) {
|
||||
cb(err, res, pkg, file);
|
||||
});
|
||||
} else cb(err, null, pkg)
|
||||
});
|
||||
};
|
||||
|
||||
if (opts.builtins === false) {
|
||||
mopts.modules = {};
|
||||
self._exclude.push.apply(self._exclude, Object.keys(builtins));
|
||||
}
|
||||
else if (opts.builtins && isArray(opts.builtins)) {
|
||||
mopts.modules = {};
|
||||
opts.builtins.forEach(function (key) {
|
||||
mopts.modules[key] = builtins[key];
|
||||
});
|
||||
}
|
||||
else if (opts.builtins && typeof opts.builtins === 'object') {
|
||||
mopts.modules = opts.builtins;
|
||||
}
|
||||
else mopts.modules = xtend(builtins);
|
||||
|
||||
Object.keys(builtins).forEach(function (key) {
|
||||
if (!hasOwn(mopts.modules, key)) self._exclude.push(key);
|
||||
});
|
||||
|
||||
mopts.globalTransform = [];
|
||||
if (!this._bundled) {
|
||||
this.once('bundle', function () {
|
||||
self.pipeline.write({
|
||||
transform: globalTr,
|
||||
global: true,
|
||||
options: {}
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
var no = [].concat(opts.noParse).filter(Boolean);
|
||||
var absno = no.filter(function(x) {
|
||||
return typeof x === 'string';
|
||||
}).map(function (x) {
|
||||
return path.resolve(basedir, x);
|
||||
});
|
||||
mopts.noParse = absno;
|
||||
|
||||
function globalTr (file) {
|
||||
if (opts.detectGlobals === false) return through();
|
||||
|
||||
if (opts.noParse === true) return through();
|
||||
if (no.indexOf(file) >= 0) return through();
|
||||
if (absno.indexOf(file) >= 0) return through();
|
||||
|
||||
var parts = file.replace(/\\/g, '/').split('/node_modules/');
|
||||
for (var i = 0; i < no.length; i++) {
|
||||
if (typeof no[i] === 'function' && no[i](file)) {
|
||||
return through();
|
||||
}
|
||||
else if (no[i] === parts[parts.length-1].split('/')[0]) {
|
||||
return through();
|
||||
}
|
||||
else if (no[i] === parts[parts.length-1]) {
|
||||
return through();
|
||||
}
|
||||
}
|
||||
|
||||
if (opts.commondir === false && opts.builtins === false) {
|
||||
opts.insertGlobalVars = xtend({
|
||||
__dirname: function(file, basedir) {
|
||||
var dir = path.dirname(path.relative(basedir, file));
|
||||
return 'require("path").join(__dirname,' + dir.split(path.sep).map(JSON.stringify).join(',') + ')';
|
||||
},
|
||||
__filename: function(file, basedir) {
|
||||
var filename = path.relative(basedir, file);
|
||||
return 'require("path").join(__dirname,' + filename.split(path.sep).map(JSON.stringify).join(',') + ')';
|
||||
}
|
||||
}, opts.insertGlobalVars);
|
||||
}
|
||||
|
||||
var vars = xtend({
|
||||
process: function () { return "require('_process')" },
|
||||
}, opts.insertGlobalVars);
|
||||
|
||||
if (opts.bundleExternal === false) {
|
||||
vars.process = undefined;
|
||||
vars.buffer = undefined;
|
||||
}
|
||||
|
||||
return insertGlobals(file, xtend(opts, {
|
||||
debug: opts.debug,
|
||||
always: opts.insertGlobals,
|
||||
basedir: opts.commondir === false && isArray(opts.builtins)
|
||||
? '/'
|
||||
: opts.basedir || process.cwd()
|
||||
,
|
||||
vars: vars
|
||||
}));
|
||||
}
|
||||
return mdeps(mopts);
|
||||
};
|
||||
|
||||
Browserify.prototype._recorder = function (opts) {
|
||||
var self = this;
|
||||
var ended = false;
|
||||
this._recorded = [];
|
||||
|
||||
if (!this._ticked) {
|
||||
process.nextTick(function () {
|
||||
self._ticked = true;
|
||||
self._recorded.forEach(function (row) {
|
||||
stream.push(row);
|
||||
});
|
||||
if (ended) stream.push(null);
|
||||
});
|
||||
}
|
||||
|
||||
var stream = through.obj(write, end);
|
||||
return stream;
|
||||
|
||||
function write (row, enc, next) {
|
||||
self._recorded.push(row);
|
||||
if (self._ticked) this.push(row);
|
||||
next();
|
||||
}
|
||||
function end () {
|
||||
ended = true;
|
||||
if (self._ticked) this.push(null);
|
||||
}
|
||||
};
|
||||
|
||||
Browserify.prototype._json = function () {
|
||||
return through.obj(function (row, enc, next) {
|
||||
if (/\.json$/.test(row.file)) {
|
||||
var sanitizedString = sanitize(row.source);
|
||||
try {
|
||||
// check json validity
|
||||
JSON.parse(sanitizedString);
|
||||
row.source = 'module.exports=' + sanitizedString;
|
||||
} catch (err) {
|
||||
err.message = 'While parsing ' + (row.file || row.id) + ': ' + err.message
|
||||
this.emit('error', err);
|
||||
return;
|
||||
}
|
||||
}
|
||||
this.push(row);
|
||||
next();
|
||||
});
|
||||
};
|
||||
|
||||
Browserify.prototype._unbom = function () {
|
||||
return through.obj(function (row, enc, next) {
|
||||
if (/^\ufeff/.test(row.source)) {
|
||||
row.source = row.source.replace(/^\ufeff/, '');
|
||||
}
|
||||
this.push(row);
|
||||
next();
|
||||
});
|
||||
};
|
||||
|
||||
Browserify.prototype._unshebang = function () {
|
||||
return through.obj(function (row, enc, next) {
|
||||
if (/^#!/.test(row.source)) {
|
||||
row.source = row.source.replace(/^#![^\n]*\n/, '');
|
||||
}
|
||||
this.push(row);
|
||||
next();
|
||||
});
|
||||
};
|
||||
|
||||
Browserify.prototype._syntax = function () {
|
||||
var self = this;
|
||||
return through.obj(function (row, enc, next) {
|
||||
var h = shasum(row.source);
|
||||
if (typeof self._syntaxCache[h] === 'undefined') {
|
||||
var err = syntaxError(row.source, row.file || row.id);
|
||||
if (err) return this.emit('error', err);
|
||||
self._syntaxCache[h] = true;
|
||||
}
|
||||
this.push(row);
|
||||
next();
|
||||
});
|
||||
};
|
||||
|
||||
Browserify.prototype._dedupe = function () {
|
||||
return through.obj(function (row, enc, next) {
|
||||
if (!row.dedupeIndex && row.dedupe) {
|
||||
row.source = 'arguments[4]['
|
||||
+ JSON.stringify(row.dedupe)
|
||||
+ '][0].apply(exports,arguments)'
|
||||
;
|
||||
row.nomap = true;
|
||||
}
|
||||
else if (row.dedupeIndex) {
|
||||
row.source = 'arguments[4]['
|
||||
+ JSON.stringify(row.dedupeIndex)
|
||||
+ '][0].apply(exports,arguments)'
|
||||
;
|
||||
row.nomap = true;
|
||||
}
|
||||
if (row.dedupeIndex && row.indexDeps) {
|
||||
row.indexDeps.dup = row.dedupeIndex;
|
||||
}
|
||||
this.push(row);
|
||||
next();
|
||||
});
|
||||
};
|
||||
|
||||
Browserify.prototype._label = function (opts) {
|
||||
var self = this;
|
||||
var basedir = defined(opts.basedir, process.cwd());
|
||||
|
||||
return through.obj(function (row, enc, next) {
|
||||
var prev = row.id;
|
||||
|
||||
if (self._external.indexOf(row.id) >= 0) return next();
|
||||
if (self._external.indexOf('/' + relativePath(basedir, row.id)) >= 0) {
|
||||
return next();
|
||||
}
|
||||
if (self._external.indexOf(row.file) >= 0) return next();
|
||||
|
||||
if (row.index) row.id = row.index;
|
||||
|
||||
self.emit('label', prev, row.id);
|
||||
if (row.indexDeps) row.deps = row.indexDeps || {};
|
||||
|
||||
Object.keys(row.deps).forEach(function (key) {
|
||||
if (self._expose[key]) {
|
||||
row.deps[key] = key;
|
||||
return;
|
||||
}
|
||||
|
||||
var afile = path.resolve(path.dirname(row.file), key);
|
||||
var rfile = '/' + relativePath(basedir, afile);
|
||||
if (self._external.indexOf(rfile) >= 0) {
|
||||
row.deps[key] = rfile;
|
||||
}
|
||||
if (self._external.indexOf(afile) >= 0) {
|
||||
row.deps[key] = rfile;
|
||||
}
|
||||
if (self._external.indexOf(key) >= 0) {
|
||||
row.deps[key] = key;
|
||||
return;
|
||||
}
|
||||
|
||||
for (var i = 0; i < self._extensions.length; i++) {
|
||||
var ex = self._extensions[i];
|
||||
if (self._external.indexOf(rfile + ex) >= 0) {
|
||||
row.deps[key] = rfile + ex;
|
||||
break;
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
if (row.entry || row.expose) {
|
||||
self._bpack.standaloneModule = row.id;
|
||||
}
|
||||
this.push(row);
|
||||
next();
|
||||
});
|
||||
};
|
||||
|
||||
Browserify.prototype._emitDeps = function () {
|
||||
var self = this;
|
||||
return through.obj(function (row, enc, next) {
|
||||
self.emit('dep', row);
|
||||
this.push(row);
|
||||
next();
|
||||
})
|
||||
};
|
||||
|
||||
Browserify.prototype._debug = function (opts) {
|
||||
var basedir = defined(opts.basedir, process.cwd());
|
||||
return through.obj(function (row, enc, next) {
|
||||
if (opts.debug) {
|
||||
row.sourceRoot = 'file://localhost';
|
||||
row.sourceFile = relativePath(basedir, row.file);
|
||||
}
|
||||
this.push(row);
|
||||
next();
|
||||
});
|
||||
};
|
||||
|
||||
Browserify.prototype.reset = function (opts) {
|
||||
if (!opts) opts = {};
|
||||
var hadExports = this._bpack.hasExports;
|
||||
this.pipeline = this._createPipeline(xtend(opts, this._options));
|
||||
this._bpack.hasExports = hadExports;
|
||||
this._entryOrder = 0;
|
||||
this._bundled = false;
|
||||
this.emit('reset');
|
||||
};
|
||||
|
||||
Browserify.prototype.bundle = function (cb) {
|
||||
var self = this;
|
||||
if (cb && typeof cb === 'object') {
|
||||
throw new Error(
|
||||
'bundle() no longer accepts option arguments.\n'
|
||||
+ 'Move all option arguments to the browserify() constructor.'
|
||||
);
|
||||
}
|
||||
if (this._bundled) {
|
||||
var recorded = this._recorded;
|
||||
this.reset();
|
||||
recorded.forEach(function (x) {
|
||||
self.pipeline.write(x);
|
||||
});
|
||||
}
|
||||
var output = readonly(this.pipeline);
|
||||
if (cb) {
|
||||
output.on('error', cb);
|
||||
output.pipe(concat(function (body) {
|
||||
cb(null, body);
|
||||
}));
|
||||
}
|
||||
|
||||
function ready () {
|
||||
self.emit('bundle', output);
|
||||
self.pipeline.end();
|
||||
}
|
||||
|
||||
if (this._pending === 0) ready();
|
||||
else this.once('_ready', ready);
|
||||
|
||||
this._bundled = true;
|
||||
return output;
|
||||
};
|
||||
|
||||
function isStream (s) { return s && typeof s.pipe === 'function' }
|
||||
function isAbsolutePath (file) {
|
||||
var regexp = process.platform === 'win32' ?
|
||||
/^\w:/ :
|
||||
/^\//;
|
||||
return regexp.test(file);
|
||||
}
|
||||
function isExternalModule (file) {
|
||||
var regexp = process.platform === 'win32' ?
|
||||
/^(\.|\w:)/ :
|
||||
/^[\/.]/;
|
||||
return !regexp.test(file);
|
||||
}
|
||||
function relativePath (from, to) {
|
||||
// Replace \ with / for OS-independent behavior
|
||||
return cachedPathRelative(from, to).replace(/\\/g, '/');
|
||||
}
|
||||
0
node_modules/browserify/lib/_empty.js
generated
vendored
Normal file
0
node_modules/browserify/lib/_empty.js
generated
vendored
Normal file
41
node_modules/browserify/lib/builtins.js
generated
vendored
Normal file
41
node_modules/browserify/lib/builtins.js
generated
vendored
Normal file
@@ -0,0 +1,41 @@
|
||||
exports.assert = require.resolve('assert/');
|
||||
exports.buffer = require.resolve('buffer/');
|
||||
exports.child_process = require.resolve('./_empty.js');
|
||||
exports.cluster = require.resolve('./_empty.js');
|
||||
exports.console = require.resolve('console-browserify');
|
||||
exports.constants = require.resolve('constants-browserify');
|
||||
exports.crypto = require.resolve('crypto-browserify');
|
||||
exports.dgram = require.resolve('./_empty.js');
|
||||
exports.dns = require.resolve('./_empty.js');
|
||||
exports.domain = require.resolve('domain-browser');
|
||||
exports.events = require.resolve('events/');
|
||||
exports.fs = require.resolve('./_empty.js');
|
||||
exports.http = require.resolve('stream-http');
|
||||
exports.https = require.resolve('https-browserify');
|
||||
exports.http2 = require.resolve('./_empty.js');
|
||||
exports.inspector = require.resolve('./_empty.js');
|
||||
exports.module = require.resolve('./_empty.js');
|
||||
exports.net = require.resolve('./_empty.js');
|
||||
exports.os = require.resolve('os-browserify/browser.js');
|
||||
exports.path = require.resolve('path-browserify');
|
||||
exports.perf_hooks = require.resolve('./_empty.js')
|
||||
exports.punycode = require.resolve('punycode/');
|
||||
exports.querystring = require.resolve('querystring-es3/');
|
||||
exports.readline = require.resolve('./_empty.js');
|
||||
exports.repl = require.resolve('./_empty.js');
|
||||
exports.stream = require.resolve('stream-browserify');
|
||||
exports._stream_duplex = require.resolve('readable-stream/duplex.js');
|
||||
exports._stream_passthrough = require.resolve('readable-stream/passthrough.js');
|
||||
exports._stream_readable = require.resolve('readable-stream/readable.js');
|
||||
exports._stream_transform = require.resolve('readable-stream/transform.js');
|
||||
exports._stream_writable = require.resolve('readable-stream/writable.js');
|
||||
exports.string_decoder = require.resolve('string_decoder/');
|
||||
exports.sys = require.resolve('util/util.js');
|
||||
exports.timers = require.resolve('timers-browserify');
|
||||
exports.tls = require.resolve('./_empty.js');
|
||||
exports.tty = require.resolve('tty-browserify');
|
||||
exports.url = require.resolve('url/');
|
||||
exports.util = require.resolve('util/util.js');
|
||||
exports.vm = require.resolve('vm-browserify');
|
||||
exports.zlib = require.resolve('browserify-zlib');
|
||||
exports._process = require.resolve('process/browser');
|
||||
55
node_modules/browserify/node_modules/buffer/AUTHORS.md
generated
vendored
Normal file
55
node_modules/browserify/node_modules/buffer/AUTHORS.md
generated
vendored
Normal file
@@ -0,0 +1,55 @@
|
||||
# Authors
|
||||
|
||||
#### Ordered by first contribution.
|
||||
|
||||
- Romain Beauxis (toots@rastageeks.org)
|
||||
- Tobias Koppers (tobias.koppers@googlemail.com)
|
||||
- Janus (ysangkok@gmail.com)
|
||||
- Rainer Dreyer (rdrey1@gmail.com)
|
||||
- Tõnis Tiigi (tonistiigi@gmail.com)
|
||||
- James Halliday (mail@substack.net)
|
||||
- Michael Williamson (mike@zwobble.org)
|
||||
- elliottcable (github@elliottcable.name)
|
||||
- rafael (rvalle@livelens.net)
|
||||
- Andrew Kelley (superjoe30@gmail.com)
|
||||
- Andreas Madsen (amwebdk@gmail.com)
|
||||
- Mike Brevoort (mike.brevoort@pearson.com)
|
||||
- Brian White (mscdex@mscdex.net)
|
||||
- Feross Aboukhadijeh (feross@feross.org)
|
||||
- Ruben Verborgh (ruben@verborgh.org)
|
||||
- eliang (eliang.cs@gmail.com)
|
||||
- Jesse Tane (jesse.tane@gmail.com)
|
||||
- Alfonso Boza (alfonso@cloud.com)
|
||||
- Mathias Buus (mathiasbuus@gmail.com)
|
||||
- Devon Govett (devongovett@gmail.com)
|
||||
- Daniel Cousens (github@dcousens.com)
|
||||
- Joseph Dykstra (josephdykstra@gmail.com)
|
||||
- Parsha Pourkhomami (parshap+git@gmail.com)
|
||||
- Damjan Košir (damjan.kosir@gmail.com)
|
||||
- daverayment (dave.rayment@gmail.com)
|
||||
- kawanet (u-suke@kawa.net)
|
||||
- Linus Unnebäck (linus@folkdatorn.se)
|
||||
- Nolan Lawson (nolan.lawson@gmail.com)
|
||||
- Calvin Metcalf (calvin.metcalf@gmail.com)
|
||||
- Koki Takahashi (hakatasiloving@gmail.com)
|
||||
- Guy Bedford (guybedford@gmail.com)
|
||||
- Jan Schär (jscissr@gmail.com)
|
||||
- RaulTsc (tomescu.raul@gmail.com)
|
||||
- Matthieu Monsch (monsch@alum.mit.edu)
|
||||
- Dan Ehrenberg (littledan@chromium.org)
|
||||
- Kirill Fomichev (fanatid@ya.ru)
|
||||
- Yusuke Kawasaki (u-suke@kawa.net)
|
||||
- DC (dcposch@dcpos.ch)
|
||||
- John-David Dalton (john.david.dalton@gmail.com)
|
||||
- adventure-yunfei (adventure030@gmail.com)
|
||||
- Emil Bay (github@tixz.dk)
|
||||
- Sam Sudar (sudar.sam@gmail.com)
|
||||
- Volker Mische (volker.mische@gmail.com)
|
||||
- David Walton (support@geekstocks.com)
|
||||
- Сковорода Никита Андреевич (chalkerx@gmail.com)
|
||||
- greenkeeper[bot] (greenkeeper[bot]@users.noreply.github.com)
|
||||
- ukstv (sergey.ukustov@machinomy.com)
|
||||
- ranbochen (ranbochen@qq.com)
|
||||
- Vladimir Borovik (bobahbdb@gmail.com)
|
||||
|
||||
#### Generated by bin/update-authors.sh.
|
||||
21
node_modules/browserify/node_modules/buffer/LICENSE
generated
vendored
Normal file
21
node_modules/browserify/node_modules/buffer/LICENSE
generated
vendored
Normal file
@@ -0,0 +1,21 @@
|
||||
The MIT License (MIT)
|
||||
|
||||
Copyright (c) Feross Aboukhadijeh, and other 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.
|
||||
409
node_modules/browserify/node_modules/buffer/README.md
generated
vendored
Normal file
409
node_modules/browserify/node_modules/buffer/README.md
generated
vendored
Normal file
@@ -0,0 +1,409 @@
|
||||
# buffer [![travis][travis-image]][travis-url] [![npm][npm-image]][npm-url] [![downloads][downloads-image]][downloads-url] [![javascript style guide][standard-image]][standard-url]
|
||||
|
||||
[travis-image]: https://img.shields.io/travis/feross/buffer/master.svg
|
||||
[travis-url]: https://travis-ci.org/feross/buffer
|
||||
[npm-image]: https://img.shields.io/npm/v/buffer.svg
|
||||
[npm-url]: https://npmjs.org/package/buffer
|
||||
[downloads-image]: https://img.shields.io/npm/dm/buffer.svg
|
||||
[downloads-url]: https://npmjs.org/package/buffer
|
||||
[standard-image]: https://img.shields.io/badge/code_style-standard-brightgreen.svg
|
||||
[standard-url]: https://standardjs.com
|
||||
|
||||
#### The buffer module from [node.js](https://nodejs.org/), for the browser.
|
||||
|
||||
[![saucelabs][saucelabs-image]][saucelabs-url]
|
||||
|
||||
[saucelabs-image]: https://saucelabs.com/browser-matrix/buffer.svg
|
||||
[saucelabs-url]: https://saucelabs.com/u/buffer
|
||||
|
||||
With [browserify](http://browserify.org), simply `require('buffer')` or use the `Buffer` global and you will get this module.
|
||||
|
||||
The goal is to provide an API that is 100% identical to
|
||||
[node's Buffer API](https://nodejs.org/api/buffer.html). Read the
|
||||
[official docs](https://nodejs.org/api/buffer.html) for the full list of properties,
|
||||
instance methods, and class methods that are supported.
|
||||
|
||||
## features
|
||||
|
||||
- Manipulate binary data like a boss, in all browsers!
|
||||
- Super fast. Backed by Typed Arrays (`Uint8Array`/`ArrayBuffer`, not `Object`)
|
||||
- Extremely small bundle size (**6.75KB minified + gzipped**, 51.9KB with comments)
|
||||
- Excellent browser support (Chrome, Firefox, Edge, Safari 9+, IE 11, iOS 9+, Android, etc.)
|
||||
- Preserves Node API exactly, with one minor difference (see below)
|
||||
- Square-bracket `buf[4]` notation works!
|
||||
- Does not modify any browser prototypes or put anything on `window`
|
||||
- Comprehensive test suite (including all buffer tests from node.js core)
|
||||
|
||||
|
||||
## install
|
||||
|
||||
To use this module directly (without browserify), install it:
|
||||
|
||||
```bash
|
||||
npm install buffer
|
||||
```
|
||||
|
||||
This module was previously called **native-buffer-browserify**, but please use **buffer**
|
||||
from now on.
|
||||
|
||||
A standalone bundle is available [here](https://wzrd.in/standalone/buffer), for non-browserify users.
|
||||
|
||||
|
||||
## usage
|
||||
|
||||
The module's API is identical to node's `Buffer` API. Read the
|
||||
[official docs](https://nodejs.org/api/buffer.html) for the full list of properties,
|
||||
instance methods, and class methods that are supported.
|
||||
|
||||
As mentioned above, `require('buffer')` or use the `Buffer` global with
|
||||
[browserify](http://browserify.org) and this module will automatically be included
|
||||
in your bundle. Almost any npm module will work in the browser, even if it assumes that
|
||||
the node `Buffer` API will be available.
|
||||
|
||||
To depend on this module explicitly (without browserify), require it like this:
|
||||
|
||||
```js
|
||||
var Buffer = require('buffer/').Buffer // note: the trailing slash is important!
|
||||
```
|
||||
|
||||
To require this module explicitly, use `require('buffer/')` which tells the node.js module
|
||||
lookup algorithm (also used by browserify) to use the **npm module** named `buffer`
|
||||
instead of the **node.js core** module named `buffer`!
|
||||
|
||||
|
||||
## how does it work?
|
||||
|
||||
The Buffer constructor returns instances of `Uint8Array` that have their prototype
|
||||
changed to `Buffer.prototype`. Furthermore, `Buffer` is a subclass of `Uint8Array`,
|
||||
so the returned instances will have all the node `Buffer` methods and the
|
||||
`Uint8Array` methods. Square bracket notation works as expected -- it returns a
|
||||
single octet.
|
||||
|
||||
The `Uint8Array` prototype remains unmodified.
|
||||
|
||||
|
||||
## tracking the latest node api
|
||||
|
||||
This module tracks the Buffer API in the latest (unstable) version of node.js. The Buffer
|
||||
API is considered **stable** in the
|
||||
[node stability index](https://nodejs.org/docs/latest/api/documentation.html#documentation_stability_index),
|
||||
so it is unlikely that there will ever be breaking changes.
|
||||
Nonetheless, when/if the Buffer API changes in node, this module's API will change
|
||||
accordingly.
|
||||
|
||||
## related packages
|
||||
|
||||
- [`buffer-reverse`](https://www.npmjs.com/package/buffer-reverse) - Reverse a buffer
|
||||
- [`buffer-xor`](https://www.npmjs.com/package/buffer-xor) - Bitwise xor a buffer
|
||||
- [`is-buffer`](https://www.npmjs.com/package/is-buffer) - Determine if an object is a Buffer without including the whole `Buffer` package
|
||||
|
||||
## conversion packages
|
||||
|
||||
### convert typed array to buffer
|
||||
|
||||
Use [`typedarray-to-buffer`](https://www.npmjs.com/package/typedarray-to-buffer) to convert any kind of typed array to a `Buffer`. Does not perform a copy, so it's super fast.
|
||||
|
||||
### convert buffer to typed array
|
||||
|
||||
`Buffer` is a subclass of `Uint8Array` (which is a typed array). So there is no need to explicitly convert to typed array. Just use the buffer as a `Uint8Array`.
|
||||
|
||||
### convert blob to buffer
|
||||
|
||||
Use [`blob-to-buffer`](https://www.npmjs.com/package/blob-to-buffer) to convert a `Blob` to a `Buffer`.
|
||||
|
||||
### convert buffer to blob
|
||||
|
||||
To convert a `Buffer` to a `Blob`, use the `Blob` constructor:
|
||||
|
||||
```js
|
||||
var blob = new Blob([ buffer ])
|
||||
```
|
||||
|
||||
Optionally, specify a mimetype:
|
||||
|
||||
```js
|
||||
var blob = new Blob([ buffer ], { type: 'text/html' })
|
||||
```
|
||||
|
||||
### convert arraybuffer to buffer
|
||||
|
||||
To convert an `ArrayBuffer` to a `Buffer`, use the `Buffer.from` function. Does not perform a copy, so it's super fast.
|
||||
|
||||
```js
|
||||
var buffer = Buffer.from(arrayBuffer)
|
||||
```
|
||||
|
||||
### convert buffer to arraybuffer
|
||||
|
||||
To convert a `Buffer` to an `ArrayBuffer`, use the `.buffer` property (which is present on all `Uint8Array` objects):
|
||||
|
||||
```js
|
||||
var arrayBuffer = buffer.buffer.slice(
|
||||
buffer.byteOffset, buffer.byteOffset + buffer.byteLength
|
||||
)
|
||||
```
|
||||
|
||||
Alternatively, use the [`to-arraybuffer`](https://www.npmjs.com/package/to-arraybuffer) module.
|
||||
|
||||
## performance
|
||||
|
||||
See perf tests in `/perf`.
|
||||
|
||||
`BrowserBuffer` is the browser `buffer` module (this repo). `Uint8Array` is included as a
|
||||
sanity check (since `BrowserBuffer` uses `Uint8Array` under the hood, `Uint8Array` will
|
||||
always be at least a bit faster). Finally, `NodeBuffer` is the node.js buffer module,
|
||||
which is included to compare against.
|
||||
|
||||
NOTE: Performance has improved since these benchmarks were taken. PR welcome to update the README.
|
||||
|
||||
### Chrome 38
|
||||
|
||||
| Method | Operations | Accuracy | Sampled | Fastest |
|
||||
|:-------|:-----------|:---------|:--------|:-------:|
|
||||
| BrowserBuffer#bracket-notation | 11,457,464 ops/sec | ±0.86% | 66 | ✓ |
|
||||
| Uint8Array#bracket-notation | 10,824,332 ops/sec | ±0.74% | 65 | |
|
||||
| | | | |
|
||||
| BrowserBuffer#concat | 450,532 ops/sec | ±0.76% | 68 | |
|
||||
| Uint8Array#concat | 1,368,911 ops/sec | ±1.50% | 62 | ✓ |
|
||||
| | | | |
|
||||
| BrowserBuffer#copy(16000) | 903,001 ops/sec | ±0.96% | 67 | |
|
||||
| Uint8Array#copy(16000) | 1,422,441 ops/sec | ±1.04% | 66 | ✓ |
|
||||
| | | | |
|
||||
| BrowserBuffer#copy(16) | 11,431,358 ops/sec | ±0.46% | 69 | |
|
||||
| Uint8Array#copy(16) | 13,944,163 ops/sec | ±1.12% | 68 | ✓ |
|
||||
| | | | |
|
||||
| BrowserBuffer#new(16000) | 106,329 ops/sec | ±6.70% | 44 | |
|
||||
| Uint8Array#new(16000) | 131,001 ops/sec | ±2.85% | 31 | ✓ |
|
||||
| | | | |
|
||||
| BrowserBuffer#new(16) | 1,554,491 ops/sec | ±1.60% | 65 | |
|
||||
| Uint8Array#new(16) | 6,623,930 ops/sec | ±1.66% | 65 | ✓ |
|
||||
| | | | |
|
||||
| BrowserBuffer#readDoubleBE | 112,830 ops/sec | ±0.51% | 69 | ✓ |
|
||||
| DataView#getFloat64 | 93,500 ops/sec | ±0.57% | 68 | |
|
||||
| | | | |
|
||||
| BrowserBuffer#readFloatBE | 146,678 ops/sec | ±0.95% | 68 | ✓ |
|
||||
| DataView#getFloat32 | 99,311 ops/sec | ±0.41% | 67 | |
|
||||
| | | | |
|
||||
| BrowserBuffer#readUInt32LE | 843,214 ops/sec | ±0.70% | 69 | ✓ |
|
||||
| DataView#getUint32 | 103,024 ops/sec | ±0.64% | 67 | |
|
||||
| | | | |
|
||||
| BrowserBuffer#slice | 1,013,941 ops/sec | ±0.75% | 67 | |
|
||||
| Uint8Array#subarray | 1,903,928 ops/sec | ±0.53% | 67 | ✓ |
|
||||
| | | | |
|
||||
| BrowserBuffer#writeFloatBE | 61,387 ops/sec | ±0.90% | 67 | |
|
||||
| DataView#setFloat32 | 141,249 ops/sec | ±0.40% | 66 | ✓ |
|
||||
|
||||
|
||||
### Firefox 33
|
||||
|
||||
| Method | Operations | Accuracy | Sampled | Fastest |
|
||||
|:-------|:-----------|:---------|:--------|:-------:|
|
||||
| BrowserBuffer#bracket-notation | 20,800,421 ops/sec | ±1.84% | 60 | |
|
||||
| Uint8Array#bracket-notation | 20,826,235 ops/sec | ±2.02% | 61 | ✓ |
|
||||
| | | | |
|
||||
| BrowserBuffer#concat | 153,076 ops/sec | ±2.32% | 61 | |
|
||||
| Uint8Array#concat | 1,255,674 ops/sec | ±8.65% | 52 | ✓ |
|
||||
| | | | |
|
||||
| BrowserBuffer#copy(16000) | 1,105,312 ops/sec | ±1.16% | 63 | |
|
||||
| Uint8Array#copy(16000) | 1,615,911 ops/sec | ±0.55% | 66 | ✓ |
|
||||
| | | | |
|
||||
| BrowserBuffer#copy(16) | 16,357,599 ops/sec | ±0.73% | 68 | |
|
||||
| Uint8Array#copy(16) | 31,436,281 ops/sec | ±1.05% | 68 | ✓ |
|
||||
| | | | |
|
||||
| BrowserBuffer#new(16000) | 52,995 ops/sec | ±6.01% | 35 | |
|
||||
| Uint8Array#new(16000) | 87,686 ops/sec | ±5.68% | 45 | ✓ |
|
||||
| | | | |
|
||||
| BrowserBuffer#new(16) | 252,031 ops/sec | ±1.61% | 66 | |
|
||||
| Uint8Array#new(16) | 8,477,026 ops/sec | ±0.49% | 68 | ✓ |
|
||||
| | | | |
|
||||
| BrowserBuffer#readDoubleBE | 99,871 ops/sec | ±0.41% | 69 | |
|
||||
| DataView#getFloat64 | 285,663 ops/sec | ±0.70% | 68 | ✓ |
|
||||
| | | | |
|
||||
| BrowserBuffer#readFloatBE | 115,540 ops/sec | ±0.42% | 69 | |
|
||||
| DataView#getFloat32 | 288,722 ops/sec | ±0.82% | 68 | ✓ |
|
||||
| | | | |
|
||||
| BrowserBuffer#readUInt32LE | 633,926 ops/sec | ±1.08% | 67 | ✓ |
|
||||
| DataView#getUint32 | 294,808 ops/sec | ±0.79% | 64 | |
|
||||
| | | | |
|
||||
| BrowserBuffer#slice | 349,425 ops/sec | ±0.46% | 69 | |
|
||||
| Uint8Array#subarray | 5,965,819 ops/sec | ±0.60% | 65 | ✓ |
|
||||
| | | | |
|
||||
| BrowserBuffer#writeFloatBE | 59,980 ops/sec | ±0.41% | 67 | |
|
||||
| DataView#setFloat32 | 317,634 ops/sec | ±0.63% | 68 | ✓ |
|
||||
|
||||
### Safari 8
|
||||
|
||||
| Method | Operations | Accuracy | Sampled | Fastest |
|
||||
|:-------|:-----------|:---------|:--------|:-------:|
|
||||
| BrowserBuffer#bracket-notation | 10,279,729 ops/sec | ±2.25% | 56 | ✓ |
|
||||
| Uint8Array#bracket-notation | 10,030,767 ops/sec | ±2.23% | 59 | |
|
||||
| | | | |
|
||||
| BrowserBuffer#concat | 144,138 ops/sec | ±1.38% | 65 | |
|
||||
| Uint8Array#concat | 4,950,764 ops/sec | ±1.70% | 63 | ✓ |
|
||||
| | | | |
|
||||
| BrowserBuffer#copy(16000) | 1,058,548 ops/sec | ±1.51% | 64 | |
|
||||
| Uint8Array#copy(16000) | 1,409,666 ops/sec | ±1.17% | 65 | ✓ |
|
||||
| | | | |
|
||||
| BrowserBuffer#copy(16) | 6,282,529 ops/sec | ±1.88% | 58 | |
|
||||
| Uint8Array#copy(16) | 11,907,128 ops/sec | ±2.87% | 58 | ✓ |
|
||||
| | | | |
|
||||
| BrowserBuffer#new(16000) | 101,663 ops/sec | ±3.89% | 57 | |
|
||||
| Uint8Array#new(16000) | 22,050,818 ops/sec | ±6.51% | 46 | ✓ |
|
||||
| | | | |
|
||||
| BrowserBuffer#new(16) | 176,072 ops/sec | ±2.13% | 64 | |
|
||||
| Uint8Array#new(16) | 24,385,731 ops/sec | ±5.01% | 51 | ✓ |
|
||||
| | | | |
|
||||
| BrowserBuffer#readDoubleBE | 41,341 ops/sec | ±1.06% | 67 | |
|
||||
| DataView#getFloat64 | 322,280 ops/sec | ±0.84% | 68 | ✓ |
|
||||
| | | | |
|
||||
| BrowserBuffer#readFloatBE | 46,141 ops/sec | ±1.06% | 65 | |
|
||||
| DataView#getFloat32 | 337,025 ops/sec | ±0.43% | 69 | ✓ |
|
||||
| | | | |
|
||||
| BrowserBuffer#readUInt32LE | 151,551 ops/sec | ±1.02% | 66 | |
|
||||
| DataView#getUint32 | 308,278 ops/sec | ±0.94% | 67 | ✓ |
|
||||
| | | | |
|
||||
| BrowserBuffer#slice | 197,365 ops/sec | ±0.95% | 66 | |
|
||||
| Uint8Array#subarray | 9,558,024 ops/sec | ±3.08% | 58 | ✓ |
|
||||
| | | | |
|
||||
| BrowserBuffer#writeFloatBE | 17,518 ops/sec | ±1.03% | 63 | |
|
||||
| DataView#setFloat32 | 319,751 ops/sec | ±0.48% | 68 | ✓ |
|
||||
|
||||
|
||||
### Node 0.11.14
|
||||
|
||||
| Method | Operations | Accuracy | Sampled | Fastest |
|
||||
|:-------|:-----------|:---------|:--------|:-------:|
|
||||
| BrowserBuffer#bracket-notation | 10,489,828 ops/sec | ±3.25% | 90 | |
|
||||
| Uint8Array#bracket-notation | 10,534,884 ops/sec | ±0.81% | 92 | ✓ |
|
||||
| NodeBuffer#bracket-notation | 10,389,910 ops/sec | ±0.97% | 87 | |
|
||||
| | | | |
|
||||
| BrowserBuffer#concat | 487,830 ops/sec | ±2.58% | 88 | |
|
||||
| Uint8Array#concat | 1,814,327 ops/sec | ±1.28% | 88 | ✓ |
|
||||
| NodeBuffer#concat | 1,636,523 ops/sec | ±1.88% | 73 | |
|
||||
| | | | |
|
||||
| BrowserBuffer#copy(16000) | 1,073,665 ops/sec | ±0.77% | 90 | |
|
||||
| Uint8Array#copy(16000) | 1,348,517 ops/sec | ±0.84% | 89 | ✓ |
|
||||
| NodeBuffer#copy(16000) | 1,289,533 ops/sec | ±0.82% | 93 | |
|
||||
| | | | |
|
||||
| BrowserBuffer#copy(16) | 12,782,706 ops/sec | ±0.74% | 85 | |
|
||||
| Uint8Array#copy(16) | 14,180,427 ops/sec | ±0.93% | 92 | ✓ |
|
||||
| NodeBuffer#copy(16) | 11,083,134 ops/sec | ±1.06% | 89 | |
|
||||
| | | | |
|
||||
| BrowserBuffer#new(16000) | 141,678 ops/sec | ±3.30% | 67 | |
|
||||
| Uint8Array#new(16000) | 161,491 ops/sec | ±2.96% | 60 | |
|
||||
| NodeBuffer#new(16000) | 292,699 ops/sec | ±3.20% | 55 | ✓ |
|
||||
| | | | |
|
||||
| BrowserBuffer#new(16) | 1,655,466 ops/sec | ±2.41% | 82 | |
|
||||
| Uint8Array#new(16) | 14,399,926 ops/sec | ±0.91% | 94 | ✓ |
|
||||
| NodeBuffer#new(16) | 3,894,696 ops/sec | ±0.88% | 92 | |
|
||||
| | | | |
|
||||
| BrowserBuffer#readDoubleBE | 109,582 ops/sec | ±0.75% | 93 | ✓ |
|
||||
| DataView#getFloat64 | 91,235 ops/sec | ±0.81% | 90 | |
|
||||
| NodeBuffer#readDoubleBE | 88,593 ops/sec | ±0.96% | 81 | |
|
||||
| | | | |
|
||||
| BrowserBuffer#readFloatBE | 139,854 ops/sec | ±1.03% | 85 | ✓ |
|
||||
| DataView#getFloat32 | 98,744 ops/sec | ±0.80% | 89 | |
|
||||
| NodeBuffer#readFloatBE | 92,769 ops/sec | ±0.94% | 93 | |
|
||||
| | | | |
|
||||
| BrowserBuffer#readUInt32LE | 710,861 ops/sec | ±0.82% | 92 | |
|
||||
| DataView#getUint32 | 117,893 ops/sec | ±0.84% | 91 | |
|
||||
| NodeBuffer#readUInt32LE | 851,412 ops/sec | ±0.72% | 93 | ✓ |
|
||||
| | | | |
|
||||
| BrowserBuffer#slice | 1,673,877 ops/sec | ±0.73% | 94 | |
|
||||
| Uint8Array#subarray | 6,919,243 ops/sec | ±0.67% | 90 | ✓ |
|
||||
| NodeBuffer#slice | 4,617,604 ops/sec | ±0.79% | 93 | |
|
||||
| | | | |
|
||||
| BrowserBuffer#writeFloatBE | 66,011 ops/sec | ±0.75% | 93 | |
|
||||
| DataView#setFloat32 | 127,760 ops/sec | ±0.72% | 93 | ✓ |
|
||||
| NodeBuffer#writeFloatBE | 103,352 ops/sec | ±0.83% | 93 | |
|
||||
|
||||
### iojs 1.8.1
|
||||
|
||||
| Method | Operations | Accuracy | Sampled | Fastest |
|
||||
|:-------|:-----------|:---------|:--------|:-------:|
|
||||
| BrowserBuffer#bracket-notation | 10,990,488 ops/sec | ±1.11% | 91 | |
|
||||
| Uint8Array#bracket-notation | 11,268,757 ops/sec | ±0.65% | 97 | |
|
||||
| NodeBuffer#bracket-notation | 11,353,260 ops/sec | ±0.83% | 94 | ✓ |
|
||||
| | | | |
|
||||
| BrowserBuffer#concat | 378,954 ops/sec | ±0.74% | 94 | |
|
||||
| Uint8Array#concat | 1,358,288 ops/sec | ±0.97% | 87 | |
|
||||
| NodeBuffer#concat | 1,934,050 ops/sec | ±1.11% | 78 | ✓ |
|
||||
| | | | |
|
||||
| BrowserBuffer#copy(16000) | 894,538 ops/sec | ±0.56% | 84 | |
|
||||
| Uint8Array#copy(16000) | 1,442,656 ops/sec | ±0.71% | 96 | |
|
||||
| NodeBuffer#copy(16000) | 1,457,898 ops/sec | ±0.53% | 92 | ✓ |
|
||||
| | | | |
|
||||
| BrowserBuffer#copy(16) | 12,870,457 ops/sec | ±0.67% | 95 | |
|
||||
| Uint8Array#copy(16) | 16,643,989 ops/sec | ±0.61% | 93 | ✓ |
|
||||
| NodeBuffer#copy(16) | 14,885,848 ops/sec | ±0.74% | 94 | |
|
||||
| | | | |
|
||||
| BrowserBuffer#new(16000) | 109,264 ops/sec | ±4.21% | 63 | |
|
||||
| Uint8Array#new(16000) | 138,916 ops/sec | ±1.87% | 61 | |
|
||||
| NodeBuffer#new(16000) | 281,449 ops/sec | ±3.58% | 51 | ✓ |
|
||||
| | | | |
|
||||
| BrowserBuffer#new(16) | 1,362,935 ops/sec | ±0.56% | 99 | |
|
||||
| Uint8Array#new(16) | 6,193,090 ops/sec | ±0.64% | 95 | ✓ |
|
||||
| NodeBuffer#new(16) | 4,745,425 ops/sec | ±1.56% | 90 | |
|
||||
| | | | |
|
||||
| BrowserBuffer#readDoubleBE | 118,127 ops/sec | ±0.59% | 93 | ✓ |
|
||||
| DataView#getFloat64 | 107,332 ops/sec | ±0.65% | 91 | |
|
||||
| NodeBuffer#readDoubleBE | 116,274 ops/sec | ±0.94% | 95 | |
|
||||
| | | | |
|
||||
| BrowserBuffer#readFloatBE | 150,326 ops/sec | ±0.58% | 95 | ✓ |
|
||||
| DataView#getFloat32 | 110,541 ops/sec | ±0.57% | 98 | |
|
||||
| NodeBuffer#readFloatBE | 121,599 ops/sec | ±0.60% | 87 | |
|
||||
| | | | |
|
||||
| BrowserBuffer#readUInt32LE | 814,147 ops/sec | ±0.62% | 93 | |
|
||||
| DataView#getUint32 | 137,592 ops/sec | ±0.64% | 90 | |
|
||||
| NodeBuffer#readUInt32LE | 931,650 ops/sec | ±0.71% | 96 | ✓ |
|
||||
| | | | |
|
||||
| BrowserBuffer#slice | 878,590 ops/sec | ±0.68% | 93 | |
|
||||
| Uint8Array#subarray | 2,843,308 ops/sec | ±1.02% | 90 | |
|
||||
| NodeBuffer#slice | 4,998,316 ops/sec | ±0.68% | 90 | ✓ |
|
||||
| | | | |
|
||||
| BrowserBuffer#writeFloatBE | 65,927 ops/sec | ±0.74% | 93 | |
|
||||
| DataView#setFloat32 | 139,823 ops/sec | ±0.97% | 89 | ✓ |
|
||||
| NodeBuffer#writeFloatBE | 135,763 ops/sec | ±0.65% | 96 | |
|
||||
| | | | |
|
||||
|
||||
## Testing the project
|
||||
|
||||
First, install the project:
|
||||
|
||||
npm install
|
||||
|
||||
Then, to run tests in Node.js, run:
|
||||
|
||||
npm run test-node
|
||||
|
||||
To test locally in a browser, you can run:
|
||||
|
||||
npm run test-browser-es5-local # For ES5 browsers that don't support ES6
|
||||
npm run test-browser-es6-local # For ES6 compliant browsers
|
||||
|
||||
This will print out a URL that you can then open in a browser to run the tests, using [airtap](https://www.npmjs.com/package/airtap).
|
||||
|
||||
To run automated browser tests using Saucelabs, ensure that your `SAUCE_USERNAME` and `SAUCE_ACCESS_KEY` environment variables are set, then run:
|
||||
|
||||
npm test
|
||||
|
||||
This is what's run in Travis, to check against various browsers. The list of browsers is kept in the `bin/airtap-es5.yml` and `bin/airtap-es6.yml` files.
|
||||
|
||||
## JavaScript Standard Style
|
||||
|
||||
This module uses [JavaScript Standard Style](https://github.com/feross/standard).
|
||||
|
||||
[](https://github.com/feross/standard)
|
||||
|
||||
To test that the code conforms to the style, `npm install` and run:
|
||||
|
||||
./node_modules/.bin/standard
|
||||
|
||||
## credit
|
||||
|
||||
This was originally forked from [buffer-browserify](https://github.com/toots/buffer-browserify).
|
||||
|
||||
|
||||
## license
|
||||
|
||||
MIT. Copyright (C) [Feross Aboukhadijeh](http://feross.org), and other contributors. Originally forked from an MIT-licensed module by Romain Beauxis.
|
||||
185
node_modules/browserify/node_modules/buffer/index.d.ts
generated
vendored
Normal file
185
node_modules/browserify/node_modules/buffer/index.d.ts
generated
vendored
Normal file
@@ -0,0 +1,185 @@
|
||||
export class Buffer extends Uint8Array {
|
||||
length: number
|
||||
write(string: string, offset?: number, length?: number, encoding?: string): number;
|
||||
toString(encoding?: string, start?: number, end?: number): string;
|
||||
toJSON(): { type: 'Buffer', data: any[] };
|
||||
equals(otherBuffer: Buffer): boolean;
|
||||
compare(otherBuffer: Buffer, targetStart?: number, targetEnd?: number, sourceStart?: number, sourceEnd?: number): number;
|
||||
copy(targetBuffer: Buffer, targetStart?: number, sourceStart?: number, sourceEnd?: number): number;
|
||||
slice(start?: number, end?: number): Buffer;
|
||||
writeUIntLE(value: number, offset: number, byteLength: number, noAssert?: boolean): number;
|
||||
writeUIntBE(value: number, offset: number, byteLength: number, noAssert?: boolean): number;
|
||||
writeIntLE(value: number, offset: number, byteLength: number, noAssert?: boolean): number;
|
||||
writeIntBE(value: number, offset: number, byteLength: number, noAssert?: boolean): number;
|
||||
readUIntLE(offset: number, byteLength: number, noAssert?: boolean): number;
|
||||
readUIntBE(offset: number, byteLength: number, noAssert?: boolean): number;
|
||||
readIntLE(offset: number, byteLength: number, noAssert?: boolean): number;
|
||||
readIntBE(offset: number, byteLength: number, noAssert?: boolean): number;
|
||||
readUInt8(offset: number, noAssert?: boolean): number;
|
||||
readUInt16LE(offset: number, noAssert?: boolean): number;
|
||||
readUInt16BE(offset: number, noAssert?: boolean): number;
|
||||
readUInt32LE(offset: number, noAssert?: boolean): number;
|
||||
readUInt32BE(offset: number, noAssert?: boolean): number;
|
||||
readInt8(offset: number, noAssert?: boolean): number;
|
||||
readInt16LE(offset: number, noAssert?: boolean): number;
|
||||
readInt16BE(offset: number, noAssert?: boolean): number;
|
||||
readInt32LE(offset: number, noAssert?: boolean): number;
|
||||
readInt32BE(offset: number, noAssert?: boolean): number;
|
||||
readFloatLE(offset: number, noAssert?: boolean): number;
|
||||
readFloatBE(offset: number, noAssert?: boolean): number;
|
||||
readDoubleLE(offset: number, noAssert?: boolean): number;
|
||||
readDoubleBE(offset: number, noAssert?: boolean): number;
|
||||
swap16(): Buffer;
|
||||
swap32(): Buffer;
|
||||
swap64(): Buffer;
|
||||
writeUInt8(value: number, offset: number, noAssert?: boolean): number;
|
||||
writeUInt16LE(value: number, offset: number, noAssert?: boolean): number;
|
||||
writeUInt16BE(value: number, offset: number, noAssert?: boolean): number;
|
||||
writeUInt32LE(value: number, offset: number, noAssert?: boolean): number;
|
||||
writeUInt32BE(value: number, offset: number, noAssert?: boolean): number;
|
||||
writeInt8(value: number, offset: number, noAssert?: boolean): number;
|
||||
writeInt16LE(value: number, offset: number, noAssert?: boolean): number;
|
||||
writeInt16BE(value: number, offset: number, noAssert?: boolean): number;
|
||||
writeInt32LE(value: number, offset: number, noAssert?: boolean): number;
|
||||
writeInt32BE(value: number, offset: number, noAssert?: boolean): number;
|
||||
writeFloatLE(value: number, offset: number, noAssert?: boolean): number;
|
||||
writeFloatBE(value: number, offset: number, noAssert?: boolean): number;
|
||||
writeDoubleLE(value: number, offset: number, noAssert?: boolean): number;
|
||||
writeDoubleBE(value: number, offset: number, noAssert?: boolean): number;
|
||||
fill(value: any, offset?: number, end?: number): this;
|
||||
indexOf(value: string | number | Buffer, byteOffset?: number, encoding?: string): number;
|
||||
lastIndexOf(value: string | number | Buffer, byteOffset?: number, encoding?: string): number;
|
||||
includes(value: string | number | Buffer, byteOffset?: number, encoding?: string): boolean;
|
||||
|
||||
/**
|
||||
* Allocates a new buffer containing the given {str}.
|
||||
*
|
||||
* @param str String to store in buffer.
|
||||
* @param encoding encoding to use, optional. Default is 'utf8'
|
||||
*/
|
||||
constructor (str: string, encoding?: string);
|
||||
/**
|
||||
* Allocates a new buffer of {size} octets.
|
||||
*
|
||||
* @param size count of octets to allocate.
|
||||
*/
|
||||
constructor (size: number);
|
||||
/**
|
||||
* Allocates a new buffer containing the given {array} of octets.
|
||||
*
|
||||
* @param array The octets to store.
|
||||
*/
|
||||
constructor (array: Uint8Array);
|
||||
/**
|
||||
* Produces a Buffer backed by the same allocated memory as
|
||||
* the given {ArrayBuffer}.
|
||||
*
|
||||
*
|
||||
* @param arrayBuffer The ArrayBuffer with which to share memory.
|
||||
*/
|
||||
constructor (arrayBuffer: ArrayBuffer);
|
||||
/**
|
||||
* Allocates a new buffer containing the given {array} of octets.
|
||||
*
|
||||
* @param array The octets to store.
|
||||
*/
|
||||
constructor (array: any[]);
|
||||
/**
|
||||
* Copies the passed {buffer} data onto a new {Buffer} instance.
|
||||
*
|
||||
* @param buffer The buffer to copy.
|
||||
*/
|
||||
constructor (buffer: Buffer);
|
||||
prototype: Buffer;
|
||||
/**
|
||||
* Allocates a new Buffer using an {array} of octets.
|
||||
*
|
||||
* @param array
|
||||
*/
|
||||
static from(array: any[]): Buffer;
|
||||
/**
|
||||
* When passed a reference to the .buffer property of a TypedArray instance,
|
||||
* the newly created Buffer will share the same allocated memory as the TypedArray.
|
||||
* The optional {byteOffset} and {length} arguments specify a memory range
|
||||
* within the {arrayBuffer} that will be shared by the Buffer.
|
||||
*
|
||||
* @param arrayBuffer The .buffer property of a TypedArray or a new ArrayBuffer()
|
||||
* @param byteOffset
|
||||
* @param length
|
||||
*/
|
||||
static from(arrayBuffer: ArrayBuffer, byteOffset?: number, length?: number): Buffer;
|
||||
/**
|
||||
* Copies the passed {buffer} data onto a new Buffer instance.
|
||||
*
|
||||
* @param buffer
|
||||
*/
|
||||
static from(buffer: Buffer): Buffer;
|
||||
/**
|
||||
* Creates a new Buffer containing the given JavaScript string {str}.
|
||||
* If provided, the {encoding} parameter identifies the character encoding.
|
||||
* If not provided, {encoding} defaults to 'utf8'.
|
||||
*
|
||||
* @param str
|
||||
*/
|
||||
static from(str: string, encoding?: string): Buffer;
|
||||
/**
|
||||
* Returns true if {obj} is a Buffer
|
||||
*
|
||||
* @param obj object to test.
|
||||
*/
|
||||
static isBuffer(obj: any): obj is Buffer;
|
||||
/**
|
||||
* Returns true if {encoding} is a valid encoding argument.
|
||||
* Valid string encodings in Node 0.12: 'ascii'|'utf8'|'utf16le'|'ucs2'(alias of 'utf16le')|'base64'|'binary'(deprecated)|'hex'
|
||||
*
|
||||
* @param encoding string to test.
|
||||
*/
|
||||
static isEncoding(encoding: string): boolean;
|
||||
/**
|
||||
* Gives the actual byte length of a string. encoding defaults to 'utf8'.
|
||||
* This is not the same as String.prototype.length since that returns the number of characters in a string.
|
||||
*
|
||||
* @param string string to test.
|
||||
* @param encoding encoding used to evaluate (defaults to 'utf8')
|
||||
*/
|
||||
static byteLength(string: string, encoding?: string): number;
|
||||
/**
|
||||
* Returns a buffer which is the result of concatenating all the buffers in the list together.
|
||||
*
|
||||
* If the list has no items, or if the totalLength is 0, then it returns a zero-length buffer.
|
||||
* If the list has exactly one item, then the first item of the list is returned.
|
||||
* If the list has more than one item, then a new Buffer is created.
|
||||
*
|
||||
* @param list An array of Buffer objects to concatenate
|
||||
* @param totalLength Total length of the buffers when concatenated.
|
||||
* If totalLength is not provided, it is read from the buffers in the list. However, this adds an additional loop to the function, so it is faster to provide the length explicitly.
|
||||
*/
|
||||
static concat(list: Buffer[], totalLength?: number): Buffer;
|
||||
/**
|
||||
* The same as buf1.compare(buf2).
|
||||
*/
|
||||
static compare(buf1: Buffer, buf2: Buffer): number;
|
||||
/**
|
||||
* Allocates a new buffer of {size} octets.
|
||||
*
|
||||
* @param size count of octets to allocate.
|
||||
* @param fill if specified, buffer will be initialized by calling buf.fill(fill).
|
||||
* If parameter is omitted, buffer will be filled with zeros.
|
||||
* @param encoding encoding used for call to buf.fill while initalizing
|
||||
*/
|
||||
static alloc(size: number, fill?: string | Buffer | number, encoding?: string): Buffer;
|
||||
/**
|
||||
* Allocates a new buffer of {size} octets, leaving memory not initialized, so the contents
|
||||
* of the newly created Buffer are unknown and may contain sensitive data.
|
||||
*
|
||||
* @param size count of octets to allocate
|
||||
*/
|
||||
static allocUnsafe(size: number): Buffer;
|
||||
/**
|
||||
* Allocates a new non-pooled buffer of {size} octets, leaving memory not initialized, so the contents
|
||||
* of the newly created Buffer are unknown and may contain sensitive data.
|
||||
*
|
||||
* @param size count of octets to allocate
|
||||
*/
|
||||
static allocUnsafeSlow(size: number): Buffer;
|
||||
}
|
||||
1777
node_modules/browserify/node_modules/buffer/index.js
generated
vendored
Normal file
1777
node_modules/browserify/node_modules/buffer/index.js
generated
vendored
Normal file
File diff suppressed because it is too large
Load Diff
79
node_modules/browserify/node_modules/buffer/package.json
generated
vendored
Normal file
79
node_modules/browserify/node_modules/buffer/package.json
generated
vendored
Normal file
@@ -0,0 +1,79 @@
|
||||
{
|
||||
"name": "buffer",
|
||||
"description": "Node.js Buffer API, for the browser",
|
||||
"version": "5.2.1",
|
||||
"author": {
|
||||
"name": "Feross Aboukhadijeh",
|
||||
"email": "feross@feross.org",
|
||||
"url": "http://feross.org"
|
||||
},
|
||||
"bugs": {
|
||||
"url": "https://github.com/feross/buffer/issues"
|
||||
},
|
||||
"contributors": [
|
||||
"Romain Beauxis <toots@rastageeks.org>",
|
||||
"James Halliday <mail@substack.net>"
|
||||
],
|
||||
"dependencies": {
|
||||
"base64-js": "^1.0.2",
|
||||
"ieee754": "^1.1.4"
|
||||
},
|
||||
"devDependencies": {
|
||||
"airtap": "0.1.0",
|
||||
"benchmark": "^2.0.0",
|
||||
"browserify": "^16.1.0",
|
||||
"concat-stream": "^1.4.7",
|
||||
"hyperquest": "^2.0.0",
|
||||
"is-buffer": "^2.0.0",
|
||||
"is-nan": "^1.0.1",
|
||||
"split": "^1.0.0",
|
||||
"standard": "*",
|
||||
"tape": "^4.0.0",
|
||||
"through2": "^2.0.0",
|
||||
"uglify-js": "^3.4.5"
|
||||
},
|
||||
"homepage": "https://github.com/feross/buffer",
|
||||
"jspm": {
|
||||
"map": {
|
||||
"./index.js": {
|
||||
"node": "@node/buffer"
|
||||
}
|
||||
}
|
||||
},
|
||||
"keywords": [
|
||||
"arraybuffer",
|
||||
"browser",
|
||||
"browserify",
|
||||
"buffer",
|
||||
"compatible",
|
||||
"dataview",
|
||||
"uint8array"
|
||||
],
|
||||
"license": "MIT",
|
||||
"main": "index.js",
|
||||
"types": "index.d.ts",
|
||||
"repository": {
|
||||
"type": "git",
|
||||
"url": "git://github.com/feross/buffer.git"
|
||||
},
|
||||
"scripts": {
|
||||
"perf": "browserify --debug perf/bracket-notation.js > perf/bundle.js && open perf/index.html",
|
||||
"perf-node": "node perf/bracket-notation.js && node perf/concat.js && node perf/copy-big.js && node perf/copy.js && node perf/new-big.js && node perf/new.js && node perf/readDoubleBE.js && node perf/readFloatBE.js && node perf/readUInt32LE.js && node perf/slice.js && node perf/writeFloatBE.js",
|
||||
"size": "browserify -r ./ | uglifyjs -c -m | gzip | wc -c",
|
||||
"test": "standard && node ./bin/test.js",
|
||||
"test-browser-es5": "airtap -- test/*.js",
|
||||
"test-browser-es5-local": "airtap --local -- test/*.js",
|
||||
"test-browser-es6": "airtap -- test/*.js test/node/*.js",
|
||||
"test-browser-es6-local": "airtap --local -- test/*.js test/node/*.js",
|
||||
"test-node": "tape test/*.js test/node/*.js",
|
||||
"update-authors": "./bin/update-authors.sh"
|
||||
},
|
||||
"standard": {
|
||||
"ignore": [
|
||||
"test/node/**/*.js",
|
||||
"test/common.js",
|
||||
"test/_polyfill.js",
|
||||
"perf/**/*.js"
|
||||
]
|
||||
}
|
||||
}
|
||||
1
node_modules/browserify/node_modules/isarray/.npmignore
generated
vendored
Normal file
1
node_modules/browserify/node_modules/isarray/.npmignore
generated
vendored
Normal file
@@ -0,0 +1 @@
|
||||
node_modules
|
||||
4
node_modules/browserify/node_modules/isarray/.travis.yml
generated
vendored
Normal file
4
node_modules/browserify/node_modules/isarray/.travis.yml
generated
vendored
Normal file
@@ -0,0 +1,4 @@
|
||||
language: node_js
|
||||
node_js:
|
||||
- "0.8"
|
||||
- "0.10"
|
||||
6
node_modules/browserify/node_modules/isarray/Makefile
generated
vendored
Normal file
6
node_modules/browserify/node_modules/isarray/Makefile
generated
vendored
Normal file
@@ -0,0 +1,6 @@
|
||||
|
||||
test:
|
||||
@node_modules/.bin/tape test.js
|
||||
|
||||
.PHONY: test
|
||||
|
||||
60
node_modules/browserify/node_modules/isarray/README.md
generated
vendored
Normal file
60
node_modules/browserify/node_modules/isarray/README.md
generated
vendored
Normal file
@@ -0,0 +1,60 @@
|
||||
|
||||
# isarray
|
||||
|
||||
`Array#isArray` for older browsers.
|
||||
|
||||
[](http://travis-ci.org/juliangruber/isarray)
|
||||
[](https://www.npmjs.org/package/isarray)
|
||||
|
||||
[
|
||||
](https://ci.testling.com/juliangruber/isarray)
|
||||
|
||||
## Usage
|
||||
|
||||
```js
|
||||
var isArray = require('isarray');
|
||||
|
||||
console.log(isArray([])); // => true
|
||||
console.log(isArray({})); // => false
|
||||
```
|
||||
|
||||
## Installation
|
||||
|
||||
With [npm](http://npmjs.org) do
|
||||
|
||||
```bash
|
||||
$ npm install isarray
|
||||
```
|
||||
|
||||
Then bundle for the browser with
|
||||
[browserify](https://github.com/substack/browserify).
|
||||
|
||||
With [component](http://component.io) do
|
||||
|
||||
```bash
|
||||
$ component install juliangruber/isarray
|
||||
```
|
||||
|
||||
## License
|
||||
|
||||
(MIT)
|
||||
|
||||
Copyright (c) 2013 Julian Gruber <julian@juliangruber.com>
|
||||
|
||||
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.
|
||||
19
node_modules/browserify/node_modules/isarray/component.json
generated
vendored
Normal file
19
node_modules/browserify/node_modules/isarray/component.json
generated
vendored
Normal file
@@ -0,0 +1,19 @@
|
||||
{
|
||||
"name" : "isarray",
|
||||
"description" : "Array#isArray for older browsers",
|
||||
"version" : "0.0.1",
|
||||
"repository" : "juliangruber/isarray",
|
||||
"homepage": "https://github.com/juliangruber/isarray",
|
||||
"main" : "index.js",
|
||||
"scripts" : [
|
||||
"index.js"
|
||||
],
|
||||
"dependencies" : {},
|
||||
"keywords": ["browser","isarray","array"],
|
||||
"author": {
|
||||
"name": "Julian Gruber",
|
||||
"email": "mail@juliangruber.com",
|
||||
"url": "http://juliangruber.com"
|
||||
},
|
||||
"license": "MIT"
|
||||
}
|
||||
5
node_modules/browserify/node_modules/isarray/index.js
generated
vendored
Normal file
5
node_modules/browserify/node_modules/isarray/index.js
generated
vendored
Normal file
@@ -0,0 +1,5 @@
|
||||
var toString = {}.toString;
|
||||
|
||||
module.exports = Array.isArray || function (arr) {
|
||||
return toString.call(arr) == '[object Array]';
|
||||
};
|
||||
45
node_modules/browserify/node_modules/isarray/package.json
generated
vendored
Normal file
45
node_modules/browserify/node_modules/isarray/package.json
generated
vendored
Normal file
@@ -0,0 +1,45 @@
|
||||
{
|
||||
"name": "isarray",
|
||||
"description": "Array#isArray for older browsers",
|
||||
"version": "1.0.0",
|
||||
"repository": {
|
||||
"type": "git",
|
||||
"url": "git://github.com/juliangruber/isarray.git"
|
||||
},
|
||||
"homepage": "https://github.com/juliangruber/isarray",
|
||||
"main": "index.js",
|
||||
"dependencies": {},
|
||||
"devDependencies": {
|
||||
"tape": "~2.13.4"
|
||||
},
|
||||
"keywords": [
|
||||
"browser",
|
||||
"isarray",
|
||||
"array"
|
||||
],
|
||||
"author": {
|
||||
"name": "Julian Gruber",
|
||||
"email": "mail@juliangruber.com",
|
||||
"url": "http://juliangruber.com"
|
||||
},
|
||||
"license": "MIT",
|
||||
"testling": {
|
||||
"files": "test.js",
|
||||
"browsers": [
|
||||
"ie/8..latest",
|
||||
"firefox/17..latest",
|
||||
"firefox/nightly",
|
||||
"chrome/22..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"
|
||||
]
|
||||
},
|
||||
"scripts": {
|
||||
"test": "tape test.js"
|
||||
}
|
||||
}
|
||||
20
node_modules/browserify/node_modules/isarray/test.js
generated
vendored
Normal file
20
node_modules/browserify/node_modules/isarray/test.js
generated
vendored
Normal file
@@ -0,0 +1,20 @@
|
||||
var isArray = require('./');
|
||||
var test = require('tape');
|
||||
|
||||
test('is array', function(t){
|
||||
t.ok(isArray([]));
|
||||
t.notOk(isArray({}));
|
||||
t.notOk(isArray(null));
|
||||
t.notOk(isArray(false));
|
||||
|
||||
var obj = {};
|
||||
obj[0] = true;
|
||||
t.notOk(isArray(obj));
|
||||
|
||||
var arr = [];
|
||||
arr.foo = 'bar';
|
||||
t.ok(isArray(arr));
|
||||
|
||||
t.end();
|
||||
});
|
||||
|
||||
34
node_modules/browserify/node_modules/readable-stream/.travis.yml
generated
vendored
Normal file
34
node_modules/browserify/node_modules/readable-stream/.travis.yml
generated
vendored
Normal file
@@ -0,0 +1,34 @@
|
||||
sudo: false
|
||||
language: node_js
|
||||
before_install:
|
||||
- (test $NPM_LEGACY && npm install -g npm@2 && npm install -g npm@3) || true
|
||||
notifications:
|
||||
email: false
|
||||
matrix:
|
||||
fast_finish: true
|
||||
include:
|
||||
- node_js: '0.8'
|
||||
env: NPM_LEGACY=true
|
||||
- node_js: '0.10'
|
||||
env: NPM_LEGACY=true
|
||||
- node_js: '0.11'
|
||||
env: NPM_LEGACY=true
|
||||
- node_js: '0.12'
|
||||
env: NPM_LEGACY=true
|
||||
- node_js: 1
|
||||
env: NPM_LEGACY=true
|
||||
- node_js: 2
|
||||
env: NPM_LEGACY=true
|
||||
- node_js: 3
|
||||
env: NPM_LEGACY=true
|
||||
- node_js: 4
|
||||
- node_js: 5
|
||||
- node_js: 6
|
||||
- node_js: 7
|
||||
- node_js: 8
|
||||
- node_js: 9
|
||||
script: "npm run test"
|
||||
env:
|
||||
global:
|
||||
- secure: rE2Vvo7vnjabYNULNyLFxOyt98BoJexDqsiOnfiD6kLYYsiQGfr/sbZkPMOFm9qfQG7pjqx+zZWZjGSswhTt+626C0t/njXqug7Yps4c3dFblzGfreQHp7wNX5TFsvrxd6dAowVasMp61sJcRnB2w8cUzoe3RAYUDHyiHktwqMc=
|
||||
- secure: g9YINaKAdMatsJ28G9jCGbSaguXCyxSTy+pBO6Ch0Cf57ZLOTka3HqDj8p3nV28LUIHZ3ut5WO43CeYKwt4AUtLpBS3a0dndHdY6D83uY6b2qh5hXlrcbeQTq2cvw2y95F7hm4D1kwrgZ7ViqaKggRcEupAL69YbJnxeUDKWEdI=
|
||||
38
node_modules/browserify/node_modules/readable-stream/CONTRIBUTING.md
generated
vendored
Normal file
38
node_modules/browserify/node_modules/readable-stream/CONTRIBUTING.md
generated
vendored
Normal file
@@ -0,0 +1,38 @@
|
||||
# Developer's Certificate of Origin 1.1
|
||||
|
||||
By making a contribution to this project, I certify that:
|
||||
|
||||
* (a) The contribution was created in whole or in part by me and I
|
||||
have the right to submit it under the open source license
|
||||
indicated in the file; or
|
||||
|
||||
* (b) The contribution is based upon previous work that, to the best
|
||||
of my knowledge, is covered under an appropriate open source
|
||||
license and I have the right under that license to submit that
|
||||
work with modifications, whether created in whole or in part
|
||||
by me, under the same open source license (unless I am
|
||||
permitted to submit under a different license), as indicated
|
||||
in the file; or
|
||||
|
||||
* (c) The contribution was provided directly to me by some other
|
||||
person who certified (a), (b) or (c) and I have not modified
|
||||
it.
|
||||
|
||||
* (d) I understand and agree that this project and the contribution
|
||||
are public and that a record of the contribution (including all
|
||||
personal information I submit with it, including my sign-off) is
|
||||
maintained indefinitely and may be redistributed consistent with
|
||||
this project or the open source license(s) involved.
|
||||
|
||||
## Moderation Policy
|
||||
|
||||
The [Node.js Moderation Policy] applies to this WG.
|
||||
|
||||
## Code of Conduct
|
||||
|
||||
The [Node.js Code of Conduct][] applies to this WG.
|
||||
|
||||
[Node.js Code of Conduct]:
|
||||
https://github.com/nodejs/node/blob/master/CODE_OF_CONDUCT.md
|
||||
[Node.js Moderation Policy]:
|
||||
https://github.com/nodejs/TSC/blob/master/Moderation-Policy.md
|
||||
136
node_modules/browserify/node_modules/readable-stream/GOVERNANCE.md
generated
vendored
Normal file
136
node_modules/browserify/node_modules/readable-stream/GOVERNANCE.md
generated
vendored
Normal file
@@ -0,0 +1,136 @@
|
||||
### Streams Working Group
|
||||
|
||||
The Node.js Streams is jointly governed by a Working Group
|
||||
(WG)
|
||||
that is responsible for high-level guidance of the project.
|
||||
|
||||
The WG has final authority over this project including:
|
||||
|
||||
* Technical direction
|
||||
* Project governance and process (including this policy)
|
||||
* Contribution policy
|
||||
* GitHub repository hosting
|
||||
* Conduct guidelines
|
||||
* Maintaining the list of additional Collaborators
|
||||
|
||||
For the current list of WG members, see the project
|
||||
[README.md](./README.md#current-project-team-members).
|
||||
|
||||
### Collaborators
|
||||
|
||||
The readable-stream GitHub repository is
|
||||
maintained by the WG and additional Collaborators who are added by the
|
||||
WG on an ongoing basis.
|
||||
|
||||
Individuals making significant and valuable contributions are made
|
||||
Collaborators and given commit-access to the project. These
|
||||
individuals are identified by the WG and their addition as
|
||||
Collaborators is discussed during the WG meeting.
|
||||
|
||||
_Note:_ If you make a significant contribution and are not considered
|
||||
for commit-access log an issue or contact a WG member directly and it
|
||||
will be brought up in the next WG meeting.
|
||||
|
||||
Modifications of the contents of the readable-stream repository are
|
||||
made on
|
||||
a collaborative basis. Anybody with a GitHub account may propose a
|
||||
modification via pull request and it will be considered by the project
|
||||
Collaborators. All pull requests must be reviewed and accepted by a
|
||||
Collaborator with sufficient expertise who is able to take full
|
||||
responsibility for the change. In the case of pull requests proposed
|
||||
by an existing Collaborator, an additional Collaborator is required
|
||||
for sign-off. Consensus should be sought if additional Collaborators
|
||||
participate and there is disagreement around a particular
|
||||
modification. See _Consensus Seeking Process_ below for further detail
|
||||
on the consensus model used for governance.
|
||||
|
||||
Collaborators may opt to elevate significant or controversial
|
||||
modifications, or modifications that have not found consensus to the
|
||||
WG for discussion by assigning the ***WG-agenda*** tag to a pull
|
||||
request or issue. The WG should serve as the final arbiter where
|
||||
required.
|
||||
|
||||
For the current list of Collaborators, see the project
|
||||
[README.md](./README.md#members).
|
||||
|
||||
### WG Membership
|
||||
|
||||
WG seats are not time-limited. There is no fixed size of the WG.
|
||||
However, the expected target is between 6 and 12, to ensure adequate
|
||||
coverage of important areas of expertise, balanced with the ability to
|
||||
make decisions efficiently.
|
||||
|
||||
There is no specific set of requirements or qualifications for WG
|
||||
membership beyond these rules.
|
||||
|
||||
The WG may add additional members to the WG by unanimous consensus.
|
||||
|
||||
A WG member may be removed from the WG by voluntary resignation, or by
|
||||
unanimous consensus of all other WG members.
|
||||
|
||||
Changes to WG membership should be posted in the agenda, and may be
|
||||
suggested as any other agenda item (see "WG Meetings" below).
|
||||
|
||||
If an addition or removal is proposed during a meeting, and the full
|
||||
WG is not in attendance to participate, then the addition or removal
|
||||
is added to the agenda for the subsequent meeting. This is to ensure
|
||||
that all members are given the opportunity to participate in all
|
||||
membership decisions. If a WG member is unable to attend a meeting
|
||||
where a planned membership decision is being made, then their consent
|
||||
is assumed.
|
||||
|
||||
No more than 1/3 of the WG members may be affiliated with the same
|
||||
employer. If removal or resignation of a WG member, or a change of
|
||||
employment by a WG member, creates a situation where more than 1/3 of
|
||||
the WG membership shares an employer, then the situation must be
|
||||
immediately remedied by the resignation or removal of one or more WG
|
||||
members affiliated with the over-represented employer(s).
|
||||
|
||||
### WG Meetings
|
||||
|
||||
The WG meets occasionally on a Google Hangout On Air. A designated moderator
|
||||
approved by the WG runs the meeting. Each meeting should be
|
||||
published to YouTube.
|
||||
|
||||
Items are added to the WG agenda that are considered contentious or
|
||||
are modifications of governance, contribution policy, WG membership,
|
||||
or release process.
|
||||
|
||||
The intention of the agenda is not to approve or review all patches;
|
||||
that should happen continuously on GitHub and be handled by the larger
|
||||
group of Collaborators.
|
||||
|
||||
Any community member or contributor can ask that something be added to
|
||||
the next meeting's agenda by logging a GitHub Issue. Any Collaborator,
|
||||
WG member or the moderator can add the item to the agenda by adding
|
||||
the ***WG-agenda*** tag to the issue.
|
||||
|
||||
Prior to each WG meeting the moderator will share the Agenda with
|
||||
members of the WG. WG members can add any items they like to the
|
||||
agenda at the beginning of each meeting. The moderator and the WG
|
||||
cannot veto or remove items.
|
||||
|
||||
The WG may invite persons or representatives from certain projects to
|
||||
participate in a non-voting capacity.
|
||||
|
||||
The moderator is responsible for summarizing the discussion of each
|
||||
agenda item and sends it as a pull request after the meeting.
|
||||
|
||||
### Consensus Seeking Process
|
||||
|
||||
The WG follows a
|
||||
[Consensus
|
||||
Seeking](http://en.wikipedia.org/wiki/Consensus-seeking_decision-making)
|
||||
decision-making model.
|
||||
|
||||
When an agenda item has appeared to reach a consensus the moderator
|
||||
will ask "Does anyone object?" as a final call for dissent from the
|
||||
consensus.
|
||||
|
||||
If an agenda item cannot reach a consensus a WG member can call for
|
||||
either a closing vote or a vote to table the issue to the next
|
||||
meeting. The call for a vote must be seconded by a majority of the WG
|
||||
or else the discussion will continue. Simple majority wins.
|
||||
|
||||
Note that changes to WG membership require a majority consensus. See
|
||||
"WG Membership" above.
|
||||
47
node_modules/browserify/node_modules/readable-stream/LICENSE
generated
vendored
Normal file
47
node_modules/browserify/node_modules/readable-stream/LICENSE
generated
vendored
Normal file
@@ -0,0 +1,47 @@
|
||||
Node.js is licensed for use as follows:
|
||||
|
||||
"""
|
||||
Copyright Node.js contributors. All rights reserved.
|
||||
|
||||
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.
|
||||
"""
|
||||
|
||||
This license applies to parts of Node.js originating from the
|
||||
https://github.com/joyent/node repository:
|
||||
|
||||
"""
|
||||
Copyright Joyent, Inc. and other Node contributors. All rights reserved.
|
||||
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.
|
||||
"""
|
||||
58
node_modules/browserify/node_modules/readable-stream/README.md
generated
vendored
Normal file
58
node_modules/browserify/node_modules/readable-stream/README.md
generated
vendored
Normal file
@@ -0,0 +1,58 @@
|
||||
# readable-stream
|
||||
|
||||
***Node-core v8.17.0 streams for userland*** [](https://travis-ci.org/nodejs/readable-stream)
|
||||
|
||||
|
||||
[](https://nodei.co/npm/readable-stream/)
|
||||
[](https://nodei.co/npm/readable-stream/)
|
||||
|
||||
|
||||
[](https://saucelabs.com/u/readable-stream)
|
||||
|
||||
```bash
|
||||
npm install --save readable-stream
|
||||
```
|
||||
|
||||
***Node-core streams for userland***
|
||||
|
||||
This package is a mirror of the Streams2 and Streams3 implementations in
|
||||
Node-core.
|
||||
|
||||
Full documentation may be found on the [Node.js website](https://nodejs.org/dist/v8.17.0/docs/api/stream.html).
|
||||
|
||||
If you want to guarantee a stable streams base, regardless of what version of
|
||||
Node you, or the users of your libraries are using, use **readable-stream** *only* and avoid the *"stream"* module in Node-core, for background see [this blogpost](http://r.va.gg/2014/06/why-i-dont-use-nodes-core-stream-module.html).
|
||||
|
||||
As of version 2.0.0 **readable-stream** uses semantic versioning.
|
||||
|
||||
# Streams Working Group
|
||||
|
||||
`readable-stream` is maintained by the Streams Working Group, which
|
||||
oversees the development and maintenance of the Streams API within
|
||||
Node.js. The responsibilities of the Streams Working Group include:
|
||||
|
||||
* Addressing stream issues on the Node.js issue tracker.
|
||||
* Authoring and editing stream documentation within the Node.js project.
|
||||
* Reviewing changes to stream subclasses within the Node.js project.
|
||||
* Redirecting changes to streams from the Node.js project to this
|
||||
project.
|
||||
* Assisting in the implementation of stream providers within Node.js.
|
||||
* Recommending versions of `readable-stream` to be included in Node.js.
|
||||
* Messaging about the future of streams to give the community advance
|
||||
notice of changes.
|
||||
|
||||
<a name="members"></a>
|
||||
## Team Members
|
||||
|
||||
* **Chris Dickinson** ([@chrisdickinson](https://github.com/chrisdickinson)) <christopher.s.dickinson@gmail.com>
|
||||
- Release GPG key: 9554F04D7259F04124DE6B476D5A82AC7E37093B
|
||||
* **Calvin Metcalf** ([@calvinmetcalf](https://github.com/calvinmetcalf)) <calvin.metcalf@gmail.com>
|
||||
- Release GPG key: F3EF5F62A87FC27A22E643F714CE4FF5015AA242
|
||||
* **Rod Vagg** ([@rvagg](https://github.com/rvagg)) <rod@vagg.org>
|
||||
- Release GPG key: DD8F2338BAE7501E3DD5AC78C273792F7D83545D
|
||||
* **Sam Newman** ([@sonewman](https://github.com/sonewman)) <newmansam@outlook.com>
|
||||
* **Mathias Buus** ([@mafintosh](https://github.com/mafintosh)) <mathiasbuus@gmail.com>
|
||||
* **Domenic Denicola** ([@domenic](https://github.com/domenic)) <d@domenic.me>
|
||||
* **Matteo Collina** ([@mcollina](https://github.com/mcollina)) <matteo.collina@gmail.com>
|
||||
- Release GPG key: 3ABC01543F22DD2239285CDD818674489FBC127E
|
||||
* **Irina Shestak** ([@lrlna](https://github.com/lrlna)) <shestak.irina@gmail.com>
|
||||
60
node_modules/browserify/node_modules/readable-stream/doc/wg-meetings/2015-01-30.md
generated
vendored
Normal file
60
node_modules/browserify/node_modules/readable-stream/doc/wg-meetings/2015-01-30.md
generated
vendored
Normal file
@@ -0,0 +1,60 @@
|
||||
# streams WG Meeting 2015-01-30
|
||||
|
||||
## Links
|
||||
|
||||
* **Google Hangouts Video**: http://www.youtube.com/watch?v=I9nDOSGfwZg
|
||||
* **GitHub Issue**: https://github.com/iojs/readable-stream/issues/106
|
||||
* **Original Minutes Google Doc**: https://docs.google.com/document/d/17aTgLnjMXIrfjgNaTUnHQO7m3xgzHR2VXBTmi03Qii4/
|
||||
|
||||
## Agenda
|
||||
|
||||
Extracted from https://github.com/iojs/readable-stream/labels/wg-agenda prior to meeting.
|
||||
|
||||
* adopt a charter [#105](https://github.com/iojs/readable-stream/issues/105)
|
||||
* release and versioning strategy [#101](https://github.com/iojs/readable-stream/issues/101)
|
||||
* simpler stream creation [#102](https://github.com/iojs/readable-stream/issues/102)
|
||||
* proposal: deprecate implicit flowing of streams [#99](https://github.com/iojs/readable-stream/issues/99)
|
||||
|
||||
## Minutes
|
||||
|
||||
### adopt a charter
|
||||
|
||||
* group: +1's all around
|
||||
|
||||
### What versioning scheme should be adopted?
|
||||
* group: +1’s 3.0.0
|
||||
* domenic+group: pulling in patches from other sources where appropriate
|
||||
* mikeal: version independently, suggesting versions for io.js
|
||||
* mikeal+domenic: work with TC to notify in advance of changes
|
||||
simpler stream creation
|
||||
|
||||
### streamline creation of streams
|
||||
* sam: streamline creation of streams
|
||||
* domenic: nice simple solution posted
|
||||
but, we lose the opportunity to change the model
|
||||
may not be backwards incompatible (double check keys)
|
||||
|
||||
**action item:** domenic will check
|
||||
|
||||
### remove implicit flowing of streams on(‘data’)
|
||||
* add isFlowing / isPaused
|
||||
* mikeal: worrying that we’re documenting polyfill methods – confuses users
|
||||
* domenic: more reflective API is probably good, with warning labels for users
|
||||
* new section for mad scientists (reflective stream access)
|
||||
* calvin: name the “third state”
|
||||
* mikeal: maybe borrow the name from whatwg?
|
||||
* domenic: we’re missing the “third state”
|
||||
* consensus: kind of difficult to name the third state
|
||||
* mikeal: figure out differences in states / compat
|
||||
* mathias: always flow on data – eliminates third state
|
||||
* explore what it breaks
|
||||
|
||||
**action items:**
|
||||
* ask isaac for ability to list packages by what public io.js APIs they use (esp. Stream)
|
||||
* ask rod/build for infrastructure
|
||||
* **chris**: explore the “flow on data” approach
|
||||
* add isPaused/isFlowing
|
||||
* add new docs section
|
||||
* move isPaused to that section
|
||||
|
||||
|
||||
1
node_modules/browserify/node_modules/readable-stream/duplex-browser.js
generated
vendored
Normal file
1
node_modules/browserify/node_modules/readable-stream/duplex-browser.js
generated
vendored
Normal file
@@ -0,0 +1 @@
|
||||
module.exports = require('./lib/_stream_duplex.js');
|
||||
1
node_modules/browserify/node_modules/readable-stream/duplex.js
generated
vendored
Normal file
1
node_modules/browserify/node_modules/readable-stream/duplex.js
generated
vendored
Normal file
@@ -0,0 +1 @@
|
||||
module.exports = require('./readable').Duplex
|
||||
131
node_modules/browserify/node_modules/readable-stream/lib/_stream_duplex.js
generated
vendored
Normal file
131
node_modules/browserify/node_modules/readable-stream/lib/_stream_duplex.js
generated
vendored
Normal file
@@ -0,0 +1,131 @@
|
||||
// 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.
|
||||
|
||||
// a duplex stream is just a stream that is both readable and writable.
|
||||
// Since JS doesn't have multiple prototypal inheritance, this class
|
||||
// prototypally inherits from Readable, and then parasitically from
|
||||
// Writable.
|
||||
|
||||
'use strict';
|
||||
|
||||
/*<replacement>*/
|
||||
|
||||
var pna = require('process-nextick-args');
|
||||
/*</replacement>*/
|
||||
|
||||
/*<replacement>*/
|
||||
var objectKeys = Object.keys || function (obj) {
|
||||
var keys = [];
|
||||
for (var key in obj) {
|
||||
keys.push(key);
|
||||
}return keys;
|
||||
};
|
||||
/*</replacement>*/
|
||||
|
||||
module.exports = Duplex;
|
||||
|
||||
/*<replacement>*/
|
||||
var util = Object.create(require('core-util-is'));
|
||||
util.inherits = require('inherits');
|
||||
/*</replacement>*/
|
||||
|
||||
var Readable = require('./_stream_readable');
|
||||
var Writable = require('./_stream_writable');
|
||||
|
||||
util.inherits(Duplex, Readable);
|
||||
|
||||
{
|
||||
// avoid scope creep, the keys array can then be collected
|
||||
var keys = objectKeys(Writable.prototype);
|
||||
for (var v = 0; v < keys.length; v++) {
|
||||
var method = keys[v];
|
||||
if (!Duplex.prototype[method]) Duplex.prototype[method] = Writable.prototype[method];
|
||||
}
|
||||
}
|
||||
|
||||
function Duplex(options) {
|
||||
if (!(this instanceof Duplex)) return new Duplex(options);
|
||||
|
||||
Readable.call(this, options);
|
||||
Writable.call(this, options);
|
||||
|
||||
if (options && options.readable === false) this.readable = false;
|
||||
|
||||
if (options && options.writable === false) this.writable = false;
|
||||
|
||||
this.allowHalfOpen = true;
|
||||
if (options && options.allowHalfOpen === false) this.allowHalfOpen = false;
|
||||
|
||||
this.once('end', onend);
|
||||
}
|
||||
|
||||
Object.defineProperty(Duplex.prototype, 'writableHighWaterMark', {
|
||||
// making it explicit this property is not enumerable
|
||||
// because otherwise some prototype manipulation in
|
||||
// userland will fail
|
||||
enumerable: false,
|
||||
get: function () {
|
||||
return this._writableState.highWaterMark;
|
||||
}
|
||||
});
|
||||
|
||||
// the no-half-open enforcer
|
||||
function onend() {
|
||||
// if we allow half-open state, or if the writable side ended,
|
||||
// then we're ok.
|
||||
if (this.allowHalfOpen || this._writableState.ended) return;
|
||||
|
||||
// no more data can be written.
|
||||
// But allow more writes to happen in this tick.
|
||||
pna.nextTick(onEndNT, this);
|
||||
}
|
||||
|
||||
function onEndNT(self) {
|
||||
self.end();
|
||||
}
|
||||
|
||||
Object.defineProperty(Duplex.prototype, 'destroyed', {
|
||||
get: function () {
|
||||
if (this._readableState === undefined || this._writableState === undefined) {
|
||||
return false;
|
||||
}
|
||||
return this._readableState.destroyed && this._writableState.destroyed;
|
||||
},
|
||||
set: function (value) {
|
||||
// we ignore the value if the stream
|
||||
// has not been initialized yet
|
||||
if (this._readableState === undefined || this._writableState === undefined) {
|
||||
return;
|
||||
}
|
||||
|
||||
// backward compatibility, the user is explicitly
|
||||
// managing destroyed
|
||||
this._readableState.destroyed = value;
|
||||
this._writableState.destroyed = value;
|
||||
}
|
||||
});
|
||||
|
||||
Duplex.prototype._destroy = function (err, cb) {
|
||||
this.push(null);
|
||||
this.end();
|
||||
|
||||
pna.nextTick(cb, err);
|
||||
};
|
||||
47
node_modules/browserify/node_modules/readable-stream/lib/_stream_passthrough.js
generated
vendored
Normal file
47
node_modules/browserify/node_modules/readable-stream/lib/_stream_passthrough.js
generated
vendored
Normal file
@@ -0,0 +1,47 @@
|
||||
// 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.
|
||||
|
||||
// a passthrough stream.
|
||||
// basically just the most minimal sort of Transform stream.
|
||||
// Every written chunk gets output as-is.
|
||||
|
||||
'use strict';
|
||||
|
||||
module.exports = PassThrough;
|
||||
|
||||
var Transform = require('./_stream_transform');
|
||||
|
||||
/*<replacement>*/
|
||||
var util = Object.create(require('core-util-is'));
|
||||
util.inherits = require('inherits');
|
||||
/*</replacement>*/
|
||||
|
||||
util.inherits(PassThrough, Transform);
|
||||
|
||||
function PassThrough(options) {
|
||||
if (!(this instanceof PassThrough)) return new PassThrough(options);
|
||||
|
||||
Transform.call(this, options);
|
||||
}
|
||||
|
||||
PassThrough.prototype._transform = function (chunk, encoding, cb) {
|
||||
cb(null, chunk);
|
||||
};
|
||||
1019
node_modules/browserify/node_modules/readable-stream/lib/_stream_readable.js
generated
vendored
Normal file
1019
node_modules/browserify/node_modules/readable-stream/lib/_stream_readable.js
generated
vendored
Normal file
File diff suppressed because it is too large
Load Diff
214
node_modules/browserify/node_modules/readable-stream/lib/_stream_transform.js
generated
vendored
Normal file
214
node_modules/browserify/node_modules/readable-stream/lib/_stream_transform.js
generated
vendored
Normal file
@@ -0,0 +1,214 @@
|
||||
// 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.
|
||||
|
||||
// a transform stream is a readable/writable stream where you do
|
||||
// something with the data. Sometimes it's called a "filter",
|
||||
// but that's not a great name for it, since that implies a thing where
|
||||
// some bits pass through, and others are simply ignored. (That would
|
||||
// be a valid example of a transform, of course.)
|
||||
//
|
||||
// While the output is causally related to the input, it's not a
|
||||
// necessarily symmetric or synchronous transformation. For example,
|
||||
// a zlib stream might take multiple plain-text writes(), and then
|
||||
// emit a single compressed chunk some time in the future.
|
||||
//
|
||||
// Here's how this works:
|
||||
//
|
||||
// The Transform stream has all the aspects of the readable and writable
|
||||
// stream classes. When you write(chunk), that calls _write(chunk,cb)
|
||||
// internally, and returns false if there's a lot of pending writes
|
||||
// buffered up. When you call read(), that calls _read(n) until
|
||||
// there's enough pending readable data buffered up.
|
||||
//
|
||||
// In a transform stream, the written data is placed in a buffer. When
|
||||
// _read(n) is called, it transforms the queued up data, calling the
|
||||
// buffered _write cb's as it consumes chunks. If consuming a single
|
||||
// written chunk would result in multiple output chunks, then the first
|
||||
// outputted bit calls the readcb, and subsequent chunks just go into
|
||||
// the read buffer, and will cause it to emit 'readable' if necessary.
|
||||
//
|
||||
// This way, back-pressure is actually determined by the reading side,
|
||||
// since _read has to be called to start processing a new chunk. However,
|
||||
// a pathological inflate type of transform can cause excessive buffering
|
||||
// here. For example, imagine a stream where every byte of input is
|
||||
// interpreted as an integer from 0-255, and then results in that many
|
||||
// bytes of output. Writing the 4 bytes {ff,ff,ff,ff} would result in
|
||||
// 1kb of data being output. In this case, you could write a very small
|
||||
// amount of input, and end up with a very large amount of output. In
|
||||
// such a pathological inflating mechanism, there'd be no way to tell
|
||||
// the system to stop doing the transform. A single 4MB write could
|
||||
// cause the system to run out of memory.
|
||||
//
|
||||
// However, even in such a pathological case, only a single written chunk
|
||||
// would be consumed, and then the rest would wait (un-transformed) until
|
||||
// the results of the previous transformed chunk were consumed.
|
||||
|
||||
'use strict';
|
||||
|
||||
module.exports = Transform;
|
||||
|
||||
var Duplex = require('./_stream_duplex');
|
||||
|
||||
/*<replacement>*/
|
||||
var util = Object.create(require('core-util-is'));
|
||||
util.inherits = require('inherits');
|
||||
/*</replacement>*/
|
||||
|
||||
util.inherits(Transform, Duplex);
|
||||
|
||||
function afterTransform(er, data) {
|
||||
var ts = this._transformState;
|
||||
ts.transforming = false;
|
||||
|
||||
var cb = ts.writecb;
|
||||
|
||||
if (!cb) {
|
||||
return this.emit('error', new Error('write callback called multiple times'));
|
||||
}
|
||||
|
||||
ts.writechunk = null;
|
||||
ts.writecb = null;
|
||||
|
||||
if (data != null) // single equals check for both `null` and `undefined`
|
||||
this.push(data);
|
||||
|
||||
cb(er);
|
||||
|
||||
var rs = this._readableState;
|
||||
rs.reading = false;
|
||||
if (rs.needReadable || rs.length < rs.highWaterMark) {
|
||||
this._read(rs.highWaterMark);
|
||||
}
|
||||
}
|
||||
|
||||
function Transform(options) {
|
||||
if (!(this instanceof Transform)) return new Transform(options);
|
||||
|
||||
Duplex.call(this, options);
|
||||
|
||||
this._transformState = {
|
||||
afterTransform: afterTransform.bind(this),
|
||||
needTransform: false,
|
||||
transforming: false,
|
||||
writecb: null,
|
||||
writechunk: null,
|
||||
writeencoding: null
|
||||
};
|
||||
|
||||
// start out asking for a readable event once data is transformed.
|
||||
this._readableState.needReadable = true;
|
||||
|
||||
// we have implemented the _read method, and done the other things
|
||||
// that Readable wants before the first _read call, so unset the
|
||||
// sync guard flag.
|
||||
this._readableState.sync = false;
|
||||
|
||||
if (options) {
|
||||
if (typeof options.transform === 'function') this._transform = options.transform;
|
||||
|
||||
if (typeof options.flush === 'function') this._flush = options.flush;
|
||||
}
|
||||
|
||||
// When the writable side finishes, then flush out anything remaining.
|
||||
this.on('prefinish', prefinish);
|
||||
}
|
||||
|
||||
function prefinish() {
|
||||
var _this = this;
|
||||
|
||||
if (typeof this._flush === 'function') {
|
||||
this._flush(function (er, data) {
|
||||
done(_this, er, data);
|
||||
});
|
||||
} else {
|
||||
done(this, null, null);
|
||||
}
|
||||
}
|
||||
|
||||
Transform.prototype.push = function (chunk, encoding) {
|
||||
this._transformState.needTransform = false;
|
||||
return Duplex.prototype.push.call(this, chunk, encoding);
|
||||
};
|
||||
|
||||
// This is the part where you do stuff!
|
||||
// override this function in implementation classes.
|
||||
// 'chunk' is an input chunk.
|
||||
//
|
||||
// Call `push(newChunk)` to pass along transformed output
|
||||
// to the readable side. You may call 'push' zero or more times.
|
||||
//
|
||||
// Call `cb(err)` when you are done with this chunk. If you pass
|
||||
// an error, then that'll put the hurt on the whole operation. If you
|
||||
// never call cb(), then you'll never get another chunk.
|
||||
Transform.prototype._transform = function (chunk, encoding, cb) {
|
||||
throw new Error('_transform() is not implemented');
|
||||
};
|
||||
|
||||
Transform.prototype._write = function (chunk, encoding, cb) {
|
||||
var ts = this._transformState;
|
||||
ts.writecb = cb;
|
||||
ts.writechunk = chunk;
|
||||
ts.writeencoding = encoding;
|
||||
if (!ts.transforming) {
|
||||
var rs = this._readableState;
|
||||
if (ts.needTransform || rs.needReadable || rs.length < rs.highWaterMark) this._read(rs.highWaterMark);
|
||||
}
|
||||
};
|
||||
|
||||
// Doesn't matter what the args are here.
|
||||
// _transform does all the work.
|
||||
// That we got here means that the readable side wants more data.
|
||||
Transform.prototype._read = function (n) {
|
||||
var ts = this._transformState;
|
||||
|
||||
if (ts.writechunk !== null && ts.writecb && !ts.transforming) {
|
||||
ts.transforming = true;
|
||||
this._transform(ts.writechunk, ts.writeencoding, ts.afterTransform);
|
||||
} else {
|
||||
// mark that we need a transform, so that any data that comes in
|
||||
// will get processed, now that we've asked for it.
|
||||
ts.needTransform = true;
|
||||
}
|
||||
};
|
||||
|
||||
Transform.prototype._destroy = function (err, cb) {
|
||||
var _this2 = this;
|
||||
|
||||
Duplex.prototype._destroy.call(this, err, function (err2) {
|
||||
cb(err2);
|
||||
_this2.emit('close');
|
||||
});
|
||||
};
|
||||
|
||||
function done(stream, er, data) {
|
||||
if (er) return stream.emit('error', er);
|
||||
|
||||
if (data != null) // single equals check for both `null` and `undefined`
|
||||
stream.push(data);
|
||||
|
||||
// if there's nothing in the write buffer, then that means
|
||||
// that nothing more will ever be provided
|
||||
if (stream._writableState.length) throw new Error('Calling transform done when ws.length != 0');
|
||||
|
||||
if (stream._transformState.transforming) throw new Error('Calling transform done when still transforming');
|
||||
|
||||
return stream.push(null);
|
||||
}
|
||||
685
node_modules/browserify/node_modules/readable-stream/lib/_stream_writable.js
generated
vendored
Normal file
685
node_modules/browserify/node_modules/readable-stream/lib/_stream_writable.js
generated
vendored
Normal file
@@ -0,0 +1,685 @@
|
||||
// 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.
|
||||
|
||||
// A bit simpler than readable streams.
|
||||
// Implement an async ._write(chunk, encoding, cb), and it'll handle all
|
||||
// the drain event emission and buffering.
|
||||
|
||||
'use strict';
|
||||
|
||||
/*<replacement>*/
|
||||
|
||||
var pna = require('process-nextick-args');
|
||||
/*</replacement>*/
|
||||
|
||||
module.exports = Writable;
|
||||
|
||||
/* <replacement> */
|
||||
function WriteReq(chunk, encoding, cb) {
|
||||
this.chunk = chunk;
|
||||
this.encoding = encoding;
|
||||
this.callback = cb;
|
||||
this.next = null;
|
||||
}
|
||||
|
||||
// It seems a linked list but it is not
|
||||
// there will be only 2 of these for each stream
|
||||
function CorkedRequest(state) {
|
||||
var _this = this;
|
||||
|
||||
this.next = null;
|
||||
this.entry = null;
|
||||
this.finish = function () {
|
||||
onCorkedFinish(_this, state);
|
||||
};
|
||||
}
|
||||
/* </replacement> */
|
||||
|
||||
/*<replacement>*/
|
||||
var asyncWrite = !process.browser && ['v0.10', 'v0.9.'].indexOf(process.version.slice(0, 5)) > -1 ? setImmediate : pna.nextTick;
|
||||
/*</replacement>*/
|
||||
|
||||
/*<replacement>*/
|
||||
var Duplex;
|
||||
/*</replacement>*/
|
||||
|
||||
Writable.WritableState = WritableState;
|
||||
|
||||
/*<replacement>*/
|
||||
var util = Object.create(require('core-util-is'));
|
||||
util.inherits = require('inherits');
|
||||
/*</replacement>*/
|
||||
|
||||
/*<replacement>*/
|
||||
var internalUtil = {
|
||||
deprecate: require('util-deprecate')
|
||||
};
|
||||
/*</replacement>*/
|
||||
|
||||
/*<replacement>*/
|
||||
var Stream = require('./internal/streams/stream');
|
||||
/*</replacement>*/
|
||||
|
||||
/*<replacement>*/
|
||||
|
||||
var Buffer = require('safe-buffer').Buffer;
|
||||
var OurUint8Array = (typeof global !== 'undefined' ? global : typeof window !== 'undefined' ? window : typeof self !== 'undefined' ? self : {}).Uint8Array || function () {};
|
||||
function _uint8ArrayToBuffer(chunk) {
|
||||
return Buffer.from(chunk);
|
||||
}
|
||||
function _isUint8Array(obj) {
|
||||
return Buffer.isBuffer(obj) || obj instanceof OurUint8Array;
|
||||
}
|
||||
|
||||
/*</replacement>*/
|
||||
|
||||
var destroyImpl = require('./internal/streams/destroy');
|
||||
|
||||
util.inherits(Writable, Stream);
|
||||
|
||||
function nop() {}
|
||||
|
||||
function WritableState(options, stream) {
|
||||
Duplex = Duplex || require('./_stream_duplex');
|
||||
|
||||
options = options || {};
|
||||
|
||||
// Duplex streams are both readable and writable, but share
|
||||
// the same options object.
|
||||
// However, some cases require setting options to different
|
||||
// values for the readable and the writable sides of the duplex stream.
|
||||
// These options can be provided separately as readableXXX and writableXXX.
|
||||
var isDuplex = stream instanceof Duplex;
|
||||
|
||||
// object stream flag to indicate whether or not this stream
|
||||
// contains buffers or objects.
|
||||
this.objectMode = !!options.objectMode;
|
||||
|
||||
if (isDuplex) this.objectMode = this.objectMode || !!options.writableObjectMode;
|
||||
|
||||
// the point at which write() starts returning false
|
||||
// Note: 0 is a valid value, means that we always return false if
|
||||
// the entire buffer is not flushed immediately on write()
|
||||
var hwm = options.highWaterMark;
|
||||
var writableHwm = options.writableHighWaterMark;
|
||||
var defaultHwm = this.objectMode ? 16 : 16 * 1024;
|
||||
|
||||
if (hwm || hwm === 0) this.highWaterMark = hwm;else if (isDuplex && (writableHwm || writableHwm === 0)) this.highWaterMark = writableHwm;else this.highWaterMark = defaultHwm;
|
||||
|
||||
// cast to ints.
|
||||
this.highWaterMark = Math.floor(this.highWaterMark);
|
||||
|
||||
// if _final has been called
|
||||
this.finalCalled = false;
|
||||
|
||||
// drain event flag.
|
||||
this.needDrain = false;
|
||||
// at the start of calling end()
|
||||
this.ending = false;
|
||||
// when end() has been called, and returned
|
||||
this.ended = false;
|
||||
// when 'finish' is emitted
|
||||
this.finished = false;
|
||||
|
||||
// has it been destroyed
|
||||
this.destroyed = false;
|
||||
|
||||
// should we decode strings into buffers before passing to _write?
|
||||
// this is here so that some node-core streams can optimize string
|
||||
// handling at a lower level.
|
||||
var noDecode = options.decodeStrings === false;
|
||||
this.decodeStrings = !noDecode;
|
||||
|
||||
// Crypto is kind of old and crusty. Historically, its default string
|
||||
// encoding is 'binary' so we have to make this configurable.
|
||||
// Everything else in the universe uses 'utf8', though.
|
||||
this.defaultEncoding = options.defaultEncoding || 'utf8';
|
||||
|
||||
// not an actual buffer we keep track of, but a measurement
|
||||
// of how much we're waiting to get pushed to some underlying
|
||||
// socket or file.
|
||||
this.length = 0;
|
||||
|
||||
// a flag to see when we're in the middle of a write.
|
||||
this.writing = false;
|
||||
|
||||
// when true all writes will be buffered until .uncork() call
|
||||
this.corked = 0;
|
||||
|
||||
// a flag to be able to tell if the onwrite cb is called immediately,
|
||||
// or on a later tick. We set this to true at first, because any
|
||||
// actions that shouldn't happen until "later" should generally also
|
||||
// not happen before the first write call.
|
||||
this.sync = true;
|
||||
|
||||
// a flag to know if we're processing previously buffered items, which
|
||||
// may call the _write() callback in the same tick, so that we don't
|
||||
// end up in an overlapped onwrite situation.
|
||||
this.bufferProcessing = false;
|
||||
|
||||
// the callback that's passed to _write(chunk,cb)
|
||||
this.onwrite = function (er) {
|
||||
onwrite(stream, er);
|
||||
};
|
||||
|
||||
// the callback that the user supplies to write(chunk,encoding,cb)
|
||||
this.writecb = null;
|
||||
|
||||
// the amount that is being written when _write is called.
|
||||
this.writelen = 0;
|
||||
|
||||
this.bufferedRequest = null;
|
||||
this.lastBufferedRequest = null;
|
||||
|
||||
// number of pending user-supplied write callbacks
|
||||
// this must be 0 before 'finish' can be emitted
|
||||
this.pendingcb = 0;
|
||||
|
||||
// emit prefinish if the only thing we're waiting for is _write cbs
|
||||
// This is relevant for synchronous Transform streams
|
||||
this.prefinished = false;
|
||||
|
||||
// True if the error was already emitted and should not be thrown again
|
||||
this.errorEmitted = false;
|
||||
|
||||
// count buffered requests
|
||||
this.bufferedRequestCount = 0;
|
||||
|
||||
// allocate the first CorkedRequest, there is always
|
||||
// one allocated and free to use, and we maintain at most two
|
||||
this.corkedRequestsFree = new CorkedRequest(this);
|
||||
}
|
||||
|
||||
WritableState.prototype.getBuffer = function getBuffer() {
|
||||
var current = this.bufferedRequest;
|
||||
var out = [];
|
||||
while (current) {
|
||||
out.push(current);
|
||||
current = current.next;
|
||||
}
|
||||
return out;
|
||||
};
|
||||
|
||||
(function () {
|
||||
try {
|
||||
Object.defineProperty(WritableState.prototype, 'buffer', {
|
||||
get: internalUtil.deprecate(function () {
|
||||
return this.getBuffer();
|
||||
}, '_writableState.buffer is deprecated. Use _writableState.getBuffer ' + 'instead.', 'DEP0003')
|
||||
});
|
||||
} catch (_) {}
|
||||
})();
|
||||
|
||||
// Test _writableState for inheritance to account for Duplex streams,
|
||||
// whose prototype chain only points to Readable.
|
||||
var realHasInstance;
|
||||
if (typeof Symbol === 'function' && Symbol.hasInstance && typeof Function.prototype[Symbol.hasInstance] === 'function') {
|
||||
realHasInstance = Function.prototype[Symbol.hasInstance];
|
||||
Object.defineProperty(Writable, Symbol.hasInstance, {
|
||||
value: function (object) {
|
||||
if (realHasInstance.call(this, object)) return true;
|
||||
if (this !== Writable) return false;
|
||||
|
||||
return object && object._writableState instanceof WritableState;
|
||||
}
|
||||
});
|
||||
} else {
|
||||
realHasInstance = function (object) {
|
||||
return object instanceof this;
|
||||
};
|
||||
}
|
||||
|
||||
function Writable(options) {
|
||||
Duplex = Duplex || require('./_stream_duplex');
|
||||
|
||||
// Writable ctor is applied to Duplexes, too.
|
||||
// `realHasInstance` is necessary because using plain `instanceof`
|
||||
// would return false, as no `_writableState` property is attached.
|
||||
|
||||
// Trying to use the custom `instanceof` for Writable here will also break the
|
||||
// Node.js LazyTransform implementation, which has a non-trivial getter for
|
||||
// `_writableState` that would lead to infinite recursion.
|
||||
if (!realHasInstance.call(Writable, this) && !(this instanceof Duplex)) {
|
||||
return new Writable(options);
|
||||
}
|
||||
|
||||
this._writableState = new WritableState(options, this);
|
||||
|
||||
// legacy.
|
||||
this.writable = true;
|
||||
|
||||
if (options) {
|
||||
if (typeof options.write === 'function') this._write = options.write;
|
||||
|
||||
if (typeof options.writev === 'function') this._writev = options.writev;
|
||||
|
||||
if (typeof options.destroy === 'function') this._destroy = options.destroy;
|
||||
|
||||
if (typeof options.final === 'function') this._final = options.final;
|
||||
}
|
||||
|
||||
Stream.call(this);
|
||||
}
|
||||
|
||||
// Otherwise people can pipe Writable streams, which is just wrong.
|
||||
Writable.prototype.pipe = function () {
|
||||
this.emit('error', new Error('Cannot pipe, not readable'));
|
||||
};
|
||||
|
||||
function writeAfterEnd(stream, cb) {
|
||||
var er = new Error('write after end');
|
||||
// TODO: defer error events consistently everywhere, not just the cb
|
||||
stream.emit('error', er);
|
||||
pna.nextTick(cb, er);
|
||||
}
|
||||
|
||||
// Checks that a user-supplied chunk is valid, especially for the particular
|
||||
// mode the stream is in. Currently this means that `null` is never accepted
|
||||
// and undefined/non-string values are only allowed in object mode.
|
||||
function validChunk(stream, state, chunk, cb) {
|
||||
var valid = true;
|
||||
var er = false;
|
||||
|
||||
if (chunk === null) {
|
||||
er = new TypeError('May not write null values to stream');
|
||||
} else if (typeof chunk !== 'string' && chunk !== undefined && !state.objectMode) {
|
||||
er = new TypeError('Invalid non-string/buffer chunk');
|
||||
}
|
||||
if (er) {
|
||||
stream.emit('error', er);
|
||||
pna.nextTick(cb, er);
|
||||
valid = false;
|
||||
}
|
||||
return valid;
|
||||
}
|
||||
|
||||
Writable.prototype.write = function (chunk, encoding, cb) {
|
||||
var state = this._writableState;
|
||||
var ret = false;
|
||||
var isBuf = !state.objectMode && _isUint8Array(chunk);
|
||||
|
||||
if (isBuf && !Buffer.isBuffer(chunk)) {
|
||||
chunk = _uint8ArrayToBuffer(chunk);
|
||||
}
|
||||
|
||||
if (typeof encoding === 'function') {
|
||||
cb = encoding;
|
||||
encoding = null;
|
||||
}
|
||||
|
||||
if (isBuf) encoding = 'buffer';else if (!encoding) encoding = state.defaultEncoding;
|
||||
|
||||
if (typeof cb !== 'function') cb = nop;
|
||||
|
||||
if (state.ended) writeAfterEnd(this, cb);else if (isBuf || validChunk(this, state, chunk, cb)) {
|
||||
state.pendingcb++;
|
||||
ret = writeOrBuffer(this, state, isBuf, chunk, encoding, cb);
|
||||
}
|
||||
|
||||
return ret;
|
||||
};
|
||||
|
||||
Writable.prototype.cork = function () {
|
||||
var state = this._writableState;
|
||||
|
||||
state.corked++;
|
||||
};
|
||||
|
||||
Writable.prototype.uncork = function () {
|
||||
var state = this._writableState;
|
||||
|
||||
if (state.corked) {
|
||||
state.corked--;
|
||||
|
||||
if (!state.writing && !state.corked && !state.bufferProcessing && state.bufferedRequest) clearBuffer(this, state);
|
||||
}
|
||||
};
|
||||
|
||||
Writable.prototype.setDefaultEncoding = function setDefaultEncoding(encoding) {
|
||||
// node::ParseEncoding() requires lower case.
|
||||
if (typeof encoding === 'string') encoding = encoding.toLowerCase();
|
||||
if (!(['hex', 'utf8', 'utf-8', 'ascii', 'binary', 'base64', 'ucs2', 'ucs-2', 'utf16le', 'utf-16le', 'raw'].indexOf((encoding + '').toLowerCase()) > -1)) throw new TypeError('Unknown encoding: ' + encoding);
|
||||
this._writableState.defaultEncoding = encoding;
|
||||
return this;
|
||||
};
|
||||
|
||||
function decodeChunk(state, chunk, encoding) {
|
||||
if (!state.objectMode && state.decodeStrings !== false && typeof chunk === 'string') {
|
||||
chunk = Buffer.from(chunk, encoding);
|
||||
}
|
||||
return chunk;
|
||||
}
|
||||
|
||||
Object.defineProperty(Writable.prototype, 'writableHighWaterMark', {
|
||||
// making it explicit this property is not enumerable
|
||||
// because otherwise some prototype manipulation in
|
||||
// userland will fail
|
||||
enumerable: false,
|
||||
get: function () {
|
||||
return this._writableState.highWaterMark;
|
||||
}
|
||||
});
|
||||
|
||||
// if we're already writing something, then just put this
|
||||
// in the queue, and wait our turn. Otherwise, call _write
|
||||
// If we return false, then we need a drain event, so set that flag.
|
||||
function writeOrBuffer(stream, state, isBuf, chunk, encoding, cb) {
|
||||
if (!isBuf) {
|
||||
var newChunk = decodeChunk(state, chunk, encoding);
|
||||
if (chunk !== newChunk) {
|
||||
isBuf = true;
|
||||
encoding = 'buffer';
|
||||
chunk = newChunk;
|
||||
}
|
||||
}
|
||||
var len = state.objectMode ? 1 : chunk.length;
|
||||
|
||||
state.length += len;
|
||||
|
||||
var ret = state.length < state.highWaterMark;
|
||||
// we must ensure that previous needDrain will not be reset to false.
|
||||
if (!ret) state.needDrain = true;
|
||||
|
||||
if (state.writing || state.corked) {
|
||||
var last = state.lastBufferedRequest;
|
||||
state.lastBufferedRequest = {
|
||||
chunk: chunk,
|
||||
encoding: encoding,
|
||||
isBuf: isBuf,
|
||||
callback: cb,
|
||||
next: null
|
||||
};
|
||||
if (last) {
|
||||
last.next = state.lastBufferedRequest;
|
||||
} else {
|
||||
state.bufferedRequest = state.lastBufferedRequest;
|
||||
}
|
||||
state.bufferedRequestCount += 1;
|
||||
} else {
|
||||
doWrite(stream, state, false, len, chunk, encoding, cb);
|
||||
}
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
function doWrite(stream, state, writev, len, chunk, encoding, cb) {
|
||||
state.writelen = len;
|
||||
state.writecb = cb;
|
||||
state.writing = true;
|
||||
state.sync = true;
|
||||
if (writev) stream._writev(chunk, state.onwrite);else stream._write(chunk, encoding, state.onwrite);
|
||||
state.sync = false;
|
||||
}
|
||||
|
||||
function onwriteError(stream, state, sync, er, cb) {
|
||||
--state.pendingcb;
|
||||
|
||||
if (sync) {
|
||||
// defer the callback if we are being called synchronously
|
||||
// to avoid piling up things on the stack
|
||||
pna.nextTick(cb, er);
|
||||
// this can emit finish, and it will always happen
|
||||
// after error
|
||||
pna.nextTick(finishMaybe, stream, state);
|
||||
stream._writableState.errorEmitted = true;
|
||||
stream.emit('error', er);
|
||||
} else {
|
||||
// the caller expect this to happen before if
|
||||
// it is async
|
||||
cb(er);
|
||||
stream._writableState.errorEmitted = true;
|
||||
stream.emit('error', er);
|
||||
// this can emit finish, but finish must
|
||||
// always follow error
|
||||
finishMaybe(stream, state);
|
||||
}
|
||||
}
|
||||
|
||||
function onwriteStateUpdate(state) {
|
||||
state.writing = false;
|
||||
state.writecb = null;
|
||||
state.length -= state.writelen;
|
||||
state.writelen = 0;
|
||||
}
|
||||
|
||||
function onwrite(stream, er) {
|
||||
var state = stream._writableState;
|
||||
var sync = state.sync;
|
||||
var cb = state.writecb;
|
||||
|
||||
onwriteStateUpdate(state);
|
||||
|
||||
if (er) onwriteError(stream, state, sync, er, cb);else {
|
||||
// Check if we're actually ready to finish, but don't emit yet
|
||||
var finished = needFinish(state);
|
||||
|
||||
if (!finished && !state.corked && !state.bufferProcessing && state.bufferedRequest) {
|
||||
clearBuffer(stream, state);
|
||||
}
|
||||
|
||||
if (sync) {
|
||||
/*<replacement>*/
|
||||
asyncWrite(afterWrite, stream, state, finished, cb);
|
||||
/*</replacement>*/
|
||||
} else {
|
||||
afterWrite(stream, state, finished, cb);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
function afterWrite(stream, state, finished, cb) {
|
||||
if (!finished) onwriteDrain(stream, state);
|
||||
state.pendingcb--;
|
||||
cb();
|
||||
finishMaybe(stream, state);
|
||||
}
|
||||
|
||||
// Must force callback to be called on nextTick, so that we don't
|
||||
// emit 'drain' before the write() consumer gets the 'false' return
|
||||
// value, and has a chance to attach a 'drain' listener.
|
||||
function onwriteDrain(stream, state) {
|
||||
if (state.length === 0 && state.needDrain) {
|
||||
state.needDrain = false;
|
||||
stream.emit('drain');
|
||||
}
|
||||
}
|
||||
|
||||
// if there's something in the buffer waiting, then process it
|
||||
function clearBuffer(stream, state) {
|
||||
state.bufferProcessing = true;
|
||||
var entry = state.bufferedRequest;
|
||||
|
||||
if (stream._writev && entry && entry.next) {
|
||||
// Fast case, write everything using _writev()
|
||||
var l = state.bufferedRequestCount;
|
||||
var buffer = new Array(l);
|
||||
var holder = state.corkedRequestsFree;
|
||||
holder.entry = entry;
|
||||
|
||||
var count = 0;
|
||||
var allBuffers = true;
|
||||
while (entry) {
|
||||
buffer[count] = entry;
|
||||
if (!entry.isBuf) allBuffers = false;
|
||||
entry = entry.next;
|
||||
count += 1;
|
||||
}
|
||||
buffer.allBuffers = allBuffers;
|
||||
|
||||
doWrite(stream, state, true, state.length, buffer, '', holder.finish);
|
||||
|
||||
// doWrite is almost always async, defer these to save a bit of time
|
||||
// as the hot path ends with doWrite
|
||||
state.pendingcb++;
|
||||
state.lastBufferedRequest = null;
|
||||
if (holder.next) {
|
||||
state.corkedRequestsFree = holder.next;
|
||||
holder.next = null;
|
||||
} else {
|
||||
state.corkedRequestsFree = new CorkedRequest(state);
|
||||
}
|
||||
state.bufferedRequestCount = 0;
|
||||
} else {
|
||||
// Slow case, write chunks one-by-one
|
||||
while (entry) {
|
||||
var chunk = entry.chunk;
|
||||
var encoding = entry.encoding;
|
||||
var cb = entry.callback;
|
||||
var len = state.objectMode ? 1 : chunk.length;
|
||||
|
||||
doWrite(stream, state, false, len, chunk, encoding, cb);
|
||||
entry = entry.next;
|
||||
state.bufferedRequestCount--;
|
||||
// if we didn't call the onwrite immediately, then
|
||||
// it means that we need to wait until it does.
|
||||
// also, that means that the chunk and cb are currently
|
||||
// being processed, so move the buffer counter past them.
|
||||
if (state.writing) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (entry === null) state.lastBufferedRequest = null;
|
||||
}
|
||||
|
||||
state.bufferedRequest = entry;
|
||||
state.bufferProcessing = false;
|
||||
}
|
||||
|
||||
Writable.prototype._write = function (chunk, encoding, cb) {
|
||||
cb(new Error('_write() is not implemented'));
|
||||
};
|
||||
|
||||
Writable.prototype._writev = null;
|
||||
|
||||
Writable.prototype.end = function (chunk, encoding, cb) {
|
||||
var state = this._writableState;
|
||||
|
||||
if (typeof chunk === 'function') {
|
||||
cb = chunk;
|
||||
chunk = null;
|
||||
encoding = null;
|
||||
} else if (typeof encoding === 'function') {
|
||||
cb = encoding;
|
||||
encoding = null;
|
||||
}
|
||||
|
||||
if (chunk !== null && chunk !== undefined) this.write(chunk, encoding);
|
||||
|
||||
// .end() fully uncorks
|
||||
if (state.corked) {
|
||||
state.corked = 1;
|
||||
this.uncork();
|
||||
}
|
||||
|
||||
// ignore unnecessary end() calls.
|
||||
if (!state.ending) endWritable(this, state, cb);
|
||||
};
|
||||
|
||||
function needFinish(state) {
|
||||
return state.ending && state.length === 0 && state.bufferedRequest === null && !state.finished && !state.writing;
|
||||
}
|
||||
function callFinal(stream, state) {
|
||||
stream._final(function (err) {
|
||||
state.pendingcb--;
|
||||
if (err) {
|
||||
stream.emit('error', err);
|
||||
}
|
||||
state.prefinished = true;
|
||||
stream.emit('prefinish');
|
||||
finishMaybe(stream, state);
|
||||
});
|
||||
}
|
||||
function prefinish(stream, state) {
|
||||
if (!state.prefinished && !state.finalCalled) {
|
||||
if (typeof stream._final === 'function') {
|
||||
state.pendingcb++;
|
||||
state.finalCalled = true;
|
||||
pna.nextTick(callFinal, stream, state);
|
||||
} else {
|
||||
state.prefinished = true;
|
||||
stream.emit('prefinish');
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
function finishMaybe(stream, state) {
|
||||
var need = needFinish(state);
|
||||
if (need) {
|
||||
prefinish(stream, state);
|
||||
if (state.pendingcb === 0) {
|
||||
state.finished = true;
|
||||
stream.emit('finish');
|
||||
}
|
||||
}
|
||||
return need;
|
||||
}
|
||||
|
||||
function endWritable(stream, state, cb) {
|
||||
state.ending = true;
|
||||
finishMaybe(stream, state);
|
||||
if (cb) {
|
||||
if (state.finished) pna.nextTick(cb);else stream.once('finish', cb);
|
||||
}
|
||||
state.ended = true;
|
||||
stream.writable = false;
|
||||
}
|
||||
|
||||
function onCorkedFinish(corkReq, state, err) {
|
||||
var entry = corkReq.entry;
|
||||
corkReq.entry = null;
|
||||
while (entry) {
|
||||
var cb = entry.callback;
|
||||
state.pendingcb--;
|
||||
cb(err);
|
||||
entry = entry.next;
|
||||
}
|
||||
|
||||
// reuse the free corkReq.
|
||||
state.corkedRequestsFree.next = corkReq;
|
||||
}
|
||||
|
||||
Object.defineProperty(Writable.prototype, 'destroyed', {
|
||||
get: function () {
|
||||
if (this._writableState === undefined) {
|
||||
return false;
|
||||
}
|
||||
return this._writableState.destroyed;
|
||||
},
|
||||
set: function (value) {
|
||||
// we ignore the value if the stream
|
||||
// has not been initialized yet
|
||||
if (!this._writableState) {
|
||||
return;
|
||||
}
|
||||
|
||||
// backward compatibility, the user is explicitly
|
||||
// managing destroyed
|
||||
this._writableState.destroyed = value;
|
||||
}
|
||||
});
|
||||
|
||||
Writable.prototype.destroy = destroyImpl.destroy;
|
||||
Writable.prototype._undestroy = destroyImpl.undestroy;
|
||||
Writable.prototype._destroy = function (err, cb) {
|
||||
this.end();
|
||||
cb(err);
|
||||
};
|
||||
78
node_modules/browserify/node_modules/readable-stream/lib/internal/streams/BufferList.js
generated
vendored
Normal file
78
node_modules/browserify/node_modules/readable-stream/lib/internal/streams/BufferList.js
generated
vendored
Normal file
@@ -0,0 +1,78 @@
|
||||
'use strict';
|
||||
|
||||
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
|
||||
|
||||
var Buffer = require('safe-buffer').Buffer;
|
||||
var util = require('util');
|
||||
|
||||
function copyBuffer(src, target, offset) {
|
||||
src.copy(target, offset);
|
||||
}
|
||||
|
||||
module.exports = function () {
|
||||
function BufferList() {
|
||||
_classCallCheck(this, BufferList);
|
||||
|
||||
this.head = null;
|
||||
this.tail = null;
|
||||
this.length = 0;
|
||||
}
|
||||
|
||||
BufferList.prototype.push = function push(v) {
|
||||
var entry = { data: v, next: null };
|
||||
if (this.length > 0) this.tail.next = entry;else this.head = entry;
|
||||
this.tail = entry;
|
||||
++this.length;
|
||||
};
|
||||
|
||||
BufferList.prototype.unshift = function unshift(v) {
|
||||
var entry = { data: v, next: this.head };
|
||||
if (this.length === 0) this.tail = entry;
|
||||
this.head = entry;
|
||||
++this.length;
|
||||
};
|
||||
|
||||
BufferList.prototype.shift = function shift() {
|
||||
if (this.length === 0) return;
|
||||
var ret = this.head.data;
|
||||
if (this.length === 1) this.head = this.tail = null;else this.head = this.head.next;
|
||||
--this.length;
|
||||
return ret;
|
||||
};
|
||||
|
||||
BufferList.prototype.clear = function clear() {
|
||||
this.head = this.tail = null;
|
||||
this.length = 0;
|
||||
};
|
||||
|
||||
BufferList.prototype.join = function join(s) {
|
||||
if (this.length === 0) return '';
|
||||
var p = this.head;
|
||||
var ret = '' + p.data;
|
||||
while (p = p.next) {
|
||||
ret += s + p.data;
|
||||
}return ret;
|
||||
};
|
||||
|
||||
BufferList.prototype.concat = function concat(n) {
|
||||
if (this.length === 0) return Buffer.alloc(0);
|
||||
var ret = Buffer.allocUnsafe(n >>> 0);
|
||||
var p = this.head;
|
||||
var i = 0;
|
||||
while (p) {
|
||||
copyBuffer(p.data, ret, i);
|
||||
i += p.data.length;
|
||||
p = p.next;
|
||||
}
|
||||
return ret;
|
||||
};
|
||||
|
||||
return BufferList;
|
||||
}();
|
||||
|
||||
if (util && util.inspect && util.inspect.custom) {
|
||||
module.exports.prototype[util.inspect.custom] = function () {
|
||||
var obj = util.inspect({ length: this.length });
|
||||
return this.constructor.name + ' ' + obj;
|
||||
};
|
||||
}
|
||||
84
node_modules/browserify/node_modules/readable-stream/lib/internal/streams/destroy.js
generated
vendored
Normal file
84
node_modules/browserify/node_modules/readable-stream/lib/internal/streams/destroy.js
generated
vendored
Normal file
@@ -0,0 +1,84 @@
|
||||
'use strict';
|
||||
|
||||
/*<replacement>*/
|
||||
|
||||
var pna = require('process-nextick-args');
|
||||
/*</replacement>*/
|
||||
|
||||
// undocumented cb() API, needed for core, not for public API
|
||||
function destroy(err, cb) {
|
||||
var _this = this;
|
||||
|
||||
var readableDestroyed = this._readableState && this._readableState.destroyed;
|
||||
var writableDestroyed = this._writableState && this._writableState.destroyed;
|
||||
|
||||
if (readableDestroyed || writableDestroyed) {
|
||||
if (cb) {
|
||||
cb(err);
|
||||
} else if (err) {
|
||||
if (!this._writableState) {
|
||||
pna.nextTick(emitErrorNT, this, err);
|
||||
} else if (!this._writableState.errorEmitted) {
|
||||
this._writableState.errorEmitted = true;
|
||||
pna.nextTick(emitErrorNT, this, err);
|
||||
}
|
||||
}
|
||||
|
||||
return this;
|
||||
}
|
||||
|
||||
// we set destroyed to true before firing error callbacks in order
|
||||
// to make it re-entrance safe in case destroy() is called within callbacks
|
||||
|
||||
if (this._readableState) {
|
||||
this._readableState.destroyed = true;
|
||||
}
|
||||
|
||||
// if this is a duplex stream mark the writable part as destroyed as well
|
||||
if (this._writableState) {
|
||||
this._writableState.destroyed = true;
|
||||
}
|
||||
|
||||
this._destroy(err || null, function (err) {
|
||||
if (!cb && err) {
|
||||
if (!_this._writableState) {
|
||||
pna.nextTick(emitErrorNT, _this, err);
|
||||
} else if (!_this._writableState.errorEmitted) {
|
||||
_this._writableState.errorEmitted = true;
|
||||
pna.nextTick(emitErrorNT, _this, err);
|
||||
}
|
||||
} else if (cb) {
|
||||
cb(err);
|
||||
}
|
||||
});
|
||||
|
||||
return this;
|
||||
}
|
||||
|
||||
function undestroy() {
|
||||
if (this._readableState) {
|
||||
this._readableState.destroyed = false;
|
||||
this._readableState.reading = false;
|
||||
this._readableState.ended = false;
|
||||
this._readableState.endEmitted = false;
|
||||
}
|
||||
|
||||
if (this._writableState) {
|
||||
this._writableState.destroyed = false;
|
||||
this._writableState.ended = false;
|
||||
this._writableState.ending = false;
|
||||
this._writableState.finalCalled = false;
|
||||
this._writableState.prefinished = false;
|
||||
this._writableState.finished = false;
|
||||
this._writableState.errorEmitted = false;
|
||||
}
|
||||
}
|
||||
|
||||
function emitErrorNT(self, err) {
|
||||
self.emit('error', err);
|
||||
}
|
||||
|
||||
module.exports = {
|
||||
destroy: destroy,
|
||||
undestroy: undestroy
|
||||
};
|
||||
1
node_modules/browserify/node_modules/readable-stream/lib/internal/streams/stream-browser.js
generated
vendored
Normal file
1
node_modules/browserify/node_modules/readable-stream/lib/internal/streams/stream-browser.js
generated
vendored
Normal file
@@ -0,0 +1 @@
|
||||
module.exports = require('events').EventEmitter;
|
||||
1
node_modules/browserify/node_modules/readable-stream/lib/internal/streams/stream.js
generated
vendored
Normal file
1
node_modules/browserify/node_modules/readable-stream/lib/internal/streams/stream.js
generated
vendored
Normal file
@@ -0,0 +1 @@
|
||||
module.exports = require('stream');
|
||||
52
node_modules/browserify/node_modules/readable-stream/package.json
generated
vendored
Normal file
52
node_modules/browserify/node_modules/readable-stream/package.json
generated
vendored
Normal file
@@ -0,0 +1,52 @@
|
||||
{
|
||||
"name": "readable-stream",
|
||||
"version": "2.3.8",
|
||||
"description": "Streams3, a user-land copy of the stream library from Node.js",
|
||||
"main": "readable.js",
|
||||
"dependencies": {
|
||||
"core-util-is": "~1.0.0",
|
||||
"inherits": "~2.0.3",
|
||||
"isarray": "~1.0.0",
|
||||
"process-nextick-args": "~2.0.0",
|
||||
"safe-buffer": "~5.1.1",
|
||||
"string_decoder": "~1.1.1",
|
||||
"util-deprecate": "~1.0.1"
|
||||
},
|
||||
"devDependencies": {
|
||||
"assert": "^1.4.0",
|
||||
"babel-polyfill": "^6.9.1",
|
||||
"buffer": "^4.9.0",
|
||||
"lolex": "^2.3.2",
|
||||
"nyc": "^6.4.0",
|
||||
"tap": "^0.7.0",
|
||||
"tape": "^4.8.0"
|
||||
},
|
||||
"scripts": {
|
||||
"test": "tap test/parallel/*.js test/ours/*.js && node test/verify-dependencies.js",
|
||||
"ci": "tap test/parallel/*.js test/ours/*.js --tap | tee test.tap && node test/verify-dependencies.js",
|
||||
"cover": "nyc npm test",
|
||||
"report": "nyc report --reporter=lcov"
|
||||
},
|
||||
"repository": {
|
||||
"type": "git",
|
||||
"url": "git://github.com/nodejs/readable-stream"
|
||||
},
|
||||
"keywords": [
|
||||
"readable",
|
||||
"stream",
|
||||
"pipe"
|
||||
],
|
||||
"browser": {
|
||||
"util": false,
|
||||
"./readable.js": "./readable-browser.js",
|
||||
"./writable.js": "./writable-browser.js",
|
||||
"./duplex.js": "./duplex-browser.js",
|
||||
"./lib/internal/streams/stream.js": "./lib/internal/streams/stream-browser.js"
|
||||
},
|
||||
"nyc": {
|
||||
"include": [
|
||||
"lib/**.js"
|
||||
]
|
||||
},
|
||||
"license": "MIT"
|
||||
}
|
||||
1
node_modules/browserify/node_modules/readable-stream/passthrough.js
generated
vendored
Normal file
1
node_modules/browserify/node_modules/readable-stream/passthrough.js
generated
vendored
Normal file
@@ -0,0 +1 @@
|
||||
module.exports = require('./readable').PassThrough
|
||||
7
node_modules/browserify/node_modules/readable-stream/readable-browser.js
generated
vendored
Normal file
7
node_modules/browserify/node_modules/readable-stream/readable-browser.js
generated
vendored
Normal file
@@ -0,0 +1,7 @@
|
||||
exports = module.exports = require('./lib/_stream_readable.js');
|
||||
exports.Stream = exports;
|
||||
exports.Readable = exports;
|
||||
exports.Writable = require('./lib/_stream_writable.js');
|
||||
exports.Duplex = require('./lib/_stream_duplex.js');
|
||||
exports.Transform = require('./lib/_stream_transform.js');
|
||||
exports.PassThrough = require('./lib/_stream_passthrough.js');
|
||||
19
node_modules/browserify/node_modules/readable-stream/readable.js
generated
vendored
Normal file
19
node_modules/browserify/node_modules/readable-stream/readable.js
generated
vendored
Normal file
@@ -0,0 +1,19 @@
|
||||
var Stream = require('stream');
|
||||
if (process.env.READABLE_STREAM === 'disable' && Stream) {
|
||||
module.exports = Stream;
|
||||
exports = module.exports = Stream.Readable;
|
||||
exports.Readable = Stream.Readable;
|
||||
exports.Writable = Stream.Writable;
|
||||
exports.Duplex = Stream.Duplex;
|
||||
exports.Transform = Stream.Transform;
|
||||
exports.PassThrough = Stream.PassThrough;
|
||||
exports.Stream = Stream;
|
||||
} else {
|
||||
exports = module.exports = require('./lib/_stream_readable.js');
|
||||
exports.Stream = Stream || exports;
|
||||
exports.Readable = exports;
|
||||
exports.Writable = require('./lib/_stream_writable.js');
|
||||
exports.Duplex = require('./lib/_stream_duplex.js');
|
||||
exports.Transform = require('./lib/_stream_transform.js');
|
||||
exports.PassThrough = require('./lib/_stream_passthrough.js');
|
||||
}
|
||||
1
node_modules/browserify/node_modules/readable-stream/transform.js
generated
vendored
Normal file
1
node_modules/browserify/node_modules/readable-stream/transform.js
generated
vendored
Normal file
@@ -0,0 +1 @@
|
||||
module.exports = require('./readable').Transform
|
||||
1
node_modules/browserify/node_modules/readable-stream/writable-browser.js
generated
vendored
Normal file
1
node_modules/browserify/node_modules/readable-stream/writable-browser.js
generated
vendored
Normal file
@@ -0,0 +1 @@
|
||||
module.exports = require('./lib/_stream_writable.js');
|
||||
8
node_modules/browserify/node_modules/readable-stream/writable.js
generated
vendored
Normal file
8
node_modules/browserify/node_modules/readable-stream/writable.js
generated
vendored
Normal file
@@ -0,0 +1,8 @@
|
||||
var Stream = require("stream")
|
||||
var Writable = require("./lib/_stream_writable.js")
|
||||
|
||||
if (process.env.READABLE_STREAM === 'disable') {
|
||||
module.exports = Stream && Stream.Writable || Writable
|
||||
} else {
|
||||
module.exports = Writable
|
||||
}
|
||||
21
node_modules/browserify/node_modules/safe-buffer/LICENSE
generated
vendored
Normal file
21
node_modules/browserify/node_modules/safe-buffer/LICENSE
generated
vendored
Normal file
@@ -0,0 +1,21 @@
|
||||
The MIT License (MIT)
|
||||
|
||||
Copyright (c) Feross Aboukhadijeh
|
||||
|
||||
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.
|
||||
584
node_modules/browserify/node_modules/safe-buffer/README.md
generated
vendored
Normal file
584
node_modules/browserify/node_modules/safe-buffer/README.md
generated
vendored
Normal file
@@ -0,0 +1,584 @@
|
||||
# safe-buffer [![travis][travis-image]][travis-url] [![npm][npm-image]][npm-url] [![downloads][downloads-image]][downloads-url] [![javascript style guide][standard-image]][standard-url]
|
||||
|
||||
[travis-image]: https://img.shields.io/travis/feross/safe-buffer/master.svg
|
||||
[travis-url]: https://travis-ci.org/feross/safe-buffer
|
||||
[npm-image]: https://img.shields.io/npm/v/safe-buffer.svg
|
||||
[npm-url]: https://npmjs.org/package/safe-buffer
|
||||
[downloads-image]: https://img.shields.io/npm/dm/safe-buffer.svg
|
||||
[downloads-url]: https://npmjs.org/package/safe-buffer
|
||||
[standard-image]: https://img.shields.io/badge/code_style-standard-brightgreen.svg
|
||||
[standard-url]: https://standardjs.com
|
||||
|
||||
#### Safer Node.js Buffer API
|
||||
|
||||
**Use the new Node.js Buffer APIs (`Buffer.from`, `Buffer.alloc`,
|
||||
`Buffer.allocUnsafe`, `Buffer.allocUnsafeSlow`) in all versions of Node.js.**
|
||||
|
||||
**Uses the built-in implementation when available.**
|
||||
|
||||
## install
|
||||
|
||||
```
|
||||
npm install safe-buffer
|
||||
```
|
||||
|
||||
## usage
|
||||
|
||||
The goal of this package is to provide a safe replacement for the node.js `Buffer`.
|
||||
|
||||
It's a drop-in replacement for `Buffer`. You can use it by adding one `require` line to
|
||||
the top of your node.js modules:
|
||||
|
||||
```js
|
||||
var Buffer = require('safe-buffer').Buffer
|
||||
|
||||
// Existing buffer code will continue to work without issues:
|
||||
|
||||
new Buffer('hey', 'utf8')
|
||||
new Buffer([1, 2, 3], 'utf8')
|
||||
new Buffer(obj)
|
||||
new Buffer(16) // create an uninitialized buffer (potentially unsafe)
|
||||
|
||||
// But you can use these new explicit APIs to make clear what you want:
|
||||
|
||||
Buffer.from('hey', 'utf8') // convert from many types to a Buffer
|
||||
Buffer.alloc(16) // create a zero-filled buffer (safe)
|
||||
Buffer.allocUnsafe(16) // create an uninitialized buffer (potentially unsafe)
|
||||
```
|
||||
|
||||
## api
|
||||
|
||||
### Class Method: Buffer.from(array)
|
||||
<!-- YAML
|
||||
added: v3.0.0
|
||||
-->
|
||||
|
||||
* `array` {Array}
|
||||
|
||||
Allocates a new `Buffer` using an `array` of octets.
|
||||
|
||||
```js
|
||||
const buf = Buffer.from([0x62,0x75,0x66,0x66,0x65,0x72]);
|
||||
// creates a new Buffer containing ASCII bytes
|
||||
// ['b','u','f','f','e','r']
|
||||
```
|
||||
|
||||
A `TypeError` will be thrown if `array` is not an `Array`.
|
||||
|
||||
### Class Method: Buffer.from(arrayBuffer[, byteOffset[, length]])
|
||||
<!-- YAML
|
||||
added: v5.10.0
|
||||
-->
|
||||
|
||||
* `arrayBuffer` {ArrayBuffer} The `.buffer` property of a `TypedArray` or
|
||||
a `new ArrayBuffer()`
|
||||
* `byteOffset` {Number} Default: `0`
|
||||
* `length` {Number} Default: `arrayBuffer.length - byteOffset`
|
||||
|
||||
When passed a reference to the `.buffer` property of a `TypedArray` instance,
|
||||
the newly created `Buffer` will share the same allocated memory as the
|
||||
TypedArray.
|
||||
|
||||
```js
|
||||
const arr = new Uint16Array(2);
|
||||
arr[0] = 5000;
|
||||
arr[1] = 4000;
|
||||
|
||||
const buf = Buffer.from(arr.buffer); // shares the memory with arr;
|
||||
|
||||
console.log(buf);
|
||||
// Prints: <Buffer 88 13 a0 0f>
|
||||
|
||||
// changing the TypedArray changes the Buffer also
|
||||
arr[1] = 6000;
|
||||
|
||||
console.log(buf);
|
||||
// Prints: <Buffer 88 13 70 17>
|
||||
```
|
||||
|
||||
The optional `byteOffset` and `length` arguments specify a memory range within
|
||||
the `arrayBuffer` that will be shared by the `Buffer`.
|
||||
|
||||
```js
|
||||
const ab = new ArrayBuffer(10);
|
||||
const buf = Buffer.from(ab, 0, 2);
|
||||
console.log(buf.length);
|
||||
// Prints: 2
|
||||
```
|
||||
|
||||
A `TypeError` will be thrown if `arrayBuffer` is not an `ArrayBuffer`.
|
||||
|
||||
### Class Method: Buffer.from(buffer)
|
||||
<!-- YAML
|
||||
added: v3.0.0
|
||||
-->
|
||||
|
||||
* `buffer` {Buffer}
|
||||
|
||||
Copies the passed `buffer` data onto a new `Buffer` instance.
|
||||
|
||||
```js
|
||||
const buf1 = Buffer.from('buffer');
|
||||
const buf2 = Buffer.from(buf1);
|
||||
|
||||
buf1[0] = 0x61;
|
||||
console.log(buf1.toString());
|
||||
// 'auffer'
|
||||
console.log(buf2.toString());
|
||||
// 'buffer' (copy is not changed)
|
||||
```
|
||||
|
||||
A `TypeError` will be thrown if `buffer` is not a `Buffer`.
|
||||
|
||||
### Class Method: Buffer.from(str[, encoding])
|
||||
<!-- YAML
|
||||
added: v5.10.0
|
||||
-->
|
||||
|
||||
* `str` {String} String to encode.
|
||||
* `encoding` {String} Encoding to use, Default: `'utf8'`
|
||||
|
||||
Creates a new `Buffer` containing the given JavaScript string `str`. If
|
||||
provided, the `encoding` parameter identifies the character encoding.
|
||||
If not provided, `encoding` defaults to `'utf8'`.
|
||||
|
||||
```js
|
||||
const buf1 = Buffer.from('this is a tést');
|
||||
console.log(buf1.toString());
|
||||
// prints: this is a tést
|
||||
console.log(buf1.toString('ascii'));
|
||||
// prints: this is a tC)st
|
||||
|
||||
const buf2 = Buffer.from('7468697320697320612074c3a97374', 'hex');
|
||||
console.log(buf2.toString());
|
||||
// prints: this is a tést
|
||||
```
|
||||
|
||||
A `TypeError` will be thrown if `str` is not a string.
|
||||
|
||||
### Class Method: Buffer.alloc(size[, fill[, encoding]])
|
||||
<!-- YAML
|
||||
added: v5.10.0
|
||||
-->
|
||||
|
||||
* `size` {Number}
|
||||
* `fill` {Value} Default: `undefined`
|
||||
* `encoding` {String} Default: `utf8`
|
||||
|
||||
Allocates a new `Buffer` of `size` bytes. If `fill` is `undefined`, the
|
||||
`Buffer` will be *zero-filled*.
|
||||
|
||||
```js
|
||||
const buf = Buffer.alloc(5);
|
||||
console.log(buf);
|
||||
// <Buffer 00 00 00 00 00>
|
||||
```
|
||||
|
||||
The `size` must be less than or equal to the value of
|
||||
`require('buffer').kMaxLength` (on 64-bit architectures, `kMaxLength` is
|
||||
`(2^31)-1`). Otherwise, a [`RangeError`][] is thrown. A zero-length Buffer will
|
||||
be created if a `size` less than or equal to 0 is specified.
|
||||
|
||||
If `fill` is specified, the allocated `Buffer` will be initialized by calling
|
||||
`buf.fill(fill)`. See [`buf.fill()`][] for more information.
|
||||
|
||||
```js
|
||||
const buf = Buffer.alloc(5, 'a');
|
||||
console.log(buf);
|
||||
// <Buffer 61 61 61 61 61>
|
||||
```
|
||||
|
||||
If both `fill` and `encoding` are specified, the allocated `Buffer` will be
|
||||
initialized by calling `buf.fill(fill, encoding)`. For example:
|
||||
|
||||
```js
|
||||
const buf = Buffer.alloc(11, 'aGVsbG8gd29ybGQ=', 'base64');
|
||||
console.log(buf);
|
||||
// <Buffer 68 65 6c 6c 6f 20 77 6f 72 6c 64>
|
||||
```
|
||||
|
||||
Calling `Buffer.alloc(size)` can be significantly slower than the alternative
|
||||
`Buffer.allocUnsafe(size)` but ensures that the newly created `Buffer` instance
|
||||
contents will *never contain sensitive data*.
|
||||
|
||||
A `TypeError` will be thrown if `size` is not a number.
|
||||
|
||||
### Class Method: Buffer.allocUnsafe(size)
|
||||
<!-- YAML
|
||||
added: v5.10.0
|
||||
-->
|
||||
|
||||
* `size` {Number}
|
||||
|
||||
Allocates a new *non-zero-filled* `Buffer` of `size` bytes. The `size` must
|
||||
be less than or equal to the value of `require('buffer').kMaxLength` (on 64-bit
|
||||
architectures, `kMaxLength` is `(2^31)-1`). Otherwise, a [`RangeError`][] is
|
||||
thrown. A zero-length Buffer will be created if a `size` less than or equal to
|
||||
0 is specified.
|
||||
|
||||
The underlying memory for `Buffer` instances created in this way is *not
|
||||
initialized*. The contents of the newly created `Buffer` are unknown and
|
||||
*may contain sensitive data*. Use [`buf.fill(0)`][] to initialize such
|
||||
`Buffer` instances to zeroes.
|
||||
|
||||
```js
|
||||
const buf = Buffer.allocUnsafe(5);
|
||||
console.log(buf);
|
||||
// <Buffer 78 e0 82 02 01>
|
||||
// (octets will be different, every time)
|
||||
buf.fill(0);
|
||||
console.log(buf);
|
||||
// <Buffer 00 00 00 00 00>
|
||||
```
|
||||
|
||||
A `TypeError` will be thrown if `size` is not a number.
|
||||
|
||||
Note that the `Buffer` module pre-allocates an internal `Buffer` instance of
|
||||
size `Buffer.poolSize` that is used as a pool for the fast allocation of new
|
||||
`Buffer` instances created using `Buffer.allocUnsafe(size)` (and the deprecated
|
||||
`new Buffer(size)` constructor) only when `size` is less than or equal to
|
||||
`Buffer.poolSize >> 1` (floor of `Buffer.poolSize` divided by two). The default
|
||||
value of `Buffer.poolSize` is `8192` but can be modified.
|
||||
|
||||
Use of this pre-allocated internal memory pool is a key difference between
|
||||
calling `Buffer.alloc(size, fill)` vs. `Buffer.allocUnsafe(size).fill(fill)`.
|
||||
Specifically, `Buffer.alloc(size, fill)` will *never* use the internal Buffer
|
||||
pool, while `Buffer.allocUnsafe(size).fill(fill)` *will* use the internal
|
||||
Buffer pool if `size` is less than or equal to half `Buffer.poolSize`. The
|
||||
difference is subtle but can be important when an application requires the
|
||||
additional performance that `Buffer.allocUnsafe(size)` provides.
|
||||
|
||||
### Class Method: Buffer.allocUnsafeSlow(size)
|
||||
<!-- YAML
|
||||
added: v5.10.0
|
||||
-->
|
||||
|
||||
* `size` {Number}
|
||||
|
||||
Allocates a new *non-zero-filled* and non-pooled `Buffer` of `size` bytes. The
|
||||
`size` must be less than or equal to the value of
|
||||
`require('buffer').kMaxLength` (on 64-bit architectures, `kMaxLength` is
|
||||
`(2^31)-1`). Otherwise, a [`RangeError`][] is thrown. A zero-length Buffer will
|
||||
be created if a `size` less than or equal to 0 is specified.
|
||||
|
||||
The underlying memory for `Buffer` instances created in this way is *not
|
||||
initialized*. The contents of the newly created `Buffer` are unknown and
|
||||
*may contain sensitive data*. Use [`buf.fill(0)`][] to initialize such
|
||||
`Buffer` instances to zeroes.
|
||||
|
||||
When using `Buffer.allocUnsafe()` to allocate new `Buffer` instances,
|
||||
allocations under 4KB are, by default, sliced from a single pre-allocated
|
||||
`Buffer`. This allows applications to avoid the garbage collection overhead of
|
||||
creating many individually allocated Buffers. This approach improves both
|
||||
performance and memory usage by eliminating the need to track and cleanup as
|
||||
many `Persistent` objects.
|
||||
|
||||
However, in the case where a developer may need to retain a small chunk of
|
||||
memory from a pool for an indeterminate amount of time, it may be appropriate
|
||||
to create an un-pooled Buffer instance using `Buffer.allocUnsafeSlow()` then
|
||||
copy out the relevant bits.
|
||||
|
||||
```js
|
||||
// need to keep around a few small chunks of memory
|
||||
const store = [];
|
||||
|
||||
socket.on('readable', () => {
|
||||
const data = socket.read();
|
||||
// allocate for retained data
|
||||
const sb = Buffer.allocUnsafeSlow(10);
|
||||
// copy the data into the new allocation
|
||||
data.copy(sb, 0, 0, 10);
|
||||
store.push(sb);
|
||||
});
|
||||
```
|
||||
|
||||
Use of `Buffer.allocUnsafeSlow()` should be used only as a last resort *after*
|
||||
a developer has observed undue memory retention in their applications.
|
||||
|
||||
A `TypeError` will be thrown if `size` is not a number.
|
||||
|
||||
### All the Rest
|
||||
|
||||
The rest of the `Buffer` API is exactly the same as in node.js.
|
||||
[See the docs](https://nodejs.org/api/buffer.html).
|
||||
|
||||
|
||||
## Related links
|
||||
|
||||
- [Node.js issue: Buffer(number) is unsafe](https://github.com/nodejs/node/issues/4660)
|
||||
- [Node.js Enhancement Proposal: Buffer.from/Buffer.alloc/Buffer.zalloc/Buffer() soft-deprecate](https://github.com/nodejs/node-eps/pull/4)
|
||||
|
||||
## Why is `Buffer` unsafe?
|
||||
|
||||
Today, the node.js `Buffer` constructor is overloaded to handle many different argument
|
||||
types like `String`, `Array`, `Object`, `TypedArrayView` (`Uint8Array`, etc.),
|
||||
`ArrayBuffer`, and also `Number`.
|
||||
|
||||
The API is optimized for convenience: you can throw any type at it, and it will try to do
|
||||
what you want.
|
||||
|
||||
Because the Buffer constructor is so powerful, you often see code like this:
|
||||
|
||||
```js
|
||||
// Convert UTF-8 strings to hex
|
||||
function toHex (str) {
|
||||
return new Buffer(str).toString('hex')
|
||||
}
|
||||
```
|
||||
|
||||
***But what happens if `toHex` is called with a `Number` argument?***
|
||||
|
||||
### Remote Memory Disclosure
|
||||
|
||||
If an attacker can make your program call the `Buffer` constructor with a `Number`
|
||||
argument, then they can make it allocate uninitialized memory from the node.js process.
|
||||
This could potentially disclose TLS private keys, user data, or database passwords.
|
||||
|
||||
When the `Buffer` constructor is passed a `Number` argument, it returns an
|
||||
**UNINITIALIZED** block of memory of the specified `size`. When you create a `Buffer` like
|
||||
this, you **MUST** overwrite the contents before returning it to the user.
|
||||
|
||||
From the [node.js docs](https://nodejs.org/api/buffer.html#buffer_new_buffer_size):
|
||||
|
||||
> `new Buffer(size)`
|
||||
>
|
||||
> - `size` Number
|
||||
>
|
||||
> The underlying memory for `Buffer` instances created in this way is not initialized.
|
||||
> **The contents of a newly created `Buffer` are unknown and could contain sensitive
|
||||
> data.** Use `buf.fill(0)` to initialize a Buffer to zeroes.
|
||||
|
||||
(Emphasis our own.)
|
||||
|
||||
Whenever the programmer intended to create an uninitialized `Buffer` you often see code
|
||||
like this:
|
||||
|
||||
```js
|
||||
var buf = new Buffer(16)
|
||||
|
||||
// Immediately overwrite the uninitialized buffer with data from another buffer
|
||||
for (var i = 0; i < buf.length; i++) {
|
||||
buf[i] = otherBuf[i]
|
||||
}
|
||||
```
|
||||
|
||||
|
||||
### Would this ever be a problem in real code?
|
||||
|
||||
Yes. It's surprisingly common to forget to check the type of your variables in a
|
||||
dynamically-typed language like JavaScript.
|
||||
|
||||
Usually the consequences of assuming the wrong type is that your program crashes with an
|
||||
uncaught exception. But the failure mode for forgetting to check the type of arguments to
|
||||
the `Buffer` constructor is more catastrophic.
|
||||
|
||||
Here's an example of a vulnerable service that takes a JSON payload and converts it to
|
||||
hex:
|
||||
|
||||
```js
|
||||
// Take a JSON payload {str: "some string"} and convert it to hex
|
||||
var server = http.createServer(function (req, res) {
|
||||
var data = ''
|
||||
req.setEncoding('utf8')
|
||||
req.on('data', function (chunk) {
|
||||
data += chunk
|
||||
})
|
||||
req.on('end', function () {
|
||||
var body = JSON.parse(data)
|
||||
res.end(new Buffer(body.str).toString('hex'))
|
||||
})
|
||||
})
|
||||
|
||||
server.listen(8080)
|
||||
```
|
||||
|
||||
In this example, an http client just has to send:
|
||||
|
||||
```json
|
||||
{
|
||||
"str": 1000
|
||||
}
|
||||
```
|
||||
|
||||
and it will get back 1,000 bytes of uninitialized memory from the server.
|
||||
|
||||
This is a very serious bug. It's similar in severity to the
|
||||
[the Heartbleed bug](http://heartbleed.com/) that allowed disclosure of OpenSSL process
|
||||
memory by remote attackers.
|
||||
|
||||
|
||||
### Which real-world packages were vulnerable?
|
||||
|
||||
#### [`bittorrent-dht`](https://www.npmjs.com/package/bittorrent-dht)
|
||||
|
||||
[Mathias Buus](https://github.com/mafintosh) and I
|
||||
([Feross Aboukhadijeh](http://feross.org/)) found this issue in one of our own packages,
|
||||
[`bittorrent-dht`](https://www.npmjs.com/package/bittorrent-dht). The bug would allow
|
||||
anyone on the internet to send a series of messages to a user of `bittorrent-dht` and get
|
||||
them to reveal 20 bytes at a time of uninitialized memory from the node.js process.
|
||||
|
||||
Here's
|
||||
[the commit](https://github.com/feross/bittorrent-dht/commit/6c7da04025d5633699800a99ec3fbadf70ad35b8)
|
||||
that fixed it. We released a new fixed version, created a
|
||||
[Node Security Project disclosure](https://nodesecurity.io/advisories/68), and deprecated all
|
||||
vulnerable versions on npm so users will get a warning to upgrade to a newer version.
|
||||
|
||||
#### [`ws`](https://www.npmjs.com/package/ws)
|
||||
|
||||
That got us wondering if there were other vulnerable packages. Sure enough, within a short
|
||||
period of time, we found the same issue in [`ws`](https://www.npmjs.com/package/ws), the
|
||||
most popular WebSocket implementation in node.js.
|
||||
|
||||
If certain APIs were called with `Number` parameters instead of `String` or `Buffer` as
|
||||
expected, then uninitialized server memory would be disclosed to the remote peer.
|
||||
|
||||
These were the vulnerable methods:
|
||||
|
||||
```js
|
||||
socket.send(number)
|
||||
socket.ping(number)
|
||||
socket.pong(number)
|
||||
```
|
||||
|
||||
Here's a vulnerable socket server with some echo functionality:
|
||||
|
||||
```js
|
||||
server.on('connection', function (socket) {
|
||||
socket.on('message', function (message) {
|
||||
message = JSON.parse(message)
|
||||
if (message.type === 'echo') {
|
||||
socket.send(message.data) // send back the user's message
|
||||
}
|
||||
})
|
||||
})
|
||||
```
|
||||
|
||||
`socket.send(number)` called on the server, will disclose server memory.
|
||||
|
||||
Here's [the release](https://github.com/websockets/ws/releases/tag/1.0.1) where the issue
|
||||
was fixed, with a more detailed explanation. Props to
|
||||
[Arnout Kazemier](https://github.com/3rd-Eden) for the quick fix. Here's the
|
||||
[Node Security Project disclosure](https://nodesecurity.io/advisories/67).
|
||||
|
||||
|
||||
### What's the solution?
|
||||
|
||||
It's important that node.js offers a fast way to get memory otherwise performance-critical
|
||||
applications would needlessly get a lot slower.
|
||||
|
||||
But we need a better way to *signal our intent* as programmers. **When we want
|
||||
uninitialized memory, we should request it explicitly.**
|
||||
|
||||
Sensitive functionality should not be packed into a developer-friendly API that loosely
|
||||
accepts many different types. This type of API encourages the lazy practice of passing
|
||||
variables in without checking the type very carefully.
|
||||
|
||||
#### A new API: `Buffer.allocUnsafe(number)`
|
||||
|
||||
The functionality of creating buffers with uninitialized memory should be part of another
|
||||
API. We propose `Buffer.allocUnsafe(number)`. This way, it's not part of an API that
|
||||
frequently gets user input of all sorts of different types passed into it.
|
||||
|
||||
```js
|
||||
var buf = Buffer.allocUnsafe(16) // careful, uninitialized memory!
|
||||
|
||||
// Immediately overwrite the uninitialized buffer with data from another buffer
|
||||
for (var i = 0; i < buf.length; i++) {
|
||||
buf[i] = otherBuf[i]
|
||||
}
|
||||
```
|
||||
|
||||
|
||||
### How do we fix node.js core?
|
||||
|
||||
We sent [a PR to node.js core](https://github.com/nodejs/node/pull/4514) (merged as
|
||||
`semver-major`) which defends against one case:
|
||||
|
||||
```js
|
||||
var str = 16
|
||||
new Buffer(str, 'utf8')
|
||||
```
|
||||
|
||||
In this situation, it's implied that the programmer intended the first argument to be a
|
||||
string, since they passed an encoding as a second argument. Today, node.js will allocate
|
||||
uninitialized memory in the case of `new Buffer(number, encoding)`, which is probably not
|
||||
what the programmer intended.
|
||||
|
||||
But this is only a partial solution, since if the programmer does `new Buffer(variable)`
|
||||
(without an `encoding` parameter) there's no way to know what they intended. If `variable`
|
||||
is sometimes a number, then uninitialized memory will sometimes be returned.
|
||||
|
||||
### What's the real long-term fix?
|
||||
|
||||
We could deprecate and remove `new Buffer(number)` and use `Buffer.allocUnsafe(number)` when
|
||||
we need uninitialized memory. But that would break 1000s of packages.
|
||||
|
||||
~~We believe the best solution is to:~~
|
||||
|
||||
~~1. Change `new Buffer(number)` to return safe, zeroed-out memory~~
|
||||
|
||||
~~2. Create a new API for creating uninitialized Buffers. We propose: `Buffer.allocUnsafe(number)`~~
|
||||
|
||||
#### Update
|
||||
|
||||
We now support adding three new APIs:
|
||||
|
||||
- `Buffer.from(value)` - convert from any type to a buffer
|
||||
- `Buffer.alloc(size)` - create a zero-filled buffer
|
||||
- `Buffer.allocUnsafe(size)` - create an uninitialized buffer with given size
|
||||
|
||||
This solves the core problem that affected `ws` and `bittorrent-dht` which is
|
||||
`Buffer(variable)` getting tricked into taking a number argument.
|
||||
|
||||
This way, existing code continues working and the impact on the npm ecosystem will be
|
||||
minimal. Over time, npm maintainers can migrate performance-critical code to use
|
||||
`Buffer.allocUnsafe(number)` instead of `new Buffer(number)`.
|
||||
|
||||
|
||||
### Conclusion
|
||||
|
||||
We think there's a serious design issue with the `Buffer` API as it exists today. It
|
||||
promotes insecure software by putting high-risk functionality into a convenient API
|
||||
with friendly "developer ergonomics".
|
||||
|
||||
This wasn't merely a theoretical exercise because we found the issue in some of the
|
||||
most popular npm packages.
|
||||
|
||||
Fortunately, there's an easy fix that can be applied today. Use `safe-buffer` in place of
|
||||
`buffer`.
|
||||
|
||||
```js
|
||||
var Buffer = require('safe-buffer').Buffer
|
||||
```
|
||||
|
||||
Eventually, we hope that node.js core can switch to this new, safer behavior. We believe
|
||||
the impact on the ecosystem would be minimal since it's not a breaking change.
|
||||
Well-maintained, popular packages would be updated to use `Buffer.alloc` quickly, while
|
||||
older, insecure packages would magically become safe from this attack vector.
|
||||
|
||||
|
||||
## links
|
||||
|
||||
- [Node.js PR: buffer: throw if both length and enc are passed](https://github.com/nodejs/node/pull/4514)
|
||||
- [Node Security Project disclosure for `ws`](https://nodesecurity.io/advisories/67)
|
||||
- [Node Security Project disclosure for`bittorrent-dht`](https://nodesecurity.io/advisories/68)
|
||||
|
||||
|
||||
## credit
|
||||
|
||||
The original issues in `bittorrent-dht`
|
||||
([disclosure](https://nodesecurity.io/advisories/68)) and
|
||||
`ws` ([disclosure](https://nodesecurity.io/advisories/67)) were discovered by
|
||||
[Mathias Buus](https://github.com/mafintosh) and
|
||||
[Feross Aboukhadijeh](http://feross.org/).
|
||||
|
||||
Thanks to [Adam Baldwin](https://github.com/evilpacket) for helping disclose these issues
|
||||
and for his work running the [Node Security Project](https://nodesecurity.io/).
|
||||
|
||||
Thanks to [John Hiesey](https://github.com/jhiesey) for proofreading this README and
|
||||
auditing the code.
|
||||
|
||||
|
||||
## license
|
||||
|
||||
MIT. Copyright (C) [Feross Aboukhadijeh](http://feross.org)
|
||||
187
node_modules/browserify/node_modules/safe-buffer/index.d.ts
generated
vendored
Normal file
187
node_modules/browserify/node_modules/safe-buffer/index.d.ts
generated
vendored
Normal file
@@ -0,0 +1,187 @@
|
||||
declare module "safe-buffer" {
|
||||
export class Buffer {
|
||||
length: number
|
||||
write(string: string, offset?: number, length?: number, encoding?: string): number;
|
||||
toString(encoding?: string, start?: number, end?: number): string;
|
||||
toJSON(): { type: 'Buffer', data: any[] };
|
||||
equals(otherBuffer: Buffer): boolean;
|
||||
compare(otherBuffer: Buffer, targetStart?: number, targetEnd?: number, sourceStart?: number, sourceEnd?: number): number;
|
||||
copy(targetBuffer: Buffer, targetStart?: number, sourceStart?: number, sourceEnd?: number): number;
|
||||
slice(start?: number, end?: number): Buffer;
|
||||
writeUIntLE(value: number, offset: number, byteLength: number, noAssert?: boolean): number;
|
||||
writeUIntBE(value: number, offset: number, byteLength: number, noAssert?: boolean): number;
|
||||
writeIntLE(value: number, offset: number, byteLength: number, noAssert?: boolean): number;
|
||||
writeIntBE(value: number, offset: number, byteLength: number, noAssert?: boolean): number;
|
||||
readUIntLE(offset: number, byteLength: number, noAssert?: boolean): number;
|
||||
readUIntBE(offset: number, byteLength: number, noAssert?: boolean): number;
|
||||
readIntLE(offset: number, byteLength: number, noAssert?: boolean): number;
|
||||
readIntBE(offset: number, byteLength: number, noAssert?: boolean): number;
|
||||
readUInt8(offset: number, noAssert?: boolean): number;
|
||||
readUInt16LE(offset: number, noAssert?: boolean): number;
|
||||
readUInt16BE(offset: number, noAssert?: boolean): number;
|
||||
readUInt32LE(offset: number, noAssert?: boolean): number;
|
||||
readUInt32BE(offset: number, noAssert?: boolean): number;
|
||||
readInt8(offset: number, noAssert?: boolean): number;
|
||||
readInt16LE(offset: number, noAssert?: boolean): number;
|
||||
readInt16BE(offset: number, noAssert?: boolean): number;
|
||||
readInt32LE(offset: number, noAssert?: boolean): number;
|
||||
readInt32BE(offset: number, noAssert?: boolean): number;
|
||||
readFloatLE(offset: number, noAssert?: boolean): number;
|
||||
readFloatBE(offset: number, noAssert?: boolean): number;
|
||||
readDoubleLE(offset: number, noAssert?: boolean): number;
|
||||
readDoubleBE(offset: number, noAssert?: boolean): number;
|
||||
swap16(): Buffer;
|
||||
swap32(): Buffer;
|
||||
swap64(): Buffer;
|
||||
writeUInt8(value: number, offset: number, noAssert?: boolean): number;
|
||||
writeUInt16LE(value: number, offset: number, noAssert?: boolean): number;
|
||||
writeUInt16BE(value: number, offset: number, noAssert?: boolean): number;
|
||||
writeUInt32LE(value: number, offset: number, noAssert?: boolean): number;
|
||||
writeUInt32BE(value: number, offset: number, noAssert?: boolean): number;
|
||||
writeInt8(value: number, offset: number, noAssert?: boolean): number;
|
||||
writeInt16LE(value: number, offset: number, noAssert?: boolean): number;
|
||||
writeInt16BE(value: number, offset: number, noAssert?: boolean): number;
|
||||
writeInt32LE(value: number, offset: number, noAssert?: boolean): number;
|
||||
writeInt32BE(value: number, offset: number, noAssert?: boolean): number;
|
||||
writeFloatLE(value: number, offset: number, noAssert?: boolean): number;
|
||||
writeFloatBE(value: number, offset: number, noAssert?: boolean): number;
|
||||
writeDoubleLE(value: number, offset: number, noAssert?: boolean): number;
|
||||
writeDoubleBE(value: number, offset: number, noAssert?: boolean): number;
|
||||
fill(value: any, offset?: number, end?: number): this;
|
||||
indexOf(value: string | number | Buffer, byteOffset?: number, encoding?: string): number;
|
||||
lastIndexOf(value: string | number | Buffer, byteOffset?: number, encoding?: string): number;
|
||||
includes(value: string | number | Buffer, byteOffset?: number, encoding?: string): boolean;
|
||||
|
||||
/**
|
||||
* Allocates a new buffer containing the given {str}.
|
||||
*
|
||||
* @param str String to store in buffer.
|
||||
* @param encoding encoding to use, optional. Default is 'utf8'
|
||||
*/
|
||||
constructor (str: string, encoding?: string);
|
||||
/**
|
||||
* Allocates a new buffer of {size} octets.
|
||||
*
|
||||
* @param size count of octets to allocate.
|
||||
*/
|
||||
constructor (size: number);
|
||||
/**
|
||||
* Allocates a new buffer containing the given {array} of octets.
|
||||
*
|
||||
* @param array The octets to store.
|
||||
*/
|
||||
constructor (array: Uint8Array);
|
||||
/**
|
||||
* Produces a Buffer backed by the same allocated memory as
|
||||
* the given {ArrayBuffer}.
|
||||
*
|
||||
*
|
||||
* @param arrayBuffer The ArrayBuffer with which to share memory.
|
||||
*/
|
||||
constructor (arrayBuffer: ArrayBuffer);
|
||||
/**
|
||||
* Allocates a new buffer containing the given {array} of octets.
|
||||
*
|
||||
* @param array The octets to store.
|
||||
*/
|
||||
constructor (array: any[]);
|
||||
/**
|
||||
* Copies the passed {buffer} data onto a new {Buffer} instance.
|
||||
*
|
||||
* @param buffer The buffer to copy.
|
||||
*/
|
||||
constructor (buffer: Buffer);
|
||||
prototype: Buffer;
|
||||
/**
|
||||
* Allocates a new Buffer using an {array} of octets.
|
||||
*
|
||||
* @param array
|
||||
*/
|
||||
static from(array: any[]): Buffer;
|
||||
/**
|
||||
* When passed a reference to the .buffer property of a TypedArray instance,
|
||||
* the newly created Buffer will share the same allocated memory as the TypedArray.
|
||||
* The optional {byteOffset} and {length} arguments specify a memory range
|
||||
* within the {arrayBuffer} that will be shared by the Buffer.
|
||||
*
|
||||
* @param arrayBuffer The .buffer property of a TypedArray or a new ArrayBuffer()
|
||||
* @param byteOffset
|
||||
* @param length
|
||||
*/
|
||||
static from(arrayBuffer: ArrayBuffer, byteOffset?: number, length?: number): Buffer;
|
||||
/**
|
||||
* Copies the passed {buffer} data onto a new Buffer instance.
|
||||
*
|
||||
* @param buffer
|
||||
*/
|
||||
static from(buffer: Buffer): Buffer;
|
||||
/**
|
||||
* Creates a new Buffer containing the given JavaScript string {str}.
|
||||
* If provided, the {encoding} parameter identifies the character encoding.
|
||||
* If not provided, {encoding} defaults to 'utf8'.
|
||||
*
|
||||
* @param str
|
||||
*/
|
||||
static from(str: string, encoding?: string): Buffer;
|
||||
/**
|
||||
* Returns true if {obj} is a Buffer
|
||||
*
|
||||
* @param obj object to test.
|
||||
*/
|
||||
static isBuffer(obj: any): obj is Buffer;
|
||||
/**
|
||||
* Returns true if {encoding} is a valid encoding argument.
|
||||
* Valid string encodings in Node 0.12: 'ascii'|'utf8'|'utf16le'|'ucs2'(alias of 'utf16le')|'base64'|'binary'(deprecated)|'hex'
|
||||
*
|
||||
* @param encoding string to test.
|
||||
*/
|
||||
static isEncoding(encoding: string): boolean;
|
||||
/**
|
||||
* Gives the actual byte length of a string. encoding defaults to 'utf8'.
|
||||
* This is not the same as String.prototype.length since that returns the number of characters in a string.
|
||||
*
|
||||
* @param string string to test.
|
||||
* @param encoding encoding used to evaluate (defaults to 'utf8')
|
||||
*/
|
||||
static byteLength(string: string, encoding?: string): number;
|
||||
/**
|
||||
* Returns a buffer which is the result of concatenating all the buffers in the list together.
|
||||
*
|
||||
* If the list has no items, or if the totalLength is 0, then it returns a zero-length buffer.
|
||||
* If the list has exactly one item, then the first item of the list is returned.
|
||||
* If the list has more than one item, then a new Buffer is created.
|
||||
*
|
||||
* @param list An array of Buffer objects to concatenate
|
||||
* @param totalLength Total length of the buffers when concatenated.
|
||||
* If totalLength is not provided, it is read from the buffers in the list. However, this adds an additional loop to the function, so it is faster to provide the length explicitly.
|
||||
*/
|
||||
static concat(list: Buffer[], totalLength?: number): Buffer;
|
||||
/**
|
||||
* The same as buf1.compare(buf2).
|
||||
*/
|
||||
static compare(buf1: Buffer, buf2: Buffer): number;
|
||||
/**
|
||||
* Allocates a new buffer of {size} octets.
|
||||
*
|
||||
* @param size count of octets to allocate.
|
||||
* @param fill if specified, buffer will be initialized by calling buf.fill(fill).
|
||||
* If parameter is omitted, buffer will be filled with zeros.
|
||||
* @param encoding encoding used for call to buf.fill while initalizing
|
||||
*/
|
||||
static alloc(size: number, fill?: string | Buffer | number, encoding?: string): Buffer;
|
||||
/**
|
||||
* Allocates a new buffer of {size} octets, leaving memory not initialized, so the contents
|
||||
* of the newly created Buffer are unknown and may contain sensitive data.
|
||||
*
|
||||
* @param size count of octets to allocate
|
||||
*/
|
||||
static allocUnsafe(size: number): Buffer;
|
||||
/**
|
||||
* Allocates a new non-pooled buffer of {size} octets, leaving memory not initialized, so the contents
|
||||
* of the newly created Buffer are unknown and may contain sensitive data.
|
||||
*
|
||||
* @param size count of octets to allocate
|
||||
*/
|
||||
static allocUnsafeSlow(size: number): Buffer;
|
||||
}
|
||||
}
|
||||
62
node_modules/browserify/node_modules/safe-buffer/index.js
generated
vendored
Normal file
62
node_modules/browserify/node_modules/safe-buffer/index.js
generated
vendored
Normal file
@@ -0,0 +1,62 @@
|
||||
/* eslint-disable node/no-deprecated-api */
|
||||
var buffer = require('buffer')
|
||||
var Buffer = buffer.Buffer
|
||||
|
||||
// alternative to using Object.keys for old browsers
|
||||
function copyProps (src, dst) {
|
||||
for (var key in src) {
|
||||
dst[key] = src[key]
|
||||
}
|
||||
}
|
||||
if (Buffer.from && Buffer.alloc && Buffer.allocUnsafe && Buffer.allocUnsafeSlow) {
|
||||
module.exports = buffer
|
||||
} else {
|
||||
// Copy properties from require('buffer')
|
||||
copyProps(buffer, exports)
|
||||
exports.Buffer = SafeBuffer
|
||||
}
|
||||
|
||||
function SafeBuffer (arg, encodingOrOffset, length) {
|
||||
return Buffer(arg, encodingOrOffset, length)
|
||||
}
|
||||
|
||||
// Copy static methods from Buffer
|
||||
copyProps(Buffer, SafeBuffer)
|
||||
|
||||
SafeBuffer.from = function (arg, encodingOrOffset, length) {
|
||||
if (typeof arg === 'number') {
|
||||
throw new TypeError('Argument must not be a number')
|
||||
}
|
||||
return Buffer(arg, encodingOrOffset, length)
|
||||
}
|
||||
|
||||
SafeBuffer.alloc = function (size, fill, encoding) {
|
||||
if (typeof size !== 'number') {
|
||||
throw new TypeError('Argument must be a number')
|
||||
}
|
||||
var buf = Buffer(size)
|
||||
if (fill !== undefined) {
|
||||
if (typeof encoding === 'string') {
|
||||
buf.fill(fill, encoding)
|
||||
} else {
|
||||
buf.fill(fill)
|
||||
}
|
||||
} else {
|
||||
buf.fill(0)
|
||||
}
|
||||
return buf
|
||||
}
|
||||
|
||||
SafeBuffer.allocUnsafe = function (size) {
|
||||
if (typeof size !== 'number') {
|
||||
throw new TypeError('Argument must be a number')
|
||||
}
|
||||
return Buffer(size)
|
||||
}
|
||||
|
||||
SafeBuffer.allocUnsafeSlow = function (size) {
|
||||
if (typeof size !== 'number') {
|
||||
throw new TypeError('Argument must be a number')
|
||||
}
|
||||
return buffer.SlowBuffer(size)
|
||||
}
|
||||
37
node_modules/browserify/node_modules/safe-buffer/package.json
generated
vendored
Normal file
37
node_modules/browserify/node_modules/safe-buffer/package.json
generated
vendored
Normal file
@@ -0,0 +1,37 @@
|
||||
{
|
||||
"name": "safe-buffer",
|
||||
"description": "Safer Node.js Buffer API",
|
||||
"version": "5.1.2",
|
||||
"author": {
|
||||
"name": "Feross Aboukhadijeh",
|
||||
"email": "feross@feross.org",
|
||||
"url": "http://feross.org"
|
||||
},
|
||||
"bugs": {
|
||||
"url": "https://github.com/feross/safe-buffer/issues"
|
||||
},
|
||||
"devDependencies": {
|
||||
"standard": "*",
|
||||
"tape": "^4.0.0"
|
||||
},
|
||||
"homepage": "https://github.com/feross/safe-buffer",
|
||||
"keywords": [
|
||||
"buffer",
|
||||
"buffer allocate",
|
||||
"node security",
|
||||
"safe",
|
||||
"safe-buffer",
|
||||
"security",
|
||||
"uninitialized"
|
||||
],
|
||||
"license": "MIT",
|
||||
"main": "index.js",
|
||||
"types": "index.d.ts",
|
||||
"repository": {
|
||||
"type": "git",
|
||||
"url": "git://github.com/feross/safe-buffer.git"
|
||||
},
|
||||
"scripts": {
|
||||
"test": "standard && tape test/*.js"
|
||||
}
|
||||
}
|
||||
50
node_modules/browserify/node_modules/string_decoder/.travis.yml
generated
vendored
Normal file
50
node_modules/browserify/node_modules/string_decoder/.travis.yml
generated
vendored
Normal file
@@ -0,0 +1,50 @@
|
||||
sudo: false
|
||||
language: node_js
|
||||
before_install:
|
||||
- npm install -g npm@2
|
||||
- test $NPM_LEGACY && npm install -g npm@latest-3 || npm install npm -g
|
||||
notifications:
|
||||
email: false
|
||||
matrix:
|
||||
fast_finish: true
|
||||
include:
|
||||
- node_js: '0.8'
|
||||
env:
|
||||
- TASK=test
|
||||
- NPM_LEGACY=true
|
||||
- node_js: '0.10'
|
||||
env:
|
||||
- TASK=test
|
||||
- NPM_LEGACY=true
|
||||
- node_js: '0.11'
|
||||
env:
|
||||
- TASK=test
|
||||
- NPM_LEGACY=true
|
||||
- node_js: '0.12'
|
||||
env:
|
||||
- TASK=test
|
||||
- NPM_LEGACY=true
|
||||
- node_js: 1
|
||||
env:
|
||||
- TASK=test
|
||||
- NPM_LEGACY=true
|
||||
- node_js: 2
|
||||
env:
|
||||
- TASK=test
|
||||
- NPM_LEGACY=true
|
||||
- node_js: 3
|
||||
env:
|
||||
- TASK=test
|
||||
- NPM_LEGACY=true
|
||||
- node_js: 4
|
||||
env: TASK=test
|
||||
- node_js: 5
|
||||
env: TASK=test
|
||||
- node_js: 6
|
||||
env: TASK=test
|
||||
- node_js: 7
|
||||
env: TASK=test
|
||||
- node_js: 8
|
||||
env: TASK=test
|
||||
- node_js: 9
|
||||
env: TASK=test
|
||||
48
node_modules/browserify/node_modules/string_decoder/LICENSE
generated
vendored
Normal file
48
node_modules/browserify/node_modules/string_decoder/LICENSE
generated
vendored
Normal file
@@ -0,0 +1,48 @@
|
||||
Node.js is licensed for use as follows:
|
||||
|
||||
"""
|
||||
Copyright Node.js contributors. All rights reserved.
|
||||
|
||||
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.
|
||||
"""
|
||||
|
||||
This license applies to parts of Node.js originating from the
|
||||
https://github.com/joyent/node repository:
|
||||
|
||||
"""
|
||||
Copyright Joyent, Inc. and other Node contributors. All rights reserved.
|
||||
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.
|
||||
"""
|
||||
|
||||
47
node_modules/browserify/node_modules/string_decoder/README.md
generated
vendored
Normal file
47
node_modules/browserify/node_modules/string_decoder/README.md
generated
vendored
Normal file
@@ -0,0 +1,47 @@
|
||||
# string_decoder
|
||||
|
||||
***Node-core v8.9.4 string_decoder for userland***
|
||||
|
||||
|
||||
[](https://nodei.co/npm/string_decoder/)
|
||||
[](https://nodei.co/npm/string_decoder/)
|
||||
|
||||
|
||||
```bash
|
||||
npm install --save string_decoder
|
||||
```
|
||||
|
||||
***Node-core string_decoder for userland***
|
||||
|
||||
This package is a mirror of the string_decoder implementation in Node-core.
|
||||
|
||||
Full documentation may be found on the [Node.js website](https://nodejs.org/dist/v8.9.4/docs/api/).
|
||||
|
||||
As of version 1.0.0 **string_decoder** uses semantic versioning.
|
||||
|
||||
## Previous versions
|
||||
|
||||
Previous version numbers match the versions found in Node core, e.g. 0.10.24 matches Node 0.10.24, likewise 0.11.10 matches Node 0.11.10.
|
||||
|
||||
## Update
|
||||
|
||||
The *build/* directory contains a build script that will scrape the source from the [nodejs/node](https://github.com/nodejs/node) repo given a specific Node version.
|
||||
|
||||
## Streams Working Group
|
||||
|
||||
`string_decoder` is maintained by the Streams Working Group, which
|
||||
oversees the development and maintenance of the Streams API within
|
||||
Node.js. The responsibilities of the Streams Working Group include:
|
||||
|
||||
* Addressing stream issues on the Node.js issue tracker.
|
||||
* Authoring and editing stream documentation within the Node.js project.
|
||||
* Reviewing changes to stream subclasses within the Node.js project.
|
||||
* Redirecting changes to streams from the Node.js project to this
|
||||
project.
|
||||
* Assisting in the implementation of stream providers within Node.js.
|
||||
* Recommending versions of `readable-stream` to be included in Node.js.
|
||||
* Messaging about the future of streams to give the community advance
|
||||
notice of changes.
|
||||
|
||||
See [readable-stream](https://github.com/nodejs/readable-stream) for
|
||||
more details.
|
||||
296
node_modules/browserify/node_modules/string_decoder/lib/string_decoder.js
generated
vendored
Normal file
296
node_modules/browserify/node_modules/string_decoder/lib/string_decoder.js
generated
vendored
Normal file
@@ -0,0 +1,296 @@
|
||||
// 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.
|
||||
|
||||
'use strict';
|
||||
|
||||
/*<replacement>*/
|
||||
|
||||
var Buffer = require('safe-buffer').Buffer;
|
||||
/*</replacement>*/
|
||||
|
||||
var isEncoding = Buffer.isEncoding || function (encoding) {
|
||||
encoding = '' + encoding;
|
||||
switch (encoding && encoding.toLowerCase()) {
|
||||
case 'hex':case 'utf8':case 'utf-8':case 'ascii':case 'binary':case 'base64':case 'ucs2':case 'ucs-2':case 'utf16le':case 'utf-16le':case 'raw':
|
||||
return true;
|
||||
default:
|
||||
return false;
|
||||
}
|
||||
};
|
||||
|
||||
function _normalizeEncoding(enc) {
|
||||
if (!enc) return 'utf8';
|
||||
var retried;
|
||||
while (true) {
|
||||
switch (enc) {
|
||||
case 'utf8':
|
||||
case 'utf-8':
|
||||
return 'utf8';
|
||||
case 'ucs2':
|
||||
case 'ucs-2':
|
||||
case 'utf16le':
|
||||
case 'utf-16le':
|
||||
return 'utf16le';
|
||||
case 'latin1':
|
||||
case 'binary':
|
||||
return 'latin1';
|
||||
case 'base64':
|
||||
case 'ascii':
|
||||
case 'hex':
|
||||
return enc;
|
||||
default:
|
||||
if (retried) return; // undefined
|
||||
enc = ('' + enc).toLowerCase();
|
||||
retried = true;
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
// Do not cache `Buffer.isEncoding` when checking encoding names as some
|
||||
// modules monkey-patch it to support additional encodings
|
||||
function normalizeEncoding(enc) {
|
||||
var nenc = _normalizeEncoding(enc);
|
||||
if (typeof nenc !== 'string' && (Buffer.isEncoding === isEncoding || !isEncoding(enc))) throw new Error('Unknown encoding: ' + enc);
|
||||
return nenc || enc;
|
||||
}
|
||||
|
||||
// StringDecoder provides an interface for efficiently splitting a series of
|
||||
// buffers into a series of JS strings without breaking apart multi-byte
|
||||
// characters.
|
||||
exports.StringDecoder = StringDecoder;
|
||||
function StringDecoder(encoding) {
|
||||
this.encoding = normalizeEncoding(encoding);
|
||||
var nb;
|
||||
switch (this.encoding) {
|
||||
case 'utf16le':
|
||||
this.text = utf16Text;
|
||||
this.end = utf16End;
|
||||
nb = 4;
|
||||
break;
|
||||
case 'utf8':
|
||||
this.fillLast = utf8FillLast;
|
||||
nb = 4;
|
||||
break;
|
||||
case 'base64':
|
||||
this.text = base64Text;
|
||||
this.end = base64End;
|
||||
nb = 3;
|
||||
break;
|
||||
default:
|
||||
this.write = simpleWrite;
|
||||
this.end = simpleEnd;
|
||||
return;
|
||||
}
|
||||
this.lastNeed = 0;
|
||||
this.lastTotal = 0;
|
||||
this.lastChar = Buffer.allocUnsafe(nb);
|
||||
}
|
||||
|
||||
StringDecoder.prototype.write = function (buf) {
|
||||
if (buf.length === 0) return '';
|
||||
var r;
|
||||
var i;
|
||||
if (this.lastNeed) {
|
||||
r = this.fillLast(buf);
|
||||
if (r === undefined) return '';
|
||||
i = this.lastNeed;
|
||||
this.lastNeed = 0;
|
||||
} else {
|
||||
i = 0;
|
||||
}
|
||||
if (i < buf.length) return r ? r + this.text(buf, i) : this.text(buf, i);
|
||||
return r || '';
|
||||
};
|
||||
|
||||
StringDecoder.prototype.end = utf8End;
|
||||
|
||||
// Returns only complete characters in a Buffer
|
||||
StringDecoder.prototype.text = utf8Text;
|
||||
|
||||
// Attempts to complete a partial non-UTF-8 character using bytes from a Buffer
|
||||
StringDecoder.prototype.fillLast = function (buf) {
|
||||
if (this.lastNeed <= buf.length) {
|
||||
buf.copy(this.lastChar, this.lastTotal - this.lastNeed, 0, this.lastNeed);
|
||||
return this.lastChar.toString(this.encoding, 0, this.lastTotal);
|
||||
}
|
||||
buf.copy(this.lastChar, this.lastTotal - this.lastNeed, 0, buf.length);
|
||||
this.lastNeed -= buf.length;
|
||||
};
|
||||
|
||||
// Checks the type of a UTF-8 byte, whether it's ASCII, a leading byte, or a
|
||||
// continuation byte. If an invalid byte is detected, -2 is returned.
|
||||
function utf8CheckByte(byte) {
|
||||
if (byte <= 0x7F) return 0;else if (byte >> 5 === 0x06) return 2;else if (byte >> 4 === 0x0E) return 3;else if (byte >> 3 === 0x1E) return 4;
|
||||
return byte >> 6 === 0x02 ? -1 : -2;
|
||||
}
|
||||
|
||||
// Checks at most 3 bytes at the end of a Buffer in order to detect an
|
||||
// incomplete multi-byte UTF-8 character. The total number of bytes (2, 3, or 4)
|
||||
// needed to complete the UTF-8 character (if applicable) are returned.
|
||||
function utf8CheckIncomplete(self, buf, i) {
|
||||
var j = buf.length - 1;
|
||||
if (j < i) return 0;
|
||||
var nb = utf8CheckByte(buf[j]);
|
||||
if (nb >= 0) {
|
||||
if (nb > 0) self.lastNeed = nb - 1;
|
||||
return nb;
|
||||
}
|
||||
if (--j < i || nb === -2) return 0;
|
||||
nb = utf8CheckByte(buf[j]);
|
||||
if (nb >= 0) {
|
||||
if (nb > 0) self.lastNeed = nb - 2;
|
||||
return nb;
|
||||
}
|
||||
if (--j < i || nb === -2) return 0;
|
||||
nb = utf8CheckByte(buf[j]);
|
||||
if (nb >= 0) {
|
||||
if (nb > 0) {
|
||||
if (nb === 2) nb = 0;else self.lastNeed = nb - 3;
|
||||
}
|
||||
return nb;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
// Validates as many continuation bytes for a multi-byte UTF-8 character as
|
||||
// needed or are available. If we see a non-continuation byte where we expect
|
||||
// one, we "replace" the validated continuation bytes we've seen so far with
|
||||
// a single UTF-8 replacement character ('\ufffd'), to match v8's UTF-8 decoding
|
||||
// behavior. The continuation byte check is included three times in the case
|
||||
// where all of the continuation bytes for a character exist in the same buffer.
|
||||
// It is also done this way as a slight performance increase instead of using a
|
||||
// loop.
|
||||
function utf8CheckExtraBytes(self, buf, p) {
|
||||
if ((buf[0] & 0xC0) !== 0x80) {
|
||||
self.lastNeed = 0;
|
||||
return '\ufffd';
|
||||
}
|
||||
if (self.lastNeed > 1 && buf.length > 1) {
|
||||
if ((buf[1] & 0xC0) !== 0x80) {
|
||||
self.lastNeed = 1;
|
||||
return '\ufffd';
|
||||
}
|
||||
if (self.lastNeed > 2 && buf.length > 2) {
|
||||
if ((buf[2] & 0xC0) !== 0x80) {
|
||||
self.lastNeed = 2;
|
||||
return '\ufffd';
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Attempts to complete a multi-byte UTF-8 character using bytes from a Buffer.
|
||||
function utf8FillLast(buf) {
|
||||
var p = this.lastTotal - this.lastNeed;
|
||||
var r = utf8CheckExtraBytes(this, buf, p);
|
||||
if (r !== undefined) return r;
|
||||
if (this.lastNeed <= buf.length) {
|
||||
buf.copy(this.lastChar, p, 0, this.lastNeed);
|
||||
return this.lastChar.toString(this.encoding, 0, this.lastTotal);
|
||||
}
|
||||
buf.copy(this.lastChar, p, 0, buf.length);
|
||||
this.lastNeed -= buf.length;
|
||||
}
|
||||
|
||||
// Returns all complete UTF-8 characters in a Buffer. If the Buffer ended on a
|
||||
// partial character, the character's bytes are buffered until the required
|
||||
// number of bytes are available.
|
||||
function utf8Text(buf, i) {
|
||||
var total = utf8CheckIncomplete(this, buf, i);
|
||||
if (!this.lastNeed) return buf.toString('utf8', i);
|
||||
this.lastTotal = total;
|
||||
var end = buf.length - (total - this.lastNeed);
|
||||
buf.copy(this.lastChar, 0, end);
|
||||
return buf.toString('utf8', i, end);
|
||||
}
|
||||
|
||||
// For UTF-8, a replacement character is added when ending on a partial
|
||||
// character.
|
||||
function utf8End(buf) {
|
||||
var r = buf && buf.length ? this.write(buf) : '';
|
||||
if (this.lastNeed) return r + '\ufffd';
|
||||
return r;
|
||||
}
|
||||
|
||||
// UTF-16LE typically needs two bytes per character, but even if we have an even
|
||||
// number of bytes available, we need to check if we end on a leading/high
|
||||
// surrogate. In that case, we need to wait for the next two bytes in order to
|
||||
// decode the last character properly.
|
||||
function utf16Text(buf, i) {
|
||||
if ((buf.length - i) % 2 === 0) {
|
||||
var r = buf.toString('utf16le', i);
|
||||
if (r) {
|
||||
var c = r.charCodeAt(r.length - 1);
|
||||
if (c >= 0xD800 && c <= 0xDBFF) {
|
||||
this.lastNeed = 2;
|
||||
this.lastTotal = 4;
|
||||
this.lastChar[0] = buf[buf.length - 2];
|
||||
this.lastChar[1] = buf[buf.length - 1];
|
||||
return r.slice(0, -1);
|
||||
}
|
||||
}
|
||||
return r;
|
||||
}
|
||||
this.lastNeed = 1;
|
||||
this.lastTotal = 2;
|
||||
this.lastChar[0] = buf[buf.length - 1];
|
||||
return buf.toString('utf16le', i, buf.length - 1);
|
||||
}
|
||||
|
||||
// For UTF-16LE we do not explicitly append special replacement characters if we
|
||||
// end on a partial character, we simply let v8 handle that.
|
||||
function utf16End(buf) {
|
||||
var r = buf && buf.length ? this.write(buf) : '';
|
||||
if (this.lastNeed) {
|
||||
var end = this.lastTotal - this.lastNeed;
|
||||
return r + this.lastChar.toString('utf16le', 0, end);
|
||||
}
|
||||
return r;
|
||||
}
|
||||
|
||||
function base64Text(buf, i) {
|
||||
var n = (buf.length - i) % 3;
|
||||
if (n === 0) return buf.toString('base64', i);
|
||||
this.lastNeed = 3 - n;
|
||||
this.lastTotal = 3;
|
||||
if (n === 1) {
|
||||
this.lastChar[0] = buf[buf.length - 1];
|
||||
} else {
|
||||
this.lastChar[0] = buf[buf.length - 2];
|
||||
this.lastChar[1] = buf[buf.length - 1];
|
||||
}
|
||||
return buf.toString('base64', i, buf.length - n);
|
||||
}
|
||||
|
||||
function base64End(buf) {
|
||||
var r = buf && buf.length ? this.write(buf) : '';
|
||||
if (this.lastNeed) return r + this.lastChar.toString('base64', 0, 3 - this.lastNeed);
|
||||
return r;
|
||||
}
|
||||
|
||||
// Pass bytes on through for single-byte encodings (e.g. ascii, latin1, hex)
|
||||
function simpleWrite(buf) {
|
||||
return buf.toString(this.encoding);
|
||||
}
|
||||
|
||||
function simpleEnd(buf) {
|
||||
return buf && buf.length ? this.write(buf) : '';
|
||||
}
|
||||
31
node_modules/browserify/node_modules/string_decoder/package.json
generated
vendored
Normal file
31
node_modules/browserify/node_modules/string_decoder/package.json
generated
vendored
Normal file
@@ -0,0 +1,31 @@
|
||||
{
|
||||
"name": "string_decoder",
|
||||
"version": "1.1.1",
|
||||
"description": "The string_decoder module from Node core",
|
||||
"main": "lib/string_decoder.js",
|
||||
"dependencies": {
|
||||
"safe-buffer": "~5.1.0"
|
||||
},
|
||||
"devDependencies": {
|
||||
"babel-polyfill": "^6.23.0",
|
||||
"core-util-is": "^1.0.2",
|
||||
"inherits": "^2.0.3",
|
||||
"tap": "~0.4.8"
|
||||
},
|
||||
"scripts": {
|
||||
"test": "tap test/parallel/*.js && node test/verify-dependencies",
|
||||
"ci": "tap test/parallel/*.js test/ours/*.js --tap | tee test.tap && node test/verify-dependencies.js"
|
||||
},
|
||||
"repository": {
|
||||
"type": "git",
|
||||
"url": "git://github.com/nodejs/string_decoder.git"
|
||||
},
|
||||
"homepage": "https://github.com/nodejs/string_decoder",
|
||||
"keywords": [
|
||||
"string",
|
||||
"decoder",
|
||||
"browser",
|
||||
"browserify"
|
||||
],
|
||||
"license": "MIT"
|
||||
}
|
||||
99
node_modules/browserify/package.json
generated
vendored
Normal file
99
node_modules/browserify/package.json
generated
vendored
Normal file
@@ -0,0 +1,99 @@
|
||||
{
|
||||
"name": "browserify",
|
||||
"version": "17.0.1",
|
||||
"description": "browser-side require() the node way",
|
||||
"main": "index.js",
|
||||
"bin": {
|
||||
"browserify": "bin/cmd.js"
|
||||
},
|
||||
"repository": {
|
||||
"type": "git",
|
||||
"url": "http://github.com/browserify/browserify.git"
|
||||
},
|
||||
"engines": {
|
||||
"node": ">= 0.8"
|
||||
},
|
||||
"keywords": [
|
||||
"browser",
|
||||
"require",
|
||||
"commonjs",
|
||||
"commonj-esque",
|
||||
"bundle",
|
||||
"npm",
|
||||
"javascript"
|
||||
],
|
||||
"dependencies": {
|
||||
"assert": "^1.4.0",
|
||||
"browser-pack": "^6.0.1",
|
||||
"browser-resolve": "^2.0.0",
|
||||
"browserify-zlib": "~0.2.0",
|
||||
"buffer": "~5.2.1",
|
||||
"cached-path-relative": "^1.0.0",
|
||||
"concat-stream": "^1.6.0",
|
||||
"console-browserify": "^1.1.0",
|
||||
"constants-browserify": "~1.0.0",
|
||||
"crypto-browserify": "^3.0.0",
|
||||
"defined": "^1.0.0",
|
||||
"deps-sort": "^2.0.1",
|
||||
"domain-browser": "^1.2.0",
|
||||
"duplexer2": "~0.1.2",
|
||||
"events": "^3.0.0",
|
||||
"glob": "^7.1.0",
|
||||
"hasown": "^2.0.0",
|
||||
"htmlescape": "^1.1.0",
|
||||
"https-browserify": "^1.0.0",
|
||||
"inherits": "~2.0.1",
|
||||
"insert-module-globals": "^7.2.1",
|
||||
"JSONStream": "^1.0.3",
|
||||
"labeled-stream-splicer": "^2.0.0",
|
||||
"mkdirp-classic": "^0.5.2",
|
||||
"module-deps": "^6.2.3",
|
||||
"os-browserify": "~0.3.0",
|
||||
"parents": "^1.0.1",
|
||||
"path-browserify": "^1.0.0",
|
||||
"process": "~0.11.0",
|
||||
"punycode": "^1.3.2",
|
||||
"querystring-es3": "~0.2.0",
|
||||
"read-only-stream": "^2.0.0",
|
||||
"readable-stream": "^2.0.2",
|
||||
"resolve": "^1.1.4",
|
||||
"shasum-object": "^1.0.0",
|
||||
"shell-quote": "^1.6.1",
|
||||
"stream-browserify": "^3.0.0",
|
||||
"stream-http": "^3.0.0",
|
||||
"string_decoder": "^1.1.1",
|
||||
"subarg": "^1.0.0",
|
||||
"syntax-error": "^1.1.1",
|
||||
"through2": "^2.0.0",
|
||||
"timers-browserify": "^1.0.1",
|
||||
"tty-browserify": "0.0.1",
|
||||
"url": "~0.11.0",
|
||||
"util": "~0.12.0",
|
||||
"vm-browserify": "^1.0.0",
|
||||
"xtend": "^4.0.0"
|
||||
},
|
||||
"devDependencies": {
|
||||
"backbone": "~0.9.2",
|
||||
"browser-unpack": "^1.1.1",
|
||||
"coffee-script": "~1.10.0",
|
||||
"coffeeify": "~1.1.0",
|
||||
"has-object-spread": "^1.0.0",
|
||||
"has-template-literals": "^1.0.0",
|
||||
"isstream": "^0.1.2",
|
||||
"make-generator-function": "^1.1.0",
|
||||
"semver": "^5.5.0",
|
||||
"seq": "0.3.5",
|
||||
"tap": "^10.7.2",
|
||||
"temp": "=0.8.3",
|
||||
"through": "^2.3.4"
|
||||
},
|
||||
"author": {
|
||||
"name": "James Halliday",
|
||||
"email": "mail@substack.net",
|
||||
"url": "http://substack.net"
|
||||
},
|
||||
"scripts": {
|
||||
"test": "tap test/*.js"
|
||||
},
|
||||
"license": "MIT"
|
||||
}
|
||||
831
node_modules/browserify/readme.markdown
generated
vendored
Normal file
831
node_modules/browserify/readme.markdown
generated
vendored
Normal file
@@ -0,0 +1,831 @@
|
||||
# browserify
|
||||
|
||||
`require('modules')` in the browser
|
||||
|
||||
Use a [node](http://nodejs.org)-style `require()` to organize your browser code
|
||||
and load modules installed by [npm](https://www.npmjs.com).
|
||||
|
||||
browserify will recursively analyze all the `require()` calls in your app in
|
||||
order to build a bundle you can serve up to the browser in a single `<script>`
|
||||
tag.
|
||||
|
||||
[](https://travis-ci.org/browserify/browserify)
|
||||
|
||||

|
||||
|
||||
# getting started
|
||||
|
||||
If you're new to browserify, check out the
|
||||
[browserify handbook](https://github.com/browserify/browserify-handbook)
|
||||
and the resources on [browserify.org](http://browserify.org/).
|
||||
|
||||
# example
|
||||
|
||||
Whip up a file, `main.js` with some `require()`s in it. You can use relative
|
||||
paths like `'./foo.js'` and `'../lib/bar.js'` or module paths like `'gamma'`
|
||||
that will search `node_modules/` using
|
||||
[node's module lookup algorithm](https://github.com/browserify/resolve).
|
||||
|
||||
``` js
|
||||
var foo = require('./foo.js');
|
||||
var bar = require('../lib/bar.js');
|
||||
var gamma = require('gamma');
|
||||
|
||||
var elem = document.getElementById('result');
|
||||
var x = foo(100) + bar('baz');
|
||||
elem.textContent = gamma(x);
|
||||
```
|
||||
|
||||
Export functionality by assigning onto `module.exports` or `exports`:
|
||||
|
||||
``` js
|
||||
module.exports = function (n) { return n * 111 }
|
||||
```
|
||||
|
||||
Now just use the `browserify` command to build a bundle starting at `main.js`:
|
||||
|
||||
```
|
||||
$ browserify main.js > bundle.js
|
||||
```
|
||||
|
||||
All of the modules that `main.js` needs are included in the `bundle.js` from a
|
||||
recursive walk of the `require()` graph using
|
||||
[required](https://github.com/defunctzombie/node-required).
|
||||
|
||||
To use this bundle, just toss a `<script src="bundle.js"></script>` into your
|
||||
html!
|
||||
|
||||
# install
|
||||
|
||||
With [npm](https://www.npmjs.com/) do:
|
||||
|
||||
```
|
||||
npm install browserify
|
||||
```
|
||||
|
||||
# usage
|
||||
|
||||
```
|
||||
Usage: browserify [entry files] {OPTIONS}
|
||||
|
||||
Standard Options:
|
||||
|
||||
--outfile, -o Write the browserify bundle to this file.
|
||||
If unspecified, browserify prints to stdout.
|
||||
|
||||
--require, -r A module name or file to bundle.require()
|
||||
Optionally use a colon separator to set the target.
|
||||
|
||||
--entry, -e An entry point of your app
|
||||
|
||||
--ignore, -i Replace a file with an empty stub. Files can be globs.
|
||||
|
||||
--exclude, -u Omit a file from the output bundle. Files can be globs.
|
||||
|
||||
--external, -x Reference a file from another bundle. Files can be globs.
|
||||
|
||||
--transform, -t Use a transform module on top-level files.
|
||||
|
||||
--command, -c Use a transform command on top-level files.
|
||||
|
||||
--standalone -s Generate a UMD bundle for the supplied export name.
|
||||
This bundle works with other module systems and sets the name
|
||||
given as a window global if no module system is found.
|
||||
|
||||
--debug -d Enable source maps that allow you to debug your files
|
||||
separately.
|
||||
|
||||
--help, -h Show this message
|
||||
|
||||
For advanced options, type `browserify --help advanced`.
|
||||
|
||||
Specify a parameter.
|
||||
```
|
||||
|
||||
```
|
||||
Advanced Options:
|
||||
|
||||
--insert-globals, --ig, --fast [default: false]
|
||||
|
||||
Skip detection and always insert definitions for process, global,
|
||||
__filename, and __dirname.
|
||||
|
||||
benefit: faster builds
|
||||
cost: extra bytes
|
||||
|
||||
--insert-global-vars, --igv
|
||||
|
||||
Comma-separated list of global variables to detect and define.
|
||||
Default: __filename,__dirname,process,Buffer,global
|
||||
|
||||
--detect-globals, --dg [default: true]
|
||||
|
||||
Detect the presence of process, global, __filename, and __dirname and define
|
||||
these values when present.
|
||||
|
||||
benefit: npm modules more likely to work
|
||||
cost: slower builds
|
||||
|
||||
--ignore-missing, --im [default: false]
|
||||
|
||||
Ignore `require()` statements that don't resolve to anything.
|
||||
|
||||
--noparse=FILE
|
||||
|
||||
Don't parse FILE at all. This will make bundling much, much faster for giant
|
||||
libs like jquery or threejs.
|
||||
|
||||
--no-builtins
|
||||
|
||||
Turn off builtins. This is handy when you want to run a bundle in node which
|
||||
provides the core builtins.
|
||||
|
||||
--no-commondir
|
||||
|
||||
Turn off setting a commondir. This is useful if you want to preserve the
|
||||
original paths that a bundle was generated with.
|
||||
|
||||
--no-bundle-external
|
||||
|
||||
Turn off bundling of all external modules. This is useful if you only want
|
||||
to bundle your local files.
|
||||
|
||||
--bare
|
||||
|
||||
Alias for both --no-builtins, --no-commondir, and sets --insert-global-vars
|
||||
to just "__filename,__dirname". This is handy if you want to run bundles in
|
||||
node.
|
||||
|
||||
--no-browser-field, --no-bf
|
||||
|
||||
Turn off package.json browser field resolution. This is also handy if you
|
||||
need to run a bundle in node.
|
||||
|
||||
--transform-key
|
||||
|
||||
Instead of the default package.json#browserify#transform field to list
|
||||
all transforms to apply when running browserify, a custom field, like, e.g.
|
||||
package.json#browserify#production or package.json#browserify#staging
|
||||
can be used, by for example running:
|
||||
* `browserify index.js --transform-key=production > bundle.js`
|
||||
* `browserify index.js --transform-key=staging > bundle.js`
|
||||
|
||||
--node
|
||||
|
||||
Alias for --bare and --no-browser-field.
|
||||
|
||||
--full-paths
|
||||
|
||||
Turn off converting module ids into numerical indexes. This is useful for
|
||||
preserving the original paths that a bundle was generated with.
|
||||
|
||||
--deps
|
||||
|
||||
Instead of standard bundle output, print the dependency array generated by
|
||||
module-deps.
|
||||
|
||||
--no-dedupe
|
||||
|
||||
Turn off deduping.
|
||||
|
||||
--list
|
||||
|
||||
Print each file in the dependency graph. Useful for makefiles.
|
||||
|
||||
--extension=EXTENSION
|
||||
|
||||
Consider files with specified EXTENSION as modules, this option can used
|
||||
multiple times.
|
||||
|
||||
--global-transform=MODULE, -g MODULE
|
||||
|
||||
Use a transform module on all files after any ordinary transforms have run.
|
||||
|
||||
--ignore-transform=MODULE, -it MODULE
|
||||
|
||||
Do not run certain transformations, even if specified elsewhere.
|
||||
|
||||
--plugin=MODULE, -p MODULE
|
||||
|
||||
Register MODULE as a plugin.
|
||||
|
||||
Passing arguments to transforms and plugins:
|
||||
|
||||
For -t, -g, and -p, you may use subarg syntax to pass options to the
|
||||
transforms or plugin function as the second parameter. For example:
|
||||
|
||||
-t [ foo -x 3 --beep ]
|
||||
|
||||
will call the `foo` transform for each applicable file by calling:
|
||||
|
||||
foo(file, { x: 3, beep: true })
|
||||
|
||||
```
|
||||
|
||||
# compatibility
|
||||
|
||||
Many [npm](https://www.npmjs.com/) modules that don't do IO will just work after being
|
||||
browserified. Others take more work.
|
||||
|
||||
Many node built-in modules have been wrapped to work in the browser, but only
|
||||
when you explicitly `require()` or use their functionality.
|
||||
|
||||
When you `require()` any of these modules, you will get a browser-specific shim:
|
||||
|
||||
* [assert](https://www.npmjs.com/package/assert)
|
||||
* [buffer](https://www.npmjs.com/package/buffer)
|
||||
* [console](https://www.npmjs.com/package/console-browserify)
|
||||
* [constants](https://www.npmjs.com/package/constants-browserify)
|
||||
* [crypto](https://www.npmjs.com/package/crypto-browserify)
|
||||
* [domain](https://www.npmjs.com/package/domain-browser)
|
||||
* [events](https://www.npmjs.com/package/events)
|
||||
* [http](https://www.npmjs.com/package/stream-http)
|
||||
* [https](https://www.npmjs.com/package/https-browserify)
|
||||
* [os](https://www.npmjs.com/package/os-browserify)
|
||||
* [path](https://www.npmjs.com/package/path-browserify)
|
||||
* [punycode](https://www.npmjs.com/package/punycode)
|
||||
* [querystring](https://www.npmjs.com/package/querystring-es3)
|
||||
* [stream](https://www.npmjs.com/package/stream-browserify)
|
||||
* [string_decoder](https://www.npmjs.com/package/string_decoder)
|
||||
* [timers](https://www.npmjs.com/package/timers-browserify)
|
||||
* [tty](https://www.npmjs.com/package/tty-browserify)
|
||||
* [url](https://www.npmjs.com/package/url)
|
||||
* [util](https://www.npmjs.com/package/util)
|
||||
* [vm](https://www.npmjs.com/package/vm-browserify)
|
||||
* [zlib](https://www.npmjs.com/package/browserify-zlib)
|
||||
|
||||
Additionally, if you use any of these variables, they
|
||||
[will be defined](https://github.com/browserify/insert-module-globals)
|
||||
in the bundled output in a browser-appropriate way:
|
||||
|
||||
* [process](https://www.npmjs.com/package/process)
|
||||
* [Buffer](https://www.npmjs.com/package/buffer)
|
||||
* global - top-level scope object (window)
|
||||
* __filename - file path of the currently executing file
|
||||
* __dirname - directory path of the currently executing file
|
||||
|
||||
# more examples
|
||||
|
||||
## external requires
|
||||
|
||||
You can just as easily create a bundle that will export a `require()` function so
|
||||
you can `require()` modules from another script tag. Here we'll create a
|
||||
`bundle.js` with the [through](https://www.npmjs.com/package/through)
|
||||
and [duplexer](https://www.npmjs.com/package/duplexer) modules.
|
||||
|
||||
```
|
||||
$ browserify -r through -r duplexer -r ./my-file.js:my-module > bundle.js
|
||||
```
|
||||
|
||||
Then in your page you can do:
|
||||
|
||||
``` html
|
||||
<script src="bundle.js"></script>
|
||||
<script>
|
||||
var through = require('through');
|
||||
var duplexer = require('duplexer');
|
||||
var myModule = require('my-module');
|
||||
/* ... */
|
||||
</script>
|
||||
```
|
||||
|
||||
## external source maps
|
||||
|
||||
If you prefer the source maps be saved to a separate `.js.map` source map file, you may use
|
||||
[exorcist](https://github.com/thlorenz/exorcist) in order to achieve that. It's as simple as:
|
||||
|
||||
```
|
||||
$ browserify main.js --debug | exorcist bundle.js.map > bundle.js
|
||||
```
|
||||
|
||||
Learn about additional options [here](https://github.com/thlorenz/exorcist#usage).
|
||||
|
||||
## multiple bundles
|
||||
|
||||
If browserify finds a `require`d function already defined in the page scope, it
|
||||
will fall back to that function if it didn't find any matches in its own set of
|
||||
bundled modules.
|
||||
|
||||
In this way, you can use browserify to split up bundles among multiple pages to
|
||||
get the benefit of caching for shared, infrequently-changing modules, while
|
||||
still being able to use `require()`. Just use a combination of `--external` and
|
||||
`--require` to factor out common dependencies.
|
||||
|
||||
For example, if a website with 2 pages, `beep.js`:
|
||||
|
||||
``` js
|
||||
var robot = require('./robot.js');
|
||||
console.log(robot('beep'));
|
||||
```
|
||||
|
||||
and `boop.js`:
|
||||
|
||||
``` js
|
||||
var robot = require('./robot.js');
|
||||
console.log(robot('boop'));
|
||||
```
|
||||
|
||||
both depend on `robot.js`:
|
||||
|
||||
``` js
|
||||
module.exports = function (s) { return s.toUpperCase() + '!' };
|
||||
```
|
||||
|
||||
```
|
||||
$ browserify -r ./robot.js > static/common.js
|
||||
$ browserify -x ./robot.js beep.js > static/beep.js
|
||||
$ browserify -x ./robot.js boop.js > static/boop.js
|
||||
```
|
||||
|
||||
Then on the beep page you can have:
|
||||
|
||||
``` html
|
||||
<script src="common.js"></script>
|
||||
<script src="beep.js"></script>
|
||||
```
|
||||
|
||||
while the boop page can have:
|
||||
|
||||
``` html
|
||||
<script src="common.js"></script>
|
||||
<script src="boop.js"></script>
|
||||
```
|
||||
|
||||
This approach using `-r` and `-x` works fine for a small number of split assets,
|
||||
but there are plugins for automatically factoring out components which are
|
||||
described in the
|
||||
[partitioning section of the browserify handbook](https://github.com/browserify/browserify-handbook#partitioning).
|
||||
|
||||
## api example
|
||||
|
||||
You can use the API directly too:
|
||||
|
||||
``` js
|
||||
var browserify = require('browserify');
|
||||
var b = browserify();
|
||||
b.add('./browser/main.js');
|
||||
b.bundle().pipe(process.stdout);
|
||||
```
|
||||
|
||||
# methods
|
||||
|
||||
``` js
|
||||
var browserify = require('browserify')
|
||||
```
|
||||
|
||||
## `browserify([files] [, opts])`
|
||||
|
||||
Returns a new browserify instance.
|
||||
|
||||
<dl>
|
||||
<dt>
|
||||
files
|
||||
</dt>
|
||||
|
||||
<dd>
|
||||
String, file object, or array of those types (they may be mixed) specifying entry file(s).
|
||||
</dd>
|
||||
|
||||
<dt>
|
||||
opts
|
||||
</dt>
|
||||
|
||||
<dd>
|
||||
Object.
|
||||
</dd>
|
||||
</dl>
|
||||
|
||||
`files` and `opts` are both optional, but must be in the order shown if both are
|
||||
passed.
|
||||
|
||||
Entry files may be passed in `files` and / or `opts.entries`.
|
||||
|
||||
External requires may be specified in `opts.require`, accepting the same formats
|
||||
that the `files` argument does.
|
||||
|
||||
If an entry file is a stream, its contents will be used. You should pass
|
||||
`opts.basedir` when using streaming files so that relative requires can be
|
||||
resolved.
|
||||
|
||||
`opts.entries` has the same definition as `files`.
|
||||
|
||||
`opts.noParse` is an array which will skip all require() and global parsing for
|
||||
each file in the array. Use this for giant libs like jquery or threejs that
|
||||
don't have any requires or node-style globals but take forever to parse.
|
||||
|
||||
`opts.transform` is an array of transform functions or modules names which will
|
||||
transform the source code before the parsing.
|
||||
|
||||
`opts.ignoreTransform` is an array of transformations that will not be run,
|
||||
even if specified elsewhere.
|
||||
|
||||
`opts.plugin` is an array of plugin functions or module names to use. See the
|
||||
plugins section below for details.
|
||||
|
||||
`opts.extensions` is an array of optional extra extensions for the module lookup
|
||||
machinery to use when the extension has not been specified.
|
||||
By default browserify considers only `.js` and `.json` files in such cases.
|
||||
|
||||
`opts.basedir` is the directory that browserify starts bundling from for
|
||||
filenames that start with `.`.
|
||||
|
||||
`opts.paths` is an array of directories that browserify searches when looking
|
||||
for modules which are not referenced using relative path. Can be absolute or
|
||||
relative to `basedir`. Equivalent of setting `NODE_PATH` environmental variable
|
||||
when calling `browserify` command.
|
||||
|
||||
`opts.commondir` sets the algorithm used to parse out the common paths. Use
|
||||
`false` to turn this off, otherwise it uses the
|
||||
[commondir](https://www.npmjs.com/package/commondir) module.
|
||||
|
||||
`opts.fullPaths` disables converting module ids into numerical indexes. This is
|
||||
useful for preserving the original paths that a bundle was generated with.
|
||||
|
||||
`opts.builtins` sets the list of built-ins to use, which by default is set in
|
||||
`lib/builtins.js` in this distribution.
|
||||
|
||||
`opts.bundleExternal` boolean option to set if external modules should be
|
||||
bundled. Defaults to true.
|
||||
|
||||
When `opts.browserField` is false, the package.json browser field will be
|
||||
ignored. When `opts.browserField` is set to a `string`, then a custom field name
|
||||
can be used instead of the default `"browser"` field.
|
||||
|
||||
When `opts.insertGlobals` is true, always insert `process`, `global`,
|
||||
`__filename`, and `__dirname` without analyzing the AST for faster builds but
|
||||
larger output bundles. Default false.
|
||||
|
||||
When `opts.detectGlobals` is true, scan all files for `process`, `global`,
|
||||
`__filename`, and `__dirname`, defining as necessary. With this option npm
|
||||
modules are more likely to work but bundling takes longer. Default true.
|
||||
|
||||
When `opts.ignoreMissing` is true, ignore `require()` statements that don't
|
||||
resolve to anything.
|
||||
|
||||
When `opts.debug` is true, add a source map inline to the end of the bundle.
|
||||
This makes debugging easier because you can see all the original files if
|
||||
you are in a modern enough browser.
|
||||
|
||||
When `opts.standalone` is a non-empty string, a standalone module is created
|
||||
with that name and a [umd](https://github.com/forbeslindesay/umd) wrapper.
|
||||
You can use namespaces in the standalone global export using a `.` in the string
|
||||
name as a separator, for example `'A.B.C'`. The global export will be [sanitized
|
||||
and camel cased](https://github.com/ForbesLindesay/umd#name-casing-and-characters).
|
||||
|
||||
Note that in standalone mode the `require()` calls from the original source will
|
||||
still be around, which may trip up AMD loaders scanning for `require()` calls.
|
||||
You can remove these calls with
|
||||
[derequire](https://www.npmjs.com/package/derequire):
|
||||
|
||||
```
|
||||
$ npm install derequire
|
||||
$ browserify main.js --standalone Foo | derequire > bundle.js
|
||||
```
|
||||
|
||||
`opts.insertGlobalVars` will be passed to
|
||||
[insert-module-globals](https://www.npmjs.com/package/insert-module-globals)
|
||||
as the `opts.vars` parameter.
|
||||
|
||||
`opts.externalRequireName` defaults to `'require'` in `expose` mode but you can
|
||||
use another name.
|
||||
|
||||
`opts.bare` creates a bundle that does not include Node builtins, and does not
|
||||
replace global Node variables except for `__dirname` and `__filename`.
|
||||
|
||||
`opts.node` creates a bundle that runs in Node and does not use the browser
|
||||
versions of dependencies. Same as passing `{ bare: true, browserField: false }`.
|
||||
|
||||
Note that if files do not contain javascript source code then you also need to
|
||||
specify a corresponding transform for them.
|
||||
|
||||
All other options are forwarded along to
|
||||
[module-deps](https://www.npmjs.com/package/module-deps)
|
||||
and [browser-pack](https://www.npmjs.com/package/browser-pack) directly.
|
||||
|
||||
## b.add(file, opts)
|
||||
|
||||
Add an entry file from `file` that will be executed when the bundle loads.
|
||||
|
||||
If `file` is an array, each item in `file` will be added as an entry file.
|
||||
|
||||
## b.require(file, opts)
|
||||
|
||||
Make `file` available from outside the bundle with `require(file)`.
|
||||
|
||||
The `file` param is anything that can be resolved by `require.resolve()`,
|
||||
including files from `node_modules`. Like with `require.resolve()`, you must
|
||||
prefix `file` with `./` to require a local file (not in `node_modules`).
|
||||
|
||||
`file` can also be a stream, but you should also use `opts.basedir` so that
|
||||
relative requires will be resolvable.
|
||||
|
||||
If `file` is an array, each item in `file` will be required.
|
||||
In `file` array form, you can use a string or object for each item. Object items
|
||||
should have a `file` property and the rest of the parameters will be used for
|
||||
the `opts`.
|
||||
|
||||
Use the `expose` property of opts to specify a custom dependency name.
|
||||
`require('./vendor/angular/angular.js', {expose: 'angular'})` enables `require('angular')`
|
||||
|
||||
## b.bundle(cb)
|
||||
|
||||
Bundle the files and their dependencies into a single javascript file.
|
||||
|
||||
Return a readable stream with the javascript file contents or
|
||||
optionally specify a `cb(err, buf)` to get the buffered results.
|
||||
|
||||
## b.external(file)
|
||||
|
||||
Prevent `file` from being loaded into the current bundle, instead referencing
|
||||
from another bundle.
|
||||
|
||||
If `file` is an array, each item in `file` will be externalized.
|
||||
|
||||
If `file` is another bundle, that bundle's contents will be read and excluded
|
||||
from the current bundle as the bundle in `file` gets bundled.
|
||||
|
||||
## b.ignore(file)
|
||||
|
||||
Prevent the module name or file at `file` from showing up in the output bundle.
|
||||
|
||||
If `file` is an array, each item in `file` will be ignored.
|
||||
|
||||
Instead you will get a file with `module.exports = {}`.
|
||||
|
||||
## b.exclude(file)
|
||||
|
||||
Prevent the module name or file at `file` from showing up in the output bundle.
|
||||
|
||||
If `file` is an array, each item in `file` will be excluded.
|
||||
|
||||
If your code tries to `require()` that file it will throw unless you've provided
|
||||
another mechanism for loading it.
|
||||
|
||||
## b.transform(tr, opts={})
|
||||
|
||||
Transform source code before parsing it for `require()` calls with the transform
|
||||
function or module name `tr`.
|
||||
|
||||
If `tr` is a function, it will be called with `tr(file)` and it should return a
|
||||
[through-stream](https://github.com/substack/stream-handbook#through)
|
||||
that takes the raw file contents and produces the transformed source.
|
||||
|
||||
If `tr` is a string, it should be a module name or file path of a
|
||||
[transform module](https://github.com/browserify/module-deps#transforms)
|
||||
with a signature of:
|
||||
|
||||
``` js
|
||||
var through = require('through');
|
||||
module.exports = function (file) { return through() };
|
||||
```
|
||||
|
||||
You don't need to necessarily use the
|
||||
[through](https://www.npmjs.com/package/through) module.
|
||||
Browserify is compatible with the newer, more verbose
|
||||
[Transform streams](http://nodejs.org/api/stream.html#stream_class_stream_transform_1)
|
||||
built into Node v0.10.
|
||||
|
||||
Here's how you might compile coffee script on the fly using `.transform()`:
|
||||
|
||||
``` js
|
||||
var coffee = require('coffee-script');
|
||||
var through = require('through');
|
||||
|
||||
b.transform(function (file) {
|
||||
var data = '';
|
||||
return through(write, end);
|
||||
|
||||
function write (buf) { data += buf }
|
||||
function end () {
|
||||
this.queue(coffee.compile(data));
|
||||
this.queue(null);
|
||||
}
|
||||
});
|
||||
```
|
||||
|
||||
Note that on the command-line with the `-c` flag you can just do:
|
||||
|
||||
```
|
||||
$ browserify -c 'coffee -sc' main.coffee > bundle.js
|
||||
```
|
||||
|
||||
Or better still, use the [coffeeify](https://github.com/jnordberg/coffeeify)
|
||||
module:
|
||||
|
||||
```
|
||||
$ npm install coffeeify
|
||||
$ browserify -t coffeeify main.coffee > bundle.js
|
||||
```
|
||||
|
||||
If `opts.global` is `true`, the transform will operate on ALL files, despite
|
||||
whether they exist up a level in a `node_modules/` directory. Use global
|
||||
transforms cautiously and sparingly, since most of the time an ordinary
|
||||
transform will suffice. You can also not configure global transforms in a
|
||||
`package.json` like you can with ordinary transforms.
|
||||
|
||||
Global transforms always run after any ordinary transforms have run.
|
||||
|
||||
Transforms may obtain options from the command-line with
|
||||
[subarg](https://www.npmjs.com/package/subarg) syntax:
|
||||
|
||||
```
|
||||
$ browserify -t [ foo --bar=555 ] main.js
|
||||
```
|
||||
|
||||
or from the api:
|
||||
|
||||
```
|
||||
b.transform('foo', { bar: 555 })
|
||||
```
|
||||
|
||||
In both cases, these options are provided as the second argument to the
|
||||
transform function:
|
||||
|
||||
```
|
||||
module.exports = function (file, opts) { /* opts.bar === 555 */ }
|
||||
```
|
||||
|
||||
Options sent to the browserify constructor are also provided under
|
||||
`opts._flags`. These browserify options are sometimes required if your transform
|
||||
needs to do something different when browserify is run in debug mode, for
|
||||
example.
|
||||
|
||||
## b.plugin(plugin, opts)
|
||||
|
||||
Register a `plugin` with `opts`. Plugins can be a string module name or a
|
||||
function the same as transforms.
|
||||
|
||||
`plugin(b, opts)` is called with the browserify instance `b`.
|
||||
|
||||
For more information, consult the plugins section below.
|
||||
|
||||
## b.pipeline
|
||||
|
||||
There is an internal
|
||||
[labeled-stream-splicer](https://www.npmjs.com/package/labeled-stream-splicer)
|
||||
pipeline with these labels:
|
||||
|
||||
* `'record'` - save inputs to play back later on subsequent `bundle()` calls
|
||||
* `'deps'` - [module-deps](https://www.npmjs.com/package/module-deps)
|
||||
* `'json'` - adds `module.exports=` to the beginning of json files
|
||||
* `'unbom'` - remove byte-order markers
|
||||
* `'unshebang'` - remove #! labels on the first line
|
||||
* `'syntax'` - check for syntax errors
|
||||
* `'sort'` - sort the dependencies for deterministic bundles
|
||||
* `'dedupe'` - remove duplicate source contents
|
||||
* `'label'` - apply integer labels to files
|
||||
* `'emit-deps'` - emit `'dep'` event
|
||||
* `'debug'` - apply source maps
|
||||
* `'pack'` - [browser-pack](https://www.npmjs.com/package/browser-pack)
|
||||
* `'wrap'` - apply final wrapping, `require=` and a newline and semicolon
|
||||
|
||||
You can call `b.pipeline.get()` with a label name to get a handle on a stream pipeline
|
||||
that you can `push()`, `unshift()`, or `splice()` to insert your own transform
|
||||
streams.
|
||||
|
||||
## b.reset(opts)
|
||||
|
||||
Reset the pipeline back to a normal state. This function is called automatically
|
||||
when `bundle()` is called multiple times.
|
||||
|
||||
This function triggers a 'reset' event.
|
||||
|
||||
# package.json
|
||||
|
||||
browserify uses the `package.json` in its module resolution algorithm, just like
|
||||
node. If there is a `"main"` field, browserify will start resolving the package
|
||||
at that point. If there is no `"main"` field, browserify will look for an
|
||||
`"index.js"` file in the module root directory. Here are some more
|
||||
sophisticated things you can do in the package.json:
|
||||
|
||||
## browser field
|
||||
|
||||
There is a special "[browser](https://github.com/defunctzombie/package-browser-field-spec)" field you can
|
||||
set in your package.json on a per-module basis to override file resolution for
|
||||
browser-specific versions of files.
|
||||
|
||||
For example, if you want to have a browser-specific module entry point for your
|
||||
`"main"` field you can just set the `"browser"` field to a string:
|
||||
|
||||
``` json
|
||||
"browser": "./browser.js"
|
||||
```
|
||||
|
||||
or you can have overrides on a per-file basis:
|
||||
|
||||
``` json
|
||||
"browser": {
|
||||
"fs": "level-fs",
|
||||
"./lib/ops.js": "./browser/opts.js"
|
||||
}
|
||||
```
|
||||
|
||||
Note that the browser field only applies to files in the local module, and like
|
||||
transforms, it doesn't apply into `node_modules` directories.
|
||||
|
||||
## browserify.transform
|
||||
|
||||
You can specify source transforms in the package.json in the
|
||||
`browserify.transform` field. There is more information about how source
|
||||
transforms work in package.json on the
|
||||
[module-deps readme](https://github.com/browserify/module-deps#transforms).
|
||||
|
||||
For example, if your module requires [brfs](https://www.npmjs.com/package/brfs), you
|
||||
can add
|
||||
|
||||
``` json
|
||||
"browserify": { "transform": [ "brfs" ] }
|
||||
```
|
||||
|
||||
to your package.json. Now when somebody `require()`s your module, brfs will
|
||||
automatically be applied to the files in your module without explicit
|
||||
intervention by the person using your module. Make sure to add transforms to
|
||||
your package.json dependencies field.
|
||||
|
||||
# events
|
||||
|
||||
## b.on('file', function (file, id, parent) {})
|
||||
## b.pipeline.on('file', function (file, id, parent) {})
|
||||
|
||||
When a file is resolved for the bundle, the bundle emits a `'file'` event with
|
||||
the full `file` path, the `id` string passed to `require()`, and the `parent`
|
||||
object used by
|
||||
[browser-resolve](https://github.com/defunctzombie/node-browser-resolve).
|
||||
|
||||
You could use the `file` event to implement a file watcher to regenerate bundles
|
||||
when files change.
|
||||
|
||||
## b.on('package', function (pkg) {})
|
||||
## b.pipeline.on('package', function (pkg) {})
|
||||
|
||||
When a package file is read, this event fires with the contents. The package
|
||||
directory is available at `pkg.__dirname`.
|
||||
|
||||
## b.on('bundle', function (bundle) {})
|
||||
|
||||
When `.bundle()` is called, this event fires with the `bundle` output stream.
|
||||
|
||||
## b.on('reset', function () {})
|
||||
|
||||
When the `.reset()` method is called or implicitly called by another call to
|
||||
`.bundle()`, this event fires.
|
||||
|
||||
## b.on('transform', function (tr, file) {})
|
||||
## b.pipeline.on('transform', function (tr, file) {})
|
||||
|
||||
When a transform is applied to a file, the `'transform'` event fires on the
|
||||
bundle stream with the transform stream `tr` and the `file` that the transform
|
||||
is being applied to.
|
||||
|
||||
# plugins
|
||||
|
||||
For some more advanced use-cases, a transform is not sufficiently extensible.
|
||||
Plugins are modules that take the bundle instance as their first parameter and
|
||||
an option hash as their second.
|
||||
|
||||
Plugins can be used to do perform some fancy features that transforms can't do.
|
||||
For example, [factor-bundle](https://www.npmjs.com/package/factor-bundle) is a
|
||||
plugin that can factor out common dependencies from multiple entry-points into a
|
||||
common bundle. Use plugins with `-p` and pass options to plugins with
|
||||
[subarg](https://www.npmjs.com/package/subarg) syntax:
|
||||
|
||||
```
|
||||
browserify x.js y.js -p [ factor-bundle -o bundle/x.js -o bundle/y.js ] \
|
||||
> bundle/common.js
|
||||
```
|
||||
|
||||
For a list of plugins, consult the
|
||||
[browserify-plugin tag](https://www.npmjs.com/browse/keyword/browserify-plugin)
|
||||
on npm.
|
||||
|
||||
# list of source transforms
|
||||
|
||||
There is a [wiki page that lists the known browserify
|
||||
transforms](https://github.com/browserify/browserify/wiki/list-of-transforms).
|
||||
|
||||
If you write a transform, make sure to add your transform to that wiki page and
|
||||
add a package.json keyword of `browserify-transform` so that
|
||||
[people can browse for all the browserify
|
||||
transforms](https://www.npmjs.com/browse/keyword/browserify-transform) on npmjs.org.
|
||||
|
||||
# third-party tools
|
||||
|
||||
There is a [wiki page that lists the known browserify
|
||||
tools](https://github.com/browserify/browserify/wiki/browserify-tools).
|
||||
|
||||
If you write a tool, make sure to add it to that wiki page and
|
||||
add a package.json keyword of `browserify-tool` so that
|
||||
[people can browse for all the browserify
|
||||
tools](https://www.npmjs.com/browse/keyword/browserify-tool) on npmjs.org.
|
||||
|
||||
# changelog
|
||||
|
||||
Releases are documented in
|
||||
[changelog.markdown](changelog.markdown) and on the
|
||||
[browserify twitter feed](https://twitter.com/browserify).
|
||||
|
||||
# license
|
||||
|
||||
[MIT](./LICENSE)
|
||||
|
||||

|
||||
10
node_modules/browserify/security.md
generated
vendored
Normal file
10
node_modules/browserify/security.md
generated
vendored
Normal 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.
|
||||
72
node_modules/browserify/test/args.js
generated
vendored
Normal file
72
node_modules/browserify/test/args.js
generated
vendored
Normal file
@@ -0,0 +1,72 @@
|
||||
var test = require('tap').test;
|
||||
var fromArgs = require('../bin/args.js');
|
||||
var path = require('path');
|
||||
var vm = require('vm');
|
||||
|
||||
test('bundle from an arguments array', function (t) {
|
||||
t.plan(2);
|
||||
|
||||
var b = fromArgs([ __dirname + '/entry/two.js', '-s', 'XYZ' ]);
|
||||
b.bundle(function (err, src) {
|
||||
t.ifError(err);
|
||||
var c = { window: {} };
|
||||
vm.runInNewContext(src, c);
|
||||
t.equal(c.window.XYZ, 2);
|
||||
});
|
||||
});
|
||||
|
||||
test('external flag for node modules', function(t) {
|
||||
t.plan(2);
|
||||
|
||||
var b = fromArgs([ __dirname + '/external_args/main.js', '-x', 'backbone' ]);
|
||||
b.bundle(function (err, src) {
|
||||
t.ifError(err);
|
||||
vm.runInNewContext(src, {t: t});
|
||||
});
|
||||
});
|
||||
|
||||
test('bundle from an arguments with --insert-global-vars', function (t) {
|
||||
t.plan(4);
|
||||
|
||||
var b = fromArgs([
|
||||
__dirname + '/global/filename.js',
|
||||
'--insert-global-vars=__filename,__dirname',
|
||||
'--basedir', __dirname
|
||||
]);
|
||||
b.require(__dirname + '/global/filename.js', { expose: 'x' });
|
||||
b.bundle(function (err, src) {
|
||||
t.ifError(err, 'b.bundle()');
|
||||
var c = {}, x;
|
||||
vm.runInNewContext(src, c);
|
||||
t.doesNotThrow(function() {
|
||||
x = c.require('x');
|
||||
}, 'x = c.require(\'x\')');
|
||||
t.equal(x && x.filename, '/global/filename.js', 'x.filename');
|
||||
t.equal(x && x.dirname, '/global', 'x.dirname');
|
||||
})
|
||||
});
|
||||
|
||||
test('numeric module names', function(t) {
|
||||
t.plan(1);
|
||||
|
||||
var b = fromArgs([ '-x', '1337' ]);
|
||||
b.bundle(function (err, src) {
|
||||
t.ifError(err);
|
||||
});
|
||||
});
|
||||
|
||||
test('entry expose', function (t) {
|
||||
t.plan(3)
|
||||
|
||||
var b = fromArgs([
|
||||
path.join(__dirname, '/entry_expose/main.js'),
|
||||
'--require', path.join(__dirname, '/entry_expose/main.js') + ':x',
|
||||
]);
|
||||
b.bundle(function (err, src) {
|
||||
t.ifError(err);
|
||||
var c = { console: { log: log } };
|
||||
function log (msg) { t.equal(msg, 'wow') }
|
||||
vm.runInNewContext(src, c);
|
||||
t.equal(c.require('x'), 555);
|
||||
})
|
||||
});
|
||||
74
node_modules/browserify/test/array.js
generated
vendored
Normal file
74
node_modules/browserify/test/array.js
generated
vendored
Normal file
@@ -0,0 +1,74 @@
|
||||
var browserify = require('../');
|
||||
var vm = require('vm');
|
||||
var test = require('tap').test;
|
||||
|
||||
test('array add', function (t) {
|
||||
var expected = [ 'ONE', 'TWO', 'THREE' ];
|
||||
t.plan(expected.length);
|
||||
|
||||
var b = browserify();
|
||||
var files = [
|
||||
__dirname + '/array/one.js',
|
||||
__dirname + '/array/two.js',
|
||||
__dirname + '/array/three.js'
|
||||
];
|
||||
b.add(files);
|
||||
b.bundle(function (err, src) {
|
||||
vm.runInNewContext(src, { console: { log: log } });
|
||||
function log (msg) {
|
||||
t.equal(msg, expected.shift());
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
test('array require', function (t) {
|
||||
t.plan(3);
|
||||
|
||||
var b = browserify();
|
||||
var files = [ 'defined', 'subarg' ];
|
||||
b.require(files);
|
||||
b.bundle(function (err, src) {
|
||||
var c = {};
|
||||
vm.runInNewContext(src, c);
|
||||
|
||||
t.equal(c.require('defined')(undefined, true), true);
|
||||
t.equal(c.require('defined')(undefined, false), false);
|
||||
t.deepEqual(c.require('subarg')(['-x', '3']), { x: 3, _: [] });
|
||||
});
|
||||
});
|
||||
|
||||
test('array require opts', function (t) {
|
||||
t.plan(3);
|
||||
|
||||
var b = browserify();
|
||||
var files = [
|
||||
{ file: require.resolve('defined'), expose: 'abc' },
|
||||
{ file: require.resolve('subarg'), expose: 'def' }
|
||||
];
|
||||
b.require(files);
|
||||
b.bundle(function (err, src) {
|
||||
var c = {};
|
||||
vm.runInNewContext(src, c);
|
||||
|
||||
t.equal(c.require('abc')(undefined, true), true);
|
||||
t.equal(c.require('abc')(undefined, false), false);
|
||||
t.deepEqual(c.require('def')(['-x', '3']), { x: 3, _: [] });
|
||||
});
|
||||
});
|
||||
|
||||
test('array external', function (t) {
|
||||
t.plan(2);
|
||||
|
||||
var b = browserify(__dirname + '/external/main.js');
|
||||
b.external(['util','freelist']);
|
||||
b.bundle(function (err, src) {
|
||||
if (err) return t.fail(err);
|
||||
vm.runInNewContext(
|
||||
'function require (x) {'
|
||||
+ 'if (x==="freelist") return function (n) { return n + 1000 }'
|
||||
+ '}'
|
||||
+ src,
|
||||
{ t: t }
|
||||
);
|
||||
});
|
||||
});
|
||||
1
node_modules/browserify/test/array/one.js
generated
vendored
Normal file
1
node_modules/browserify/test/array/one.js
generated
vendored
Normal file
@@ -0,0 +1 @@
|
||||
console.log('ONE');
|
||||
1
node_modules/browserify/test/array/three.js
generated
vendored
Normal file
1
node_modules/browserify/test/array/three.js
generated
vendored
Normal file
@@ -0,0 +1 @@
|
||||
console.log('THREE');
|
||||
1
node_modules/browserify/test/array/two.js
generated
vendored
Normal file
1
node_modules/browserify/test/array/two.js
generated
vendored
Normal file
@@ -0,0 +1 @@
|
||||
console.log('TWO');
|
||||
24
node_modules/browserify/test/async.js
generated
vendored
Normal file
24
node_modules/browserify/test/async.js
generated
vendored
Normal file
@@ -0,0 +1,24 @@
|
||||
var browserify = require('../');
|
||||
var fs = require('fs');
|
||||
var vm = require('vm');
|
||||
var test = require('tap').test;
|
||||
|
||||
var src = fs.readFileSync(__dirname + '/async/src.js','utf8');
|
||||
var canAsync = true;
|
||||
try { Function(src) } catch (err) { canAsync = false }
|
||||
|
||||
if (!canAsync) console.error('# async/await unsupported in this environment')
|
||||
else test('async/await', function (t) {
|
||||
t.plan(2);
|
||||
var b = browserify(__dirname + '/async/src.js');
|
||||
b.bundle(function (err, src) {
|
||||
t.error(err)
|
||||
var c = {
|
||||
console: { log: log },
|
||||
setTimeout: setTimeout,
|
||||
clearTimeout: clearTimeout
|
||||
}
|
||||
vm.runInNewContext(src, c);
|
||||
function log (msg) { t.equal(msg, 60) }
|
||||
});
|
||||
});
|
||||
8
node_modules/browserify/test/async/src.js
generated
vendored
Normal file
8
node_modules/browserify/test/async/src.js
generated
vendored
Normal file
@@ -0,0 +1,8 @@
|
||||
function f (x) { return new Promise(resolve => {
|
||||
process.nextTick(() => { resolve(x) }) }) }
|
||||
|
||||
async function add (x) {
|
||||
return x + await f(20) + await f(30)
|
||||
}
|
||||
|
||||
add(10).then(v => { console.log(v) })
|
||||
23
node_modules/browserify/test/backbone.js
generated
vendored
Normal file
23
node_modules/browserify/test/backbone.js
generated
vendored
Normal file
@@ -0,0 +1,23 @@
|
||||
var browserify = require('../');
|
||||
var vm = require('vm');
|
||||
var backbone = require('backbone');
|
||||
var test = require('tap').test;
|
||||
|
||||
test('backbone', function (t) {
|
||||
t.plan(3);
|
||||
var b = browserify();
|
||||
b.require('backbone');
|
||||
b.bundle(function (err, buf) {
|
||||
t.ok(Buffer.isBuffer(buf));
|
||||
var src = buf.toString('utf8');
|
||||
t.ok(src.length > 0);
|
||||
|
||||
var c = { console: console };
|
||||
vm.runInNewContext(src, c);
|
||||
t.deepEqual(
|
||||
Object.keys(backbone).sort(),
|
||||
Object.keys(c.require('backbone')).sort()
|
||||
);
|
||||
t.end();
|
||||
});
|
||||
});
|
||||
173
node_modules/browserify/test/bare.js
generated
vendored
Normal file
173
node_modules/browserify/test/bare.js
generated
vendored
Normal file
@@ -0,0 +1,173 @@
|
||||
var test = require('tap').test;
|
||||
var spawn = require('child_process').spawn;
|
||||
var browserify = require('../');
|
||||
var path = require('path');
|
||||
var concat = require('concat-stream');
|
||||
var vm = require('vm');
|
||||
var fs = require('fs');
|
||||
var through = require('through2');
|
||||
var temp = require('temp');
|
||||
temp.track();
|
||||
var tmpdir = temp.mkdirSync({prefix: 'browserify-test'});
|
||||
|
||||
test('bare', function (t) {
|
||||
t.plan(4);
|
||||
|
||||
var cwd = process.cwd();
|
||||
process.chdir(__dirname);
|
||||
|
||||
var ps = spawn(process.execPath, [
|
||||
path.resolve(__dirname, '../bin/cmd.js'),
|
||||
'-', '--bare'
|
||||
]);
|
||||
ps.stdout.pipe(concat(function (body) {
|
||||
vm.runInNewContext(body, {
|
||||
Buffer: function (s) { return s.toLowerCase() },
|
||||
console: {
|
||||
log: function (msg) { t.equal(msg, 'abc') }
|
||||
}
|
||||
});
|
||||
vm.runInNewContext(body, {
|
||||
Buffer: Buffer,
|
||||
console: {
|
||||
log: function (msg) {
|
||||
t.ok(Buffer.isBuffer(msg));
|
||||
t.equal(msg.toString('utf8'), 'ABC')
|
||||
}
|
||||
}
|
||||
});
|
||||
}));
|
||||
ps.stdin.end('console.log(Buffer("ABC"))');
|
||||
|
||||
ps.on('exit', function (code) {
|
||||
t.equal(code, 0);
|
||||
});
|
||||
});
|
||||
|
||||
test('bare api', function (t) {
|
||||
t.plan(3);
|
||||
|
||||
var input = through();
|
||||
var b = browserify(input, { bare: true });
|
||||
b.bundle().pipe(concat(function (body) {
|
||||
vm.runInNewContext(body, {
|
||||
Buffer: function (s) { return s.toLowerCase() },
|
||||
console: {
|
||||
log: function (msg) { t.equal(msg, 'abc') }
|
||||
}
|
||||
});
|
||||
vm.runInNewContext(body, {
|
||||
Buffer: Buffer,
|
||||
console: {
|
||||
log: function (msg) {
|
||||
t.ok(Buffer.isBuffer(msg));
|
||||
t.equal(msg.toString('utf8'), 'ABC')
|
||||
}
|
||||
}
|
||||
});
|
||||
}));
|
||||
input.end('console.log(Buffer("ABC"))');
|
||||
});
|
||||
|
||||
test('bare inserts __filename,__dirname but not process,global,Buffer', function (t) {
|
||||
t.plan(2);
|
||||
|
||||
var file = path.resolve(__dirname, 'bare/main.js');
|
||||
var ps = spawn(process.execPath, [
|
||||
path.resolve(__dirname, '../bin/cmd.js'),
|
||||
file,
|
||||
'--bare'
|
||||
]);
|
||||
|
||||
ps.stdout.pipe(concat(function (body) {
|
||||
vm.runInNewContext(body, {
|
||||
require: require,
|
||||
__dirname: process.cwd(),
|
||||
console: {
|
||||
log: function (msg) {
|
||||
t.same(msg, [
|
||||
path.join(__dirname, 'bare'),
|
||||
path.join(__dirname, 'bare/main.js'),
|
||||
'undefined',
|
||||
'undefined',
|
||||
'undefined'
|
||||
]);
|
||||
}
|
||||
}
|
||||
});
|
||||
}));
|
||||
ps.stdin.end();
|
||||
|
||||
ps.on('exit', function (code) {
|
||||
t.equal(code, 0);
|
||||
});
|
||||
});
|
||||
|
||||
test('bare inserts dynamic __filename,__dirname', function (t) {
|
||||
t.plan(2);
|
||||
|
||||
var file = path.join(tmpdir, 'dirname-filename.js');
|
||||
|
||||
fs.writeFileSync(
|
||||
file,
|
||||
fs.readFileSync(path.resolve(__dirname, 'bare/dirname-filename.js'))
|
||||
);
|
||||
|
||||
var ps = spawn(process.execPath, [
|
||||
path.resolve(__dirname, '../bin/cmd.js'),
|
||||
file,
|
||||
'--bare'
|
||||
]);
|
||||
|
||||
ps.stdout.pipe(concat(function (body) {
|
||||
vm.runInNewContext(body, {
|
||||
require: require,
|
||||
__dirname: process.cwd(),
|
||||
console: {
|
||||
log: function (msg) {
|
||||
t.same(msg, [
|
||||
path.dirname(file),
|
||||
file
|
||||
]);
|
||||
}
|
||||
}
|
||||
});
|
||||
}));
|
||||
ps.stdin.end();
|
||||
|
||||
ps.on('exit', function (code) {
|
||||
t.equal(code, 0);
|
||||
});
|
||||
});
|
||||
|
||||
test('bare inserts dynamic __filename,__dirname with basedir', function (t) {
|
||||
t.plan(2);
|
||||
|
||||
var file = 'dirname-filename.js';
|
||||
var ps = spawn(process.execPath, [
|
||||
path.resolve(__dirname, '../bin/cmd.js'),
|
||||
file,
|
||||
'--bare',
|
||||
'--basedir=' + path.join(__dirname, 'bare')
|
||||
]);
|
||||
|
||||
ps.stdout.pipe(concat(function (body) {
|
||||
vm.runInNewContext(body, {
|
||||
require: require,
|
||||
__dirname: process.cwd(),
|
||||
console: {
|
||||
log: function (msg) {
|
||||
t.same(msg, [
|
||||
__dirname,
|
||||
path.join(__dirname, file)
|
||||
]);
|
||||
}
|
||||
}
|
||||
});
|
||||
}));
|
||||
ps.stdin.end();
|
||||
|
||||
ps.on('exit', function (code) {
|
||||
t.equal(code, 0);
|
||||
});
|
||||
});
|
||||
4
node_modules/browserify/test/bare/dirname-filename.js
generated
vendored
Normal file
4
node_modules/browserify/test/bare/dirname-filename.js
generated
vendored
Normal file
@@ -0,0 +1,4 @@
|
||||
console.log([
|
||||
__dirname,
|
||||
__filename
|
||||
]);
|
||||
7
node_modules/browserify/test/bare/main.js
generated
vendored
Normal file
7
node_modules/browserify/test/bare/main.js
generated
vendored
Normal file
@@ -0,0 +1,7 @@
|
||||
console.log([
|
||||
__dirname,
|
||||
__filename,
|
||||
typeof process,
|
||||
typeof global,
|
||||
typeof Buffer
|
||||
]);
|
||||
37
node_modules/browserify/test/bare_shebang.js
generated
vendored
Normal file
37
node_modules/browserify/test/bare_shebang.js
generated
vendored
Normal file
@@ -0,0 +1,37 @@
|
||||
var test = require('tap').test;
|
||||
var spawn = require('child_process').spawn;
|
||||
var path = require('path');
|
||||
var concat = require('concat-stream');
|
||||
var vm = require('vm');
|
||||
|
||||
test('bare shebang', function (t) {
|
||||
t.plan(4);
|
||||
|
||||
var ps = spawn(process.execPath, [
|
||||
path.resolve(__dirname, '../bin/cmd.js'),
|
||||
'-', '--bare'
|
||||
]);
|
||||
ps.stderr.pipe(process.stderr);
|
||||
ps.stdout.pipe(concat(function (body) {
|
||||
vm.runInNewContext(body, {
|
||||
Buffer: function (s) { return s.toLowerCase() },
|
||||
console: {
|
||||
log: function (msg) { t.equal(msg, 'woo') }
|
||||
}
|
||||
});
|
||||
vm.runInNewContext(body, {
|
||||
Buffer: Buffer,
|
||||
console: {
|
||||
log: function (msg) {
|
||||
t.ok(Buffer.isBuffer(msg));
|
||||
t.equal(msg.toString('utf8'), 'WOO')
|
||||
}
|
||||
}
|
||||
});
|
||||
}));
|
||||
ps.stdin.end('#!/usr/bin/env node\nconsole.log(Buffer("WOO"))');
|
||||
|
||||
ps.on('exit', function (code) {
|
||||
t.equal(code, 0);
|
||||
});
|
||||
});
|
||||
31
node_modules/browserify/test/bin.js
generated
vendored
Normal file
31
node_modules/browserify/test/bin.js
generated
vendored
Normal file
@@ -0,0 +1,31 @@
|
||||
var test = require('tap').test;
|
||||
var spawn = require('child_process').spawn;
|
||||
var path = require('path');
|
||||
var vm = require('vm');
|
||||
|
||||
test('bin', function (t) {
|
||||
t.plan(3);
|
||||
|
||||
var cwd = process.cwd();
|
||||
process.chdir(__dirname);
|
||||
|
||||
var ps = spawn(process.execPath, [
|
||||
path.resolve(__dirname, '../bin/cmd.js'),
|
||||
'entry/main.js'
|
||||
]);
|
||||
var src = '';
|
||||
var err = '';
|
||||
ps.stdout.on('data', function (buf) { src += buf });
|
||||
ps.stderr.on('data', function (buf) { err += buf });
|
||||
|
||||
ps.on('exit', function (code) {
|
||||
t.equal(code, 0);
|
||||
t.equal(err, '');
|
||||
|
||||
var allDone = false;
|
||||
var c = { done : function () { allDone = true } };
|
||||
|
||||
vm.runInNewContext(src, c);
|
||||
t.ok(allDone);
|
||||
});
|
||||
});
|
||||
31
node_modules/browserify/test/bin_entry.js
generated
vendored
Normal file
31
node_modules/browserify/test/bin_entry.js
generated
vendored
Normal file
@@ -0,0 +1,31 @@
|
||||
var test = require('tap').test;
|
||||
var spawn = require('child_process').spawn;
|
||||
var path = require('path');
|
||||
var vm = require('vm');
|
||||
|
||||
test('bin --entry', function (t) {
|
||||
t.plan(3);
|
||||
|
||||
var cwd = process.cwd();
|
||||
process.chdir(__dirname);
|
||||
|
||||
var ps = spawn(process.execPath, [
|
||||
path.resolve(__dirname, '../bin/cmd.js'),
|
||||
'--entry', 'entry/main.js'
|
||||
]);
|
||||
var src = '';
|
||||
var err = '';
|
||||
ps.stdout.on('data', function (buf) { src += buf });
|
||||
ps.stderr.on('data', function (buf) { err += buf });
|
||||
|
||||
ps.on('exit', function (code) {
|
||||
t.equal(code, 0);
|
||||
t.equal(err, '');
|
||||
|
||||
var allDone = false;
|
||||
var c = { done : function () { allDone = true } };
|
||||
|
||||
vm.runInNewContext(src, c);
|
||||
t.ok(allDone);
|
||||
});
|
||||
});
|
||||
27
node_modules/browserify/test/bin_tr_error.js
generated
vendored
Normal file
27
node_modules/browserify/test/bin_tr_error.js
generated
vendored
Normal file
@@ -0,0 +1,27 @@
|
||||
var browserify = require('../');
|
||||
var spawn = require('child_process').spawn;
|
||||
var test = require('tap').test;
|
||||
var path = require('path')
|
||||
var semver = require('semver');
|
||||
|
||||
// TODO this should be fixable I guess
|
||||
var flaky = process.platform === 'win32' && semver.satisfies(process.version, 'v0.10.x');
|
||||
|
||||
test('function transform', { skip: flaky }, function (t) {
|
||||
t.plan(3);
|
||||
var ps = spawn(process.execPath, [
|
||||
path.resolve(__dirname, '../bin/cmd.js'),
|
||||
'-t', './tr.js', './main.js'
|
||||
], {cwd: path.resolve(__dirname, 'bin_tr_error')});
|
||||
var src = '';
|
||||
var err = '';
|
||||
ps.stdout.on('data', function (buf) { src += buf });
|
||||
ps.stderr.on('data', function (buf) { err += buf });
|
||||
|
||||
ps.on('exit', function (code) {
|
||||
t.notEqual(code, 0);
|
||||
var errorFile = path.resolve(__dirname, 'bin_tr_error', 'tr.js');
|
||||
t.notEqual(err.indexOf('there was error'), -1, 'Error should contain error message')
|
||||
t.notEqual(err.indexOf(errorFile), -1, 'Error should contain stack trace')
|
||||
});
|
||||
});
|
||||
1
node_modules/browserify/test/bin_tr_error/main.js
generated
vendored
Normal file
1
node_modules/browserify/test/bin_tr_error/main.js
generated
vendored
Normal file
@@ -0,0 +1 @@
|
||||
t.equal(XXX * 5, 555);
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user