08-27-周三_17-09-29
This commit is contained in:
6
node_modules/natives/LICENSE.md
generated
vendored
Normal file
6
node_modules/natives/LICENSE.md
generated
vendored
Normal file
@@ -0,0 +1,6 @@
|
||||
ISC License (ISC)
|
||||
Copyright 2018 Isaac Z. Schlueter
|
||||
|
||||
Permission to use, copy, modify, and/or distribute this software for any purpose with or without fee is hereby granted, provided that the above copyright notice and this permission notice appear in all copies.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
|
64
node_modules/natives/README.md
generated
vendored
Normal file
64
node_modules/natives/README.md
generated
vendored
Normal file
@@ -0,0 +1,64 @@
|
||||
# natives
|
||||
|
||||
Do stuff with Node.js's native JavaScript modules
|
||||
|
||||
## Caveat
|
||||
|
||||
Dear Beloved User,
|
||||
|
||||
I feel compelled to give you a word of warning if you are considering
|
||||
using this module.
|
||||
|
||||
This module lets you do some creative things with the JavaScript code
|
||||
in Node.js. There are some things here that are basically a recipe
|
||||
for memory leaks, or at the very least, being broken with each new
|
||||
release of Node, since none of these API surfaces are "technically"
|
||||
"supported" by the team managing the Node.js project.
|
||||
|
||||
This module does not ship a _copy_ of Node's internals. It does its
|
||||
thing by using the exposed source code that lives in Node.js itself.
|
||||
So, running this on different versions of Node.js will produce
|
||||
different results.
|
||||
|
||||
When your program is broken by changes to Node's internals, or when
|
||||
Node changes in such a way that this module becomes fundamentally
|
||||
broken, you will likely get little sympathy. Many people in the Node
|
||||
community consider this sort of behavior to be unwise and unseemly, if
|
||||
not outright hostile and morally wrong.
|
||||
|
||||
At the very least, you probably just want to run Node with the
|
||||
(undocumented!) `--expose-internals` flag, rather than go to such
|
||||
lengths.
|
||||
|
||||
Don't use unless you know what you're doing, or at least, are ok with
|
||||
the risks. Don't say I didn't warn you.
|
||||
|
||||
Eternally Yours in OSS,
|
||||
Isaac Z. Schlueter
|
||||
|
||||
## USAGE
|
||||
|
||||
```javascript
|
||||
var natives = require('natives')
|
||||
|
||||
// get the source code
|
||||
var fsCode = natives.source('fs')
|
||||
|
||||
// get a evaluated copy of the module
|
||||
var fsCopy = natives.require('fs')
|
||||
|
||||
// you can pass in a whitelist to NOT shim certain things
|
||||
var fsCopyWithNativeStreams = natives.require('fs', ['stream'])
|
||||
|
||||
// note that this is not the same as the "real" fs
|
||||
assert(fsCopy !== require('fs'))
|
||||
|
||||
// but it does have all the same entries
|
||||
fsCopy.readFileSync(__filename, 'utf8') // etc
|
||||
```
|
||||
|
||||
## Another Caveat
|
||||
|
||||
You can't use this to override `require("buffer")` because everything
|
||||
depends on `Buffer.isBuffer` working properly, so it's important for
|
||||
that one to be given a pass.
|
161
node_modules/natives/index.js
generated
vendored
Normal file
161
node_modules/natives/index.js
generated
vendored
Normal file
@@ -0,0 +1,161 @@
|
||||
var natives = process.binding('natives')
|
||||
var module = require('module')
|
||||
var normalRequire = require
|
||||
exports.source = src
|
||||
exports.require = req
|
||||
var vm = require('vm')
|
||||
|
||||
// fallback for 0.x support
|
||||
var runInThisContext, ContextifyScript, Script
|
||||
/*istanbul ignore next*/
|
||||
try {
|
||||
ContextifyScript = process.binding('contextify').ContextifyScript;
|
||||
/*istanbul ignore next*/
|
||||
if (process.version.split('.')[0].length > 2) { // v10.0.0 and above
|
||||
runInThisContext = vm.runInThisContext;
|
||||
} else {
|
||||
runInThisContext = function runInThisContext(code, options) {
|
||||
var script = new ContextifyScript(code, options);
|
||||
return script.runInThisContext();
|
||||
}
|
||||
}
|
||||
} catch (er) {
|
||||
Script = process.binding('evals').NodeScript;
|
||||
runInThisContext = Script.runInThisContext;
|
||||
}
|
||||
|
||||
var wrap = [
|
||||
'(function (internalBinding) {' +
|
||||
' return function (exports, require, module, __filename, __dirname) { ',
|
||||
'\n };\n});'
|
||||
];
|
||||
|
||||
|
||||
// Basically the same functionality as node's (buried deep)
|
||||
// NativeModule class, but without caching, or internal/ blocking,
|
||||
// or a class, since that's not really necessary. I assume that if
|
||||
// you're loading something with this module, it's because you WANT
|
||||
// a separate copy. However, to preserve semantics, any require()
|
||||
// calls made throughout the internal module load IS cached.
|
||||
function req (id, whitelist) {
|
||||
var cache = Object.create(null)
|
||||
|
||||
if (Array.isArray(whitelist)) {
|
||||
// a whitelist of things to pull from the "actual" native modules
|
||||
whitelist.forEach(function (id) {
|
||||
cache[id] = {
|
||||
loading: false,
|
||||
loaded: true,
|
||||
filename: id + '.js',
|
||||
exports: require(id)
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
return req_(id, cache)
|
||||
}
|
||||
|
||||
function req_ (id, cache) {
|
||||
// Buffer is special, because it's a type rather than a "normal"
|
||||
// class, and many things depend on `Buffer.isBuffer` working.
|
||||
if (id === 'buffer') {
|
||||
return require('buffer')
|
||||
}
|
||||
|
||||
// native_module isn't actually a natives binding.
|
||||
// weird, right?
|
||||
if (id === 'native_module') {
|
||||
return {
|
||||
getSource: src,
|
||||
wrap: function (script) {
|
||||
return wrap[0] + script + wrap[1]
|
||||
},
|
||||
wrapper: wrap,
|
||||
_cache: cache,
|
||||
_source: natives,
|
||||
nonInternalExists: function (id) {
|
||||
return id.indexOf('internal/') !== 0;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
var source = src(id)
|
||||
if (!source) {
|
||||
return undefined
|
||||
}
|
||||
source = wrap[0] + source + wrap[1]
|
||||
|
||||
var internalBinding = function(name) {
|
||||
if (name === 'types') {
|
||||
return process.binding('util');
|
||||
} else {
|
||||
try {
|
||||
return process.binding(name);
|
||||
} catch (e) {}
|
||||
return {};
|
||||
}
|
||||
}
|
||||
|
||||
var cachingRequire = function require (id) {
|
||||
if (cache[id]) {
|
||||
return cache[id].exports
|
||||
}
|
||||
if (id === 'internal/bootstrap/loaders' || id === 'internal/process') {
|
||||
// Provide just enough to keep `graceful-fs@3` working and tests passing.
|
||||
// For now.
|
||||
return {
|
||||
internalBinding: internalBinding,
|
||||
NativeModule: {
|
||||
_source: process.binding('natives'),
|
||||
nonInternalExists: function(id) {
|
||||
return !id.startsWith('internal/');
|
||||
}
|
||||
}
|
||||
};
|
||||
}
|
||||
return req_(id, cache)
|
||||
}
|
||||
|
||||
var nm = {
|
||||
exports: {},
|
||||
loading: true,
|
||||
loaded: false,
|
||||
filename: id + '.js'
|
||||
}
|
||||
cache[id] = nm
|
||||
var fn
|
||||
var setV8Flags = false
|
||||
try {
|
||||
require('v8').setFlagsFromString('--allow_natives_syntax')
|
||||
setV8Flags = true
|
||||
} catch (e) {}
|
||||
try {
|
||||
/* istanbul ignore else */
|
||||
if (ContextifyScript) {
|
||||
fn = runInThisContext(source, {
|
||||
filename: nm.filename,
|
||||
lineOffset: 0,
|
||||
displayErrors: true
|
||||
});
|
||||
} else {
|
||||
fn = runInThisContext(source, nm.filename, true);
|
||||
}
|
||||
fn(internalBinding)(nm.exports, cachingRequire, nm, nm.filename, '<no dirname available>')
|
||||
nm.loaded = true
|
||||
} finally {
|
||||
nm.loading = false
|
||||
/*istanbul ignore next*/
|
||||
if (setV8Flags) {
|
||||
// Ref: https://github.com/nodejs/node/blob/591a24b819d53a555463b1cbf9290a6d8bcc1bcb/lib/internal/bootstrap_node.js#L429-L434
|
||||
var re = /^--allow[-_]natives[-_]syntax$/
|
||||
if (!process.execArgv.some(function (s) { return re.test(s) }))
|
||||
require('v8').setFlagsFromString('--noallow_natives_syntax')
|
||||
}
|
||||
}
|
||||
|
||||
return nm.exports
|
||||
}
|
||||
|
||||
function src (id) {
|
||||
return natives[id]
|
||||
}
|
92
node_modules/natives/package.json
generated
vendored
Normal file
92
node_modules/natives/package.json
generated
vendored
Normal file
@@ -0,0 +1,92 @@
|
||||
{
|
||||
"_args": [
|
||||
[
|
||||
{
|
||||
"name": "natives",
|
||||
"raw": "natives@^1.1.3",
|
||||
"rawSpec": "^1.1.3",
|
||||
"scope": null,
|
||||
"spec": ">=1.1.3 <2.0.0",
|
||||
"type": "range"
|
||||
},
|
||||
"F:\\tmp\\gitbook\\node_modules\\graceful-fs"
|
||||
]
|
||||
],
|
||||
"_from": "natives@>=1.1.3 <2.0.0",
|
||||
"_hasShrinkwrap": false,
|
||||
"_id": "natives@1.1.6",
|
||||
"_inCache": true,
|
||||
"_installable": true,
|
||||
"_location": "/natives",
|
||||
"_nodeVersion": "11.0.0-pre",
|
||||
"_npmOperationalInternal": {
|
||||
"host": "s3://npm-registry-packages",
|
||||
"tmp": "tmp/natives_1.1.6_1539054291028_0.08681927369353137"
|
||||
},
|
||||
"_npmUser": {
|
||||
"email": "anna@addaleax.net",
|
||||
"name": "addaleax"
|
||||
},
|
||||
"_npmVersion": "6.4.1",
|
||||
"_phantomChildren": {},
|
||||
"_requested": {
|
||||
"name": "natives",
|
||||
"raw": "natives@^1.1.3",
|
||||
"rawSpec": "^1.1.3",
|
||||
"scope": null,
|
||||
"spec": ">=1.1.3 <2.0.0",
|
||||
"type": "range"
|
||||
},
|
||||
"_requiredBy": [
|
||||
"/graceful-fs"
|
||||
],
|
||||
"_resolved": "https://registry.npmjs.org/natives/-/natives-1.1.6.tgz",
|
||||
"_shasum": "a603b4a498ab77173612b9ea1acdec4d980f00bb",
|
||||
"_shrinkwrap": null,
|
||||
"_spec": "natives@^1.1.3",
|
||||
"_where": "F:\\tmp\\gitbook\\node_modules\\graceful-fs",
|
||||
"author": {
|
||||
"email": "i@izs.me",
|
||||
"name": "Isaac Z. Schlueter",
|
||||
"url": "http://blog.izs.me/"
|
||||
},
|
||||
"bugs": {
|
||||
"url": "https://github.com/addaleax/natives/issues"
|
||||
},
|
||||
"dependencies": {},
|
||||
"deprecated": "This module relies on Node.js's internals and will break at some point. Do not use it, and update to graceful-fs@4.x.",
|
||||
"description": "Do stuff with Node.js's native JavaScript modules",
|
||||
"devDependencies": {
|
||||
"tap": "^11.0.0"
|
||||
},
|
||||
"directories": {},
|
||||
"dist": {
|
||||
"fileCount": 4,
|
||||
"integrity": "sha512-6+TDFewD4yxY14ptjKaS63GVdtKiES1pTPyxn9Jb0rBqPMZ7VcCiooEhPNsr+mqHtMGxa/5c/HhcC4uPEUw/nA==",
|
||||
"npm-signature": "-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.4\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJbvBrTCRA9TVsSAnZWagAAjxIP/1+MijSszg2mmnQi1qLB\nS7uI4WWApwscO0MgBoiGnQP4FrcS72bGdq/EHC6RrJ3pdnfKd6PlzGRHbgwc\nHsE5BCNXhIwqiwr3xFGLoQvaDiPLAmEr5SOozgMSkB+zGgPqJ5ue1PnZDDkY\nYT2ZHtQK5UOwc3RcI6x+XaPoliqCwNIMFLWMQ7J9EL24Co1Eld5WTz+uYKor\nLZq2LEBoGy4qLuUlT28Sd2hwQV/ApGBUMISWjY99LpxvDZQgQCPNM568S9uo\nRsMz0ODHoIsYVZDFvoPOc7yu2/aFNXe2c8xmybNMPBLmik/kaXb1Nvq4CcFA\nsHZXnwwS3zpxK2E3P4b+ecZ0YggmIO72l9W3A4PAxIswG3HBGq8TZlhS6XSC\nnq7zcxWCzERfkem0kfHuUAHe0bAps3E7UnX2QHdyX4v3S4KMqXtr1QLcFeaG\nDjNJPJmXq6QyLb7HChR2tpLmGyaGUwfqX8cRU+13Hc7N33wO8Xnqwrl7fipl\nCwjp15/VMCyoWFZYhdK7PqRsRNpQ+cm7quhErBaHoY3Phcr7Pm/0D2GGL216\nF92E1e/M2ofHup0mclnInrJKgJyegC3WXzo9YWd+GMqdNCd0wI7G6gxLbg0E\nUidgJgfZAttjbWhXm8+ePL06QC5Q1AjcsDpw41p4OwlHQddXVmwr6rUvRzxZ\n/5eP\r\n=tEn4\r\n-----END PGP SIGNATURE-----\r\n",
|
||||
"shasum": "a603b4a498ab77173612b9ea1acdec4d980f00bb",
|
||||
"tarball": "https://registry.npmjs.org/natives/-/natives-1.1.6.tgz",
|
||||
"unpackedSize": 7693
|
||||
},
|
||||
"gitHead": "77743479b77ffbfbbd052fc54ffd37f39701aed5",
|
||||
"homepage": "https://github.com/addaleax/natives#readme",
|
||||
"license": "ISC",
|
||||
"main": "index.js",
|
||||
"maintainers": [
|
||||
{
|
||||
"email": "anna@addaleax.net",
|
||||
"name": "addaleax"
|
||||
}
|
||||
],
|
||||
"name": "natives",
|
||||
"optionalDependencies": {},
|
||||
"readme": "ERROR: No README data found!",
|
||||
"repository": {
|
||||
"type": "git",
|
||||
"url": "git+https://github.com/addaleax/natives.git"
|
||||
},
|
||||
"scripts": {
|
||||
"test": "tap test/*.js"
|
||||
},
|
||||
"version": "1.1.6"
|
||||
}
|
Reference in New Issue
Block a user