@openclaw/google-meet 2026.7.1 → 2026.7.2-beta.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/{chrome-create-BhgM0jQO.js → chrome-create-DM1XJCOH.js} +87 -61
- package/dist/{cli-D364Yrym.js → cli-SodPSOFX.js} +47 -90
- package/dist/{config-DDYRr7-P.js → config-BeoHH_z5.js} +49 -13
- package/dist/{create-CkkaRlbI.js → create-CWcFI0ub.js} +2 -2
- package/dist/index.js +1236 -361
- package/dist/{oauth-75iPDzIn.js → oauth-DOfMKlGp.js} +3 -1
- package/node_modules/core-util-is/LICENSE +19 -0
- package/node_modules/core-util-is/README.md +3 -0
- package/node_modules/core-util-is/lib/util.js +107 -0
- package/node_modules/core-util-is/package.json +38 -0
- package/node_modules/immediate/LICENSE.txt +20 -0
- package/node_modules/immediate/README.md +93 -0
- package/node_modules/immediate/dist/immediate.js +75 -0
- package/node_modules/immediate/dist/immediate.min.js +1 -0
- package/node_modules/immediate/lib/browser.js +69 -0
- package/node_modules/immediate/lib/index.js +73 -0
- package/node_modules/immediate/package.json +42 -0
- package/node_modules/inherits/LICENSE +16 -0
- package/node_modules/inherits/README.md +42 -0
- package/node_modules/inherits/inherits.js +9 -0
- package/node_modules/inherits/inherits_browser.js +27 -0
- package/node_modules/inherits/package.json +29 -0
- package/node_modules/isarray/.npmignore +1 -0
- package/node_modules/isarray/.travis.yml +4 -0
- package/node_modules/isarray/Makefile +6 -0
- package/node_modules/isarray/README.md +60 -0
- package/node_modules/isarray/component.json +19 -0
- package/node_modules/isarray/index.js +5 -0
- package/node_modules/isarray/package.json +45 -0
- package/node_modules/isarray/test.js +20 -0
- package/node_modules/jszip/.codeclimate.yml +16 -0
- package/node_modules/jszip/.editorconfig +8 -0
- package/node_modules/jszip/.eslintrc.js +43 -0
- package/node_modules/jszip/.github/workflows/pr.yaml +58 -0
- package/node_modules/jszip/.jekyll-metadata +0 -0
- package/node_modules/jszip/.travis.yml +17 -0
- package/node_modules/jszip/CHANGES.md +204 -0
- package/node_modules/jszip/LICENSE.markdown +651 -0
- package/node_modules/jszip/README.markdown +33 -0
- package/node_modules/jszip/deps.js +37 -0
- package/node_modules/jszip/dist/jszip.js +11577 -0
- package/node_modules/jszip/dist/jszip.min.js +13 -0
- package/node_modules/jszip/graph.svg +601 -0
- package/node_modules/jszip/index.d.ts +330 -0
- package/node_modules/jszip/lib/base64.js +106 -0
- package/node_modules/jszip/lib/compressedObject.js +74 -0
- package/node_modules/jszip/lib/compressions.js +14 -0
- package/node_modules/jszip/lib/crc32.js +77 -0
- package/node_modules/jszip/lib/defaults.js +11 -0
- package/node_modules/jszip/lib/external.js +18 -0
- package/node_modules/jszip/lib/flate.js +85 -0
- package/node_modules/jszip/lib/generate/ZipFileWorker.js +539 -0
- package/node_modules/jszip/lib/generate/index.js +57 -0
- package/node_modules/jszip/lib/index.js +55 -0
- package/node_modules/jszip/lib/license_header.js +11 -0
- package/node_modules/jszip/lib/load.js +88 -0
- package/node_modules/jszip/lib/nodejs/NodejsStreamInputAdapter.js +74 -0
- package/node_modules/jszip/lib/nodejs/NodejsStreamOutputAdapter.js +42 -0
- package/node_modules/jszip/lib/nodejsUtils.js +57 -0
- package/node_modules/jszip/lib/object.js +384 -0
- package/node_modules/jszip/lib/readable-stream-browser.js +10 -0
- package/node_modules/jszip/lib/reader/ArrayReader.js +57 -0
- package/node_modules/jszip/lib/reader/DataReader.js +116 -0
- package/node_modules/jszip/lib/reader/NodeBufferReader.js +19 -0
- package/node_modules/jszip/lib/reader/StringReader.js +38 -0
- package/node_modules/jszip/lib/reader/Uint8ArrayReader.js +22 -0
- package/node_modules/jszip/lib/reader/readerFor.js +28 -0
- package/node_modules/jszip/lib/signature.js +7 -0
- package/node_modules/jszip/lib/stream/ConvertWorker.js +26 -0
- package/node_modules/jszip/lib/stream/Crc32Probe.js +24 -0
- package/node_modules/jszip/lib/stream/DataLengthProbe.js +29 -0
- package/node_modules/jszip/lib/stream/DataWorker.js +116 -0
- package/node_modules/jszip/lib/stream/GenericWorker.js +263 -0
- package/node_modules/jszip/lib/stream/StreamHelper.js +214 -0
- package/node_modules/jszip/lib/support.js +38 -0
- package/node_modules/jszip/lib/utf8.js +275 -0
- package/node_modules/jszip/lib/utils.js +501 -0
- package/node_modules/jszip/lib/zipEntries.js +261 -0
- package/node_modules/jszip/lib/zipEntry.js +293 -0
- package/node_modules/jszip/lib/zipObject.js +133 -0
- package/node_modules/jszip/package.json +67 -0
- package/node_modules/jszip/sponsors.md +21 -0
- package/node_modules/jszip/tsconfig.json +101 -0
- package/node_modules/jszip/vendor/FileSaver.js +247 -0
- package/node_modules/lie/README.md +62 -0
- package/node_modules/lie/dist/lie.js +350 -0
- package/node_modules/lie/dist/lie.min.js +1 -0
- package/node_modules/lie/dist/lie.polyfill.js +358 -0
- package/node_modules/lie/dist/lie.polyfill.min.js +1 -0
- package/node_modules/lie/lib/browser.js +273 -0
- package/node_modules/lie/lib/index.js +298 -0
- package/node_modules/lie/license.md +7 -0
- package/node_modules/lie/lie.d.ts +244 -0
- package/node_modules/lie/package.json +69 -0
- package/node_modules/lie/polyfill.js +4 -0
- package/node_modules/pako/CHANGELOG.md +164 -0
- package/node_modules/pako/LICENSE +21 -0
- package/node_modules/pako/README.md +191 -0
- package/node_modules/pako/dist/pako.js +6818 -0
- package/node_modules/pako/dist/pako.min.js +1 -0
- package/node_modules/pako/dist/pako_deflate.js +3997 -0
- package/node_modules/pako/dist/pako_deflate.min.js +1 -0
- package/node_modules/pako/dist/pako_inflate.js +3300 -0
- package/node_modules/pako/dist/pako_inflate.min.js +1 -0
- package/node_modules/pako/index.js +14 -0
- package/node_modules/pako/lib/deflate.js +400 -0
- package/node_modules/pako/lib/inflate.js +423 -0
- package/node_modules/pako/lib/utils/common.js +105 -0
- package/node_modules/pako/lib/utils/strings.js +187 -0
- package/node_modules/pako/lib/zlib/README +59 -0
- package/node_modules/pako/lib/zlib/adler32.js +51 -0
- package/node_modules/pako/lib/zlib/constants.js +68 -0
- package/node_modules/pako/lib/zlib/crc32.js +59 -0
- package/node_modules/pako/lib/zlib/deflate.js +1874 -0
- package/node_modules/pako/lib/zlib/gzheader.js +58 -0
- package/node_modules/pako/lib/zlib/inffast.js +345 -0
- package/node_modules/pako/lib/zlib/inflate.js +1556 -0
- package/node_modules/pako/lib/zlib/inftrees.js +343 -0
- package/node_modules/pako/lib/zlib/messages.js +32 -0
- package/node_modules/pako/lib/zlib/trees.js +1222 -0
- package/node_modules/pako/lib/zlib/zstream.js +47 -0
- package/node_modules/pako/package.json +44 -0
- package/node_modules/parse-ms/index.d.ts +30 -0
- package/node_modules/parse-ms/index.js +45 -0
- package/node_modules/parse-ms/license +9 -0
- package/node_modules/parse-ms/package.json +47 -0
- package/node_modules/parse-ms/readme.md +46 -0
- package/node_modules/pretty-ms/index.d.ts +157 -0
- package/node_modules/pretty-ms/index.js +149 -0
- package/node_modules/pretty-ms/license +9 -0
- package/node_modules/pretty-ms/package.json +55 -0
- package/node_modules/pretty-ms/readme.md +179 -0
- package/node_modules/process-nextick-args/index.js +45 -0
- package/node_modules/process-nextick-args/license.md +19 -0
- package/node_modules/process-nextick-args/package.json +25 -0
- package/node_modules/process-nextick-args/readme.md +18 -0
- package/node_modules/readable-stream/.travis.yml +34 -0
- package/node_modules/readable-stream/CONTRIBUTING.md +38 -0
- package/node_modules/readable-stream/GOVERNANCE.md +136 -0
- package/node_modules/readable-stream/LICENSE +47 -0
- package/node_modules/readable-stream/README.md +58 -0
- package/node_modules/readable-stream/doc/wg-meetings/2015-01-30.md +60 -0
- package/node_modules/readable-stream/duplex-browser.js +1 -0
- package/node_modules/readable-stream/duplex.js +1 -0
- package/node_modules/readable-stream/lib/_stream_duplex.js +131 -0
- package/node_modules/readable-stream/lib/_stream_passthrough.js +47 -0
- package/node_modules/readable-stream/lib/_stream_readable.js +1019 -0
- package/node_modules/readable-stream/lib/_stream_transform.js +214 -0
- package/node_modules/readable-stream/lib/_stream_writable.js +685 -0
- package/node_modules/readable-stream/lib/internal/streams/BufferList.js +78 -0
- package/node_modules/readable-stream/lib/internal/streams/destroy.js +84 -0
- package/node_modules/readable-stream/lib/internal/streams/stream-browser.js +1 -0
- package/node_modules/readable-stream/lib/internal/streams/stream.js +1 -0
- package/node_modules/readable-stream/package.json +52 -0
- package/node_modules/readable-stream/passthrough.js +1 -0
- package/node_modules/readable-stream/readable-browser.js +7 -0
- package/node_modules/readable-stream/readable.js +19 -0
- package/node_modules/readable-stream/transform.js +1 -0
- package/node_modules/readable-stream/writable-browser.js +1 -0
- package/node_modules/readable-stream/writable.js +8 -0
- package/node_modules/safe-buffer/LICENSE +21 -0
- package/node_modules/safe-buffer/README.md +584 -0
- package/node_modules/safe-buffer/index.d.ts +187 -0
- package/node_modules/safe-buffer/index.js +62 -0
- package/node_modules/safe-buffer/package.json +37 -0
- package/node_modules/{commander/LICENSE → setimmediate/LICENSE.txt} +8 -10
- package/node_modules/setimmediate/package.json +30 -0
- package/node_modules/setimmediate/setImmediate.js +186 -0
- package/node_modules/string_decoder/.travis.yml +50 -0
- package/node_modules/string_decoder/LICENSE +48 -0
- package/node_modules/string_decoder/README.md +47 -0
- package/node_modules/string_decoder/lib/string_decoder.js +296 -0
- package/node_modules/string_decoder/package.json +31 -0
- package/node_modules/util-deprecate/History.md +16 -0
- package/node_modules/util-deprecate/LICENSE +24 -0
- package/node_modules/util-deprecate/README.md +53 -0
- package/node_modules/util-deprecate/browser.js +67 -0
- package/node_modules/util-deprecate/node.js +6 -0
- package/node_modules/util-deprecate/package.json +27 -0
- package/npm-shrinkwrap.json +127 -9
- package/openclaw.plugin.json +1 -1
- package/package.json +8 -6
- package/node_modules/commander/Readme.md +0 -1172
- package/node_modules/commander/index.js +0 -21
- package/node_modules/commander/lib/argument.js +0 -147
- package/node_modules/commander/lib/command.js +0 -2790
- package/node_modules/commander/lib/error.js +0 -36
- package/node_modules/commander/lib/help.js +0 -731
- package/node_modules/commander/lib/option.js +0 -377
- package/node_modules/commander/lib/suggestSimilar.js +0 -99
- package/node_modules/commander/package-support.json +0 -19
- package/node_modules/commander/package.json +0 -64
- package/node_modules/commander/typings/index.d.ts +0 -1113
|
@@ -11,6 +11,7 @@ const GOOGLE_MEET_TOKEN_URL = "https://oauth2.googleapis.com/token";
|
|
|
11
11
|
const GOOGLE_MEET_TOKEN_HOST = "oauth2.googleapis.com";
|
|
12
12
|
const GOOGLE_MEET_DEFAULT_TOKEN_LIFETIME_SECONDS = 3600;
|
|
13
13
|
const GOOGLE_OAUTH_TOKEN_JSON_MAX_BYTES = 256 * 1024;
|
|
14
|
+
const GOOGLE_OAUTH_REQUEST_TIMEOUT_MS = 3e4;
|
|
14
15
|
const GOOGLE_MEET_SCOPES = [
|
|
15
16
|
"https://www.googleapis.com/auth/meetings.space.created",
|
|
16
17
|
"https://www.googleapis.com/auth/meetings.space.readonly",
|
|
@@ -50,7 +51,8 @@ async function executeGoogleTokenRequest(body) {
|
|
|
50
51
|
body
|
|
51
52
|
},
|
|
52
53
|
policy: { allowedHostnames: [GOOGLE_MEET_TOKEN_HOST] },
|
|
53
|
-
auditContext: "google-meet.oauth.token"
|
|
54
|
+
auditContext: "google-meet.oauth.token",
|
|
55
|
+
timeoutMs: GOOGLE_OAUTH_REQUEST_TIMEOUT_MS
|
|
54
56
|
});
|
|
55
57
|
try {
|
|
56
58
|
if (!response.ok) {
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
Copyright Node.js contributors. All rights reserved.
|
|
2
|
+
|
|
3
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
4
|
+
of this software and associated documentation files (the "Software"), to
|
|
5
|
+
deal in the Software without restriction, including without limitation the
|
|
6
|
+
rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
|
|
7
|
+
sell copies of the Software, and to permit persons to whom the Software is
|
|
8
|
+
furnished to do so, subject to the following conditions:
|
|
9
|
+
|
|
10
|
+
The above copyright notice and this permission notice shall be included in
|
|
11
|
+
all copies or substantial portions of the Software.
|
|
12
|
+
|
|
13
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
14
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
15
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
16
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
17
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
|
|
18
|
+
FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
|
|
19
|
+
IN THE SOFTWARE.
|
|
@@ -0,0 +1,107 @@
|
|
|
1
|
+
// Copyright Joyent, Inc. and other Node contributors.
|
|
2
|
+
//
|
|
3
|
+
// Permission is hereby granted, free of charge, to any person obtaining a
|
|
4
|
+
// copy of this software and associated documentation files (the
|
|
5
|
+
// "Software"), to deal in the Software without restriction, including
|
|
6
|
+
// without limitation the rights to use, copy, modify, merge, publish,
|
|
7
|
+
// distribute, sublicense, and/or sell copies of the Software, and to permit
|
|
8
|
+
// persons to whom the Software is furnished to do so, subject to the
|
|
9
|
+
// following conditions:
|
|
10
|
+
//
|
|
11
|
+
// The above copyright notice and this permission notice shall be included
|
|
12
|
+
// in all copies or substantial portions of the Software.
|
|
13
|
+
//
|
|
14
|
+
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
|
|
15
|
+
// OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
|
16
|
+
// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN
|
|
17
|
+
// NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
|
|
18
|
+
// DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
|
|
19
|
+
// OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE
|
|
20
|
+
// USE OR OTHER DEALINGS IN THE SOFTWARE.
|
|
21
|
+
|
|
22
|
+
// NOTE: These type checking functions intentionally don't use `instanceof`
|
|
23
|
+
// because it is fragile and can be easily faked with `Object.create()`.
|
|
24
|
+
|
|
25
|
+
function isArray(arg) {
|
|
26
|
+
if (Array.isArray) {
|
|
27
|
+
return Array.isArray(arg);
|
|
28
|
+
}
|
|
29
|
+
return objectToString(arg) === '[object Array]';
|
|
30
|
+
}
|
|
31
|
+
exports.isArray = isArray;
|
|
32
|
+
|
|
33
|
+
function isBoolean(arg) {
|
|
34
|
+
return typeof arg === 'boolean';
|
|
35
|
+
}
|
|
36
|
+
exports.isBoolean = isBoolean;
|
|
37
|
+
|
|
38
|
+
function isNull(arg) {
|
|
39
|
+
return arg === null;
|
|
40
|
+
}
|
|
41
|
+
exports.isNull = isNull;
|
|
42
|
+
|
|
43
|
+
function isNullOrUndefined(arg) {
|
|
44
|
+
return arg == null;
|
|
45
|
+
}
|
|
46
|
+
exports.isNullOrUndefined = isNullOrUndefined;
|
|
47
|
+
|
|
48
|
+
function isNumber(arg) {
|
|
49
|
+
return typeof arg === 'number';
|
|
50
|
+
}
|
|
51
|
+
exports.isNumber = isNumber;
|
|
52
|
+
|
|
53
|
+
function isString(arg) {
|
|
54
|
+
return typeof arg === 'string';
|
|
55
|
+
}
|
|
56
|
+
exports.isString = isString;
|
|
57
|
+
|
|
58
|
+
function isSymbol(arg) {
|
|
59
|
+
return typeof arg === 'symbol';
|
|
60
|
+
}
|
|
61
|
+
exports.isSymbol = isSymbol;
|
|
62
|
+
|
|
63
|
+
function isUndefined(arg) {
|
|
64
|
+
return arg === void 0;
|
|
65
|
+
}
|
|
66
|
+
exports.isUndefined = isUndefined;
|
|
67
|
+
|
|
68
|
+
function isRegExp(re) {
|
|
69
|
+
return objectToString(re) === '[object RegExp]';
|
|
70
|
+
}
|
|
71
|
+
exports.isRegExp = isRegExp;
|
|
72
|
+
|
|
73
|
+
function isObject(arg) {
|
|
74
|
+
return typeof arg === 'object' && arg !== null;
|
|
75
|
+
}
|
|
76
|
+
exports.isObject = isObject;
|
|
77
|
+
|
|
78
|
+
function isDate(d) {
|
|
79
|
+
return objectToString(d) === '[object Date]';
|
|
80
|
+
}
|
|
81
|
+
exports.isDate = isDate;
|
|
82
|
+
|
|
83
|
+
function isError(e) {
|
|
84
|
+
return (objectToString(e) === '[object Error]' || e instanceof Error);
|
|
85
|
+
}
|
|
86
|
+
exports.isError = isError;
|
|
87
|
+
|
|
88
|
+
function isFunction(arg) {
|
|
89
|
+
return typeof arg === 'function';
|
|
90
|
+
}
|
|
91
|
+
exports.isFunction = isFunction;
|
|
92
|
+
|
|
93
|
+
function isPrimitive(arg) {
|
|
94
|
+
return arg === null ||
|
|
95
|
+
typeof arg === 'boolean' ||
|
|
96
|
+
typeof arg === 'number' ||
|
|
97
|
+
typeof arg === 'string' ||
|
|
98
|
+
typeof arg === 'symbol' || // ES6 symbol
|
|
99
|
+
typeof arg === 'undefined';
|
|
100
|
+
}
|
|
101
|
+
exports.isPrimitive = isPrimitive;
|
|
102
|
+
|
|
103
|
+
exports.isBuffer = require('buffer').Buffer.isBuffer;
|
|
104
|
+
|
|
105
|
+
function objectToString(o) {
|
|
106
|
+
return Object.prototype.toString.call(o);
|
|
107
|
+
}
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "core-util-is",
|
|
3
|
+
"version": "1.0.3",
|
|
4
|
+
"description": "The `util.is*` functions introduced in Node v0.12.",
|
|
5
|
+
"main": "lib/util.js",
|
|
6
|
+
"files": [
|
|
7
|
+
"lib"
|
|
8
|
+
],
|
|
9
|
+
"repository": {
|
|
10
|
+
"type": "git",
|
|
11
|
+
"url": "git://github.com/isaacs/core-util-is"
|
|
12
|
+
},
|
|
13
|
+
"keywords": [
|
|
14
|
+
"util",
|
|
15
|
+
"isBuffer",
|
|
16
|
+
"isArray",
|
|
17
|
+
"isNumber",
|
|
18
|
+
"isString",
|
|
19
|
+
"isRegExp",
|
|
20
|
+
"isThis",
|
|
21
|
+
"isThat",
|
|
22
|
+
"polyfill"
|
|
23
|
+
],
|
|
24
|
+
"author": "Isaac Z. Schlueter <i@izs.me> (http://blog.izs.me/)",
|
|
25
|
+
"license": "MIT",
|
|
26
|
+
"bugs": {
|
|
27
|
+
"url": "https://github.com/isaacs/core-util-is/issues"
|
|
28
|
+
},
|
|
29
|
+
"scripts": {
|
|
30
|
+
"test": "tap test.js",
|
|
31
|
+
"preversion": "npm test",
|
|
32
|
+
"postversion": "npm publish",
|
|
33
|
+
"prepublishOnly": "git push origin --follow-tags"
|
|
34
|
+
},
|
|
35
|
+
"devDependencies": {
|
|
36
|
+
"tap": "^15.0.9"
|
|
37
|
+
}
|
|
38
|
+
}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
Copyright (c) 2012 Barnesandnoble.com, llc, Donavon West, Domenic Denicola, Brian Cavalier
|
|
2
|
+
|
|
3
|
+
Permission is hereby granted, free of charge, to any person obtaining
|
|
4
|
+
a copy of this software and associated documentation files (the
|
|
5
|
+
"Software"), to deal in the Software without restriction, including
|
|
6
|
+
without limitation the rights to use, copy, modify, merge, publish,
|
|
7
|
+
distribute, sublicense, and/or sell copies of the Software, and to
|
|
8
|
+
permit persons to whom the Software is furnished to do so, subject to
|
|
9
|
+
the following conditions:
|
|
10
|
+
|
|
11
|
+
The above copyright notice and this permission notice shall be
|
|
12
|
+
included in all copies or substantial portions of the Software.
|
|
13
|
+
|
|
14
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
|
15
|
+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
|
16
|
+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
|
17
|
+
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
|
18
|
+
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
|
19
|
+
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
|
20
|
+
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
|
@@ -0,0 +1,93 @@
|
|
|
1
|
+
# immediate [](https://travis-ci.org/calvinmetcalf/immediate)
|
|
2
|
+
|
|
3
|
+
```
|
|
4
|
+
npm install immediate --save
|
|
5
|
+
```
|
|
6
|
+
|
|
7
|
+
then
|
|
8
|
+
|
|
9
|
+
```js
|
|
10
|
+
var immediate = require("immediate");
|
|
11
|
+
|
|
12
|
+
immediate(function () {
|
|
13
|
+
// this will run soon
|
|
14
|
+
});
|
|
15
|
+
|
|
16
|
+
immediate(function (arg1, arg2) {
|
|
17
|
+
// get your args like in iojs
|
|
18
|
+
}, thing1, thing2);
|
|
19
|
+
```
|
|
20
|
+
|
|
21
|
+
## Introduction
|
|
22
|
+
|
|
23
|
+
**immediate** is a microtask library, decended from [NobleJS's setImmediate](https://github.com/NobleJS/setImmediate), but including ideas from [Cujo's When](https://github.com/cujojs/when) and [RSVP][RSVP].
|
|
24
|
+
|
|
25
|
+
immediate takes the tricks from setImmedate and RSVP and combines them with the schedualer inspired (vaugly) by whens.
|
|
26
|
+
|
|
27
|
+
Note versions 2.6.5 and earlier were strictly speaking a 'macrotask' library not a microtask one, [see this for the difference](https://github.com/YuzuJS/setImmediate#macrotasks-and-microtasks), if you need a macrotask library, [I got you covered](https://github.com/calvinmetcalf/macrotask).
|
|
28
|
+
|
|
29
|
+
Several new features were added in versions 3.1.0 and 3.2.0 to maintain parity with
|
|
30
|
+
process.nextTick, but the 3.0.x series is still being kept up to date if you just need
|
|
31
|
+
the small barebones version.
|
|
32
|
+
|
|
33
|
+
|
|
34
|
+
## The Tricks
|
|
35
|
+
|
|
36
|
+
### `process.nextTick`
|
|
37
|
+
|
|
38
|
+
Note that we check for *actual* Node.js environments, not emulated ones like those produced by browserify or similar.
|
|
39
|
+
|
|
40
|
+
### `MutationObserver`
|
|
41
|
+
|
|
42
|
+
This is what [RSVP][RSVP] uses, it's very fast, details on [MDN](https://developer.mozilla.org/en-US/docs/Web/API/MutationObserver).
|
|
43
|
+
|
|
44
|
+
|
|
45
|
+
### `MessageChannel`
|
|
46
|
+
|
|
47
|
+
Unfortunately, `postMessage` has completely different semantics inside web workers, and so cannot be used there. So we
|
|
48
|
+
turn to [`MessageChannel`][MessageChannel], which has worse browser support, but does work inside a web worker.
|
|
49
|
+
|
|
50
|
+
### `<script> onreadystatechange`
|
|
51
|
+
|
|
52
|
+
For our last trick, we pull something out to make things fast in Internet Explorer versions 6 through 8: namely,
|
|
53
|
+
creating a `<script>` element and firing our calls in its `onreadystatechange` event. This does execute in a future
|
|
54
|
+
turn of the event loop, and is also faster than `setTimeout(…, 0)`, so hey, why not?
|
|
55
|
+
|
|
56
|
+
## Tricks we don't use
|
|
57
|
+
|
|
58
|
+
### `setImmediate`
|
|
59
|
+
We avoid this process.nextTick in node is better suited to our needs and in Internet Explorer 10 there is a broken version of setImmediate we avoid using this.
|
|
60
|
+
|
|
61
|
+
|
|
62
|
+
In Node.js, do
|
|
63
|
+
|
|
64
|
+
```
|
|
65
|
+
npm install immediate
|
|
66
|
+
```
|
|
67
|
+
|
|
68
|
+
then
|
|
69
|
+
|
|
70
|
+
```js
|
|
71
|
+
var immediate = require("immediate");
|
|
72
|
+
```
|
|
73
|
+
|
|
74
|
+
|
|
75
|
+
## Reference and Reading
|
|
76
|
+
|
|
77
|
+
* [Efficient Script Yielding W3C Editor's Draft][spec]
|
|
78
|
+
* [W3C mailing list post introducing the specification][list-post]
|
|
79
|
+
* [IE Test Drive demo][ie-demo]
|
|
80
|
+
* [Introductory blog post by Nicholas C. Zakas][ncz]
|
|
81
|
+
* I wrote a couple blog pots on this, [part 1][my-blog-1] and [part 2][my-blog-2]
|
|
82
|
+
|
|
83
|
+
[RSVP]: https://github.com/tildeio/rsvp.js
|
|
84
|
+
[spec]: https://dvcs.w3.org/hg/webperf/raw-file/tip/specs/setImmediate/Overview.html
|
|
85
|
+
[list-post]: http://lists.w3.org/Archives/Public/public-web-perf/2011Jun/0100.html
|
|
86
|
+
[ie-demo]: http://ie.microsoft.com/testdrive/Performance/setImmediateSorting/Default.html
|
|
87
|
+
[ncz]: http://www.nczonline.net/blog/2011/09/19/script-yielding-with-setimmediate/
|
|
88
|
+
[nextTick]: http://nodejs.org/docs/v0.8.16/api/process.html#process_process_nexttick_callback
|
|
89
|
+
[postMessage]: http://www.whatwg.org/specs/web-apps/current-work/multipage/web-messaging.html#posting-messages
|
|
90
|
+
[MessageChannel]: http://www.whatwg.org/specs/web-apps/current-work/multipage/web-messaging.html#channel-messaging
|
|
91
|
+
[cross-browser-demo]: http://calvinmetcalf.github.io/setImmediate-shim-demo
|
|
92
|
+
[my-blog-1]:http://calvinmetcalf.com/post/61672207151/setimmediate-etc
|
|
93
|
+
[my-blog-2]:http://calvinmetcalf.com/post/61761231881/javascript-schedulers
|
|
@@ -0,0 +1,75 @@
|
|
|
1
|
+
(function(f){if(typeof exports==="object"&&typeof module!=="undefined"){module.exports=f()}else if(typeof define==="function"&&define.amd){define([],f)}else{var g;if(typeof window!=="undefined"){g=window}else if(typeof global!=="undefined"){g=global}else if(typeof self!=="undefined"){g=self}else{g=this}g.immediate = f()}})(function(){var define,module,exports;return (function e(t,n,r){function s(o,u){if(!n[o]){if(!t[o]){var a=typeof require=="function"&&require;if(!u&&a)return a(o,!0);if(i)return i(o,!0);var f=new Error("Cannot find module '"+o+"'");throw f.code="MODULE_NOT_FOUND",f}var l=n[o]={exports:{}};t[o][0].call(l.exports,function(e){var n=t[o][1][e];return s(n?n:e)},l,l.exports,e,t,n,r)}return n[o].exports}var i=typeof require=="function"&&require;for(var o=0;o<r.length;o++)s(r[o]);return s})({1:[function(_dereq_,module,exports){
|
|
2
|
+
(function (global){
|
|
3
|
+
'use strict';
|
|
4
|
+
var Mutation = global.MutationObserver || global.WebKitMutationObserver;
|
|
5
|
+
|
|
6
|
+
var scheduleDrain;
|
|
7
|
+
|
|
8
|
+
{
|
|
9
|
+
if (Mutation) {
|
|
10
|
+
var called = 0;
|
|
11
|
+
var observer = new Mutation(nextTick);
|
|
12
|
+
var element = global.document.createTextNode('');
|
|
13
|
+
observer.observe(element, {
|
|
14
|
+
characterData: true
|
|
15
|
+
});
|
|
16
|
+
scheduleDrain = function () {
|
|
17
|
+
element.data = (called = ++called % 2);
|
|
18
|
+
};
|
|
19
|
+
} else if (!global.setImmediate && typeof global.MessageChannel !== 'undefined') {
|
|
20
|
+
var channel = new global.MessageChannel();
|
|
21
|
+
channel.port1.onmessage = nextTick;
|
|
22
|
+
scheduleDrain = function () {
|
|
23
|
+
channel.port2.postMessage(0);
|
|
24
|
+
};
|
|
25
|
+
} else if ('document' in global && 'onreadystatechange' in global.document.createElement('script')) {
|
|
26
|
+
scheduleDrain = function () {
|
|
27
|
+
|
|
28
|
+
// Create a <script> element; its readystatechange event will be fired asynchronously once it is inserted
|
|
29
|
+
// into the document. Do so, thus queuing up the task. Remember to clean up once it's been called.
|
|
30
|
+
var scriptEl = global.document.createElement('script');
|
|
31
|
+
scriptEl.onreadystatechange = function () {
|
|
32
|
+
nextTick();
|
|
33
|
+
|
|
34
|
+
scriptEl.onreadystatechange = null;
|
|
35
|
+
scriptEl.parentNode.removeChild(scriptEl);
|
|
36
|
+
scriptEl = null;
|
|
37
|
+
};
|
|
38
|
+
global.document.documentElement.appendChild(scriptEl);
|
|
39
|
+
};
|
|
40
|
+
} else {
|
|
41
|
+
scheduleDrain = function () {
|
|
42
|
+
setTimeout(nextTick, 0);
|
|
43
|
+
};
|
|
44
|
+
}
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
var draining;
|
|
48
|
+
var queue = [];
|
|
49
|
+
//named nextTick for less confusing stack traces
|
|
50
|
+
function nextTick() {
|
|
51
|
+
draining = true;
|
|
52
|
+
var i, oldQueue;
|
|
53
|
+
var len = queue.length;
|
|
54
|
+
while (len) {
|
|
55
|
+
oldQueue = queue;
|
|
56
|
+
queue = [];
|
|
57
|
+
i = -1;
|
|
58
|
+
while (++i < len) {
|
|
59
|
+
oldQueue[i]();
|
|
60
|
+
}
|
|
61
|
+
len = queue.length;
|
|
62
|
+
}
|
|
63
|
+
draining = false;
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
module.exports = immediate;
|
|
67
|
+
function immediate(task) {
|
|
68
|
+
if (queue.push(task) === 1 && !draining) {
|
|
69
|
+
scheduleDrain();
|
|
70
|
+
}
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
}).call(this,typeof global !== "undefined" ? global : typeof self !== "undefined" ? self : typeof window !== "undefined" ? window : {})
|
|
74
|
+
},{}]},{},[1])(1)
|
|
75
|
+
});
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
!function(e){if("object"==typeof exports&&"undefined"!=typeof module)module.exports=e();else if("function"==typeof define&&define.amd)define([],e);else{var n;n="undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self?self:this,n.immediate=e()}}(function(){return function e(n,t,o){function r(f,u){if(!t[f]){if(!n[f]){var a="function"==typeof require&&require;if(!u&&a)return a(f,!0);if(i)return i(f,!0);var d=new Error("Cannot find module '"+f+"'");throw d.code="MODULE_NOT_FOUND",d}var s=t[f]={exports:{}};n[f][0].call(s.exports,function(e){var t=n[f][1][e];return r(t?t:e)},s,s.exports,e,n,t,o)}return t[f].exports}for(var i="function"==typeof require&&require,f=0;f<o.length;f++)r(o[f]);return r}({1:[function(e,n,t){(function(e){"use strict";function t(){s=!0;for(var e,n,t=c.length;t;){for(n=c,c=[],e=-1;++e<t;)n[e]();t=c.length}s=!1}function o(e){1!==c.push(e)||s||r()}var r,i=e.MutationObserver||e.WebKitMutationObserver;if(i){var f=0,u=new i(t),a=e.document.createTextNode("");u.observe(a,{characterData:!0}),r=function(){a.data=f=++f%2}}else if(e.setImmediate||"undefined"==typeof e.MessageChannel)r="document"in e&&"onreadystatechange"in e.document.createElement("script")?function(){var n=e.document.createElement("script");n.onreadystatechange=function(){t(),n.onreadystatechange=null,n.parentNode.removeChild(n),n=null},e.document.documentElement.appendChild(n)}:function(){setTimeout(t,0)};else{var d=new e.MessageChannel;d.port1.onmessage=t,r=function(){d.port2.postMessage(0)}}var s,c=[];n.exports=o}).call(this,"undefined"!=typeof global?global:"undefined"!=typeof self?self:"undefined"!=typeof window?window:{})},{}]},{},[1])(1)});
|
|
@@ -0,0 +1,69 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
var Mutation = global.MutationObserver || global.WebKitMutationObserver;
|
|
3
|
+
|
|
4
|
+
var scheduleDrain;
|
|
5
|
+
|
|
6
|
+
{
|
|
7
|
+
if (Mutation) {
|
|
8
|
+
var called = 0;
|
|
9
|
+
var observer = new Mutation(nextTick);
|
|
10
|
+
var element = global.document.createTextNode('');
|
|
11
|
+
observer.observe(element, {
|
|
12
|
+
characterData: true
|
|
13
|
+
});
|
|
14
|
+
scheduleDrain = function () {
|
|
15
|
+
element.data = (called = ++called % 2);
|
|
16
|
+
};
|
|
17
|
+
} else if (!global.setImmediate && typeof global.MessageChannel !== 'undefined') {
|
|
18
|
+
var channel = new global.MessageChannel();
|
|
19
|
+
channel.port1.onmessage = nextTick;
|
|
20
|
+
scheduleDrain = function () {
|
|
21
|
+
channel.port2.postMessage(0);
|
|
22
|
+
};
|
|
23
|
+
} else if ('document' in global && 'onreadystatechange' in global.document.createElement('script')) {
|
|
24
|
+
scheduleDrain = function () {
|
|
25
|
+
|
|
26
|
+
// Create a <script> element; its readystatechange event will be fired asynchronously once it is inserted
|
|
27
|
+
// into the document. Do so, thus queuing up the task. Remember to clean up once it's been called.
|
|
28
|
+
var scriptEl = global.document.createElement('script');
|
|
29
|
+
scriptEl.onreadystatechange = function () {
|
|
30
|
+
nextTick();
|
|
31
|
+
|
|
32
|
+
scriptEl.onreadystatechange = null;
|
|
33
|
+
scriptEl.parentNode.removeChild(scriptEl);
|
|
34
|
+
scriptEl = null;
|
|
35
|
+
};
|
|
36
|
+
global.document.documentElement.appendChild(scriptEl);
|
|
37
|
+
};
|
|
38
|
+
} else {
|
|
39
|
+
scheduleDrain = function () {
|
|
40
|
+
setTimeout(nextTick, 0);
|
|
41
|
+
};
|
|
42
|
+
}
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
var draining;
|
|
46
|
+
var queue = [];
|
|
47
|
+
//named nextTick for less confusing stack traces
|
|
48
|
+
function nextTick() {
|
|
49
|
+
draining = true;
|
|
50
|
+
var i, oldQueue;
|
|
51
|
+
var len = queue.length;
|
|
52
|
+
while (len) {
|
|
53
|
+
oldQueue = queue;
|
|
54
|
+
queue = [];
|
|
55
|
+
i = -1;
|
|
56
|
+
while (++i < len) {
|
|
57
|
+
oldQueue[i]();
|
|
58
|
+
}
|
|
59
|
+
len = queue.length;
|
|
60
|
+
}
|
|
61
|
+
draining = false;
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
module.exports = immediate;
|
|
65
|
+
function immediate(task) {
|
|
66
|
+
if (queue.push(task) === 1 && !draining) {
|
|
67
|
+
scheduleDrain();
|
|
68
|
+
}
|
|
69
|
+
}
|
|
@@ -0,0 +1,73 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
var Mutation = global.MutationObserver || global.WebKitMutationObserver;
|
|
3
|
+
|
|
4
|
+
var scheduleDrain;
|
|
5
|
+
|
|
6
|
+
if (process.browser) {
|
|
7
|
+
if (Mutation) {
|
|
8
|
+
var called = 0;
|
|
9
|
+
var observer = new Mutation(nextTick);
|
|
10
|
+
var element = global.document.createTextNode('');
|
|
11
|
+
observer.observe(element, {
|
|
12
|
+
characterData: true
|
|
13
|
+
});
|
|
14
|
+
scheduleDrain = function () {
|
|
15
|
+
element.data = (called = ++called % 2);
|
|
16
|
+
};
|
|
17
|
+
} else if (!global.setImmediate && typeof global.MessageChannel !== 'undefined') {
|
|
18
|
+
var channel = new global.MessageChannel();
|
|
19
|
+
channel.port1.onmessage = nextTick;
|
|
20
|
+
scheduleDrain = function () {
|
|
21
|
+
channel.port2.postMessage(0);
|
|
22
|
+
};
|
|
23
|
+
} else if ('document' in global && 'onreadystatechange' in global.document.createElement('script')) {
|
|
24
|
+
scheduleDrain = function () {
|
|
25
|
+
|
|
26
|
+
// Create a <script> element; its readystatechange event will be fired asynchronously once it is inserted
|
|
27
|
+
// into the document. Do so, thus queuing up the task. Remember to clean up once it's been called.
|
|
28
|
+
var scriptEl = global.document.createElement('script');
|
|
29
|
+
scriptEl.onreadystatechange = function () {
|
|
30
|
+
nextTick();
|
|
31
|
+
|
|
32
|
+
scriptEl.onreadystatechange = null;
|
|
33
|
+
scriptEl.parentNode.removeChild(scriptEl);
|
|
34
|
+
scriptEl = null;
|
|
35
|
+
};
|
|
36
|
+
global.document.documentElement.appendChild(scriptEl);
|
|
37
|
+
};
|
|
38
|
+
} else {
|
|
39
|
+
scheduleDrain = function () {
|
|
40
|
+
setTimeout(nextTick, 0);
|
|
41
|
+
};
|
|
42
|
+
}
|
|
43
|
+
} else {
|
|
44
|
+
scheduleDrain = function () {
|
|
45
|
+
process.nextTick(nextTick);
|
|
46
|
+
};
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
var draining;
|
|
50
|
+
var queue = [];
|
|
51
|
+
//named nextTick for less confusing stack traces
|
|
52
|
+
function nextTick() {
|
|
53
|
+
draining = true;
|
|
54
|
+
var i, oldQueue;
|
|
55
|
+
var len = queue.length;
|
|
56
|
+
while (len) {
|
|
57
|
+
oldQueue = queue;
|
|
58
|
+
queue = [];
|
|
59
|
+
i = -1;
|
|
60
|
+
while (++i < len) {
|
|
61
|
+
oldQueue[i]();
|
|
62
|
+
}
|
|
63
|
+
len = queue.length;
|
|
64
|
+
}
|
|
65
|
+
draining = false;
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
module.exports = immediate;
|
|
69
|
+
function immediate(task) {
|
|
70
|
+
if (queue.push(task) === 1 && !draining) {
|
|
71
|
+
scheduleDrain();
|
|
72
|
+
}
|
|
73
|
+
}
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "immediate",
|
|
3
|
+
"version": "3.0.6",
|
|
4
|
+
"description": "A cross browser microtask library",
|
|
5
|
+
"contributors": [
|
|
6
|
+
"Domenic Denicola <domenic@domenicdenicola.com> (http://domenicdenicola.com)",
|
|
7
|
+
"Donavon West <github@donavon.com> (http://donavon.com)",
|
|
8
|
+
"Yaffle",
|
|
9
|
+
"Calvin Metcalf <calvin.metcalf@gmail.com>"
|
|
10
|
+
],
|
|
11
|
+
"license": "MIT",
|
|
12
|
+
"repository": {
|
|
13
|
+
"type": "git",
|
|
14
|
+
"url": "git://github.com/calvinmetcalf/immediate.git"
|
|
15
|
+
},
|
|
16
|
+
"files": [
|
|
17
|
+
"lib",
|
|
18
|
+
"dist"
|
|
19
|
+
],
|
|
20
|
+
"bugs": "https://github.com/calvinmetcalf/immediate/issues",
|
|
21
|
+
"main": "lib/index.js",
|
|
22
|
+
"scripts": {
|
|
23
|
+
"build": "npm run build-node && npm run build-js && npm run uglify",
|
|
24
|
+
"build-node": "browserify-transform-cli inline-process-browser unreachable-branch-transform < ./lib/index.js > ./lib/browser.js",
|
|
25
|
+
"uglify": "uglifyjs dist/immediate.js -mc > dist/immediate.min.js",
|
|
26
|
+
"build-js": "browserify -s immediate ./lib/browser.js | derequire > dist/immediate.js",
|
|
27
|
+
"test": "jshint lib/*.js && node test/tests.js"
|
|
28
|
+
},
|
|
29
|
+
"browser": {
|
|
30
|
+
"./lib/index.js": "./lib/browser.js"
|
|
31
|
+
},
|
|
32
|
+
"devDependencies": {
|
|
33
|
+
"browserify": "^13.0.0",
|
|
34
|
+
"browserify-transform-cli": "^1.1.1",
|
|
35
|
+
"derequire": "^2.0.0",
|
|
36
|
+
"inline-process-browser": "^2.0.0",
|
|
37
|
+
"jshint": "^2.5.1",
|
|
38
|
+
"tape": "^4.0.0",
|
|
39
|
+
"uglify-js": "^2.4.13",
|
|
40
|
+
"unreachable-branch-transform": "^0.5.1"
|
|
41
|
+
}
|
|
42
|
+
}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
The ISC License
|
|
2
|
+
|
|
3
|
+
Copyright (c) Isaac Z. Schlueter
|
|
4
|
+
|
|
5
|
+
Permission to use, copy, modify, and/or distribute this software for any
|
|
6
|
+
purpose with or without fee is hereby granted, provided that the above
|
|
7
|
+
copyright notice and this permission notice appear in all copies.
|
|
8
|
+
|
|
9
|
+
THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH
|
|
10
|
+
REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND
|
|
11
|
+
FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT,
|
|
12
|
+
INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
|
|
13
|
+
LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
|
|
14
|
+
OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
|
|
15
|
+
PERFORMANCE OF THIS SOFTWARE.
|
|
16
|
+
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
Browser-friendly inheritance fully compatible with standard node.js
|
|
2
|
+
[inherits](http://nodejs.org/api/util.html#util_util_inherits_constructor_superconstructor).
|
|
3
|
+
|
|
4
|
+
This package exports standard `inherits` from node.js `util` module in
|
|
5
|
+
node environment, but also provides alternative browser-friendly
|
|
6
|
+
implementation through [browser
|
|
7
|
+
field](https://gist.github.com/shtylman/4339901). Alternative
|
|
8
|
+
implementation is a literal copy of standard one located in standalone
|
|
9
|
+
module to avoid requiring of `util`. It also has a shim for old
|
|
10
|
+
browsers with no `Object.create` support.
|
|
11
|
+
|
|
12
|
+
While keeping you sure you are using standard `inherits`
|
|
13
|
+
implementation in node.js environment, it allows bundlers such as
|
|
14
|
+
[browserify](https://github.com/substack/node-browserify) to not
|
|
15
|
+
include full `util` package to your client code if all you need is
|
|
16
|
+
just `inherits` function. It worth, because browser shim for `util`
|
|
17
|
+
package is large and `inherits` is often the single function you need
|
|
18
|
+
from it.
|
|
19
|
+
|
|
20
|
+
It's recommended to use this package instead of
|
|
21
|
+
`require('util').inherits` for any code that has chances to be used
|
|
22
|
+
not only in node.js but in browser too.
|
|
23
|
+
|
|
24
|
+
## usage
|
|
25
|
+
|
|
26
|
+
```js
|
|
27
|
+
var inherits = require('inherits');
|
|
28
|
+
// then use exactly as the standard one
|
|
29
|
+
```
|
|
30
|
+
|
|
31
|
+
## note on version ~1.0
|
|
32
|
+
|
|
33
|
+
Version ~1.0 had completely different motivation and is not compatible
|
|
34
|
+
neither with 2.0 nor with standard node.js `inherits`.
|
|
35
|
+
|
|
36
|
+
If you are using version ~1.0 and planning to switch to ~2.0, be
|
|
37
|
+
careful:
|
|
38
|
+
|
|
39
|
+
* new version uses `super_` instead of `super` for referencing
|
|
40
|
+
superclass
|
|
41
|
+
* new version overwrites current prototype while old one preserves any
|
|
42
|
+
existing fields on it
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
if (typeof Object.create === 'function') {
|
|
2
|
+
// implementation from standard node.js 'util' module
|
|
3
|
+
module.exports = function inherits(ctor, superCtor) {
|
|
4
|
+
if (superCtor) {
|
|
5
|
+
ctor.super_ = superCtor
|
|
6
|
+
ctor.prototype = Object.create(superCtor.prototype, {
|
|
7
|
+
constructor: {
|
|
8
|
+
value: ctor,
|
|
9
|
+
enumerable: false,
|
|
10
|
+
writable: true,
|
|
11
|
+
configurable: true
|
|
12
|
+
}
|
|
13
|
+
})
|
|
14
|
+
}
|
|
15
|
+
};
|
|
16
|
+
} else {
|
|
17
|
+
// old school shim for old browsers
|
|
18
|
+
module.exports = function inherits(ctor, superCtor) {
|
|
19
|
+
if (superCtor) {
|
|
20
|
+
ctor.super_ = superCtor
|
|
21
|
+
var TempCtor = function () {}
|
|
22
|
+
TempCtor.prototype = superCtor.prototype
|
|
23
|
+
ctor.prototype = new TempCtor()
|
|
24
|
+
ctor.prototype.constructor = ctor
|
|
25
|
+
}
|
|
26
|
+
}
|
|
27
|
+
}
|