Add files using upload-large-folder tool
Browse filesThis view is limited to 50 files because it contains too many changes. See raw diff
- .gitattributes +6 -0
- 2019_--master/DRF框架讲义/images/保存图书返回信息.png +3 -0
- 2019_--master/Project/day10/ygwz/images/full/2d8d941e28a5453e0295ae4f9726bb400e20a674.jpg +3 -0
- 2019_--master/美多商城项目讲义/images/部署架构图.png +3 -0
- 2020-7-7-git-master/venv/Scripts/tcl86t.dll +3 -0
- 220-Advanced-Summer-2019-master/students/LincolnZ/lesson03/activity/DatabaseDiagram.jpeg +3 -0
- 220-Advanced-Summer-2019-master/students/LincolnZ/lesson09/assignment/data/furniture/chair/couch/sofa_400_clr_10056.png +3 -0
- 220-Advanced-Summer-2019-master/students/LincolnZ/lesson09/assignment/data/new/hotel_room_400_clr_12721.png +3 -0
- 220-Advanced-Summer-2019-master/students/LincolnZ/lesson09/assignment/data/old/couple_on_swing_bench_400_clr_12844.png +3 -0
- 220-Advanced-Summer-2019-master/students/LincolnZ/lesson09/assignment/data/old/sitting_in_chair_relaxing_400_clr_6028.png +3 -0
- 220-Advanced-Summer-2019-master/students/Ron_Nair/lesson09/assignment/data/furniture/table/basic_desk_main_400_clr_17523.png +3 -0
- 220-Advanced-Summer-2019-master/students/Ron_Nair/lesson09/assignment/data/furniture/table/desk_isometric_back_400_clr_17524.png +3 -0
- 220-Advanced-Summer-2019-master/students/Ron_Nair/lesson09/assignment/data/furniture/table/table_with_cloth_400_clr_10664.png +3 -0
- 220-Advanced-Summer-2019-master/students/Ron_Nair/lesson09/assignment/data/new/chairs_balancing_stacked_400_clr_11525.png +3 -0
- 220-Advanced-Summer-2019-master/students/Ron_Nair/lesson09/assignment/data/new/hotel_room_400_clr_12721.png +3 -0
- 220-Advanced-Summer-2019-master/students/Ron_Nair/lesson09/assignment/data/old/couple_on_swing_bench_400_clr_12844.png +3 -0
- 220-Advanced-Summer-2019-master/students/Ron_Nair/lesson09/assignment/data/old/sitting_in_chair_relaxing_400_clr_6028.png +3 -0
- 220-Advanced-Summer-2019-master/students/charlie_england/lesson03/activity/DatabaseDiagram.jpeg +3 -0
- 220-Advanced-Summer-2019-master/students/charlie_england/lesson09/assignment/data/furniture/table/desk_isometric_back_400_clr_17524.png +3 -0
- 220-Advanced-Summer-2019-master/students/colephalen/lesson06/assignment/src/big_ass_csv.csv +3 -0
- 220-Advanced-Summer-2019-master/students/colephalen/lesson09/assignment/data/furniture/table/basic_desk_main_400_clr_17523.png +3 -0
- 220-Advanced-Summer-2019-master/students/colephalen/lesson09/assignment/data/old/couple_on_swing_bench_400_clr_12844.png +3 -0
- 3D-CNN-Gesture-recognition-master/20BN-JESTER/24/00033.jpg +3 -0
- 3D-CNN-Gesture-recognition-master/20BN-JESTER/24/00034.jpg +3 -0
- 3D-CNN-Gesture-recognition-master/training_samples/24/00001.jpg +3 -0
- 3D-CNN-Gesture-recognition-master/training_samples/24/00002.jpg +3 -0
- 3D-CNN-Gesture-recognition-master/training_samples/24/00003.jpg +3 -0
- 3D-CNN-Gesture-recognition-master/training_samples/24/00004.jpg +3 -0
- 3D-CNN-Gesture-recognition-master/training_samples/24/00005.jpg +3 -0
- 3D-CNN-Gesture-recognition-master/training_samples/24/00006.jpg +3 -0
- 3D-CNN-Gesture-recognition-master/training_samples/24/00007.jpg +3 -0
- 3D-CNN-Gesture-recognition-master/training_samples/24/00008.jpg +3 -0
- 3D-CNN-Gesture-recognition-master/training_samples/24/00009.jpg +3 -0
- 3D-CNN-Gesture-recognition-master/training_samples/24/00010.jpg +3 -0
- 3D-CNN-Gesture-recognition-master/training_samples/24/00011.jpg +3 -0
- 3D-CNN-Gesture-recognition-master/training_samples/24/00012.jpg +3 -0
- 4D-Compositional-Representation-master/lib/utils/torchdiffeq/assets/ode_demo.gif +3 -0
- 4D-Compositional-Representation-master/lib/utils/torchdiffeq/assets/odenet_0_viz.png +3 -0
- 4D-Compositional-Representation-master/lib/utils/torchdiffeq/assets/resnet_0_viz.png +3 -0
- 5485-master/demos/node_modules/mongoose/node_modules/bson/node_modules/bson-ext/node_modules/node-pre-gyp/node_modules/npmlog/node_modules/are-we-there-yet/node_modules/readable-stream/lib/_stream_duplex.js +89 -0
- 5485-master/demos/node_modules/mongoose/node_modules/bson/node_modules/bson-ext/node_modules/node-pre-gyp/node_modules/npmlog/node_modules/are-we-there-yet/node_modules/readable-stream/lib/_stream_passthrough.js +46 -0
- 5485-master/demos/node_modules/mongoose/node_modules/bson/node_modules/bson-ext/node_modules/node-pre-gyp/node_modules/npmlog/node_modules/are-we-there-yet/node_modules/readable-stream/lib/_stream_readable.js +951 -0
- 5485-master/demos/node_modules/mongoose/node_modules/bson/node_modules/bson-ext/node_modules/node-pre-gyp/node_modules/npmlog/node_modules/are-we-there-yet/node_modules/readable-stream/lib/_stream_transform.js +209 -0
- 5485-master/demos/node_modules/mongoose/node_modules/bson/node_modules/bson-ext/node_modules/node-pre-gyp/node_modules/npmlog/node_modules/are-we-there-yet/node_modules/readable-stream/lib/_stream_writable.js +477 -0
- 5485-master/demos/node_modules/mongoose/node_modules/bson/node_modules/bson-ext/node_modules/node-pre-gyp/node_modules/npmlog/node_modules/are-we-there-yet/node_modules/readable-stream/node_modules/core-util-is/README.md +3 -0
- 5485-master/demos/node_modules/mongoose/node_modules/bson/node_modules/bson-ext/node_modules/node-pre-gyp/node_modules/npmlog/node_modules/are-we-there-yet/node_modules/readable-stream/node_modules/core-util-is/float.patch +604 -0
- 5485-master/demos/node_modules/mongoose/node_modules/bson/node_modules/bson-ext/node_modules/node-pre-gyp/node_modules/npmlog/node_modules/are-we-there-yet/node_modules/readable-stream/node_modules/core-util-is/lib/util.js +107 -0
- 5485-master/demos/node_modules/mongoose/node_modules/bson/node_modules/bson-ext/node_modules/node-pre-gyp/node_modules/npmlog/node_modules/are-we-there-yet/node_modules/readable-stream/node_modules/core-util-is/package.json +53 -0
- 5485-master/demos/node_modules/mongoose/node_modules/bson/node_modules/bson-ext/node_modules/node-pre-gyp/node_modules/npmlog/node_modules/are-we-there-yet/node_modules/readable-stream/node_modules/core-util-is/util.js +106 -0
- 5485-master/demos/node_modules/mongoose/node_modules/bson/node_modules/bson-ext/node_modules/node-pre-gyp/node_modules/npmlog/node_modules/are-we-there-yet/node_modules/readable-stream/node_modules/inherits/LICENSE +16 -0
.gitattributes
CHANGED
|
@@ -116,3 +116,9 @@ saved_model/**/* filter=lfs diff=lfs merge=lfs -text
|
|
| 116 |
2020-7-7-git-master/venv/Scripts/tk86t.dll filter=lfs diff=lfs merge=lfs -text
|
| 117 |
2020-7-7-git-master/venv/Scripts/unicodedata.pyd filter=lfs diff=lfs merge=lfs -text
|
| 118 |
2020-7-7-git-master/venv/Scripts/python37.dll filter=lfs diff=lfs merge=lfs -text
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 116 |
2020-7-7-git-master/venv/Scripts/tk86t.dll filter=lfs diff=lfs merge=lfs -text
|
| 117 |
2020-7-7-git-master/venv/Scripts/unicodedata.pyd filter=lfs diff=lfs merge=lfs -text
|
| 118 |
2020-7-7-git-master/venv/Scripts/python37.dll filter=lfs diff=lfs merge=lfs -text
|
| 119 |
+
220-Advanced-Summer-2019-master/students/colephalen/lesson06/assignment/src/big_ass_csv.csv filter=lfs diff=lfs merge=lfs -text
|
| 120 |
+
5dolar-website-meme-master/static/webfonts/fa-brands-400.ttf filter=lfs diff=lfs merge=lfs -text
|
| 121 |
+
5dolar-website-meme-master/static/webfonts/fa-solid-900.eot filter=lfs diff=lfs merge=lfs -text
|
| 122 |
+
5dolar-website-meme-master/static/webfonts/fa-solid-900.woff filter=lfs diff=lfs merge=lfs -text
|
| 123 |
+
5dolar-website-meme-master/static/webfonts/fa-solid-900.ttf filter=lfs diff=lfs merge=lfs -text
|
| 124 |
+
2020-7-7-git-master/venv/Scripts/tcl86t.dll filter=lfs diff=lfs merge=lfs -text
|
2019_--master/DRF框架讲义/images/保存图书返回信息.png
ADDED
|
Git LFS Details
|
2019_--master/Project/day10/ygwz/images/full/2d8d941e28a5453e0295ae4f9726bb400e20a674.jpg
ADDED
|
Git LFS Details
|
2019_--master/美多商城项目讲义/images/部署架构图.png
ADDED
|
Git LFS Details
|
2020-7-7-git-master/venv/Scripts/tcl86t.dll
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:7116542f44a2976574500cc1e8c6f0aeaaf95c18486066bc7eb133effceb5d0c
|
| 3 |
+
size 1731744
|
220-Advanced-Summer-2019-master/students/LincolnZ/lesson03/activity/DatabaseDiagram.jpeg
ADDED
|
Git LFS Details
|
220-Advanced-Summer-2019-master/students/LincolnZ/lesson09/assignment/data/furniture/chair/couch/sofa_400_clr_10056.png
ADDED
|
Git LFS Details
|
220-Advanced-Summer-2019-master/students/LincolnZ/lesson09/assignment/data/new/hotel_room_400_clr_12721.png
ADDED
|
Git LFS Details
|
220-Advanced-Summer-2019-master/students/LincolnZ/lesson09/assignment/data/old/couple_on_swing_bench_400_clr_12844.png
ADDED
|
Git LFS Details
|
220-Advanced-Summer-2019-master/students/LincolnZ/lesson09/assignment/data/old/sitting_in_chair_relaxing_400_clr_6028.png
ADDED
|
Git LFS Details
|
220-Advanced-Summer-2019-master/students/Ron_Nair/lesson09/assignment/data/furniture/table/basic_desk_main_400_clr_17523.png
ADDED
|
Git LFS Details
|
220-Advanced-Summer-2019-master/students/Ron_Nair/lesson09/assignment/data/furniture/table/desk_isometric_back_400_clr_17524.png
ADDED
|
Git LFS Details
|
220-Advanced-Summer-2019-master/students/Ron_Nair/lesson09/assignment/data/furniture/table/table_with_cloth_400_clr_10664.png
ADDED
|
Git LFS Details
|
220-Advanced-Summer-2019-master/students/Ron_Nair/lesson09/assignment/data/new/chairs_balancing_stacked_400_clr_11525.png
ADDED
|
Git LFS Details
|
220-Advanced-Summer-2019-master/students/Ron_Nair/lesson09/assignment/data/new/hotel_room_400_clr_12721.png
ADDED
|
Git LFS Details
|
220-Advanced-Summer-2019-master/students/Ron_Nair/lesson09/assignment/data/old/couple_on_swing_bench_400_clr_12844.png
ADDED
|
Git LFS Details
|
220-Advanced-Summer-2019-master/students/Ron_Nair/lesson09/assignment/data/old/sitting_in_chair_relaxing_400_clr_6028.png
ADDED
|
Git LFS Details
|
220-Advanced-Summer-2019-master/students/charlie_england/lesson03/activity/DatabaseDiagram.jpeg
ADDED
|
Git LFS Details
|
220-Advanced-Summer-2019-master/students/charlie_england/lesson09/assignment/data/furniture/table/desk_isometric_back_400_clr_17524.png
ADDED
|
Git LFS Details
|
220-Advanced-Summer-2019-master/students/colephalen/lesson06/assignment/src/big_ass_csv.csv
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:95eee8c42b750049589964ce4d65a0a520e2c80bd5a5d2d00a8deb5d80f8a5cf
|
| 3 |
+
size 104119916
|
220-Advanced-Summer-2019-master/students/colephalen/lesson09/assignment/data/furniture/table/basic_desk_main_400_clr_17523.png
ADDED
|
Git LFS Details
|
220-Advanced-Summer-2019-master/students/colephalen/lesson09/assignment/data/old/couple_on_swing_bench_400_clr_12844.png
ADDED
|
Git LFS Details
|
3D-CNN-Gesture-recognition-master/20BN-JESTER/24/00033.jpg
ADDED
|
Git LFS Details
|
3D-CNN-Gesture-recognition-master/20BN-JESTER/24/00034.jpg
ADDED
|
Git LFS Details
|
3D-CNN-Gesture-recognition-master/training_samples/24/00001.jpg
ADDED
|
Git LFS Details
|
3D-CNN-Gesture-recognition-master/training_samples/24/00002.jpg
ADDED
|
Git LFS Details
|
3D-CNN-Gesture-recognition-master/training_samples/24/00003.jpg
ADDED
|
Git LFS Details
|
3D-CNN-Gesture-recognition-master/training_samples/24/00004.jpg
ADDED
|
Git LFS Details
|
3D-CNN-Gesture-recognition-master/training_samples/24/00005.jpg
ADDED
|
Git LFS Details
|
3D-CNN-Gesture-recognition-master/training_samples/24/00006.jpg
ADDED
|
Git LFS Details
|
3D-CNN-Gesture-recognition-master/training_samples/24/00007.jpg
ADDED
|
Git LFS Details
|
3D-CNN-Gesture-recognition-master/training_samples/24/00008.jpg
ADDED
|
Git LFS Details
|
3D-CNN-Gesture-recognition-master/training_samples/24/00009.jpg
ADDED
|
Git LFS Details
|
3D-CNN-Gesture-recognition-master/training_samples/24/00010.jpg
ADDED
|
Git LFS Details
|
3D-CNN-Gesture-recognition-master/training_samples/24/00011.jpg
ADDED
|
Git LFS Details
|
3D-CNN-Gesture-recognition-master/training_samples/24/00012.jpg
ADDED
|
Git LFS Details
|
4D-Compositional-Representation-master/lib/utils/torchdiffeq/assets/ode_demo.gif
ADDED
|
Git LFS Details
|
4D-Compositional-Representation-master/lib/utils/torchdiffeq/assets/odenet_0_viz.png
ADDED
|
Git LFS Details
|
4D-Compositional-Representation-master/lib/utils/torchdiffeq/assets/resnet_0_viz.png
ADDED
|
Git LFS Details
|
5485-master/demos/node_modules/mongoose/node_modules/bson/node_modules/bson-ext/node_modules/node-pre-gyp/node_modules/npmlog/node_modules/are-we-there-yet/node_modules/readable-stream/lib/_stream_duplex.js
ADDED
|
@@ -0,0 +1,89 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 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 |
+
// a duplex stream is just a stream that is both readable and writable.
|
| 23 |
+
// Since JS doesn't have multiple prototypal inheritance, this class
|
| 24 |
+
// prototypally inherits from Readable, and then parasitically from
|
| 25 |
+
// Writable.
|
| 26 |
+
|
| 27 |
+
module.exports = Duplex;
|
| 28 |
+
|
| 29 |
+
/*<replacement>*/
|
| 30 |
+
var objectKeys = Object.keys || function (obj) {
|
| 31 |
+
var keys = [];
|
| 32 |
+
for (var key in obj) keys.push(key);
|
| 33 |
+
return keys;
|
| 34 |
+
}
|
| 35 |
+
/*</replacement>*/
|
| 36 |
+
|
| 37 |
+
|
| 38 |
+
/*<replacement>*/
|
| 39 |
+
var util = require('core-util-is');
|
| 40 |
+
util.inherits = require('inherits');
|
| 41 |
+
/*</replacement>*/
|
| 42 |
+
|
| 43 |
+
var Readable = require('./_stream_readable');
|
| 44 |
+
var Writable = require('./_stream_writable');
|
| 45 |
+
|
| 46 |
+
util.inherits(Duplex, Readable);
|
| 47 |
+
|
| 48 |
+
forEach(objectKeys(Writable.prototype), function(method) {
|
| 49 |
+
if (!Duplex.prototype[method])
|
| 50 |
+
Duplex.prototype[method] = Writable.prototype[method];
|
| 51 |
+
});
|
| 52 |
+
|
| 53 |
+
function Duplex(options) {
|
| 54 |
+
if (!(this instanceof Duplex))
|
| 55 |
+
return new Duplex(options);
|
| 56 |
+
|
| 57 |
+
Readable.call(this, options);
|
| 58 |
+
Writable.call(this, options);
|
| 59 |
+
|
| 60 |
+
if (options && options.readable === false)
|
| 61 |
+
this.readable = false;
|
| 62 |
+
|
| 63 |
+
if (options && options.writable === false)
|
| 64 |
+
this.writable = false;
|
| 65 |
+
|
| 66 |
+
this.allowHalfOpen = true;
|
| 67 |
+
if (options && options.allowHalfOpen === false)
|
| 68 |
+
this.allowHalfOpen = false;
|
| 69 |
+
|
| 70 |
+
this.once('end', onend);
|
| 71 |
+
}
|
| 72 |
+
|
| 73 |
+
// the no-half-open enforcer
|
| 74 |
+
function onend() {
|
| 75 |
+
// if we allow half-open state, or if the writable side ended,
|
| 76 |
+
// then we're ok.
|
| 77 |
+
if (this.allowHalfOpen || this._writableState.ended)
|
| 78 |
+
return;
|
| 79 |
+
|
| 80 |
+
// no more data can be written.
|
| 81 |
+
// But allow more writes to happen in this tick.
|
| 82 |
+
process.nextTick(this.end.bind(this));
|
| 83 |
+
}
|
| 84 |
+
|
| 85 |
+
function forEach (xs, f) {
|
| 86 |
+
for (var i = 0, l = xs.length; i < l; i++) {
|
| 87 |
+
f(xs[i], i);
|
| 88 |
+
}
|
| 89 |
+
}
|
5485-master/demos/node_modules/mongoose/node_modules/bson/node_modules/bson-ext/node_modules/node-pre-gyp/node_modules/npmlog/node_modules/are-we-there-yet/node_modules/readable-stream/lib/_stream_passthrough.js
ADDED
|
@@ -0,0 +1,46 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 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 |
+
// a passthrough stream.
|
| 23 |
+
// basically just the most minimal sort of Transform stream.
|
| 24 |
+
// Every written chunk gets output as-is.
|
| 25 |
+
|
| 26 |
+
module.exports = PassThrough;
|
| 27 |
+
|
| 28 |
+
var Transform = require('./_stream_transform');
|
| 29 |
+
|
| 30 |
+
/*<replacement>*/
|
| 31 |
+
var util = require('core-util-is');
|
| 32 |
+
util.inherits = require('inherits');
|
| 33 |
+
/*</replacement>*/
|
| 34 |
+
|
| 35 |
+
util.inherits(PassThrough, Transform);
|
| 36 |
+
|
| 37 |
+
function PassThrough(options) {
|
| 38 |
+
if (!(this instanceof PassThrough))
|
| 39 |
+
return new PassThrough(options);
|
| 40 |
+
|
| 41 |
+
Transform.call(this, options);
|
| 42 |
+
}
|
| 43 |
+
|
| 44 |
+
PassThrough.prototype._transform = function(chunk, encoding, cb) {
|
| 45 |
+
cb(null, chunk);
|
| 46 |
+
};
|
5485-master/demos/node_modules/mongoose/node_modules/bson/node_modules/bson-ext/node_modules/node-pre-gyp/node_modules/npmlog/node_modules/are-we-there-yet/node_modules/readable-stream/lib/_stream_readable.js
ADDED
|
@@ -0,0 +1,951 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|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
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 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 |
+
module.exports = Readable;
|
| 23 |
+
|
| 24 |
+
/*<replacement>*/
|
| 25 |
+
var isArray = require('isarray');
|
| 26 |
+
/*</replacement>*/
|
| 27 |
+
|
| 28 |
+
|
| 29 |
+
/*<replacement>*/
|
| 30 |
+
var Buffer = require('buffer').Buffer;
|
| 31 |
+
/*</replacement>*/
|
| 32 |
+
|
| 33 |
+
Readable.ReadableState = ReadableState;
|
| 34 |
+
|
| 35 |
+
var EE = require('events').EventEmitter;
|
| 36 |
+
|
| 37 |
+
/*<replacement>*/
|
| 38 |
+
if (!EE.listenerCount) EE.listenerCount = function(emitter, type) {
|
| 39 |
+
return emitter.listeners(type).length;
|
| 40 |
+
};
|
| 41 |
+
/*</replacement>*/
|
| 42 |
+
|
| 43 |
+
var Stream = require('stream');
|
| 44 |
+
|
| 45 |
+
/*<replacement>*/
|
| 46 |
+
var util = require('core-util-is');
|
| 47 |
+
util.inherits = require('inherits');
|
| 48 |
+
/*</replacement>*/
|
| 49 |
+
|
| 50 |
+
var StringDecoder;
|
| 51 |
+
|
| 52 |
+
|
| 53 |
+
/*<replacement>*/
|
| 54 |
+
var debug = require('util');
|
| 55 |
+
if (debug && debug.debuglog) {
|
| 56 |
+
debug = debug.debuglog('stream');
|
| 57 |
+
} else {
|
| 58 |
+
debug = function () {};
|
| 59 |
+
}
|
| 60 |
+
/*</replacement>*/
|
| 61 |
+
|
| 62 |
+
|
| 63 |
+
util.inherits(Readable, Stream);
|
| 64 |
+
|
| 65 |
+
function ReadableState(options, stream) {
|
| 66 |
+
var Duplex = require('./_stream_duplex');
|
| 67 |
+
|
| 68 |
+
options = options || {};
|
| 69 |
+
|
| 70 |
+
// the point at which it stops calling _read() to fill the buffer
|
| 71 |
+
// Note: 0 is a valid value, means "don't call _read preemptively ever"
|
| 72 |
+
var hwm = options.highWaterMark;
|
| 73 |
+
var defaultHwm = options.objectMode ? 16 : 16 * 1024;
|
| 74 |
+
this.highWaterMark = (hwm || hwm === 0) ? hwm : defaultHwm;
|
| 75 |
+
|
| 76 |
+
// cast to ints.
|
| 77 |
+
this.highWaterMark = ~~this.highWaterMark;
|
| 78 |
+
|
| 79 |
+
this.buffer = [];
|
| 80 |
+
this.length = 0;
|
| 81 |
+
this.pipes = null;
|
| 82 |
+
this.pipesCount = 0;
|
| 83 |
+
this.flowing = null;
|
| 84 |
+
this.ended = false;
|
| 85 |
+
this.endEmitted = false;
|
| 86 |
+
this.reading = false;
|
| 87 |
+
|
| 88 |
+
// a flag to be able to tell if the onwrite cb is called immediately,
|
| 89 |
+
// or on a later tick. We set this to true at first, because any
|
| 90 |
+
// actions that shouldn't happen until "later" should generally also
|
| 91 |
+
// not happen before the first write call.
|
| 92 |
+
this.sync = true;
|
| 93 |
+
|
| 94 |
+
// whenever we return null, then we set a flag to say
|
| 95 |
+
// that we're awaiting a 'readable' event emission.
|
| 96 |
+
this.needReadable = false;
|
| 97 |
+
this.emittedReadable = false;
|
| 98 |
+
this.readableListening = false;
|
| 99 |
+
|
| 100 |
+
|
| 101 |
+
// object stream flag. Used to make read(n) ignore n and to
|
| 102 |
+
// make all the buffer merging and length checks go away
|
| 103 |
+
this.objectMode = !!options.objectMode;
|
| 104 |
+
|
| 105 |
+
if (stream instanceof Duplex)
|
| 106 |
+
this.objectMode = this.objectMode || !!options.readableObjectMode;
|
| 107 |
+
|
| 108 |
+
// Crypto is kind of old and crusty. Historically, its default string
|
| 109 |
+
// encoding is 'binary' so we have to make this configurable.
|
| 110 |
+
// Everything else in the universe uses 'utf8', though.
|
| 111 |
+
this.defaultEncoding = options.defaultEncoding || 'utf8';
|
| 112 |
+
|
| 113 |
+
// when piping, we only care about 'readable' events that happen
|
| 114 |
+
// after read()ing all the bytes and not getting any pushback.
|
| 115 |
+
this.ranOut = false;
|
| 116 |
+
|
| 117 |
+
// the number of writers that are awaiting a drain event in .pipe()s
|
| 118 |
+
this.awaitDrain = 0;
|
| 119 |
+
|
| 120 |
+
// if true, a maybeReadMore has been scheduled
|
| 121 |
+
this.readingMore = false;
|
| 122 |
+
|
| 123 |
+
this.decoder = null;
|
| 124 |
+
this.encoding = null;
|
| 125 |
+
if (options.encoding) {
|
| 126 |
+
if (!StringDecoder)
|
| 127 |
+
StringDecoder = require('string_decoder/').StringDecoder;
|
| 128 |
+
this.decoder = new StringDecoder(options.encoding);
|
| 129 |
+
this.encoding = options.encoding;
|
| 130 |
+
}
|
| 131 |
+
}
|
| 132 |
+
|
| 133 |
+
function Readable(options) {
|
| 134 |
+
var Duplex = require('./_stream_duplex');
|
| 135 |
+
|
| 136 |
+
if (!(this instanceof Readable))
|
| 137 |
+
return new Readable(options);
|
| 138 |
+
|
| 139 |
+
this._readableState = new ReadableState(options, this);
|
| 140 |
+
|
| 141 |
+
// legacy
|
| 142 |
+
this.readable = true;
|
| 143 |
+
|
| 144 |
+
Stream.call(this);
|
| 145 |
+
}
|
| 146 |
+
|
| 147 |
+
// Manually shove something into the read() buffer.
|
| 148 |
+
// This returns true if the highWaterMark has not been hit yet,
|
| 149 |
+
// similar to how Writable.write() returns true if you should
|
| 150 |
+
// write() some more.
|
| 151 |
+
Readable.prototype.push = function(chunk, encoding) {
|
| 152 |
+
var state = this._readableState;
|
| 153 |
+
|
| 154 |
+
if (util.isString(chunk) && !state.objectMode) {
|
| 155 |
+
encoding = encoding || state.defaultEncoding;
|
| 156 |
+
if (encoding !== state.encoding) {
|
| 157 |
+
chunk = new Buffer(chunk, encoding);
|
| 158 |
+
encoding = '';
|
| 159 |
+
}
|
| 160 |
+
}
|
| 161 |
+
|
| 162 |
+
return readableAddChunk(this, state, chunk, encoding, false);
|
| 163 |
+
};
|
| 164 |
+
|
| 165 |
+
// Unshift should *always* be something directly out of read()
|
| 166 |
+
Readable.prototype.unshift = function(chunk) {
|
| 167 |
+
var state = this._readableState;
|
| 168 |
+
return readableAddChunk(this, state, chunk, '', true);
|
| 169 |
+
};
|
| 170 |
+
|
| 171 |
+
function readableAddChunk(stream, state, chunk, encoding, addToFront) {
|
| 172 |
+
var er = chunkInvalid(state, chunk);
|
| 173 |
+
if (er) {
|
| 174 |
+
stream.emit('error', er);
|
| 175 |
+
} else if (util.isNullOrUndefined(chunk)) {
|
| 176 |
+
state.reading = false;
|
| 177 |
+
if (!state.ended)
|
| 178 |
+
onEofChunk(stream, state);
|
| 179 |
+
} else if (state.objectMode || chunk && chunk.length > 0) {
|
| 180 |
+
if (state.ended && !addToFront) {
|
| 181 |
+
var e = new Error('stream.push() after EOF');
|
| 182 |
+
stream.emit('error', e);
|
| 183 |
+
} else if (state.endEmitted && addToFront) {
|
| 184 |
+
var e = new Error('stream.unshift() after end event');
|
| 185 |
+
stream.emit('error', e);
|
| 186 |
+
} else {
|
| 187 |
+
if (state.decoder && !addToFront && !encoding)
|
| 188 |
+
chunk = state.decoder.write(chunk);
|
| 189 |
+
|
| 190 |
+
if (!addToFront)
|
| 191 |
+
state.reading = false;
|
| 192 |
+
|
| 193 |
+
// if we want the data now, just emit it.
|
| 194 |
+
if (state.flowing && state.length === 0 && !state.sync) {
|
| 195 |
+
stream.emit('data', chunk);
|
| 196 |
+
stream.read(0);
|
| 197 |
+
} else {
|
| 198 |
+
// update the buffer info.
|
| 199 |
+
state.length += state.objectMode ? 1 : chunk.length;
|
| 200 |
+
if (addToFront)
|
| 201 |
+
state.buffer.unshift(chunk);
|
| 202 |
+
else
|
| 203 |
+
state.buffer.push(chunk);
|
| 204 |
+
|
| 205 |
+
if (state.needReadable)
|
| 206 |
+
emitReadable(stream);
|
| 207 |
+
}
|
| 208 |
+
|
| 209 |
+
maybeReadMore(stream, state);
|
| 210 |
+
}
|
| 211 |
+
} else if (!addToFront) {
|
| 212 |
+
state.reading = false;
|
| 213 |
+
}
|
| 214 |
+
|
| 215 |
+
return needMoreData(state);
|
| 216 |
+
}
|
| 217 |
+
|
| 218 |
+
|
| 219 |
+
|
| 220 |
+
// if it's past the high water mark, we can push in some more.
|
| 221 |
+
// Also, if we have no data yet, we can stand some
|
| 222 |
+
// more bytes. This is to work around cases where hwm=0,
|
| 223 |
+
// such as the repl. Also, if the push() triggered a
|
| 224 |
+
// readable event, and the user called read(largeNumber) such that
|
| 225 |
+
// needReadable was set, then we ought to push more, so that another
|
| 226 |
+
// 'readable' event will be triggered.
|
| 227 |
+
function needMoreData(state) {
|
| 228 |
+
return !state.ended &&
|
| 229 |
+
(state.needReadable ||
|
| 230 |
+
state.length < state.highWaterMark ||
|
| 231 |
+
state.length === 0);
|
| 232 |
+
}
|
| 233 |
+
|
| 234 |
+
// backwards compatibility.
|
| 235 |
+
Readable.prototype.setEncoding = function(enc) {
|
| 236 |
+
if (!StringDecoder)
|
| 237 |
+
StringDecoder = require('string_decoder/').StringDecoder;
|
| 238 |
+
this._readableState.decoder = new StringDecoder(enc);
|
| 239 |
+
this._readableState.encoding = enc;
|
| 240 |
+
return this;
|
| 241 |
+
};
|
| 242 |
+
|
| 243 |
+
// Don't raise the hwm > 128MB
|
| 244 |
+
var MAX_HWM = 0x800000;
|
| 245 |
+
function roundUpToNextPowerOf2(n) {
|
| 246 |
+
if (n >= MAX_HWM) {
|
| 247 |
+
n = MAX_HWM;
|
| 248 |
+
} else {
|
| 249 |
+
// Get the next highest power of 2
|
| 250 |
+
n--;
|
| 251 |
+
for (var p = 1; p < 32; p <<= 1) n |= n >> p;
|
| 252 |
+
n++;
|
| 253 |
+
}
|
| 254 |
+
return n;
|
| 255 |
+
}
|
| 256 |
+
|
| 257 |
+
function howMuchToRead(n, state) {
|
| 258 |
+
if (state.length === 0 && state.ended)
|
| 259 |
+
return 0;
|
| 260 |
+
|
| 261 |
+
if (state.objectMode)
|
| 262 |
+
return n === 0 ? 0 : 1;
|
| 263 |
+
|
| 264 |
+
if (isNaN(n) || util.isNull(n)) {
|
| 265 |
+
// only flow one buffer at a time
|
| 266 |
+
if (state.flowing && state.buffer.length)
|
| 267 |
+
return state.buffer[0].length;
|
| 268 |
+
else
|
| 269 |
+
return state.length;
|
| 270 |
+
}
|
| 271 |
+
|
| 272 |
+
if (n <= 0)
|
| 273 |
+
return 0;
|
| 274 |
+
|
| 275 |
+
// If we're asking for more than the target buffer level,
|
| 276 |
+
// then raise the water mark. Bump up to the next highest
|
| 277 |
+
// power of 2, to prevent increasing it excessively in tiny
|
| 278 |
+
// amounts.
|
| 279 |
+
if (n > state.highWaterMark)
|
| 280 |
+
state.highWaterMark = roundUpToNextPowerOf2(n);
|
| 281 |
+
|
| 282 |
+
// don't have that much. return null, unless we've ended.
|
| 283 |
+
if (n > state.length) {
|
| 284 |
+
if (!state.ended) {
|
| 285 |
+
state.needReadable = true;
|
| 286 |
+
return 0;
|
| 287 |
+
} else
|
| 288 |
+
return state.length;
|
| 289 |
+
}
|
| 290 |
+
|
| 291 |
+
return n;
|
| 292 |
+
}
|
| 293 |
+
|
| 294 |
+
// you can override either this method, or the async _read(n) below.
|
| 295 |
+
Readable.prototype.read = function(n) {
|
| 296 |
+
debug('read', n);
|
| 297 |
+
var state = this._readableState;
|
| 298 |
+
var nOrig = n;
|
| 299 |
+
|
| 300 |
+
if (!util.isNumber(n) || n > 0)
|
| 301 |
+
state.emittedReadable = false;
|
| 302 |
+
|
| 303 |
+
// if we're doing read(0) to trigger a readable event, but we
|
| 304 |
+
// already have a bunch of data in the buffer, then just trigger
|
| 305 |
+
// the 'readable' event and move on.
|
| 306 |
+
if (n === 0 &&
|
| 307 |
+
state.needReadable &&
|
| 308 |
+
(state.length >= state.highWaterMark || state.ended)) {
|
| 309 |
+
debug('read: emitReadable', state.length, state.ended);
|
| 310 |
+
if (state.length === 0 && state.ended)
|
| 311 |
+
endReadable(this);
|
| 312 |
+
else
|
| 313 |
+
emitReadable(this);
|
| 314 |
+
return null;
|
| 315 |
+
}
|
| 316 |
+
|
| 317 |
+
n = howMuchToRead(n, state);
|
| 318 |
+
|
| 319 |
+
// if we've ended, and we're now clear, then finish it up.
|
| 320 |
+
if (n === 0 && state.ended) {
|
| 321 |
+
if (state.length === 0)
|
| 322 |
+
endReadable(this);
|
| 323 |
+
return null;
|
| 324 |
+
}
|
| 325 |
+
|
| 326 |
+
// All the actual chunk generation logic needs to be
|
| 327 |
+
// *below* the call to _read. The reason is that in certain
|
| 328 |
+
// synthetic stream cases, such as passthrough streams, _read
|
| 329 |
+
// may be a completely synchronous operation which may change
|
| 330 |
+
// the state of the read buffer, providing enough data when
|
| 331 |
+
// before there was *not* enough.
|
| 332 |
+
//
|
| 333 |
+
// So, the steps are:
|
| 334 |
+
// 1. Figure out what the state of things will be after we do
|
| 335 |
+
// a read from the buffer.
|
| 336 |
+
//
|
| 337 |
+
// 2. If that resulting state will trigger a _read, then call _read.
|
| 338 |
+
// Note that this may be asynchronous, or synchronous. Yes, it is
|
| 339 |
+
// deeply ugly to write APIs this way, but that still doesn't mean
|
| 340 |
+
// that the Readable class should behave improperly, as streams are
|
| 341 |
+
// designed to be sync/async agnostic.
|
| 342 |
+
// Take note if the _read call is sync or async (ie, if the read call
|
| 343 |
+
// has returned yet), so that we know whether or not it's safe to emit
|
| 344 |
+
// 'readable' etc.
|
| 345 |
+
//
|
| 346 |
+
// 3. Actually pull the requested chunks out of the buffer and return.
|
| 347 |
+
|
| 348 |
+
// if we need a readable event, then we need to do some reading.
|
| 349 |
+
var doRead = state.needReadable;
|
| 350 |
+
debug('need readable', doRead);
|
| 351 |
+
|
| 352 |
+
// if we currently have less than the highWaterMark, then also read some
|
| 353 |
+
if (state.length === 0 || state.length - n < state.highWaterMark) {
|
| 354 |
+
doRead = true;
|
| 355 |
+
debug('length less than watermark', doRead);
|
| 356 |
+
}
|
| 357 |
+
|
| 358 |
+
// however, if we've ended, then there's no point, and if we're already
|
| 359 |
+
// reading, then it's unnecessary.
|
| 360 |
+
if (state.ended || state.reading) {
|
| 361 |
+
doRead = false;
|
| 362 |
+
debug('reading or ended', doRead);
|
| 363 |
+
}
|
| 364 |
+
|
| 365 |
+
if (doRead) {
|
| 366 |
+
debug('do read');
|
| 367 |
+
state.reading = true;
|
| 368 |
+
state.sync = true;
|
| 369 |
+
// if the length is currently zero, then we *need* a readable event.
|
| 370 |
+
if (state.length === 0)
|
| 371 |
+
state.needReadable = true;
|
| 372 |
+
// call internal read method
|
| 373 |
+
this._read(state.highWaterMark);
|
| 374 |
+
state.sync = false;
|
| 375 |
+
}
|
| 376 |
+
|
| 377 |
+
// If _read pushed data synchronously, then `reading` will be false,
|
| 378 |
+
// and we need to re-evaluate how much data we can return to the user.
|
| 379 |
+
if (doRead && !state.reading)
|
| 380 |
+
n = howMuchToRead(nOrig, state);
|
| 381 |
+
|
| 382 |
+
var ret;
|
| 383 |
+
if (n > 0)
|
| 384 |
+
ret = fromList(n, state);
|
| 385 |
+
else
|
| 386 |
+
ret = null;
|
| 387 |
+
|
| 388 |
+
if (util.isNull(ret)) {
|
| 389 |
+
state.needReadable = true;
|
| 390 |
+
n = 0;
|
| 391 |
+
}
|
| 392 |
+
|
| 393 |
+
state.length -= n;
|
| 394 |
+
|
| 395 |
+
// If we have nothing in the buffer, then we want to know
|
| 396 |
+
// as soon as we *do* get something into the buffer.
|
| 397 |
+
if (state.length === 0 && !state.ended)
|
| 398 |
+
state.needReadable = true;
|
| 399 |
+
|
| 400 |
+
// If we tried to read() past the EOF, then emit end on the next tick.
|
| 401 |
+
if (nOrig !== n && state.ended && state.length === 0)
|
| 402 |
+
endReadable(this);
|
| 403 |
+
|
| 404 |
+
if (!util.isNull(ret))
|
| 405 |
+
this.emit('data', ret);
|
| 406 |
+
|
| 407 |
+
return ret;
|
| 408 |
+
};
|
| 409 |
+
|
| 410 |
+
function chunkInvalid(state, chunk) {
|
| 411 |
+
var er = null;
|
| 412 |
+
if (!util.isBuffer(chunk) &&
|
| 413 |
+
!util.isString(chunk) &&
|
| 414 |
+
!util.isNullOrUndefined(chunk) &&
|
| 415 |
+
!state.objectMode) {
|
| 416 |
+
er = new TypeError('Invalid non-string/buffer chunk');
|
| 417 |
+
}
|
| 418 |
+
return er;
|
| 419 |
+
}
|
| 420 |
+
|
| 421 |
+
|
| 422 |
+
function onEofChunk(stream, state) {
|
| 423 |
+
if (state.decoder && !state.ended) {
|
| 424 |
+
var chunk = state.decoder.end();
|
| 425 |
+
if (chunk && chunk.length) {
|
| 426 |
+
state.buffer.push(chunk);
|
| 427 |
+
state.length += state.objectMode ? 1 : chunk.length;
|
| 428 |
+
}
|
| 429 |
+
}
|
| 430 |
+
state.ended = true;
|
| 431 |
+
|
| 432 |
+
// emit 'readable' now to make sure it gets picked up.
|
| 433 |
+
emitReadable(stream);
|
| 434 |
+
}
|
| 435 |
+
|
| 436 |
+
// Don't emit readable right away in sync mode, because this can trigger
|
| 437 |
+
// another read() call => stack overflow. This way, it might trigger
|
| 438 |
+
// a nextTick recursion warning, but that's not so bad.
|
| 439 |
+
function emitReadable(stream) {
|
| 440 |
+
var state = stream._readableState;
|
| 441 |
+
state.needReadable = false;
|
| 442 |
+
if (!state.emittedReadable) {
|
| 443 |
+
debug('emitReadable', state.flowing);
|
| 444 |
+
state.emittedReadable = true;
|
| 445 |
+
if (state.sync)
|
| 446 |
+
process.nextTick(function() {
|
| 447 |
+
emitReadable_(stream);
|
| 448 |
+
});
|
| 449 |
+
else
|
| 450 |
+
emitReadable_(stream);
|
| 451 |
+
}
|
| 452 |
+
}
|
| 453 |
+
|
| 454 |
+
function emitReadable_(stream) {
|
| 455 |
+
debug('emit readable');
|
| 456 |
+
stream.emit('readable');
|
| 457 |
+
flow(stream);
|
| 458 |
+
}
|
| 459 |
+
|
| 460 |
+
|
| 461 |
+
// at this point, the user has presumably seen the 'readable' event,
|
| 462 |
+
// and called read() to consume some data. that may have triggered
|
| 463 |
+
// in turn another _read(n) call, in which case reading = true if
|
| 464 |
+
// it's in progress.
|
| 465 |
+
// However, if we're not ended, or reading, and the length < hwm,
|
| 466 |
+
// then go ahead and try to read some more preemptively.
|
| 467 |
+
function maybeReadMore(stream, state) {
|
| 468 |
+
if (!state.readingMore) {
|
| 469 |
+
state.readingMore = true;
|
| 470 |
+
process.nextTick(function() {
|
| 471 |
+
maybeReadMore_(stream, state);
|
| 472 |
+
});
|
| 473 |
+
}
|
| 474 |
+
}
|
| 475 |
+
|
| 476 |
+
function maybeReadMore_(stream, state) {
|
| 477 |
+
var len = state.length;
|
| 478 |
+
while (!state.reading && !state.flowing && !state.ended &&
|
| 479 |
+
state.length < state.highWaterMark) {
|
| 480 |
+
debug('maybeReadMore read 0');
|
| 481 |
+
stream.read(0);
|
| 482 |
+
if (len === state.length)
|
| 483 |
+
// didn't get any data, stop spinning.
|
| 484 |
+
break;
|
| 485 |
+
else
|
| 486 |
+
len = state.length;
|
| 487 |
+
}
|
| 488 |
+
state.readingMore = false;
|
| 489 |
+
}
|
| 490 |
+
|
| 491 |
+
// abstract method. to be overridden in specific implementation classes.
|
| 492 |
+
// call cb(er, data) where data is <= n in length.
|
| 493 |
+
// for virtual (non-string, non-buffer) streams, "length" is somewhat
|
| 494 |
+
// arbitrary, and perhaps not very meaningful.
|
| 495 |
+
Readable.prototype._read = function(n) {
|
| 496 |
+
this.emit('error', new Error('not implemented'));
|
| 497 |
+
};
|
| 498 |
+
|
| 499 |
+
Readable.prototype.pipe = function(dest, pipeOpts) {
|
| 500 |
+
var src = this;
|
| 501 |
+
var state = this._readableState;
|
| 502 |
+
|
| 503 |
+
switch (state.pipesCount) {
|
| 504 |
+
case 0:
|
| 505 |
+
state.pipes = dest;
|
| 506 |
+
break;
|
| 507 |
+
case 1:
|
| 508 |
+
state.pipes = [state.pipes, dest];
|
| 509 |
+
break;
|
| 510 |
+
default:
|
| 511 |
+
state.pipes.push(dest);
|
| 512 |
+
break;
|
| 513 |
+
}
|
| 514 |
+
state.pipesCount += 1;
|
| 515 |
+
debug('pipe count=%d opts=%j', state.pipesCount, pipeOpts);
|
| 516 |
+
|
| 517 |
+
var doEnd = (!pipeOpts || pipeOpts.end !== false) &&
|
| 518 |
+
dest !== process.stdout &&
|
| 519 |
+
dest !== process.stderr;
|
| 520 |
+
|
| 521 |
+
var endFn = doEnd ? onend : cleanup;
|
| 522 |
+
if (state.endEmitted)
|
| 523 |
+
process.nextTick(endFn);
|
| 524 |
+
else
|
| 525 |
+
src.once('end', endFn);
|
| 526 |
+
|
| 527 |
+
dest.on('unpipe', onunpipe);
|
| 528 |
+
function onunpipe(readable) {
|
| 529 |
+
debug('onunpipe');
|
| 530 |
+
if (readable === src) {
|
| 531 |
+
cleanup();
|
| 532 |
+
}
|
| 533 |
+
}
|
| 534 |
+
|
| 535 |
+
function onend() {
|
| 536 |
+
debug('onend');
|
| 537 |
+
dest.end();
|
| 538 |
+
}
|
| 539 |
+
|
| 540 |
+
// when the dest drains, it reduces the awaitDrain counter
|
| 541 |
+
// on the source. This would be more elegant with a .once()
|
| 542 |
+
// handler in flow(), but adding and removing repeatedly is
|
| 543 |
+
// too slow.
|
| 544 |
+
var ondrain = pipeOnDrain(src);
|
| 545 |
+
dest.on('drain', ondrain);
|
| 546 |
+
|
| 547 |
+
function cleanup() {
|
| 548 |
+
debug('cleanup');
|
| 549 |
+
// cleanup event handlers once the pipe is broken
|
| 550 |
+
dest.removeListener('close', onclose);
|
| 551 |
+
dest.removeListener('finish', onfinish);
|
| 552 |
+
dest.removeListener('drain', ondrain);
|
| 553 |
+
dest.removeListener('error', onerror);
|
| 554 |
+
dest.removeListener('unpipe', onunpipe);
|
| 555 |
+
src.removeListener('end', onend);
|
| 556 |
+
src.removeListener('end', cleanup);
|
| 557 |
+
src.removeListener('data', ondata);
|
| 558 |
+
|
| 559 |
+
// if the reader is waiting for a drain event from this
|
| 560 |
+
// specific writer, then it would cause it to never start
|
| 561 |
+
// flowing again.
|
| 562 |
+
// So, if this is awaiting a drain, then we just call it now.
|
| 563 |
+
// If we don't know, then assume that we are waiting for one.
|
| 564 |
+
if (state.awaitDrain &&
|
| 565 |
+
(!dest._writableState || dest._writableState.needDrain))
|
| 566 |
+
ondrain();
|
| 567 |
+
}
|
| 568 |
+
|
| 569 |
+
src.on('data', ondata);
|
| 570 |
+
function ondata(chunk) {
|
| 571 |
+
debug('ondata');
|
| 572 |
+
var ret = dest.write(chunk);
|
| 573 |
+
if (false === ret) {
|
| 574 |
+
debug('false write response, pause',
|
| 575 |
+
src._readableState.awaitDrain);
|
| 576 |
+
src._readableState.awaitDrain++;
|
| 577 |
+
src.pause();
|
| 578 |
+
}
|
| 579 |
+
}
|
| 580 |
+
|
| 581 |
+
// if the dest has an error, then stop piping into it.
|
| 582 |
+
// however, don't suppress the throwing behavior for this.
|
| 583 |
+
function onerror(er) {
|
| 584 |
+
debug('onerror', er);
|
| 585 |
+
unpipe();
|
| 586 |
+
dest.removeListener('error', onerror);
|
| 587 |
+
if (EE.listenerCount(dest, 'error') === 0)
|
| 588 |
+
dest.emit('error', er);
|
| 589 |
+
}
|
| 590 |
+
// This is a brutally ugly hack to make sure that our error handler
|
| 591 |
+
// is attached before any userland ones. NEVER DO THIS.
|
| 592 |
+
if (!dest._events || !dest._events.error)
|
| 593 |
+
dest.on('error', onerror);
|
| 594 |
+
else if (isArray(dest._events.error))
|
| 595 |
+
dest._events.error.unshift(onerror);
|
| 596 |
+
else
|
| 597 |
+
dest._events.error = [onerror, dest._events.error];
|
| 598 |
+
|
| 599 |
+
|
| 600 |
+
|
| 601 |
+
// Both close and finish should trigger unpipe, but only once.
|
| 602 |
+
function onclose() {
|
| 603 |
+
dest.removeListener('finish', onfinish);
|
| 604 |
+
unpipe();
|
| 605 |
+
}
|
| 606 |
+
dest.once('close', onclose);
|
| 607 |
+
function onfinish() {
|
| 608 |
+
debug('onfinish');
|
| 609 |
+
dest.removeListener('close', onclose);
|
| 610 |
+
unpipe();
|
| 611 |
+
}
|
| 612 |
+
dest.once('finish', onfinish);
|
| 613 |
+
|
| 614 |
+
function unpipe() {
|
| 615 |
+
debug('unpipe');
|
| 616 |
+
src.unpipe(dest);
|
| 617 |
+
}
|
| 618 |
+
|
| 619 |
+
// tell the dest that it's being piped to
|
| 620 |
+
dest.emit('pipe', src);
|
| 621 |
+
|
| 622 |
+
// start the flow if it hasn't been started already.
|
| 623 |
+
if (!state.flowing) {
|
| 624 |
+
debug('pipe resume');
|
| 625 |
+
src.resume();
|
| 626 |
+
}
|
| 627 |
+
|
| 628 |
+
return dest;
|
| 629 |
+
};
|
| 630 |
+
|
| 631 |
+
function pipeOnDrain(src) {
|
| 632 |
+
return function() {
|
| 633 |
+
var state = src._readableState;
|
| 634 |
+
debug('pipeOnDrain', state.awaitDrain);
|
| 635 |
+
if (state.awaitDrain)
|
| 636 |
+
state.awaitDrain--;
|
| 637 |
+
if (state.awaitDrain === 0 && EE.listenerCount(src, 'data')) {
|
| 638 |
+
state.flowing = true;
|
| 639 |
+
flow(src);
|
| 640 |
+
}
|
| 641 |
+
};
|
| 642 |
+
}
|
| 643 |
+
|
| 644 |
+
|
| 645 |
+
Readable.prototype.unpipe = function(dest) {
|
| 646 |
+
var state = this._readableState;
|
| 647 |
+
|
| 648 |
+
// if we're not piping anywhere, then do nothing.
|
| 649 |
+
if (state.pipesCount === 0)
|
| 650 |
+
return this;
|
| 651 |
+
|
| 652 |
+
// just one destination. most common case.
|
| 653 |
+
if (state.pipesCount === 1) {
|
| 654 |
+
// passed in one, but it's not the right one.
|
| 655 |
+
if (dest && dest !== state.pipes)
|
| 656 |
+
return this;
|
| 657 |
+
|
| 658 |
+
if (!dest)
|
| 659 |
+
dest = state.pipes;
|
| 660 |
+
|
| 661 |
+
// got a match.
|
| 662 |
+
state.pipes = null;
|
| 663 |
+
state.pipesCount = 0;
|
| 664 |
+
state.flowing = false;
|
| 665 |
+
if (dest)
|
| 666 |
+
dest.emit('unpipe', this);
|
| 667 |
+
return this;
|
| 668 |
+
}
|
| 669 |
+
|
| 670 |
+
// slow case. multiple pipe destinations.
|
| 671 |
+
|
| 672 |
+
if (!dest) {
|
| 673 |
+
// remove all.
|
| 674 |
+
var dests = state.pipes;
|
| 675 |
+
var len = state.pipesCount;
|
| 676 |
+
state.pipes = null;
|
| 677 |
+
state.pipesCount = 0;
|
| 678 |
+
state.flowing = false;
|
| 679 |
+
|
| 680 |
+
for (var i = 0; i < len; i++)
|
| 681 |
+
dests[i].emit('unpipe', this);
|
| 682 |
+
return this;
|
| 683 |
+
}
|
| 684 |
+
|
| 685 |
+
// try to find the right one.
|
| 686 |
+
var i = indexOf(state.pipes, dest);
|
| 687 |
+
if (i === -1)
|
| 688 |
+
return this;
|
| 689 |
+
|
| 690 |
+
state.pipes.splice(i, 1);
|
| 691 |
+
state.pipesCount -= 1;
|
| 692 |
+
if (state.pipesCount === 1)
|
| 693 |
+
state.pipes = state.pipes[0];
|
| 694 |
+
|
| 695 |
+
dest.emit('unpipe', this);
|
| 696 |
+
|
| 697 |
+
return this;
|
| 698 |
+
};
|
| 699 |
+
|
| 700 |
+
// set up data events if they are asked for
|
| 701 |
+
// Ensure readable listeners eventually get something
|
| 702 |
+
Readable.prototype.on = function(ev, fn) {
|
| 703 |
+
var res = Stream.prototype.on.call(this, ev, fn);
|
| 704 |
+
|
| 705 |
+
// If listening to data, and it has not explicitly been paused,
|
| 706 |
+
// then call resume to start the flow of data on the next tick.
|
| 707 |
+
if (ev === 'data' && false !== this._readableState.flowing) {
|
| 708 |
+
this.resume();
|
| 709 |
+
}
|
| 710 |
+
|
| 711 |
+
if (ev === 'readable' && this.readable) {
|
| 712 |
+
var state = this._readableState;
|
| 713 |
+
if (!state.readableListening) {
|
| 714 |
+
state.readableListening = true;
|
| 715 |
+
state.emittedReadable = false;
|
| 716 |
+
state.needReadable = true;
|
| 717 |
+
if (!state.reading) {
|
| 718 |
+
var self = this;
|
| 719 |
+
process.nextTick(function() {
|
| 720 |
+
debug('readable nexttick read 0');
|
| 721 |
+
self.read(0);
|
| 722 |
+
});
|
| 723 |
+
} else if (state.length) {
|
| 724 |
+
emitReadable(this, state);
|
| 725 |
+
}
|
| 726 |
+
}
|
| 727 |
+
}
|
| 728 |
+
|
| 729 |
+
return res;
|
| 730 |
+
};
|
| 731 |
+
Readable.prototype.addListener = Readable.prototype.on;
|
| 732 |
+
|
| 733 |
+
// pause() and resume() are remnants of the legacy readable stream API
|
| 734 |
+
// If the user uses them, then switch into old mode.
|
| 735 |
+
Readable.prototype.resume = function() {
|
| 736 |
+
var state = this._readableState;
|
| 737 |
+
if (!state.flowing) {
|
| 738 |
+
debug('resume');
|
| 739 |
+
state.flowing = true;
|
| 740 |
+
if (!state.reading) {
|
| 741 |
+
debug('resume read 0');
|
| 742 |
+
this.read(0);
|
| 743 |
+
}
|
| 744 |
+
resume(this, state);
|
| 745 |
+
}
|
| 746 |
+
return this;
|
| 747 |
+
};
|
| 748 |
+
|
| 749 |
+
function resume(stream, state) {
|
| 750 |
+
if (!state.resumeScheduled) {
|
| 751 |
+
state.resumeScheduled = true;
|
| 752 |
+
process.nextTick(function() {
|
| 753 |
+
resume_(stream, state);
|
| 754 |
+
});
|
| 755 |
+
}
|
| 756 |
+
}
|
| 757 |
+
|
| 758 |
+
function resume_(stream, state) {
|
| 759 |
+
state.resumeScheduled = false;
|
| 760 |
+
stream.emit('resume');
|
| 761 |
+
flow(stream);
|
| 762 |
+
if (state.flowing && !state.reading)
|
| 763 |
+
stream.read(0);
|
| 764 |
+
}
|
| 765 |
+
|
| 766 |
+
Readable.prototype.pause = function() {
|
| 767 |
+
debug('call pause flowing=%j', this._readableState.flowing);
|
| 768 |
+
if (false !== this._readableState.flowing) {
|
| 769 |
+
debug('pause');
|
| 770 |
+
this._readableState.flowing = false;
|
| 771 |
+
this.emit('pause');
|
| 772 |
+
}
|
| 773 |
+
return this;
|
| 774 |
+
};
|
| 775 |
+
|
| 776 |
+
function flow(stream) {
|
| 777 |
+
var state = stream._readableState;
|
| 778 |
+
debug('flow', state.flowing);
|
| 779 |
+
if (state.flowing) {
|
| 780 |
+
do {
|
| 781 |
+
var chunk = stream.read();
|
| 782 |
+
} while (null !== chunk && state.flowing);
|
| 783 |
+
}
|
| 784 |
+
}
|
| 785 |
+
|
| 786 |
+
// wrap an old-style stream as the async data source.
|
| 787 |
+
// This is *not* part of the readable stream interface.
|
| 788 |
+
// It is an ugly unfortunate mess of history.
|
| 789 |
+
Readable.prototype.wrap = function(stream) {
|
| 790 |
+
var state = this._readableState;
|
| 791 |
+
var paused = false;
|
| 792 |
+
|
| 793 |
+
var self = this;
|
| 794 |
+
stream.on('end', function() {
|
| 795 |
+
debug('wrapped end');
|
| 796 |
+
if (state.decoder && !state.ended) {
|
| 797 |
+
var chunk = state.decoder.end();
|
| 798 |
+
if (chunk && chunk.length)
|
| 799 |
+
self.push(chunk);
|
| 800 |
+
}
|
| 801 |
+
|
| 802 |
+
self.push(null);
|
| 803 |
+
});
|
| 804 |
+
|
| 805 |
+
stream.on('data', function(chunk) {
|
| 806 |
+
debug('wrapped data');
|
| 807 |
+
if (state.decoder)
|
| 808 |
+
chunk = state.decoder.write(chunk);
|
| 809 |
+
if (!chunk || !state.objectMode && !chunk.length)
|
| 810 |
+
return;
|
| 811 |
+
|
| 812 |
+
var ret = self.push(chunk);
|
| 813 |
+
if (!ret) {
|
| 814 |
+
paused = true;
|
| 815 |
+
stream.pause();
|
| 816 |
+
}
|
| 817 |
+
});
|
| 818 |
+
|
| 819 |
+
// proxy all the other methods.
|
| 820 |
+
// important when wrapping filters and duplexes.
|
| 821 |
+
for (var i in stream) {
|
| 822 |
+
if (util.isFunction(stream[i]) && util.isUndefined(this[i])) {
|
| 823 |
+
this[i] = function(method) { return function() {
|
| 824 |
+
return stream[method].apply(stream, arguments);
|
| 825 |
+
}}(i);
|
| 826 |
+
}
|
| 827 |
+
}
|
| 828 |
+
|
| 829 |
+
// proxy certain important events.
|
| 830 |
+
var events = ['error', 'close', 'destroy', 'pause', 'resume'];
|
| 831 |
+
forEach(events, function(ev) {
|
| 832 |
+
stream.on(ev, self.emit.bind(self, ev));
|
| 833 |
+
});
|
| 834 |
+
|
| 835 |
+
// when we try to consume some more bytes, simply unpause the
|
| 836 |
+
// underlying stream.
|
| 837 |
+
self._read = function(n) {
|
| 838 |
+
debug('wrapped _read', n);
|
| 839 |
+
if (paused) {
|
| 840 |
+
paused = false;
|
| 841 |
+
stream.resume();
|
| 842 |
+
}
|
| 843 |
+
};
|
| 844 |
+
|
| 845 |
+
return self;
|
| 846 |
+
};
|
| 847 |
+
|
| 848 |
+
|
| 849 |
+
|
| 850 |
+
// exposed for testing purposes only.
|
| 851 |
+
Readable._fromList = fromList;
|
| 852 |
+
|
| 853 |
+
// Pluck off n bytes from an array of buffers.
|
| 854 |
+
// Length is the combined lengths of all the buffers in the list.
|
| 855 |
+
function fromList(n, state) {
|
| 856 |
+
var list = state.buffer;
|
| 857 |
+
var length = state.length;
|
| 858 |
+
var stringMode = !!state.decoder;
|
| 859 |
+
var objectMode = !!state.objectMode;
|
| 860 |
+
var ret;
|
| 861 |
+
|
| 862 |
+
// nothing in the list, definitely empty.
|
| 863 |
+
if (list.length === 0)
|
| 864 |
+
return null;
|
| 865 |
+
|
| 866 |
+
if (length === 0)
|
| 867 |
+
ret = null;
|
| 868 |
+
else if (objectMode)
|
| 869 |
+
ret = list.shift();
|
| 870 |
+
else if (!n || n >= length) {
|
| 871 |
+
// read it all, truncate the array.
|
| 872 |
+
if (stringMode)
|
| 873 |
+
ret = list.join('');
|
| 874 |
+
else
|
| 875 |
+
ret = Buffer.concat(list, length);
|
| 876 |
+
list.length = 0;
|
| 877 |
+
} else {
|
| 878 |
+
// read just some of it.
|
| 879 |
+
if (n < list[0].length) {
|
| 880 |
+
// just take a part of the first list item.
|
| 881 |
+
// slice is the same for buffers and strings.
|
| 882 |
+
var buf = list[0];
|
| 883 |
+
ret = buf.slice(0, n);
|
| 884 |
+
list[0] = buf.slice(n);
|
| 885 |
+
} else if (n === list[0].length) {
|
| 886 |
+
// first list is a perfect match
|
| 887 |
+
ret = list.shift();
|
| 888 |
+
} else {
|
| 889 |
+
// complex case.
|
| 890 |
+
// we have enough to cover it, but it spans past the first buffer.
|
| 891 |
+
if (stringMode)
|
| 892 |
+
ret = '';
|
| 893 |
+
else
|
| 894 |
+
ret = new Buffer(n);
|
| 895 |
+
|
| 896 |
+
var c = 0;
|
| 897 |
+
for (var i = 0, l = list.length; i < l && c < n; i++) {
|
| 898 |
+
var buf = list[0];
|
| 899 |
+
var cpy = Math.min(n - c, buf.length);
|
| 900 |
+
|
| 901 |
+
if (stringMode)
|
| 902 |
+
ret += buf.slice(0, cpy);
|
| 903 |
+
else
|
| 904 |
+
buf.copy(ret, c, 0, cpy);
|
| 905 |
+
|
| 906 |
+
if (cpy < buf.length)
|
| 907 |
+
list[0] = buf.slice(cpy);
|
| 908 |
+
else
|
| 909 |
+
list.shift();
|
| 910 |
+
|
| 911 |
+
c += cpy;
|
| 912 |
+
}
|
| 913 |
+
}
|
| 914 |
+
}
|
| 915 |
+
|
| 916 |
+
return ret;
|
| 917 |
+
}
|
| 918 |
+
|
| 919 |
+
function endReadable(stream) {
|
| 920 |
+
var state = stream._readableState;
|
| 921 |
+
|
| 922 |
+
// If we get here before consuming all the bytes, then that is a
|
| 923 |
+
// bug in node. Should never happen.
|
| 924 |
+
if (state.length > 0)
|
| 925 |
+
throw new Error('endReadable called on non-empty stream');
|
| 926 |
+
|
| 927 |
+
if (!state.endEmitted) {
|
| 928 |
+
state.ended = true;
|
| 929 |
+
process.nextTick(function() {
|
| 930 |
+
// Check that we didn't get one last unshift.
|
| 931 |
+
if (!state.endEmitted && state.length === 0) {
|
| 932 |
+
state.endEmitted = true;
|
| 933 |
+
stream.readable = false;
|
| 934 |
+
stream.emit('end');
|
| 935 |
+
}
|
| 936 |
+
});
|
| 937 |
+
}
|
| 938 |
+
}
|
| 939 |
+
|
| 940 |
+
function forEach (xs, f) {
|
| 941 |
+
for (var i = 0, l = xs.length; i < l; i++) {
|
| 942 |
+
f(xs[i], i);
|
| 943 |
+
}
|
| 944 |
+
}
|
| 945 |
+
|
| 946 |
+
function indexOf (xs, x) {
|
| 947 |
+
for (var i = 0, l = xs.length; i < l; i++) {
|
| 948 |
+
if (xs[i] === x) return i;
|
| 949 |
+
}
|
| 950 |
+
return -1;
|
| 951 |
+
}
|
5485-master/demos/node_modules/mongoose/node_modules/bson/node_modules/bson-ext/node_modules/node-pre-gyp/node_modules/npmlog/node_modules/are-we-there-yet/node_modules/readable-stream/lib/_stream_transform.js
ADDED
|
@@ -0,0 +1,209 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 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 |
+
|
| 23 |
+
// a transform stream is a readable/writable stream where you do
|
| 24 |
+
// something with the data. Sometimes it's called a "filter",
|
| 25 |
+
// but that's not a great name for it, since that implies a thing where
|
| 26 |
+
// some bits pass through, and others are simply ignored. (That would
|
| 27 |
+
// be a valid example of a transform, of course.)
|
| 28 |
+
//
|
| 29 |
+
// While the output is causally related to the input, it's not a
|
| 30 |
+
// necessarily symmetric or synchronous transformation. For example,
|
| 31 |
+
// a zlib stream might take multiple plain-text writes(), and then
|
| 32 |
+
// emit a single compressed chunk some time in the future.
|
| 33 |
+
//
|
| 34 |
+
// Here's how this works:
|
| 35 |
+
//
|
| 36 |
+
// The Transform stream has all the aspects of the readable and writable
|
| 37 |
+
// stream classes. When you write(chunk), that calls _write(chunk,cb)
|
| 38 |
+
// internally, and returns false if there's a lot of pending writes
|
| 39 |
+
// buffered up. When you call read(), that calls _read(n) until
|
| 40 |
+
// there's enough pending readable data buffered up.
|
| 41 |
+
//
|
| 42 |
+
// In a transform stream, the written data is placed in a buffer. When
|
| 43 |
+
// _read(n) is called, it transforms the queued up data, calling the
|
| 44 |
+
// buffered _write cb's as it consumes chunks. If consuming a single
|
| 45 |
+
// written chunk would result in multiple output chunks, then the first
|
| 46 |
+
// outputted bit calls the readcb, and subsequent chunks just go into
|
| 47 |
+
// the read buffer, and will cause it to emit 'readable' if necessary.
|
| 48 |
+
//
|
| 49 |
+
// This way, back-pressure is actually determined by the reading side,
|
| 50 |
+
// since _read has to be called to start processing a new chunk. However,
|
| 51 |
+
// a pathological inflate type of transform can cause excessive buffering
|
| 52 |
+
// here. For example, imagine a stream where every byte of input is
|
| 53 |
+
// interpreted as an integer from 0-255, and then results in that many
|
| 54 |
+
// bytes of output. Writing the 4 bytes {ff,ff,ff,ff} would result in
|
| 55 |
+
// 1kb of data being output. In this case, you could write a very small
|
| 56 |
+
// amount of input, and end up with a very large amount of output. In
|
| 57 |
+
// such a pathological inflating mechanism, there'd be no way to tell
|
| 58 |
+
// the system to stop doing the transform. A single 4MB write could
|
| 59 |
+
// cause the system to run out of memory.
|
| 60 |
+
//
|
| 61 |
+
// However, even in such a pathological case, only a single written chunk
|
| 62 |
+
// would be consumed, and then the rest would wait (un-transformed) until
|
| 63 |
+
// the results of the previous transformed chunk were consumed.
|
| 64 |
+
|
| 65 |
+
module.exports = Transform;
|
| 66 |
+
|
| 67 |
+
var Duplex = require('./_stream_duplex');
|
| 68 |
+
|
| 69 |
+
/*<replacement>*/
|
| 70 |
+
var util = require('core-util-is');
|
| 71 |
+
util.inherits = require('inherits');
|
| 72 |
+
/*</replacement>*/
|
| 73 |
+
|
| 74 |
+
util.inherits(Transform, Duplex);
|
| 75 |
+
|
| 76 |
+
|
| 77 |
+
function TransformState(options, stream) {
|
| 78 |
+
this.afterTransform = function(er, data) {
|
| 79 |
+
return afterTransform(stream, er, data);
|
| 80 |
+
};
|
| 81 |
+
|
| 82 |
+
this.needTransform = false;
|
| 83 |
+
this.transforming = false;
|
| 84 |
+
this.writecb = null;
|
| 85 |
+
this.writechunk = null;
|
| 86 |
+
}
|
| 87 |
+
|
| 88 |
+
function afterTransform(stream, er, data) {
|
| 89 |
+
var ts = stream._transformState;
|
| 90 |
+
ts.transforming = false;
|
| 91 |
+
|
| 92 |
+
var cb = ts.writecb;
|
| 93 |
+
|
| 94 |
+
if (!cb)
|
| 95 |
+
return stream.emit('error', new Error('no writecb in Transform class'));
|
| 96 |
+
|
| 97 |
+
ts.writechunk = null;
|
| 98 |
+
ts.writecb = null;
|
| 99 |
+
|
| 100 |
+
if (!util.isNullOrUndefined(data))
|
| 101 |
+
stream.push(data);
|
| 102 |
+
|
| 103 |
+
if (cb)
|
| 104 |
+
cb(er);
|
| 105 |
+
|
| 106 |
+
var rs = stream._readableState;
|
| 107 |
+
rs.reading = false;
|
| 108 |
+
if (rs.needReadable || rs.length < rs.highWaterMark) {
|
| 109 |
+
stream._read(rs.highWaterMark);
|
| 110 |
+
}
|
| 111 |
+
}
|
| 112 |
+
|
| 113 |
+
|
| 114 |
+
function Transform(options) {
|
| 115 |
+
if (!(this instanceof Transform))
|
| 116 |
+
return new Transform(options);
|
| 117 |
+
|
| 118 |
+
Duplex.call(this, options);
|
| 119 |
+
|
| 120 |
+
this._transformState = new TransformState(options, this);
|
| 121 |
+
|
| 122 |
+
// when the writable side finishes, then flush out anything remaining.
|
| 123 |
+
var stream = this;
|
| 124 |
+
|
| 125 |
+
// start out asking for a readable event once data is transformed.
|
| 126 |
+
this._readableState.needReadable = true;
|
| 127 |
+
|
| 128 |
+
// we have implemented the _read method, and done the other things
|
| 129 |
+
// that Readable wants before the first _read call, so unset the
|
| 130 |
+
// sync guard flag.
|
| 131 |
+
this._readableState.sync = false;
|
| 132 |
+
|
| 133 |
+
this.once('prefinish', function() {
|
| 134 |
+
if (util.isFunction(this._flush))
|
| 135 |
+
this._flush(function(er) {
|
| 136 |
+
done(stream, er);
|
| 137 |
+
});
|
| 138 |
+
else
|
| 139 |
+
done(stream);
|
| 140 |
+
});
|
| 141 |
+
}
|
| 142 |
+
|
| 143 |
+
Transform.prototype.push = function(chunk, encoding) {
|
| 144 |
+
this._transformState.needTransform = false;
|
| 145 |
+
return Duplex.prototype.push.call(this, chunk, encoding);
|
| 146 |
+
};
|
| 147 |
+
|
| 148 |
+
// This is the part where you do stuff!
|
| 149 |
+
// override this function in implementation classes.
|
| 150 |
+
// 'chunk' is an input chunk.
|
| 151 |
+
//
|
| 152 |
+
// Call `push(newChunk)` to pass along transformed output
|
| 153 |
+
// to the readable side. You may call 'push' zero or more times.
|
| 154 |
+
//
|
| 155 |
+
// Call `cb(err)` when you are done with this chunk. If you pass
|
| 156 |
+
// an error, then that'll put the hurt on the whole operation. If you
|
| 157 |
+
// never call cb(), then you'll never get another chunk.
|
| 158 |
+
Transform.prototype._transform = function(chunk, encoding, cb) {
|
| 159 |
+
throw new Error('not implemented');
|
| 160 |
+
};
|
| 161 |
+
|
| 162 |
+
Transform.prototype._write = function(chunk, encoding, cb) {
|
| 163 |
+
var ts = this._transformState;
|
| 164 |
+
ts.writecb = cb;
|
| 165 |
+
ts.writechunk = chunk;
|
| 166 |
+
ts.writeencoding = encoding;
|
| 167 |
+
if (!ts.transforming) {
|
| 168 |
+
var rs = this._readableState;
|
| 169 |
+
if (ts.needTransform ||
|
| 170 |
+
rs.needReadable ||
|
| 171 |
+
rs.length < rs.highWaterMark)
|
| 172 |
+
this._read(rs.highWaterMark);
|
| 173 |
+
}
|
| 174 |
+
};
|
| 175 |
+
|
| 176 |
+
// Doesn't matter what the args are here.
|
| 177 |
+
// _transform does all the work.
|
| 178 |
+
// That we got here means that the readable side wants more data.
|
| 179 |
+
Transform.prototype._read = function(n) {
|
| 180 |
+
var ts = this._transformState;
|
| 181 |
+
|
| 182 |
+
if (!util.isNull(ts.writechunk) && ts.writecb && !ts.transforming) {
|
| 183 |
+
ts.transforming = true;
|
| 184 |
+
this._transform(ts.writechunk, ts.writeencoding, ts.afterTransform);
|
| 185 |
+
} else {
|
| 186 |
+
// mark that we need a transform, so that any data that comes in
|
| 187 |
+
// will get processed, now that we've asked for it.
|
| 188 |
+
ts.needTransform = true;
|
| 189 |
+
}
|
| 190 |
+
};
|
| 191 |
+
|
| 192 |
+
|
| 193 |
+
function done(stream, er) {
|
| 194 |
+
if (er)
|
| 195 |
+
return stream.emit('error', er);
|
| 196 |
+
|
| 197 |
+
// if there's nothing in the write buffer, then that means
|
| 198 |
+
// that nothing more will ever be provided
|
| 199 |
+
var ws = stream._writableState;
|
| 200 |
+
var ts = stream._transformState;
|
| 201 |
+
|
| 202 |
+
if (ws.length)
|
| 203 |
+
throw new Error('calling transform done when ws.length != 0');
|
| 204 |
+
|
| 205 |
+
if (ts.transforming)
|
| 206 |
+
throw new Error('calling transform done when still transforming');
|
| 207 |
+
|
| 208 |
+
return stream.push(null);
|
| 209 |
+
}
|
5485-master/demos/node_modules/mongoose/node_modules/bson/node_modules/bson-ext/node_modules/node-pre-gyp/node_modules/npmlog/node_modules/are-we-there-yet/node_modules/readable-stream/lib/_stream_writable.js
ADDED
|
@@ -0,0 +1,477 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
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
//
|
| 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 |
+
// A bit simpler than readable streams.
|
| 23 |
+
// Implement an async ._write(chunk, cb), and it'll handle all
|
| 24 |
+
// the drain event emission and buffering.
|
| 25 |
+
|
| 26 |
+
module.exports = Writable;
|
| 27 |
+
|
| 28 |
+
/*<replacement>*/
|
| 29 |
+
var Buffer = require('buffer').Buffer;
|
| 30 |
+
/*</replacement>*/
|
| 31 |
+
|
| 32 |
+
Writable.WritableState = WritableState;
|
| 33 |
+
|
| 34 |
+
|
| 35 |
+
/*<replacement>*/
|
| 36 |
+
var util = require('core-util-is');
|
| 37 |
+
util.inherits = require('inherits');
|
| 38 |
+
/*</replacement>*/
|
| 39 |
+
|
| 40 |
+
var Stream = require('stream');
|
| 41 |
+
|
| 42 |
+
util.inherits(Writable, Stream);
|
| 43 |
+
|
| 44 |
+
function WriteReq(chunk, encoding, cb) {
|
| 45 |
+
this.chunk = chunk;
|
| 46 |
+
this.encoding = encoding;
|
| 47 |
+
this.callback = cb;
|
| 48 |
+
}
|
| 49 |
+
|
| 50 |
+
function WritableState(options, stream) {
|
| 51 |
+
var Duplex = require('./_stream_duplex');
|
| 52 |
+
|
| 53 |
+
options = options || {};
|
| 54 |
+
|
| 55 |
+
// the point at which write() starts returning false
|
| 56 |
+
// Note: 0 is a valid value, means that we always return false if
|
| 57 |
+
// the entire buffer is not flushed immediately on write()
|
| 58 |
+
var hwm = options.highWaterMark;
|
| 59 |
+
var defaultHwm = options.objectMode ? 16 : 16 * 1024;
|
| 60 |
+
this.highWaterMark = (hwm || hwm === 0) ? hwm : defaultHwm;
|
| 61 |
+
|
| 62 |
+
// object stream flag to indicate whether or not this stream
|
| 63 |
+
// contains buffers or objects.
|
| 64 |
+
this.objectMode = !!options.objectMode;
|
| 65 |
+
|
| 66 |
+
if (stream instanceof Duplex)
|
| 67 |
+
this.objectMode = this.objectMode || !!options.writableObjectMode;
|
| 68 |
+
|
| 69 |
+
// cast to ints.
|
| 70 |
+
this.highWaterMark = ~~this.highWaterMark;
|
| 71 |
+
|
| 72 |
+
this.needDrain = false;
|
| 73 |
+
// at the start of calling end()
|
| 74 |
+
this.ending = false;
|
| 75 |
+
// when end() has been called, and returned
|
| 76 |
+
this.ended = false;
|
| 77 |
+
// when 'finish' is emitted
|
| 78 |
+
this.finished = false;
|
| 79 |
+
|
| 80 |
+
// should we decode strings into buffers before passing to _write?
|
| 81 |
+
// this is here so that some node-core streams can optimize string
|
| 82 |
+
// handling at a lower level.
|
| 83 |
+
var noDecode = options.decodeStrings === false;
|
| 84 |
+
this.decodeStrings = !noDecode;
|
| 85 |
+
|
| 86 |
+
// Crypto is kind of old and crusty. Historically, its default string
|
| 87 |
+
// encoding is 'binary' so we have to make this configurable.
|
| 88 |
+
// Everything else in the universe uses 'utf8', though.
|
| 89 |
+
this.defaultEncoding = options.defaultEncoding || 'utf8';
|
| 90 |
+
|
| 91 |
+
// not an actual buffer we keep track of, but a measurement
|
| 92 |
+
// of how much we're waiting to get pushed to some underlying
|
| 93 |
+
// socket or file.
|
| 94 |
+
this.length = 0;
|
| 95 |
+
|
| 96 |
+
// a flag to see when we're in the middle of a write.
|
| 97 |
+
this.writing = false;
|
| 98 |
+
|
| 99 |
+
// when true all writes will be buffered until .uncork() call
|
| 100 |
+
this.corked = 0;
|
| 101 |
+
|
| 102 |
+
// a flag to be able to tell if the onwrite cb is called immediately,
|
| 103 |
+
// or on a later tick. We set this to true at first, because any
|
| 104 |
+
// actions that shouldn't happen until "later" should generally also
|
| 105 |
+
// not happen before the first write call.
|
| 106 |
+
this.sync = true;
|
| 107 |
+
|
| 108 |
+
// a flag to know if we're processing previously buffered items, which
|
| 109 |
+
// may call the _write() callback in the same tick, so that we don't
|
| 110 |
+
// end up in an overlapped onwrite situation.
|
| 111 |
+
this.bufferProcessing = false;
|
| 112 |
+
|
| 113 |
+
// the callback that's passed to _write(chunk,cb)
|
| 114 |
+
this.onwrite = function(er) {
|
| 115 |
+
onwrite(stream, er);
|
| 116 |
+
};
|
| 117 |
+
|
| 118 |
+
// the callback that the user supplies to write(chunk,encoding,cb)
|
| 119 |
+
this.writecb = null;
|
| 120 |
+
|
| 121 |
+
// the amount that is being written when _write is called.
|
| 122 |
+
this.writelen = 0;
|
| 123 |
+
|
| 124 |
+
this.buffer = [];
|
| 125 |
+
|
| 126 |
+
// number of pending user-supplied write callbacks
|
| 127 |
+
// this must be 0 before 'finish' can be emitted
|
| 128 |
+
this.pendingcb = 0;
|
| 129 |
+
|
| 130 |
+
// emit prefinish if the only thing we're waiting for is _write cbs
|
| 131 |
+
// This is relevant for synchronous Transform streams
|
| 132 |
+
this.prefinished = false;
|
| 133 |
+
|
| 134 |
+
// True if the error was already emitted and should not be thrown again
|
| 135 |
+
this.errorEmitted = false;
|
| 136 |
+
}
|
| 137 |
+
|
| 138 |
+
function Writable(options) {
|
| 139 |
+
var Duplex = require('./_stream_duplex');
|
| 140 |
+
|
| 141 |
+
// Writable ctor is applied to Duplexes, though they're not
|
| 142 |
+
// instanceof Writable, they're instanceof Readable.
|
| 143 |
+
if (!(this instanceof Writable) && !(this instanceof Duplex))
|
| 144 |
+
return new Writable(options);
|
| 145 |
+
|
| 146 |
+
this._writableState = new WritableState(options, this);
|
| 147 |
+
|
| 148 |
+
// legacy.
|
| 149 |
+
this.writable = true;
|
| 150 |
+
|
| 151 |
+
Stream.call(this);
|
| 152 |
+
}
|
| 153 |
+
|
| 154 |
+
// Otherwise people can pipe Writable streams, which is just wrong.
|
| 155 |
+
Writable.prototype.pipe = function() {
|
| 156 |
+
this.emit('error', new Error('Cannot pipe. Not readable.'));
|
| 157 |
+
};
|
| 158 |
+
|
| 159 |
+
|
| 160 |
+
function writeAfterEnd(stream, state, cb) {
|
| 161 |
+
var er = new Error('write after end');
|
| 162 |
+
// TODO: defer error events consistently everywhere, not just the cb
|
| 163 |
+
stream.emit('error', er);
|
| 164 |
+
process.nextTick(function() {
|
| 165 |
+
cb(er);
|
| 166 |
+
});
|
| 167 |
+
}
|
| 168 |
+
|
| 169 |
+
// If we get something that is not a buffer, string, null, or undefined,
|
| 170 |
+
// and we're not in objectMode, then that's an error.
|
| 171 |
+
// Otherwise stream chunks are all considered to be of length=1, and the
|
| 172 |
+
// watermarks determine how many objects to keep in the buffer, rather than
|
| 173 |
+
// how many bytes or characters.
|
| 174 |
+
function validChunk(stream, state, chunk, cb) {
|
| 175 |
+
var valid = true;
|
| 176 |
+
if (!util.isBuffer(chunk) &&
|
| 177 |
+
!util.isString(chunk) &&
|
| 178 |
+
!util.isNullOrUndefined(chunk) &&
|
| 179 |
+
!state.objectMode) {
|
| 180 |
+
var er = new TypeError('Invalid non-string/buffer chunk');
|
| 181 |
+
stream.emit('error', er);
|
| 182 |
+
process.nextTick(function() {
|
| 183 |
+
cb(er);
|
| 184 |
+
});
|
| 185 |
+
valid = false;
|
| 186 |
+
}
|
| 187 |
+
return valid;
|
| 188 |
+
}
|
| 189 |
+
|
| 190 |
+
Writable.prototype.write = function(chunk, encoding, cb) {
|
| 191 |
+
var state = this._writableState;
|
| 192 |
+
var ret = false;
|
| 193 |
+
|
| 194 |
+
if (util.isFunction(encoding)) {
|
| 195 |
+
cb = encoding;
|
| 196 |
+
encoding = null;
|
| 197 |
+
}
|
| 198 |
+
|
| 199 |
+
if (util.isBuffer(chunk))
|
| 200 |
+
encoding = 'buffer';
|
| 201 |
+
else if (!encoding)
|
| 202 |
+
encoding = state.defaultEncoding;
|
| 203 |
+
|
| 204 |
+
if (!util.isFunction(cb))
|
| 205 |
+
cb = function() {};
|
| 206 |
+
|
| 207 |
+
if (state.ended)
|
| 208 |
+
writeAfterEnd(this, state, cb);
|
| 209 |
+
else if (validChunk(this, state, chunk, cb)) {
|
| 210 |
+
state.pendingcb++;
|
| 211 |
+
ret = writeOrBuffer(this, state, chunk, encoding, cb);
|
| 212 |
+
}
|
| 213 |
+
|
| 214 |
+
return ret;
|
| 215 |
+
};
|
| 216 |
+
|
| 217 |
+
Writable.prototype.cork = function() {
|
| 218 |
+
var state = this._writableState;
|
| 219 |
+
|
| 220 |
+
state.corked++;
|
| 221 |
+
};
|
| 222 |
+
|
| 223 |
+
Writable.prototype.uncork = function() {
|
| 224 |
+
var state = this._writableState;
|
| 225 |
+
|
| 226 |
+
if (state.corked) {
|
| 227 |
+
state.corked--;
|
| 228 |
+
|
| 229 |
+
if (!state.writing &&
|
| 230 |
+
!state.corked &&
|
| 231 |
+
!state.finished &&
|
| 232 |
+
!state.bufferProcessing &&
|
| 233 |
+
state.buffer.length)
|
| 234 |
+
clearBuffer(this, state);
|
| 235 |
+
}
|
| 236 |
+
};
|
| 237 |
+
|
| 238 |
+
function decodeChunk(state, chunk, encoding) {
|
| 239 |
+
if (!state.objectMode &&
|
| 240 |
+
state.decodeStrings !== false &&
|
| 241 |
+
util.isString(chunk)) {
|
| 242 |
+
chunk = new Buffer(chunk, encoding);
|
| 243 |
+
}
|
| 244 |
+
return chunk;
|
| 245 |
+
}
|
| 246 |
+
|
| 247 |
+
// if we're already writing something, then just put this
|
| 248 |
+
// in the queue, and wait our turn. Otherwise, call _write
|
| 249 |
+
// If we return false, then we need a drain event, so set that flag.
|
| 250 |
+
function writeOrBuffer(stream, state, chunk, encoding, cb) {
|
| 251 |
+
chunk = decodeChunk(state, chunk, encoding);
|
| 252 |
+
if (util.isBuffer(chunk))
|
| 253 |
+
encoding = 'buffer';
|
| 254 |
+
var len = state.objectMode ? 1 : chunk.length;
|
| 255 |
+
|
| 256 |
+
state.length += len;
|
| 257 |
+
|
| 258 |
+
var ret = state.length < state.highWaterMark;
|
| 259 |
+
// we must ensure that previous needDrain will not be reset to false.
|
| 260 |
+
if (!ret)
|
| 261 |
+
state.needDrain = true;
|
| 262 |
+
|
| 263 |
+
if (state.writing || state.corked)
|
| 264 |
+
state.buffer.push(new WriteReq(chunk, encoding, cb));
|
| 265 |
+
else
|
| 266 |
+
doWrite(stream, state, false, len, chunk, encoding, cb);
|
| 267 |
+
|
| 268 |
+
return ret;
|
| 269 |
+
}
|
| 270 |
+
|
| 271 |
+
function doWrite(stream, state, writev, len, chunk, encoding, cb) {
|
| 272 |
+
state.writelen = len;
|
| 273 |
+
state.writecb = cb;
|
| 274 |
+
state.writing = true;
|
| 275 |
+
state.sync = true;
|
| 276 |
+
if (writev)
|
| 277 |
+
stream._writev(chunk, state.onwrite);
|
| 278 |
+
else
|
| 279 |
+
stream._write(chunk, encoding, state.onwrite);
|
| 280 |
+
state.sync = false;
|
| 281 |
+
}
|
| 282 |
+
|
| 283 |
+
function onwriteError(stream, state, sync, er, cb) {
|
| 284 |
+
if (sync)
|
| 285 |
+
process.nextTick(function() {
|
| 286 |
+
state.pendingcb--;
|
| 287 |
+
cb(er);
|
| 288 |
+
});
|
| 289 |
+
else {
|
| 290 |
+
state.pendingcb--;
|
| 291 |
+
cb(er);
|
| 292 |
+
}
|
| 293 |
+
|
| 294 |
+
stream._writableState.errorEmitted = true;
|
| 295 |
+
stream.emit('error', er);
|
| 296 |
+
}
|
| 297 |
+
|
| 298 |
+
function onwriteStateUpdate(state) {
|
| 299 |
+
state.writing = false;
|
| 300 |
+
state.writecb = null;
|
| 301 |
+
state.length -= state.writelen;
|
| 302 |
+
state.writelen = 0;
|
| 303 |
+
}
|
| 304 |
+
|
| 305 |
+
function onwrite(stream, er) {
|
| 306 |
+
var state = stream._writableState;
|
| 307 |
+
var sync = state.sync;
|
| 308 |
+
var cb = state.writecb;
|
| 309 |
+
|
| 310 |
+
onwriteStateUpdate(state);
|
| 311 |
+
|
| 312 |
+
if (er)
|
| 313 |
+
onwriteError(stream, state, sync, er, cb);
|
| 314 |
+
else {
|
| 315 |
+
// Check if we're actually ready to finish, but don't emit yet
|
| 316 |
+
var finished = needFinish(stream, state);
|
| 317 |
+
|
| 318 |
+
if (!finished &&
|
| 319 |
+
!state.corked &&
|
| 320 |
+
!state.bufferProcessing &&
|
| 321 |
+
state.buffer.length) {
|
| 322 |
+
clearBuffer(stream, state);
|
| 323 |
+
}
|
| 324 |
+
|
| 325 |
+
if (sync) {
|
| 326 |
+
process.nextTick(function() {
|
| 327 |
+
afterWrite(stream, state, finished, cb);
|
| 328 |
+
});
|
| 329 |
+
} else {
|
| 330 |
+
afterWrite(stream, state, finished, cb);
|
| 331 |
+
}
|
| 332 |
+
}
|
| 333 |
+
}
|
| 334 |
+
|
| 335 |
+
function afterWrite(stream, state, finished, cb) {
|
| 336 |
+
if (!finished)
|
| 337 |
+
onwriteDrain(stream, state);
|
| 338 |
+
state.pendingcb--;
|
| 339 |
+
cb();
|
| 340 |
+
finishMaybe(stream, state);
|
| 341 |
+
}
|
| 342 |
+
|
| 343 |
+
// Must force callback to be called on nextTick, so that we don't
|
| 344 |
+
// emit 'drain' before the write() consumer gets the 'false' return
|
| 345 |
+
// value, and has a chance to attach a 'drain' listener.
|
| 346 |
+
function onwriteDrain(stream, state) {
|
| 347 |
+
if (state.length === 0 && state.needDrain) {
|
| 348 |
+
state.needDrain = false;
|
| 349 |
+
stream.emit('drain');
|
| 350 |
+
}
|
| 351 |
+
}
|
| 352 |
+
|
| 353 |
+
|
| 354 |
+
// if there's something in the buffer waiting, then process it
|
| 355 |
+
function clearBuffer(stream, state) {
|
| 356 |
+
state.bufferProcessing = true;
|
| 357 |
+
|
| 358 |
+
if (stream._writev && state.buffer.length > 1) {
|
| 359 |
+
// Fast case, write everything using _writev()
|
| 360 |
+
var cbs = [];
|
| 361 |
+
for (var c = 0; c < state.buffer.length; c++)
|
| 362 |
+
cbs.push(state.buffer[c].callback);
|
| 363 |
+
|
| 364 |
+
// count the one we are adding, as well.
|
| 365 |
+
// TODO(isaacs) clean this up
|
| 366 |
+
state.pendingcb++;
|
| 367 |
+
doWrite(stream, state, true, state.length, state.buffer, '', function(err) {
|
| 368 |
+
for (var i = 0; i < cbs.length; i++) {
|
| 369 |
+
state.pendingcb--;
|
| 370 |
+
cbs[i](err);
|
| 371 |
+
}
|
| 372 |
+
});
|
| 373 |
+
|
| 374 |
+
// Clear buffer
|
| 375 |
+
state.buffer = [];
|
| 376 |
+
} else {
|
| 377 |
+
// Slow case, write chunks one-by-one
|
| 378 |
+
for (var c = 0; c < state.buffer.length; c++) {
|
| 379 |
+
var entry = state.buffer[c];
|
| 380 |
+
var chunk = entry.chunk;
|
| 381 |
+
var encoding = entry.encoding;
|
| 382 |
+
var cb = entry.callback;
|
| 383 |
+
var len = state.objectMode ? 1 : chunk.length;
|
| 384 |
+
|
| 385 |
+
doWrite(stream, state, false, len, chunk, encoding, cb);
|
| 386 |
+
|
| 387 |
+
// if we didn't call the onwrite immediately, then
|
| 388 |
+
// it means that we need to wait until it does.
|
| 389 |
+
// also, that means that the chunk and cb are currently
|
| 390 |
+
// being processed, so move the buffer counter past them.
|
| 391 |
+
if (state.writing) {
|
| 392 |
+
c++;
|
| 393 |
+
break;
|
| 394 |
+
}
|
| 395 |
+
}
|
| 396 |
+
|
| 397 |
+
if (c < state.buffer.length)
|
| 398 |
+
state.buffer = state.buffer.slice(c);
|
| 399 |
+
else
|
| 400 |
+
state.buffer.length = 0;
|
| 401 |
+
}
|
| 402 |
+
|
| 403 |
+
state.bufferProcessing = false;
|
| 404 |
+
}
|
| 405 |
+
|
| 406 |
+
Writable.prototype._write = function(chunk, encoding, cb) {
|
| 407 |
+
cb(new Error('not implemented'));
|
| 408 |
+
|
| 409 |
+
};
|
| 410 |
+
|
| 411 |
+
Writable.prototype._writev = null;
|
| 412 |
+
|
| 413 |
+
Writable.prototype.end = function(chunk, encoding, cb) {
|
| 414 |
+
var state = this._writableState;
|
| 415 |
+
|
| 416 |
+
if (util.isFunction(chunk)) {
|
| 417 |
+
cb = chunk;
|
| 418 |
+
chunk = null;
|
| 419 |
+
encoding = null;
|
| 420 |
+
} else if (util.isFunction(encoding)) {
|
| 421 |
+
cb = encoding;
|
| 422 |
+
encoding = null;
|
| 423 |
+
}
|
| 424 |
+
|
| 425 |
+
if (!util.isNullOrUndefined(chunk))
|
| 426 |
+
this.write(chunk, encoding);
|
| 427 |
+
|
| 428 |
+
// .end() fully uncorks
|
| 429 |
+
if (state.corked) {
|
| 430 |
+
state.corked = 1;
|
| 431 |
+
this.uncork();
|
| 432 |
+
}
|
| 433 |
+
|
| 434 |
+
// ignore unnecessary end() calls.
|
| 435 |
+
if (!state.ending && !state.finished)
|
| 436 |
+
endWritable(this, state, cb);
|
| 437 |
+
};
|
| 438 |
+
|
| 439 |
+
|
| 440 |
+
function needFinish(stream, state) {
|
| 441 |
+
return (state.ending &&
|
| 442 |
+
state.length === 0 &&
|
| 443 |
+
!state.finished &&
|
| 444 |
+
!state.writing);
|
| 445 |
+
}
|
| 446 |
+
|
| 447 |
+
function prefinish(stream, state) {
|
| 448 |
+
if (!state.prefinished) {
|
| 449 |
+
state.prefinished = true;
|
| 450 |
+
stream.emit('prefinish');
|
| 451 |
+
}
|
| 452 |
+
}
|
| 453 |
+
|
| 454 |
+
function finishMaybe(stream, state) {
|
| 455 |
+
var need = needFinish(stream, state);
|
| 456 |
+
if (need) {
|
| 457 |
+
if (state.pendingcb === 0) {
|
| 458 |
+
prefinish(stream, state);
|
| 459 |
+
state.finished = true;
|
| 460 |
+
stream.emit('finish');
|
| 461 |
+
} else
|
| 462 |
+
prefinish(stream, state);
|
| 463 |
+
}
|
| 464 |
+
return need;
|
| 465 |
+
}
|
| 466 |
+
|
| 467 |
+
function endWritable(stream, state, cb) {
|
| 468 |
+
state.ending = true;
|
| 469 |
+
finishMaybe(stream, state);
|
| 470 |
+
if (cb) {
|
| 471 |
+
if (state.finished)
|
| 472 |
+
process.nextTick(cb);
|
| 473 |
+
else
|
| 474 |
+
stream.once('finish', cb);
|
| 475 |
+
}
|
| 476 |
+
state.ended = true;
|
| 477 |
+
}
|
5485-master/demos/node_modules/mongoose/node_modules/bson/node_modules/bson-ext/node_modules/node-pre-gyp/node_modules/npmlog/node_modules/are-we-there-yet/node_modules/readable-stream/node_modules/core-util-is/README.md
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
# core-util-is
|
| 2 |
+
|
| 3 |
+
The `util.is*` functions introduced in Node v0.12.
|
5485-master/demos/node_modules/mongoose/node_modules/bson/node_modules/bson-ext/node_modules/node-pre-gyp/node_modules/npmlog/node_modules/are-we-there-yet/node_modules/readable-stream/node_modules/core-util-is/float.patch
ADDED
|
@@ -0,0 +1,604 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
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|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
diff --git a/lib/util.js b/lib/util.js
|
| 2 |
+
index a03e874..9074e8e 100644
|
| 3 |
+
--- a/lib/util.js
|
| 4 |
+
+++ b/lib/util.js
|
| 5 |
+
@@ -19,430 +19,6 @@
|
| 6 |
+
// OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE
|
| 7 |
+
// USE OR OTHER DEALINGS IN THE SOFTWARE.
|
| 8 |
+
|
| 9 |
+
-var formatRegExp = /%[sdj%]/g;
|
| 10 |
+
-exports.format = function(f) {
|
| 11 |
+
- if (!isString(f)) {
|
| 12 |
+
- var objects = [];
|
| 13 |
+
- for (var i = 0; i < arguments.length; i++) {
|
| 14 |
+
- objects.push(inspect(arguments[i]));
|
| 15 |
+
- }
|
| 16 |
+
- return objects.join(' ');
|
| 17 |
+
- }
|
| 18 |
+
-
|
| 19 |
+
- var i = 1;
|
| 20 |
+
- var args = arguments;
|
| 21 |
+
- var len = args.length;
|
| 22 |
+
- var str = String(f).replace(formatRegExp, function(x) {
|
| 23 |
+
- if (x === '%%') return '%';
|
| 24 |
+
- if (i >= len) return x;
|
| 25 |
+
- switch (x) {
|
| 26 |
+
- case '%s': return String(args[i++]);
|
| 27 |
+
- case '%d': return Number(args[i++]);
|
| 28 |
+
- case '%j':
|
| 29 |
+
- try {
|
| 30 |
+
- return JSON.stringify(args[i++]);
|
| 31 |
+
- } catch (_) {
|
| 32 |
+
- return '[Circular]';
|
| 33 |
+
- }
|
| 34 |
+
- default:
|
| 35 |
+
- return x;
|
| 36 |
+
- }
|
| 37 |
+
- });
|
| 38 |
+
- for (var x = args[i]; i < len; x = args[++i]) {
|
| 39 |
+
- if (isNull(x) || !isObject(x)) {
|
| 40 |
+
- str += ' ' + x;
|
| 41 |
+
- } else {
|
| 42 |
+
- str += ' ' + inspect(x);
|
| 43 |
+
- }
|
| 44 |
+
- }
|
| 45 |
+
- return str;
|
| 46 |
+
-};
|
| 47 |
+
-
|
| 48 |
+
-
|
| 49 |
+
-// Mark that a method should not be used.
|
| 50 |
+
-// Returns a modified function which warns once by default.
|
| 51 |
+
-// If --no-deprecation is set, then it is a no-op.
|
| 52 |
+
-exports.deprecate = function(fn, msg) {
|
| 53 |
+
- // Allow for deprecating things in the process of starting up.
|
| 54 |
+
- if (isUndefined(global.process)) {
|
| 55 |
+
- return function() {
|
| 56 |
+
- return exports.deprecate(fn, msg).apply(this, arguments);
|
| 57 |
+
- };
|
| 58 |
+
- }
|
| 59 |
+
-
|
| 60 |
+
- if (process.noDeprecation === true) {
|
| 61 |
+
- return fn;
|
| 62 |
+
- }
|
| 63 |
+
-
|
| 64 |
+
- var warned = false;
|
| 65 |
+
- function deprecated() {
|
| 66 |
+
- if (!warned) {
|
| 67 |
+
- if (process.throwDeprecation) {
|
| 68 |
+
- throw new Error(msg);
|
| 69 |
+
- } else if (process.traceDeprecation) {
|
| 70 |
+
- console.trace(msg);
|
| 71 |
+
- } else {
|
| 72 |
+
- console.error(msg);
|
| 73 |
+
- }
|
| 74 |
+
- warned = true;
|
| 75 |
+
- }
|
| 76 |
+
- return fn.apply(this, arguments);
|
| 77 |
+
- }
|
| 78 |
+
-
|
| 79 |
+
- return deprecated;
|
| 80 |
+
-};
|
| 81 |
+
-
|
| 82 |
+
-
|
| 83 |
+
-var debugs = {};
|
| 84 |
+
-var debugEnviron;
|
| 85 |
+
-exports.debuglog = function(set) {
|
| 86 |
+
- if (isUndefined(debugEnviron))
|
| 87 |
+
- debugEnviron = process.env.NODE_DEBUG || '';
|
| 88 |
+
- set = set.toUpperCase();
|
| 89 |
+
- if (!debugs[set]) {
|
| 90 |
+
- if (new RegExp('\\b' + set + '\\b', 'i').test(debugEnviron)) {
|
| 91 |
+
- var pid = process.pid;
|
| 92 |
+
- debugs[set] = function() {
|
| 93 |
+
- var msg = exports.format.apply(exports, arguments);
|
| 94 |
+
- console.error('%s %d: %s', set, pid, msg);
|
| 95 |
+
- };
|
| 96 |
+
- } else {
|
| 97 |
+
- debugs[set] = function() {};
|
| 98 |
+
- }
|
| 99 |
+
- }
|
| 100 |
+
- return debugs[set];
|
| 101 |
+
-};
|
| 102 |
+
-
|
| 103 |
+
-
|
| 104 |
+
-/**
|
| 105 |
+
- * Echos the value of a value. Trys to print the value out
|
| 106 |
+
- * in the best way possible given the different types.
|
| 107 |
+
- *
|
| 108 |
+
- * @param {Object} obj The object to print out.
|
| 109 |
+
- * @param {Object} opts Optional options object that alters the output.
|
| 110 |
+
- */
|
| 111 |
+
-/* legacy: obj, showHidden, depth, colors*/
|
| 112 |
+
-function inspect(obj, opts) {
|
| 113 |
+
- // default options
|
| 114 |
+
- var ctx = {
|
| 115 |
+
- seen: [],
|
| 116 |
+
- stylize: stylizeNoColor
|
| 117 |
+
- };
|
| 118 |
+
- // legacy...
|
| 119 |
+
- if (arguments.length >= 3) ctx.depth = arguments[2];
|
| 120 |
+
- if (arguments.length >= 4) ctx.colors = arguments[3];
|
| 121 |
+
- if (isBoolean(opts)) {
|
| 122 |
+
- // legacy...
|
| 123 |
+
- ctx.showHidden = opts;
|
| 124 |
+
- } else if (opts) {
|
| 125 |
+
- // got an "options" object
|
| 126 |
+
- exports._extend(ctx, opts);
|
| 127 |
+
- }
|
| 128 |
+
- // set default options
|
| 129 |
+
- if (isUndefined(ctx.showHidden)) ctx.showHidden = false;
|
| 130 |
+
- if (isUndefined(ctx.depth)) ctx.depth = 2;
|
| 131 |
+
- if (isUndefined(ctx.colors)) ctx.colors = false;
|
| 132 |
+
- if (isUndefined(ctx.customInspect)) ctx.customInspect = true;
|
| 133 |
+
- if (ctx.colors) ctx.stylize = stylizeWithColor;
|
| 134 |
+
- return formatValue(ctx, obj, ctx.depth);
|
| 135 |
+
-}
|
| 136 |
+
-exports.inspect = inspect;
|
| 137 |
+
-
|
| 138 |
+
-
|
| 139 |
+
-// http://en.wikipedia.org/wiki/ANSI_escape_code#graphics
|
| 140 |
+
-inspect.colors = {
|
| 141 |
+
- 'bold' : [1, 22],
|
| 142 |
+
- 'italic' : [3, 23],
|
| 143 |
+
- 'underline' : [4, 24],
|
| 144 |
+
- 'inverse' : [7, 27],
|
| 145 |
+
- 'white' : [37, 39],
|
| 146 |
+
- 'grey' : [90, 39],
|
| 147 |
+
- 'black' : [30, 39],
|
| 148 |
+
- 'blue' : [34, 39],
|
| 149 |
+
- 'cyan' : [36, 39],
|
| 150 |
+
- 'green' : [32, 39],
|
| 151 |
+
- 'magenta' : [35, 39],
|
| 152 |
+
- 'red' : [31, 39],
|
| 153 |
+
- 'yellow' : [33, 39]
|
| 154 |
+
-};
|
| 155 |
+
-
|
| 156 |
+
-// Don't use 'blue' not visible on cmd.exe
|
| 157 |
+
-inspect.styles = {
|
| 158 |
+
- 'special': 'cyan',
|
| 159 |
+
- 'number': 'yellow',
|
| 160 |
+
- 'boolean': 'yellow',
|
| 161 |
+
- 'undefined': 'grey',
|
| 162 |
+
- 'null': 'bold',
|
| 163 |
+
- 'string': 'green',
|
| 164 |
+
- 'date': 'magenta',
|
| 165 |
+
- // "name": intentionally not styling
|
| 166 |
+
- 'regexp': 'red'
|
| 167 |
+
-};
|
| 168 |
+
-
|
| 169 |
+
-
|
| 170 |
+
-function stylizeWithColor(str, styleType) {
|
| 171 |
+
- var style = inspect.styles[styleType];
|
| 172 |
+
-
|
| 173 |
+
- if (style) {
|
| 174 |
+
- return '\u001b[' + inspect.colors[style][0] + 'm' + str +
|
| 175 |
+
- '\u001b[' + inspect.colors[style][1] + 'm';
|
| 176 |
+
- } else {
|
| 177 |
+
- return str;
|
| 178 |
+
- }
|
| 179 |
+
-}
|
| 180 |
+
-
|
| 181 |
+
-
|
| 182 |
+
-function stylizeNoColor(str, styleType) {
|
| 183 |
+
- return str;
|
| 184 |
+
-}
|
| 185 |
+
-
|
| 186 |
+
-
|
| 187 |
+
-function arrayToHash(array) {
|
| 188 |
+
- var hash = {};
|
| 189 |
+
-
|
| 190 |
+
- array.forEach(function(val, idx) {
|
| 191 |
+
- hash[val] = true;
|
| 192 |
+
- });
|
| 193 |
+
-
|
| 194 |
+
- return hash;
|
| 195 |
+
-}
|
| 196 |
+
-
|
| 197 |
+
-
|
| 198 |
+
-function formatValue(ctx, value, recurseTimes) {
|
| 199 |
+
- // Provide a hook for user-specified inspect functions.
|
| 200 |
+
- // Check that value is an object with an inspect function on it
|
| 201 |
+
- if (ctx.customInspect &&
|
| 202 |
+
- value &&
|
| 203 |
+
- isFunction(value.inspect) &&
|
| 204 |
+
- // Filter out the util module, it's inspect function is special
|
| 205 |
+
- value.inspect !== exports.inspect &&
|
| 206 |
+
- // Also filter out any prototype objects using the circular check.
|
| 207 |
+
- !(value.constructor && value.constructor.prototype === value)) {
|
| 208 |
+
- var ret = value.inspect(recurseTimes, ctx);
|
| 209 |
+
- if (!isString(ret)) {
|
| 210 |
+
- ret = formatValue(ctx, ret, recurseTimes);
|
| 211 |
+
- }
|
| 212 |
+
- return ret;
|
| 213 |
+
- }
|
| 214 |
+
-
|
| 215 |
+
- // Primitive types cannot have properties
|
| 216 |
+
- var primitive = formatPrimitive(ctx, value);
|
| 217 |
+
- if (primitive) {
|
| 218 |
+
- return primitive;
|
| 219 |
+
- }
|
| 220 |
+
-
|
| 221 |
+
- // Look up the keys of the object.
|
| 222 |
+
- var keys = Object.keys(value);
|
| 223 |
+
- var visibleKeys = arrayToHash(keys);
|
| 224 |
+
-
|
| 225 |
+
- if (ctx.showHidden) {
|
| 226 |
+
- keys = Object.getOwnPropertyNames(value);
|
| 227 |
+
- }
|
| 228 |
+
-
|
| 229 |
+
- // Some type of object without properties can be shortcutted.
|
| 230 |
+
- if (keys.length === 0) {
|
| 231 |
+
- if (isFunction(value)) {
|
| 232 |
+
- var name = value.name ? ': ' + value.name : '';
|
| 233 |
+
- return ctx.stylize('[Function' + name + ']', 'special');
|
| 234 |
+
- }
|
| 235 |
+
- if (isRegExp(value)) {
|
| 236 |
+
- return ctx.stylize(RegExp.prototype.toString.call(value), 'regexp');
|
| 237 |
+
- }
|
| 238 |
+
- if (isDate(value)) {
|
| 239 |
+
- return ctx.stylize(Date.prototype.toString.call(value), 'date');
|
| 240 |
+
- }
|
| 241 |
+
- if (isError(value)) {
|
| 242 |
+
- return formatError(value);
|
| 243 |
+
- }
|
| 244 |
+
- }
|
| 245 |
+
-
|
| 246 |
+
- var base = '', array = false, braces = ['{', '}'];
|
| 247 |
+
-
|
| 248 |
+
- // Make Array say that they are Array
|
| 249 |
+
- if (isArray(value)) {
|
| 250 |
+
- array = true;
|
| 251 |
+
- braces = ['[', ']'];
|
| 252 |
+
- }
|
| 253 |
+
-
|
| 254 |
+
- // Make functions say that they are functions
|
| 255 |
+
- if (isFunction(value)) {
|
| 256 |
+
- var n = value.name ? ': ' + value.name : '';
|
| 257 |
+
- base = ' [Function' + n + ']';
|
| 258 |
+
- }
|
| 259 |
+
-
|
| 260 |
+
- // Make RegExps say that they are RegExps
|
| 261 |
+
- if (isRegExp(value)) {
|
| 262 |
+
- base = ' ' + RegExp.prototype.toString.call(value);
|
| 263 |
+
- }
|
| 264 |
+
-
|
| 265 |
+
- // Make dates with properties first say the date
|
| 266 |
+
- if (isDate(value)) {
|
| 267 |
+
- base = ' ' + Date.prototype.toUTCString.call(value);
|
| 268 |
+
- }
|
| 269 |
+
-
|
| 270 |
+
- // Make error with message first say the error
|
| 271 |
+
- if (isError(value)) {
|
| 272 |
+
- base = ' ' + formatError(value);
|
| 273 |
+
- }
|
| 274 |
+
-
|
| 275 |
+
- if (keys.length === 0 && (!array || value.length == 0)) {
|
| 276 |
+
- return braces[0] + base + braces[1];
|
| 277 |
+
- }
|
| 278 |
+
-
|
| 279 |
+
- if (recurseTimes < 0) {
|
| 280 |
+
- if (isRegExp(value)) {
|
| 281 |
+
- return ctx.stylize(RegExp.prototype.toString.call(value), 'regexp');
|
| 282 |
+
- } else {
|
| 283 |
+
- return ctx.stylize('[Object]', 'special');
|
| 284 |
+
- }
|
| 285 |
+
- }
|
| 286 |
+
-
|
| 287 |
+
- ctx.seen.push(value);
|
| 288 |
+
-
|
| 289 |
+
- var output;
|
| 290 |
+
- if (array) {
|
| 291 |
+
- output = formatArray(ctx, value, recurseTimes, visibleKeys, keys);
|
| 292 |
+
- } else {
|
| 293 |
+
- output = keys.map(function(key) {
|
| 294 |
+
- return formatProperty(ctx, value, recurseTimes, visibleKeys, key, array);
|
| 295 |
+
- });
|
| 296 |
+
- }
|
| 297 |
+
-
|
| 298 |
+
- ctx.seen.pop();
|
| 299 |
+
-
|
| 300 |
+
- return reduceToSingleString(output, base, braces);
|
| 301 |
+
-}
|
| 302 |
+
-
|
| 303 |
+
-
|
| 304 |
+
-function formatPrimitive(ctx, value) {
|
| 305 |
+
- if (isUndefined(value))
|
| 306 |
+
- return ctx.stylize('undefined', 'undefined');
|
| 307 |
+
- if (isString(value)) {
|
| 308 |
+
- var simple = '\'' + JSON.stringify(value).replace(/^"|"$/g, '')
|
| 309 |
+
- .replace(/'/g, "\\'")
|
| 310 |
+
- .replace(/\\"/g, '"') + '\'';
|
| 311 |
+
- return ctx.stylize(simple, 'string');
|
| 312 |
+
- }
|
| 313 |
+
- if (isNumber(value)) {
|
| 314 |
+
- // Format -0 as '-0'. Strict equality won't distinguish 0 from -0,
|
| 315 |
+
- // so instead we use the fact that 1 / -0 < 0 whereas 1 / 0 > 0 .
|
| 316 |
+
- if (value === 0 && 1 / value < 0)
|
| 317 |
+
- return ctx.stylize('-0', 'number');
|
| 318 |
+
- return ctx.stylize('' + value, 'number');
|
| 319 |
+
- }
|
| 320 |
+
- if (isBoolean(value))
|
| 321 |
+
- return ctx.stylize('' + value, 'boolean');
|
| 322 |
+
- // For some reason typeof null is "object", so special case here.
|
| 323 |
+
- if (isNull(value))
|
| 324 |
+
- return ctx.stylize('null', 'null');
|
| 325 |
+
-}
|
| 326 |
+
-
|
| 327 |
+
-
|
| 328 |
+
-function formatError(value) {
|
| 329 |
+
- return '[' + Error.prototype.toString.call(value) + ']';
|
| 330 |
+
-}
|
| 331 |
+
-
|
| 332 |
+
-
|
| 333 |
+
-function formatArray(ctx, value, recurseTimes, visibleKeys, keys) {
|
| 334 |
+
- var output = [];
|
| 335 |
+
- for (var i = 0, l = value.length; i < l; ++i) {
|
| 336 |
+
- if (hasOwnProperty(value, String(i))) {
|
| 337 |
+
- output.push(formatProperty(ctx, value, recurseTimes, visibleKeys,
|
| 338 |
+
- String(i), true));
|
| 339 |
+
- } else {
|
| 340 |
+
- output.push('');
|
| 341 |
+
- }
|
| 342 |
+
- }
|
| 343 |
+
- keys.forEach(function(key) {
|
| 344 |
+
- if (!key.match(/^\d+$/)) {
|
| 345 |
+
- output.push(formatProperty(ctx, value, recurseTimes, visibleKeys,
|
| 346 |
+
- key, true));
|
| 347 |
+
- }
|
| 348 |
+
- });
|
| 349 |
+
- return output;
|
| 350 |
+
-}
|
| 351 |
+
-
|
| 352 |
+
-
|
| 353 |
+
-function formatProperty(ctx, value, recurseTimes, visibleKeys, key, array) {
|
| 354 |
+
- var name, str, desc;
|
| 355 |
+
- desc = Object.getOwnPropertyDescriptor(value, key) || { value: value[key] };
|
| 356 |
+
- if (desc.get) {
|
| 357 |
+
- if (desc.set) {
|
| 358 |
+
- str = ctx.stylize('[Getter/Setter]', 'special');
|
| 359 |
+
- } else {
|
| 360 |
+
- str = ctx.stylize('[Getter]', 'special');
|
| 361 |
+
- }
|
| 362 |
+
- } else {
|
| 363 |
+
- if (desc.set) {
|
| 364 |
+
- str = ctx.stylize('[Setter]', 'special');
|
| 365 |
+
- }
|
| 366 |
+
- }
|
| 367 |
+
- if (!hasOwnProperty(visibleKeys, key)) {
|
| 368 |
+
- name = '[' + key + ']';
|
| 369 |
+
- }
|
| 370 |
+
- if (!str) {
|
| 371 |
+
- if (ctx.seen.indexOf(desc.value) < 0) {
|
| 372 |
+
- if (isNull(recurseTimes)) {
|
| 373 |
+
- str = formatValue(ctx, desc.value, null);
|
| 374 |
+
- } else {
|
| 375 |
+
- str = formatValue(ctx, desc.value, recurseTimes - 1);
|
| 376 |
+
- }
|
| 377 |
+
- if (str.indexOf('\n') > -1) {
|
| 378 |
+
- if (array) {
|
| 379 |
+
- str = str.split('\n').map(function(line) {
|
| 380 |
+
- return ' ' + line;
|
| 381 |
+
- }).join('\n').substr(2);
|
| 382 |
+
- } else {
|
| 383 |
+
- str = '\n' + str.split('\n').map(function(line) {
|
| 384 |
+
- return ' ' + line;
|
| 385 |
+
- }).join('\n');
|
| 386 |
+
- }
|
| 387 |
+
- }
|
| 388 |
+
- } else {
|
| 389 |
+
- str = ctx.stylize('[Circular]', 'special');
|
| 390 |
+
- }
|
| 391 |
+
- }
|
| 392 |
+
- if (isUndefined(name)) {
|
| 393 |
+
- if (array && key.match(/^\d+$/)) {
|
| 394 |
+
- return str;
|
| 395 |
+
- }
|
| 396 |
+
- name = JSON.stringify('' + key);
|
| 397 |
+
- if (name.match(/^"([a-zA-Z_][a-zA-Z_0-9]*)"$/)) {
|
| 398 |
+
- name = name.substr(1, name.length - 2);
|
| 399 |
+
- name = ctx.stylize(name, 'name');
|
| 400 |
+
- } else {
|
| 401 |
+
- name = name.replace(/'/g, "\\'")
|
| 402 |
+
- .replace(/\\"/g, '"')
|
| 403 |
+
- .replace(/(^"|"$)/g, "'");
|
| 404 |
+
- name = ctx.stylize(name, 'string');
|
| 405 |
+
- }
|
| 406 |
+
- }
|
| 407 |
+
-
|
| 408 |
+
- return name + ': ' + str;
|
| 409 |
+
-}
|
| 410 |
+
-
|
| 411 |
+
-
|
| 412 |
+
-function reduceToSingleString(output, base, braces) {
|
| 413 |
+
- var numLinesEst = 0;
|
| 414 |
+
- var length = output.reduce(function(prev, cur) {
|
| 415 |
+
- numLinesEst++;
|
| 416 |
+
- if (cur.indexOf('\n') >= 0) numLinesEst++;
|
| 417 |
+
- return prev + cur.replace(/\u001b\[\d\d?m/g, '').length + 1;
|
| 418 |
+
- }, 0);
|
| 419 |
+
-
|
| 420 |
+
- if (length > 60) {
|
| 421 |
+
- return braces[0] +
|
| 422 |
+
- (base === '' ? '' : base + '\n ') +
|
| 423 |
+
- ' ' +
|
| 424 |
+
- output.join(',\n ') +
|
| 425 |
+
- ' ' +
|
| 426 |
+
- braces[1];
|
| 427 |
+
- }
|
| 428 |
+
-
|
| 429 |
+
- return braces[0] + base + ' ' + output.join(', ') + ' ' + braces[1];
|
| 430 |
+
-}
|
| 431 |
+
-
|
| 432 |
+
-
|
| 433 |
+
// NOTE: These type checking functions intentionally don't use `instanceof`
|
| 434 |
+
// because it is fragile and can be easily faked with `Object.create()`.
|
| 435 |
+
function isArray(ar) {
|
| 436 |
+
@@ -522,166 +98,10 @@ function isPrimitive(arg) {
|
| 437 |
+
exports.isPrimitive = isPrimitive;
|
| 438 |
+
|
| 439 |
+
function isBuffer(arg) {
|
| 440 |
+
- return arg instanceof Buffer;
|
| 441 |
+
+ return Buffer.isBuffer(arg);
|
| 442 |
+
}
|
| 443 |
+
exports.isBuffer = isBuffer;
|
| 444 |
+
|
| 445 |
+
function objectToString(o) {
|
| 446 |
+
return Object.prototype.toString.call(o);
|
| 447 |
+
-}
|
| 448 |
+
-
|
| 449 |
+
-
|
| 450 |
+
-function pad(n) {
|
| 451 |
+
- return n < 10 ? '0' + n.toString(10) : n.toString(10);
|
| 452 |
+
-}
|
| 453 |
+
-
|
| 454 |
+
-
|
| 455 |
+
-var months = ['Jan', 'Feb', 'Mar', 'Apr', 'May', 'Jun', 'Jul', 'Aug', 'Sep',
|
| 456 |
+
- 'Oct', 'Nov', 'Dec'];
|
| 457 |
+
-
|
| 458 |
+
-// 26 Feb 16:19:34
|
| 459 |
+
-function timestamp() {
|
| 460 |
+
- var d = new Date();
|
| 461 |
+
- var time = [pad(d.getHours()),
|
| 462 |
+
- pad(d.getMinutes()),
|
| 463 |
+
- pad(d.getSeconds())].join(':');
|
| 464 |
+
- return [d.getDate(), months[d.getMonth()], time].join(' ');
|
| 465 |
+
-}
|
| 466 |
+
-
|
| 467 |
+
-
|
| 468 |
+
-// log is just a thin wrapper to console.log that prepends a timestamp
|
| 469 |
+
-exports.log = function() {
|
| 470 |
+
- console.log('%s - %s', timestamp(), exports.format.apply(exports, arguments));
|
| 471 |
+
-};
|
| 472 |
+
-
|
| 473 |
+
-
|
| 474 |
+
-/**
|
| 475 |
+
- * Inherit the prototype methods from one constructor into another.
|
| 476 |
+
- *
|
| 477 |
+
- * The Function.prototype.inherits from lang.js rewritten as a standalone
|
| 478 |
+
- * function (not on Function.prototype). NOTE: If this file is to be loaded
|
| 479 |
+
- * during bootstrapping this function needs to be rewritten using some native
|
| 480 |
+
- * functions as prototype setup using normal JavaScript does not work as
|
| 481 |
+
- * expected during bootstrapping (see mirror.js in r114903).
|
| 482 |
+
- *
|
| 483 |
+
- * @param {function} ctor Constructor function which needs to inherit the
|
| 484 |
+
- * prototype.
|
| 485 |
+
- * @param {function} superCtor Constructor function to inherit prototype from.
|
| 486 |
+
- */
|
| 487 |
+
-exports.inherits = function(ctor, superCtor) {
|
| 488 |
+
- ctor.super_ = superCtor;
|
| 489 |
+
- ctor.prototype = Object.create(superCtor.prototype, {
|
| 490 |
+
- constructor: {
|
| 491 |
+
- value: ctor,
|
| 492 |
+
- enumerable: false,
|
| 493 |
+
- writable: true,
|
| 494 |
+
- configurable: true
|
| 495 |
+
- }
|
| 496 |
+
- });
|
| 497 |
+
-};
|
| 498 |
+
-
|
| 499 |
+
-exports._extend = function(origin, add) {
|
| 500 |
+
- // Don't do anything if add isn't an object
|
| 501 |
+
- if (!add || !isObject(add)) return origin;
|
| 502 |
+
-
|
| 503 |
+
- var keys = Object.keys(add);
|
| 504 |
+
- var i = keys.length;
|
| 505 |
+
- while (i--) {
|
| 506 |
+
- origin[keys[i]] = add[keys[i]];
|
| 507 |
+
- }
|
| 508 |
+
- return origin;
|
| 509 |
+
-};
|
| 510 |
+
-
|
| 511 |
+
-function hasOwnProperty(obj, prop) {
|
| 512 |
+
- return Object.prototype.hasOwnProperty.call(obj, prop);
|
| 513 |
+
-}
|
| 514 |
+
-
|
| 515 |
+
-
|
| 516 |
+
-// Deprecated old stuff.
|
| 517 |
+
-
|
| 518 |
+
-exports.p = exports.deprecate(function() {
|
| 519 |
+
- for (var i = 0, len = arguments.length; i < len; ++i) {
|
| 520 |
+
- console.error(exports.inspect(arguments[i]));
|
| 521 |
+
- }
|
| 522 |
+
-}, 'util.p: Use console.error() instead');
|
| 523 |
+
-
|
| 524 |
+
-
|
| 525 |
+
-exports.exec = exports.deprecate(function() {
|
| 526 |
+
- return require('child_process').exec.apply(this, arguments);
|
| 527 |
+
-}, 'util.exec is now called `child_process.exec`.');
|
| 528 |
+
-
|
| 529 |
+
-
|
| 530 |
+
-exports.print = exports.deprecate(function() {
|
| 531 |
+
- for (var i = 0, len = arguments.length; i < len; ++i) {
|
| 532 |
+
- process.stdout.write(String(arguments[i]));
|
| 533 |
+
- }
|
| 534 |
+
-}, 'util.print: Use console.log instead');
|
| 535 |
+
-
|
| 536 |
+
-
|
| 537 |
+
-exports.puts = exports.deprecate(function() {
|
| 538 |
+
- for (var i = 0, len = arguments.length; i < len; ++i) {
|
| 539 |
+
- process.stdout.write(arguments[i] + '\n');
|
| 540 |
+
- }
|
| 541 |
+
-}, 'util.puts: Use console.log instead');
|
| 542 |
+
-
|
| 543 |
+
-
|
| 544 |
+
-exports.debug = exports.deprecate(function(x) {
|
| 545 |
+
- process.stderr.write('DEBUG: ' + x + '\n');
|
| 546 |
+
-}, 'util.debug: Use console.error instead');
|
| 547 |
+
-
|
| 548 |
+
-
|
| 549 |
+
-exports.error = exports.deprecate(function(x) {
|
| 550 |
+
- for (var i = 0, len = arguments.length; i < len; ++i) {
|
| 551 |
+
- process.stderr.write(arguments[i] + '\n');
|
| 552 |
+
- }
|
| 553 |
+
-}, 'util.error: Use console.error instead');
|
| 554 |
+
-
|
| 555 |
+
-
|
| 556 |
+
-exports.pump = exports.deprecate(function(readStream, writeStream, callback) {
|
| 557 |
+
- var callbackCalled = false;
|
| 558 |
+
-
|
| 559 |
+
- function call(a, b, c) {
|
| 560 |
+
- if (callback && !callbackCalled) {
|
| 561 |
+
- callback(a, b, c);
|
| 562 |
+
- callbackCalled = true;
|
| 563 |
+
- }
|
| 564 |
+
- }
|
| 565 |
+
-
|
| 566 |
+
- readStream.addListener('data', function(chunk) {
|
| 567 |
+
- if (writeStream.write(chunk) === false) readStream.pause();
|
| 568 |
+
- });
|
| 569 |
+
-
|
| 570 |
+
- writeStream.addListener('drain', function() {
|
| 571 |
+
- readStream.resume();
|
| 572 |
+
- });
|
| 573 |
+
-
|
| 574 |
+
- readStream.addListener('end', function() {
|
| 575 |
+
- writeStream.end();
|
| 576 |
+
- });
|
| 577 |
+
-
|
| 578 |
+
- readStream.addListener('close', function() {
|
| 579 |
+
- call();
|
| 580 |
+
- });
|
| 581 |
+
-
|
| 582 |
+
- readStream.addListener('error', function(err) {
|
| 583 |
+
- writeStream.end();
|
| 584 |
+
- call(err);
|
| 585 |
+
- });
|
| 586 |
+
-
|
| 587 |
+
- writeStream.addListener('error', function(err) {
|
| 588 |
+
- readStream.destroy();
|
| 589 |
+
- call(err);
|
| 590 |
+
- });
|
| 591 |
+
-}, 'util.pump(): Use readableStream.pipe() instead');
|
| 592 |
+
-
|
| 593 |
+
-
|
| 594 |
+
-var uv;
|
| 595 |
+
-exports._errnoException = function(err, syscall) {
|
| 596 |
+
- if (isUndefined(uv)) uv = process.binding('uv');
|
| 597 |
+
- var errname = uv.errname(err);
|
| 598 |
+
- var e = new Error(syscall + ' ' + errname);
|
| 599 |
+
- e.code = errname;
|
| 600 |
+
- e.errno = errname;
|
| 601 |
+
- e.syscall = syscall;
|
| 602 |
+
- return e;
|
| 603 |
+
-};
|
| 604 |
+
+}
|
5485-master/demos/node_modules/mongoose/node_modules/bson/node_modules/bson-ext/node_modules/node-pre-gyp/node_modules/npmlog/node_modules/are-we-there-yet/node_modules/readable-stream/node_modules/core-util-is/lib/util.js
ADDED
|
@@ -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 |
+
function isArray(ar) {
|
| 25 |
+
return Array.isArray(ar);
|
| 26 |
+
}
|
| 27 |
+
exports.isArray = isArray;
|
| 28 |
+
|
| 29 |
+
function isBoolean(arg) {
|
| 30 |
+
return typeof arg === 'boolean';
|
| 31 |
+
}
|
| 32 |
+
exports.isBoolean = isBoolean;
|
| 33 |
+
|
| 34 |
+
function isNull(arg) {
|
| 35 |
+
return arg === null;
|
| 36 |
+
}
|
| 37 |
+
exports.isNull = isNull;
|
| 38 |
+
|
| 39 |
+
function isNullOrUndefined(arg) {
|
| 40 |
+
return arg == null;
|
| 41 |
+
}
|
| 42 |
+
exports.isNullOrUndefined = isNullOrUndefined;
|
| 43 |
+
|
| 44 |
+
function isNumber(arg) {
|
| 45 |
+
return typeof arg === 'number';
|
| 46 |
+
}
|
| 47 |
+
exports.isNumber = isNumber;
|
| 48 |
+
|
| 49 |
+
function isString(arg) {
|
| 50 |
+
return typeof arg === 'string';
|
| 51 |
+
}
|
| 52 |
+
exports.isString = isString;
|
| 53 |
+
|
| 54 |
+
function isSymbol(arg) {
|
| 55 |
+
return typeof arg === 'symbol';
|
| 56 |
+
}
|
| 57 |
+
exports.isSymbol = isSymbol;
|
| 58 |
+
|
| 59 |
+
function isUndefined(arg) {
|
| 60 |
+
return arg === void 0;
|
| 61 |
+
}
|
| 62 |
+
exports.isUndefined = isUndefined;
|
| 63 |
+
|
| 64 |
+
function isRegExp(re) {
|
| 65 |
+
return isObject(re) && objectToString(re) === '[object RegExp]';
|
| 66 |
+
}
|
| 67 |
+
exports.isRegExp = isRegExp;
|
| 68 |
+
|
| 69 |
+
function isObject(arg) {
|
| 70 |
+
return typeof arg === 'object' && arg !== null;
|
| 71 |
+
}
|
| 72 |
+
exports.isObject = isObject;
|
| 73 |
+
|
| 74 |
+
function isDate(d) {
|
| 75 |
+
return isObject(d) && objectToString(d) === '[object Date]';
|
| 76 |
+
}
|
| 77 |
+
exports.isDate = isDate;
|
| 78 |
+
|
| 79 |
+
function isError(e) {
|
| 80 |
+
return isObject(e) &&
|
| 81 |
+
(objectToString(e) === '[object Error]' || e instanceof Error);
|
| 82 |
+
}
|
| 83 |
+
exports.isError = isError;
|
| 84 |
+
|
| 85 |
+
function isFunction(arg) {
|
| 86 |
+
return typeof arg === 'function';
|
| 87 |
+
}
|
| 88 |
+
exports.isFunction = isFunction;
|
| 89 |
+
|
| 90 |
+
function isPrimitive(arg) {
|
| 91 |
+
return arg === null ||
|
| 92 |
+
typeof arg === 'boolean' ||
|
| 93 |
+
typeof arg === 'number' ||
|
| 94 |
+
typeof arg === 'string' ||
|
| 95 |
+
typeof arg === 'symbol' || // ES6 symbol
|
| 96 |
+
typeof arg === 'undefined';
|
| 97 |
+
}
|
| 98 |
+
exports.isPrimitive = isPrimitive;
|
| 99 |
+
|
| 100 |
+
function isBuffer(arg) {
|
| 101 |
+
return Buffer.isBuffer(arg);
|
| 102 |
+
}
|
| 103 |
+
exports.isBuffer = isBuffer;
|
| 104 |
+
|
| 105 |
+
function objectToString(o) {
|
| 106 |
+
return Object.prototype.toString.call(o);
|
| 107 |
+
}
|
5485-master/demos/node_modules/mongoose/node_modules/bson/node_modules/bson-ext/node_modules/node-pre-gyp/node_modules/npmlog/node_modules/are-we-there-yet/node_modules/readable-stream/node_modules/core-util-is/package.json
ADDED
|
@@ -0,0 +1,53 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
{
|
| 2 |
+
"name": "core-util-is",
|
| 3 |
+
"version": "1.0.1",
|
| 4 |
+
"description": "The `util.is*` functions introduced in Node v0.12.",
|
| 5 |
+
"main": "lib/util.js",
|
| 6 |
+
"repository": {
|
| 7 |
+
"type": "git",
|
| 8 |
+
"url": "git://github.com/isaacs/core-util-is.git"
|
| 9 |
+
},
|
| 10 |
+
"keywords": [
|
| 11 |
+
"util",
|
| 12 |
+
"isBuffer",
|
| 13 |
+
"isArray",
|
| 14 |
+
"isNumber",
|
| 15 |
+
"isString",
|
| 16 |
+
"isRegExp",
|
| 17 |
+
"isThis",
|
| 18 |
+
"isThat",
|
| 19 |
+
"polyfill"
|
| 20 |
+
],
|
| 21 |
+
"author": {
|
| 22 |
+
"name": "Isaac Z. Schlueter",
|
| 23 |
+
"email": "i@izs.me",
|
| 24 |
+
"url": "http://blog.izs.me/"
|
| 25 |
+
},
|
| 26 |
+
"license": "MIT",
|
| 27 |
+
"bugs": {
|
| 28 |
+
"url": "https://github.com/isaacs/core-util-is/issues"
|
| 29 |
+
},
|
| 30 |
+
"readme": "# core-util-is\n\nThe `util.is*` functions introduced in Node v0.12.\n",
|
| 31 |
+
"readmeFilename": "README.md",
|
| 32 |
+
"homepage": "https://github.com/isaacs/core-util-is",
|
| 33 |
+
"_id": "core-util-is@1.0.1",
|
| 34 |
+
"dist": {
|
| 35 |
+
"shasum": "6b07085aef9a3ccac6ee53bf9d3df0c1521a5538",
|
| 36 |
+
"tarball": "http://registry.npmjs.org/core-util-is/-/core-util-is-1.0.1.tgz"
|
| 37 |
+
},
|
| 38 |
+
"_from": "core-util-is@>=1.0.0 <1.1.0",
|
| 39 |
+
"_npmVersion": "1.3.23",
|
| 40 |
+
"_npmUser": {
|
| 41 |
+
"name": "isaacs",
|
| 42 |
+
"email": "i@izs.me"
|
| 43 |
+
},
|
| 44 |
+
"maintainers": [
|
| 45 |
+
{
|
| 46 |
+
"name": "isaacs",
|
| 47 |
+
"email": "i@izs.me"
|
| 48 |
+
}
|
| 49 |
+
],
|
| 50 |
+
"directories": {},
|
| 51 |
+
"_shasum": "6b07085aef9a3ccac6ee53bf9d3df0c1521a5538",
|
| 52 |
+
"_resolved": "https://registry.npmjs.org/core-util-is/-/core-util-is-1.0.1.tgz"
|
| 53 |
+
}
|
5485-master/demos/node_modules/mongoose/node_modules/bson/node_modules/bson-ext/node_modules/node-pre-gyp/node_modules/npmlog/node_modules/are-we-there-yet/node_modules/readable-stream/node_modules/core-util-is/util.js
ADDED
|
@@ -0,0 +1,106 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 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 |
+
function isArray(ar) {
|
| 25 |
+
return Array.isArray(ar);
|
| 26 |
+
}
|
| 27 |
+
exports.isArray = isArray;
|
| 28 |
+
|
| 29 |
+
function isBoolean(arg) {
|
| 30 |
+
return typeof arg === 'boolean';
|
| 31 |
+
}
|
| 32 |
+
exports.isBoolean = isBoolean;
|
| 33 |
+
|
| 34 |
+
function isNull(arg) {
|
| 35 |
+
return arg === null;
|
| 36 |
+
}
|
| 37 |
+
exports.isNull = isNull;
|
| 38 |
+
|
| 39 |
+
function isNullOrUndefined(arg) {
|
| 40 |
+
return arg == null;
|
| 41 |
+
}
|
| 42 |
+
exports.isNullOrUndefined = isNullOrUndefined;
|
| 43 |
+
|
| 44 |
+
function isNumber(arg) {
|
| 45 |
+
return typeof arg === 'number';
|
| 46 |
+
}
|
| 47 |
+
exports.isNumber = isNumber;
|
| 48 |
+
|
| 49 |
+
function isString(arg) {
|
| 50 |
+
return typeof arg === 'string';
|
| 51 |
+
}
|
| 52 |
+
exports.isString = isString;
|
| 53 |
+
|
| 54 |
+
function isSymbol(arg) {
|
| 55 |
+
return typeof arg === 'symbol';
|
| 56 |
+
}
|
| 57 |
+
exports.isSymbol = isSymbol;
|
| 58 |
+
|
| 59 |
+
function isUndefined(arg) {
|
| 60 |
+
return arg === void 0;
|
| 61 |
+
}
|
| 62 |
+
exports.isUndefined = isUndefined;
|
| 63 |
+
|
| 64 |
+
function isRegExp(re) {
|
| 65 |
+
return isObject(re) && objectToString(re) === '[object RegExp]';
|
| 66 |
+
}
|
| 67 |
+
exports.isRegExp = isRegExp;
|
| 68 |
+
|
| 69 |
+
function isObject(arg) {
|
| 70 |
+
return typeof arg === 'object' && arg !== null;
|
| 71 |
+
}
|
| 72 |
+
exports.isObject = isObject;
|
| 73 |
+
|
| 74 |
+
function isDate(d) {
|
| 75 |
+
return isObject(d) && objectToString(d) === '[object Date]';
|
| 76 |
+
}
|
| 77 |
+
exports.isDate = isDate;
|
| 78 |
+
|
| 79 |
+
function isError(e) {
|
| 80 |
+
return isObject(e) && objectToString(e) === '[object Error]';
|
| 81 |
+
}
|
| 82 |
+
exports.isError = isError;
|
| 83 |
+
|
| 84 |
+
function isFunction(arg) {
|
| 85 |
+
return typeof arg === 'function';
|
| 86 |
+
}
|
| 87 |
+
exports.isFunction = isFunction;
|
| 88 |
+
|
| 89 |
+
function isPrimitive(arg) {
|
| 90 |
+
return arg === null ||
|
| 91 |
+
typeof arg === 'boolean' ||
|
| 92 |
+
typeof arg === 'number' ||
|
| 93 |
+
typeof arg === 'string' ||
|
| 94 |
+
typeof arg === 'symbol' || // ES6 symbol
|
| 95 |
+
typeof arg === 'undefined';
|
| 96 |
+
}
|
| 97 |
+
exports.isPrimitive = isPrimitive;
|
| 98 |
+
|
| 99 |
+
function isBuffer(arg) {
|
| 100 |
+
return arg instanceof Buffer;
|
| 101 |
+
}
|
| 102 |
+
exports.isBuffer = isBuffer;
|
| 103 |
+
|
| 104 |
+
function objectToString(o) {
|
| 105 |
+
return Object.prototype.toString.call(o);
|
| 106 |
+
}
|
5485-master/demos/node_modules/mongoose/node_modules/bson/node_modules/bson-ext/node_modules/node-pre-gyp/node_modules/npmlog/node_modules/are-we-there-yet/node_modules/readable-stream/node_modules/inherits/LICENSE
ADDED
|
@@ -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 |
+
|