Firebase Update
This commit is contained in:
26
express-server/node_modules/split-array-stream/.jshintrc
generated
vendored
Normal file
26
express-server/node_modules/split-array-stream/.jshintrc
generated
vendored
Normal file
@ -0,0 +1,26 @@
|
||||
{
|
||||
"bitwise": true,
|
||||
"curly": true,
|
||||
"eqeqeq": true,
|
||||
"esnext": true,
|
||||
"freeze": true,
|
||||
"immed": true,
|
||||
"indent": 2,
|
||||
"latedef": "nofunc",
|
||||
"newcap": true,
|
||||
"node": true,
|
||||
"noarg": true,
|
||||
"quotmark": "single",
|
||||
"strict": true,
|
||||
"trailing": true,
|
||||
"undef": true,
|
||||
"unused": true,
|
||||
"globals": {
|
||||
"describe": true,
|
||||
"it": true,
|
||||
"before": true,
|
||||
"after": true,
|
||||
"beforeEach": true,
|
||||
"afterEach": true
|
||||
}
|
||||
}
|
22
express-server/node_modules/split-array-stream/index.js
generated
vendored
Normal file
22
express-server/node_modules/split-array-stream/index.js
generated
vendored
Normal file
@ -0,0 +1,22 @@
|
||||
'use strict';
|
||||
|
||||
var async = require('async');
|
||||
var ended = require('is-stream-ended');
|
||||
|
||||
module.exports = function (array, stream, callback) {
|
||||
var arr = [].slice.call(array);
|
||||
|
||||
async.whilst(
|
||||
function () {
|
||||
return !ended(stream) && arr.length > 0;
|
||||
},
|
||||
|
||||
function (next) {
|
||||
stream.push(arr.shift());
|
||||
setImmediate(next);
|
||||
},
|
||||
|
||||
function () {
|
||||
callback(ended(stream));
|
||||
});
|
||||
};
|
20
express-server/node_modules/split-array-stream/license
generated
vendored
Normal file
20
express-server/node_modules/split-array-stream/license
generated
vendored
Normal file
@ -0,0 +1,20 @@
|
||||
The MIT License (MIT)
|
||||
|
||||
Copyright (c) 2015 Stephen Sawchuk
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy of
|
||||
this software and associated documentation files (the "Software"), to deal in
|
||||
the Software without restriction, including without limitation the rights to
|
||||
use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
|
||||
the Software, and to permit persons to whom the Software is furnished to do so,
|
||||
subject to the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be included in all
|
||||
copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
|
||||
FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
|
||||
COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
|
||||
IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
|
||||
CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
61
express-server/node_modules/split-array-stream/package.json
generated
vendored
Normal file
61
express-server/node_modules/split-array-stream/package.json
generated
vendored
Normal file
@ -0,0 +1,61 @@
|
||||
{
|
||||
"_from": "split-array-stream@^1.0.0",
|
||||
"_id": "split-array-stream@1.0.3",
|
||||
"_inBundle": false,
|
||||
"_integrity": "sha1-0rdajl4Ngk1S/eyLgiWDncLjXfo=",
|
||||
"_location": "/split-array-stream",
|
||||
"_phantomChildren": {},
|
||||
"_requested": {
|
||||
"type": "range",
|
||||
"registry": true,
|
||||
"raw": "split-array-stream@^1.0.0",
|
||||
"name": "split-array-stream",
|
||||
"escapedName": "split-array-stream",
|
||||
"rawSpec": "^1.0.0",
|
||||
"saveSpec": null,
|
||||
"fetchSpec": "^1.0.0"
|
||||
},
|
||||
"_requiredBy": [
|
||||
"/@google-cloud/common"
|
||||
],
|
||||
"_resolved": "https://registry.npmjs.org/split-array-stream/-/split-array-stream-1.0.3.tgz",
|
||||
"_shasum": "d2b75a8e5e0d824d52fdec8b8225839dc2e35dfa",
|
||||
"_spec": "split-array-stream@^1.0.0",
|
||||
"_where": "D:\\Desktop\\Git\\Firebase\\SmartShopperFirebase\\node_modules\\@google-cloud\\common",
|
||||
"author": {
|
||||
"name": "Stephen Sawchuk",
|
||||
"email": "sawchuk@gmail.com"
|
||||
},
|
||||
"bugs": {
|
||||
"url": "https://github.com/stephenplusplus/split-array-stream/issues"
|
||||
},
|
||||
"bundleDependencies": false,
|
||||
"dependencies": {
|
||||
"async": "^2.4.0",
|
||||
"is-stream-ended": "^0.1.0"
|
||||
},
|
||||
"deprecated": false,
|
||||
"description": "Safely push each item of an array to a stream",
|
||||
"devDependencies": {
|
||||
"mocha": "^3.3.0",
|
||||
"through2": "^2.0.0"
|
||||
},
|
||||
"homepage": "https://github.com/stephenplusplus/split-array-stream#readme",
|
||||
"keywords": [
|
||||
"array",
|
||||
"stream",
|
||||
"split",
|
||||
"push"
|
||||
],
|
||||
"license": "MIT",
|
||||
"main": "index.js",
|
||||
"name": "split-array-stream",
|
||||
"repository": {
|
||||
"type": "git",
|
||||
"url": "git+https://github.com/stephenplusplus/split-array-stream.git"
|
||||
},
|
||||
"scripts": {
|
||||
"test": "mocha"
|
||||
},
|
||||
"version": "1.0.3"
|
||||
}
|
107
express-server/node_modules/split-array-stream/readme.md
generated
vendored
Normal file
107
express-server/node_modules/split-array-stream/readme.md
generated
vendored
Normal file
@ -0,0 +1,107 @@
|
||||
# split-array-stream
|
||||
> Safely push each item of an array to a stream.
|
||||
|
||||
```sh
|
||||
$ npm install --save split-array-stream
|
||||
```
|
||||
```js
|
||||
var split = require('split-array-stream');
|
||||
var through = require('through2');
|
||||
|
||||
var array = [
|
||||
{ id: 1, user: 'Dave' },
|
||||
{ id: 2, user: 'Stephen' }
|
||||
];
|
||||
|
||||
var stream = through.obj();
|
||||
|
||||
stream.on('data', function (item) {
|
||||
// { id: 1, user: 'Dave' }
|
||||
// ...later...
|
||||
// { id: 2, user: 'Stephen' }
|
||||
});
|
||||
|
||||
split(array, stream, function (streamEnded) {
|
||||
if (!streamEnded) {
|
||||
stream.push(null);
|
||||
stream.end();
|
||||
}
|
||||
});
|
||||
```
|
||||
|
||||
Before pushing an item to the stream, `split-array-stream` checks that the stream hasn't been ended. This avoids those "push() after EOF" errors.
|
||||
|
||||
### Use case
|
||||
|
||||
Say you're getting many items from an upstream API. Multiple requests might be required to page through all of the results. You want to push the results to the stream as they come in, and only get more results if the user hasn't ended the stream.
|
||||
|
||||
```js
|
||||
function getAllUsers() {
|
||||
var stream = through.obj();
|
||||
|
||||
var requestOptions = {
|
||||
method: 'get',
|
||||
url: 'http://api/users',
|
||||
};
|
||||
|
||||
request(requestOptions, onResponse);
|
||||
|
||||
function onResponse(err, response) {
|
||||
split(response.users, stream, function (streamEnded) {
|
||||
if (streamEnded) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (response.nextPageToken) {
|
||||
requestOptions.pageToken = response.nextPageToken;
|
||||
request(requestOptions, onResponse);
|
||||
return;
|
||||
}
|
||||
|
||||
stream.push(null);
|
||||
stream.end();
|
||||
});
|
||||
|
||||
});
|
||||
|
||||
return stream;
|
||||
}
|
||||
|
||||
getAllUsers()
|
||||
.on('data', function (user) {
|
||||
// An item from the `response.users` API response
|
||||
})
|
||||
.on('end', function () {
|
||||
// All users received
|
||||
});
|
||||
```
|
||||
|
||||
|
||||
### split(array, stream, callback)
|
||||
|
||||
#### array
|
||||
|
||||
- Type: `Array`
|
||||
- Required
|
||||
|
||||
The source array. Each item will be pushed to the provided stream.
|
||||
|
||||
#### stream
|
||||
|
||||
- Type: `Stream`
|
||||
- Required
|
||||
|
||||
The destination stream to receive the items of the array.
|
||||
|
||||
#### callback(streamEnded)
|
||||
|
||||
- Type: `Function`
|
||||
- Required
|
||||
|
||||
Callback function executed after all items of the array have been iterated.
|
||||
|
||||
##### callback.streamEnded
|
||||
|
||||
- Type: `Boolean`
|
||||
|
||||
Lets you know if the stream has been ended while items were being pushed.
|
65
express-server/node_modules/split-array-stream/test.js
generated
vendored
Normal file
65
express-server/node_modules/split-array-stream/test.js
generated
vendored
Normal file
@ -0,0 +1,65 @@
|
||||
'use strict';
|
||||
|
||||
var assert = require('assert');
|
||||
var through = require('through2');
|
||||
|
||||
var split = require('./index.js');
|
||||
|
||||
describe('split-array-stream', function () {
|
||||
var array = [
|
||||
{ id: 1, user: 'Dave' },
|
||||
{ id: 2, user: 'Dave' },
|
||||
{ id: 3, user: 'Dave' },
|
||||
{ id: 4, user: 'Stephen' }
|
||||
];
|
||||
|
||||
it('should work', function (done) {
|
||||
var numDataEvents = 0;
|
||||
|
||||
var stream = through.obj();
|
||||
|
||||
stream.on('data', function () { numDataEvents++; });
|
||||
|
||||
split(array, stream, function (streamEnded) {
|
||||
assert.strictEqual(streamEnded, false);
|
||||
assert.strictEqual(numDataEvents, array.length);
|
||||
|
||||
done();
|
||||
});
|
||||
});
|
||||
|
||||
it('should not push more results after end', function (done) {
|
||||
var stream = through.obj();
|
||||
|
||||
var numDataEvents = 0;
|
||||
var expectedNumDataEvents = 2;
|
||||
|
||||
stream.on('data', function () {
|
||||
numDataEvents++;
|
||||
|
||||
if (numDataEvents === expectedNumDataEvents) {
|
||||
this.end();
|
||||
}
|
||||
|
||||
if (numDataEvents > expectedNumDataEvents) {
|
||||
throw new Error('Should not have received this event.');
|
||||
}
|
||||
});
|
||||
|
||||
split(array, stream, function (streamEnded) {
|
||||
assert.strictEqual(streamEnded, true);
|
||||
assert.strictEqual(numDataEvents, expectedNumDataEvents);
|
||||
|
||||
done();
|
||||
});
|
||||
});
|
||||
|
||||
it('should not modify original array', function (done) {
|
||||
var expectedArray = [].slice.call(array);
|
||||
|
||||
split(array, through.obj(), function () {
|
||||
assert.deepEqual(array, expectedArray);
|
||||
done();
|
||||
});
|
||||
});
|
||||
});
|
Reference in New Issue
Block a user