14 |
15 |
16 |
17 |
18 |
19 |
20 |
--------------------------------------------------------------------------------
/src/prod/node_modules/double-ended-queue/.npmignore:
--------------------------------------------------------------------------------
1 | node_modules/*
2 | todo.txt
3 | npm-debug.log
4 | test/*
5 | benchmark/*
6 | browser/*
7 | src/*
8 | async
9 | sync
10 | mixed
11 | bench.json
12 | js/browser
13 | js/browser/*
14 | js/debug
15 | js/debug/*
16 | reader.js
17 | read.txt
18 | bench
19 | .editorconfig
20 | .jshintrc
21 | ast_passes.js
22 | mocharun.js
23 | throwaway.js
24 | throwaway.html
25 | deque.sublime-workspace
26 | deque.sublime-project
27 | changelog.js
28 | .travis.yml
29 | sauce_connect.log
30 | nodex64.exe
31 | bump.js
32 |
--------------------------------------------------------------------------------
/src/prod/node_modules/double-ended-queue/LICENSE:
--------------------------------------------------------------------------------
1 | Copyright (c) 2013 Petka Antonov
2 |
3 | Permission is hereby granted, free of charge, to any person obtaining a copy
4 | of this software and associated documentation files (the "Software"), to deal
5 | in the Software without restriction, including without limitation the rights
6 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
7 | copies of the Software, and to permit persons to whom the Software is
8 | furnished to do so, subject to the following conditions:
9 |
10 | The above copyright notice and this permission notice shall be included in
11 | all copies or substantial portions of the Software.
12 |
13 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
14 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
15 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
16 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
17 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
18 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
19 | THE SOFTWARE.
--------------------------------------------------------------------------------
/src/prod/node_modules/options/.npmignore:
--------------------------------------------------------------------------------
1 | npm-debug.log
2 | node_modules
3 | .*.swp
4 | .lock-*
5 | build/
6 |
7 | test
8 |
--------------------------------------------------------------------------------
/src/prod/node_modules/options/Makefile:
--------------------------------------------------------------------------------
1 | ALL_TESTS = $(shell find test/ -name '*.test.js')
2 |
3 | run-tests:
4 | @./node_modules/.bin/mocha \
5 | -t 2000 \
6 | $(TESTFLAGS) \
7 | $(TESTS)
8 |
9 | test:
10 | @$(MAKE) NODE_PATH=lib TESTS="$(ALL_TESTS)" run-tests
11 |
12 | .PHONY: test
13 |
--------------------------------------------------------------------------------
/src/prod/node_modules/options/README.md:
--------------------------------------------------------------------------------
1 | # options.js #
2 |
3 | A very light-weight in-code option parsers for node.js.
4 |
5 | ## Usage ##
6 |
7 | ``` js
8 | var Options = require("options");
9 |
10 | // Create an Options object
11 | function foo(options) {
12 | var default_options = {
13 | foo : "bar"
14 | };
15 |
16 | // Create an option object with default value
17 | var opts = new Options(default_options);
18 |
19 | // Merge options
20 | opts = opts.merge(options);
21 |
22 | // Reset to default value
23 | opts.reset();
24 |
25 | // Copy selected attributes out
26 | var seled_att = opts.copy("foo");
27 |
28 | // Read json options from a file.
29 | opts.read("options.file"); // Sync
30 | opts.read("options.file", function(err){ // Async
31 | if(err){ // If error occurs
32 | console.log("File error.");
33 | }else{
34 | // No error
35 | }
36 | });
37 |
38 | // Attributes defined or not
39 | opts.isDefinedAndNonNull("foobar");
40 | opts.isDefined("foobar");
41 | }
42 |
43 | ```
44 |
45 |
46 | ## License ##
47 |
48 | (The MIT License)
49 |
50 | Copyright (c) 2012 Einar Otto Stangvik <einaros@gmail.com>
51 |
52 | Permission is hereby granted, free of charge, to any person obtaining
53 | a copy of this software and associated documentation files (the
54 | 'Software'), to deal in the Software without restriction, including
55 | without limitation the rights to use, copy, modify, merge, publish,
56 | distribute, sublicense, and/or sell copies of the Software, and to
57 | permit persons to whom the Software is furnished to do so, subject to
58 | the following conditions:
59 |
60 | The above copyright notice and this permission notice shall be
61 | included in all copies or substantial portions of the Software.
62 |
63 | THE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND,
64 | EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
65 | MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
66 | IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
67 | CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
68 | TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
69 | SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
70 |
--------------------------------------------------------------------------------
/src/prod/node_modules/redis-commands/.npmignore:
--------------------------------------------------------------------------------
1 | # Logs
2 | logs
3 | *.log
4 |
5 | # Runtime data
6 | pids
7 | *.pid
8 | *.seed
9 | *.rdb
10 |
11 | # Directory for instrumented libs generated by jscoverage/JSCover
12 | lib-cov
13 |
14 | # Coverage directory used by tools like istanbul
15 | coverage
16 |
17 | # Grunt intermediate storage (http://gruntjs.com/creating-plugins#storing-task-files)
18 | .grunt
19 |
20 | # Compiled binary addons (http://nodejs.org/api/addons.html)
21 | build/Release
22 |
23 | # Dependency directory
24 | # Commenting this out is preferred by some people, see
25 | # https://www.npmjs.org/doc/misc/npm-faq.html#should-i-check-my-node_modules-folder-into-git-
26 | node_modules
27 |
28 | # Users Environment Variables
29 | .lock-wscript
30 |
--------------------------------------------------------------------------------
/src/prod/node_modules/redis-commands/.travis.yml:
--------------------------------------------------------------------------------
1 | language: node_js
2 | sudo: false
3 | node_js:
4 | - "0.10"
5 | - "0.12"
6 | - "4"
7 | - "5"
8 | after_success:
9 | - CODECLIMATE_REPO_TOKEN=b57723fafcf0516f275d6b380cd506fd082ea88d86507eb82c8abd489b9b9a09 node ./node_modules/.bin/codeclimate-test-reporter < coverage/lcov.info
10 |
--------------------------------------------------------------------------------
/src/prod/node_modules/redis-commands/LICENSE:
--------------------------------------------------------------------------------
1 | The MIT License (MIT)
2 |
3 | Copyright (c) 2015 NodeRedis
4 |
5 | Permission is hereby granted, free of charge, to any person obtaining a copy
6 | of this software and associated documentation files (the "Software"), to deal
7 | in the Software without restriction, including without limitation the rights
8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9 | copies of the Software, and to permit persons to whom the Software is
10 | furnished to do so, subject to the following conditions:
11 |
12 | The above copyright notice and this permission notice shall be included in all
13 | copies or substantial portions of the Software.
14 |
15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21 | SOFTWARE.
22 |
23 |
--------------------------------------------------------------------------------
/src/prod/node_modules/redis-commands/README.md:
--------------------------------------------------------------------------------
1 | # Redis Commands
2 |
3 | [](https://travis-ci.org/NodeRedis/redis-commands)
4 | [](https://codeclimate.com/github/NodeRedis/redis-commands)
5 | [](https://codeclimate.com/github/NodeRedis/redis-commands/coverage)
6 |
7 | This module exports all the commands that Redis supports.
8 |
9 | ## Install
10 |
11 | ```shell
12 | $ npm install redis-commands
13 | ```
14 |
15 | ## Usage
16 |
17 | ```javascript
18 | var commands = require('redis-commands');
19 | ```
20 |
21 | `.list` is an array contains all the lowercased commands:
22 |
23 | ```javascript
24 | commands.list.forEach(function (command) {
25 | console.log(command);
26 | });
27 | ```
28 |
29 | `.exists()` is used to check if the command exists:
30 |
31 | ```javascript
32 | commands.exists('set') // true
33 | commands.exists('other-command') // false
34 | ```
35 |
36 | `.hasFlag()` is used to check if the command has the flag:
37 |
38 | ```javascript
39 | commands.hasFlag('set', 'readonly') // false
40 | ```
41 |
42 | `.getKeyIndexes()` is used to get the indexes of keys in the command arguments:
43 |
44 | ```javascript
45 | commands.getKeyIndexes('set', ['key', 'value']) // [0]
46 | commands.getKeyIndexes('mget', ['key1', 'key2']) // [0, 1]
47 | ```
48 |
49 | ## Acknowledgment
50 |
51 | Thank [@Yuan Chuan](https://github.com/yuanchuan) for the package name. The original redis-commands is renamed to [@yuanchuan/redis-commands](https://www.npmjs.com/package/@yuanchuan/redis-commands).
52 |
--------------------------------------------------------------------------------
/src/prod/node_modules/redis-commands/changelog.md:
--------------------------------------------------------------------------------
1 | ## v.1.2.0 - 21 Apr, 2016
2 |
3 | Features
4 |
5 | - Added support for `MIGRATE [...] KEYS key1, key2` (Redis >= v.3.0.6)
6 | - Added build sanity check for unhandled commands with moveable keys
7 | - Rebuild the commands with the newest unstable release
8 | - Improved performance of .getKeyIndexes()
9 |
10 | Bugfix
11 |
12 | - Fixed command command returning the wrong arity due to a Redis bug
13 | - Fixed brpop command returning the wrong keystop due to a Redis bug
14 |
15 | ## v.1.1.0 - 09 Feb, 2016
16 |
17 | Features
18 |
19 | - Added .exists() to check for command existence
20 | - Improved performance of .hasFlag()
21 |
--------------------------------------------------------------------------------
/src/prod/node_modules/redis-commands/tools/build.js:
--------------------------------------------------------------------------------
1 | var fs = require('fs');
2 | var path = require('path');
3 | var stringify = require('json-stable-stringify');
4 | var commandPath = path.join(__dirname, '..', 'commands.json');
5 | var redisCommands = require('../');
6 |
7 | var Redis = require('ioredis');
8 | var redis = new Redis(process.env.REDIS_URI);
9 |
10 | redis.command().then(function (res) {
11 | redis.disconnect();
12 |
13 | // Find all special handled cases
14 | var movableKeys = String(redisCommands.getKeyIndexes).match(/case '[a-z-]+':/g).map(function (entry) {
15 | return entry.replace(/^case \'|\':$/g, '');
16 | });
17 |
18 | var commands = res.reduce(function (prev, current) {
19 | var currentCommandPos = movableKeys.indexOf(current[0]);
20 | if (currentCommandPos !== -1 && current[2].indexOf('movablekeys') !== -1) {
21 | movableKeys.splice(currentCommandPos, 1);
22 | }
23 | // https://github.com/antirez/redis/issues/2598
24 | if (current[0] === 'brpop' && current[4] === 1) {
25 | current[4] = -2;
26 | }
27 | prev[current[0]] = {
28 | arity: current[1] || 1, // https://github.com/antirez/redis/pull/2986
29 | flags: current[2],
30 | keyStart: current[3],
31 | keyStop: current[4],
32 | step: current[5]
33 | };
34 | return prev;
35 | }, {});
36 |
37 | // Future proof. Redis might implement this at some point
38 | // https://github.com/antirez/redis/pull/2982
39 | if (!commands.quit) {
40 | commands.quit = {
41 | arity: 1,
42 | flags: [
43 | 'loading',
44 | 'stale',
45 | 'readonly'
46 | ],
47 | keyStart: 0,
48 | keyStop: 0,
49 | step: 0
50 | }
51 | }
52 |
53 | if (movableKeys.length !== 0) {
54 | throw new Error('Not all commands (\'' + movableKeys.join('\', \'') + '\') with the "movablekeys" flag are handled in the code');
55 | }
56 |
57 | // Use json-stable-stringify instead fo JSON.stringify
58 | // for easier diffing
59 | var content = stringify(commands, { space: ' ' });
60 |
61 | fs.writeFile(commandPath, content);
62 | });
63 |
--------------------------------------------------------------------------------
/src/prod/node_modules/redis-parser/.codeclimate.yml:
--------------------------------------------------------------------------------
1 | languages:
2 | JavaScript: true
3 | exclude_paths:
4 | - "benchmark/index.js"
5 | - "benchmark/old/javascript.js"
6 | - "test/parsers.spec.js"
7 |
--------------------------------------------------------------------------------
/src/prod/node_modules/redis-parser/.npmignore:
--------------------------------------------------------------------------------
1 | # IntelliJ project files
2 | .idea
3 | *.iml
4 | out
5 | gen
6 |
7 | # Unrelevant files and folders
8 | benchmark
9 | coverage
10 | test
11 | .travis.yml
12 | .gitignore
13 |
--------------------------------------------------------------------------------
/src/prod/node_modules/redis-parser/LICENSE:
--------------------------------------------------------------------------------
1 | The MIT License (MIT)
2 |
3 | Copyright (c) 2015 NodeRedis
4 |
5 | Permission is hereby granted, free of charge, to any person obtaining a copy
6 | of this software and associated documentation files (the "Software"), to deal
7 | in the Software without restriction, including without limitation the rights
8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9 | copies of the Software, and to permit persons to whom the Software is
10 | furnished to do so, subject to the following conditions:
11 |
12 | The above copyright notice and this permission notice shall be included in all
13 | copies or substantial portions of the Software.
14 |
15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21 | SOFTWARE.
22 |
23 |
--------------------------------------------------------------------------------
/src/prod/node_modules/redis-parser/changelog.md:
--------------------------------------------------------------------------------
1 | ## v.2.0.4 - 21 Jul, 2016
2 |
3 | Bugfixes
4 |
5 | - Fixed multi byte characters getting corrupted
6 |
7 | ## v.2.0.3 - 17 Jun, 2016
8 |
9 | Bugfixes
10 |
11 | - Fixed parser not working with huge buffers (e.g. 300 MB)
12 |
13 | ## v.2.0.2 - 08 Jun, 2016
14 |
15 | Bugfixes
16 |
17 | - Fixed parser with returnBuffers option returning corrupted data
18 |
19 | ## v.2.0.1 - 04 Jun, 2016
20 |
21 | Bugfixes
22 |
23 | - Fixed multiple parsers working concurrently resulting in faulty data in some cases
24 |
25 | ## v.2.0.0 - 29 May, 2016
26 |
27 | The javascript parser got completly rewritten by [Michael Diarmid](https://github.com/Salakar) and [Ruben Bridgewater](https://github.com/BridgeAR) and is now a lot faster than the hiredis parser.
28 | Therefore the hiredis parser was deprecated and should only be used for testing purposes and benchmarking comparison.
29 |
30 | All Errors returned by the parser are from now on of class ReplyError
31 |
32 | Features
33 |
34 | - Improved performance by up to 15x as fast as before
35 | - Improved options validation
36 | - Added ReplyError Class
37 | - Added parser benchmark
38 | - Switched default parser from hiredis to JS, no matter if hiredis is installed or not
39 |
40 | Removed
41 |
42 | - Deprecated hiredis support
43 |
44 | ## v.1.3.0 - 27 Mar, 2016
45 |
46 | Features
47 |
48 | - Added `auto` as parser name option to check what parser is available
49 | - Non existing requested parsers falls back into auto mode instead of always choosing the JS parser
50 |
51 | ## v.1.2.0 - 27 Mar, 2016
52 |
53 | Features
54 |
55 | - Added `stringNumbers` option to make sure all numbers are returned as string instead of a js number for precision
56 | - The parser is from now on going to print warnings if a parser is explicitly requested that does not exist and gracefully chooses the JS parser
57 |
58 | ## v.1.1.0 - 26 Jan, 2016
59 |
60 | Features
61 |
62 | - The parser is from now on going to reset itself on protocol errors
63 |
--------------------------------------------------------------------------------
/src/prod/node_modules/redis-parser/index.js:
--------------------------------------------------------------------------------
1 | 'use strict'
2 |
3 | module.exports = require('./lib/parser')
4 | module.exports.ReplyError = require('./lib/replyError')
5 |
--------------------------------------------------------------------------------
/src/prod/node_modules/redis-parser/lib/hiredis.js:
--------------------------------------------------------------------------------
1 | 'use strict'
2 |
3 | var hiredis = require('hiredis')
4 | var ReplyError = require('../lib/replyError')
5 |
6 | /**
7 | * Parse data
8 | * @param parser
9 | * @returns {*}
10 | */
11 | function parseData (parser) {
12 | try {
13 | return parser.reader.get()
14 | } catch (err) {
15 | // Protocol errors land here
16 | // Reset the parser. Otherwise new commands can't be processed properly
17 | parser.reader = new hiredis.Reader(parser.options)
18 | parser.returnFatalError(new ReplyError(err.message))
19 | }
20 | }
21 |
22 | /**
23 | * Hiredis Parser
24 | * @param options
25 | * @constructor
26 | */
27 | function HiredisReplyParser (options) {
28 | this.returnError = options.returnError
29 | this.returnFatalError = options.returnFatalError || options.returnError
30 | this.returnReply = options.returnReply
31 | this.name = 'hiredis'
32 | this.options = {
33 | return_buffers: !!options.returnBuffers
34 | }
35 | this.reader = new hiredis.Reader(this.options)
36 | }
37 |
38 | HiredisReplyParser.prototype.execute = function (data) {
39 | this.reader.feed(data)
40 | var reply = parseData(this)
41 |
42 | while (reply !== undefined) {
43 | if (reply && reply.name === 'Error') {
44 | this.returnError(new ReplyError(reply.message))
45 | } else {
46 | this.returnReply(reply)
47 | }
48 | reply = parseData(this)
49 | }
50 | }
51 |
52 | module.exports = HiredisReplyParser
53 |
--------------------------------------------------------------------------------
/src/prod/node_modules/redis-parser/lib/replyError.js:
--------------------------------------------------------------------------------
1 | 'use strict'
2 |
3 | var util = require('util')
4 |
5 | function ReplyError (message) {
6 | var limit = Error.stackTraceLimit
7 | Error.stackTraceLimit = 2
8 | Error.captureStackTrace(this, this.constructor)
9 | Error.stackTraceLimit = limit
10 | Object.defineProperty(this, 'message', {
11 | value: message || '',
12 | writable: true
13 | })
14 | }
15 |
16 | util.inherits(ReplyError, Error)
17 |
18 | Object.defineProperty(ReplyError.prototype, 'name', {
19 | value: 'ReplyError',
20 | writable: true
21 | })
22 |
23 | module.exports = ReplyError
24 |
--------------------------------------------------------------------------------
/src/prod/node_modules/redis/.eslintignore:
--------------------------------------------------------------------------------
1 | node_modules/**
2 | coverage/**
3 | **.md
4 | **.log
5 |
--------------------------------------------------------------------------------
/src/prod/node_modules/redis/.github/ISSUE_TEMPLATE.md:
--------------------------------------------------------------------------------
1 | _Thanks for wanting to report an issue you've found in node_redis. Please delete
2 | this text and fill in the template below. Please note that the issue tracker is only
3 | for bug reports or feature requests. If you have a question, please ask that on [gitter].
4 | If unsure about something, just do as best as you're able._
5 |
6 | _Note that it will be much easier to fix the issue if a test case that reproduces
7 | the problem is provided. It is of course not always possible to reduce your code
8 | to a small test case, but it's highly appreciated to have as much data as possible.
9 | Thank you!_
10 |
11 | * **Version**: What node_redis and what redis version is the issue happening on?
12 | * **Platform**: What platform / version? (For example Node.js 0.10 or Node.js 5.7.0 on Windows 7 / Ubuntu 15.10 / Azure)
13 | * **Description**: Description of your issue, stack traces from errors and code that reproduces the issue
14 |
15 | [gitter]: https://gitter.im/NodeRedis/node_redis?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge
--------------------------------------------------------------------------------
/src/prod/node_modules/redis/.github/PULL_REQUEST_TEMPLATE.md:
--------------------------------------------------------------------------------
1 | ### Pull Request check-list
2 |
3 | _Please make sure to review and check all of these items:_
4 |
5 | - [ ] Does `npm test` pass with this change (including linting)?
6 | - [ ] Is the new or changed code fully tested?
7 | - [ ] Is a documentation update included (if this change modifies existing APIs, or introduces new ones)?
8 |
9 | _NOTE: these things are not required to open a PR and can be done
10 | afterwards / while the PR is open._
11 |
12 | ### Description of change
13 |
14 | _Please provide a description of the change here._
--------------------------------------------------------------------------------
/src/prod/node_modules/redis/.npmignore:
--------------------------------------------------------------------------------
1 | examples/
2 | benchmarks/
3 | test/
4 | .nyc_output/
5 | coverage/
6 | .tern-port
7 | *.log
8 | *.rdb
9 | *.out
10 | *.yml
11 |
--------------------------------------------------------------------------------
/src/prod/node_modules/redis/LICENSE:
--------------------------------------------------------------------------------
1 | LICENSE - "MIT License"
2 |
3 | Copyright (c) 2016 by NodeRedis
4 |
5 | Permission is hereby granted, free of charge, to any person
6 | obtaining a copy of this software and associated documentation
7 | files (the "Software"), to deal in the Software without
8 | restriction, including without limitation the rights to use,
9 | copy, modify, merge, publish, distribute, sublicense, and/or sell
10 | copies of the Software, and to permit persons to whom the
11 | Software is furnished to do so, subject to the following
12 | conditions:
13 |
14 | The above copyright notice and this permission notice shall be
15 | included in all copies or substantial portions of the Software.
16 |
17 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
18 | EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
19 | OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
20 | NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
21 | HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
22 | WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
23 | FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
24 | OTHER DEALINGS IN THE SOFTWARE.
--------------------------------------------------------------------------------
/src/prod/node_modules/redis/lib/command.js:
--------------------------------------------------------------------------------
1 | 'use strict';
2 |
3 | var betterStackTraces = /development/i.test(process.env.NODE_ENV) || /\bredis\b/i.test(process.env.NODE_DEBUG);
4 |
5 | function Command (command, args, callback, call_on_write) {
6 | this.command = command;
7 | this.args = args;
8 | this.buffer_args = false;
9 | this.callback = callback;
10 | this.call_on_write = call_on_write;
11 | if (betterStackTraces) {
12 | this.error = new Error();
13 | }
14 | }
15 |
16 | module.exports = Command;
17 |
--------------------------------------------------------------------------------
/src/prod/node_modules/redis/lib/customErrors.js:
--------------------------------------------------------------------------------
1 | 'use strict';
2 |
3 | var util = require('util');
4 |
5 | function AbortError (obj) {
6 | Error.captureStackTrace(this, this.constructor);
7 | Object.defineProperty(this, 'message', {
8 | value: obj.message || '',
9 | configurable: true,
10 | writable: true
11 | });
12 | for (var keys = Object.keys(obj), key = keys.pop(); key; key = keys.pop()) {
13 | this[key] = obj[key];
14 | }
15 | }
16 |
17 | function AggregateError (obj) {
18 | Error.captureStackTrace(this, this.constructor);
19 | Object.defineProperty(this, 'message', {
20 | value: obj.message || '',
21 | configurable: true,
22 | writable: true
23 | });
24 | for (var keys = Object.keys(obj), key = keys.pop(); key; key = keys.pop()) {
25 | this[key] = obj[key];
26 | }
27 | }
28 |
29 | util.inherits(AbortError, Error);
30 | util.inherits(AggregateError, AbortError);
31 |
32 | Object.defineProperty(AbortError.prototype, 'name', {
33 | value: 'AbortError',
34 | // configurable: true,
35 | writable: true
36 | });
37 | Object.defineProperty(AggregateError.prototype, 'name', {
38 | value: 'AggregateError',
39 | // configurable: true,
40 | writable: true
41 | });
42 |
43 | module.exports = {
44 | AbortError: AbortError,
45 | AggregateError: AggregateError
46 | };
47 |
--------------------------------------------------------------------------------
/src/prod/node_modules/redis/lib/debug.js:
--------------------------------------------------------------------------------
1 | 'use strict';
2 |
3 | var index = require('../');
4 |
5 | function debug () {
6 | if (index.debug_mode) {
7 | console.error.apply(null, arguments);
8 | }
9 | }
10 |
11 | module.exports = debug;
12 |
--------------------------------------------------------------------------------
/src/prod/node_modules/submono/LICENSE:
--------------------------------------------------------------------------------
1 | The MIT License (MIT)
2 |
3 | Copyright (c) 2015 Benji Kay
4 |
5 | Permission is hereby granted, free of charge, to any person obtaining a copy
6 | of this software and associated documentation files (the "Software"), to deal
7 | in the Software without restriction, including without limitation the rights
8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9 | copies of the Software, and to permit persons to whom the Software is
10 | furnished to do so, subject to the following conditions:
11 |
12 | The above copyright notice and this permission notice shall be included in all
13 | copies or substantial portions of the Software.
14 |
15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21 | SOFTWARE.
22 |
--------------------------------------------------------------------------------
/src/prod/node_modules/submono/README.md:
--------------------------------------------------------------------------------
1 | # submono
2 | A Web Audio subtractive, monophonic synthesizer. Looking for polyphony? Check out [subpoly](https://github.com/okaybenji/subpoly)!
3 |
4 | ### Create a synth.
5 | ```
6 | var audioCtx = new AudioContext();
7 | var synth = new Monosynth(audioCtx);
8 | ```
9 |
10 | ### Play a note.
11 | `synth.start();`
12 |
13 | ### Stop playing.
14 | `synth.stop();`
15 |
16 | ### Use methods to access pitch and waveform...
17 | ```
18 | synth.pitch(440); // in hertz
19 | console.log(synth.waveform()); // 'sawtooth' (or sine, triangle, square)
20 | ```
21 |
22 | ### ...get or set any other properties directly.
23 | ```
24 | synth.maxGain = 0.5; // out of 1
25 | synth.attack = 1.0; // in seconds
26 | ```
27 |
28 | ### Configure any or all the properties on initialization.
29 | ```
30 | var config = {
31 | waveform: 'sawtooth', // or sine, triangle, square
32 | pitch: 440, // in hertz
33 | maxGain: 0.5, // out of 1
34 | attack: 0.1, // in seconds
35 | decay: 0.0, // in seconds
36 | sustain: 1.0, // out of 1
37 | release: 0.8, // in seconds
38 | cutoff: {
39 | maxFrequency: 7500, // in hertz
40 | attack: 0.1, // in seconds
41 | decay: 2.5, // in seconds
42 | sustain: 0.2 // 0-5; maxFrequency multiplied by this
43 | }
44 | };
45 |
46 | var synth = new Monosynth(audioCtx, config);
47 | ```
48 |
49 | ### Demo
50 | [Tiles: a musical, multiplayer web toy](http://okaybenji.github.io/tiles-client/)
51 |
--------------------------------------------------------------------------------
/src/prod/node_modules/ultron/.npmignore:
--------------------------------------------------------------------------------
1 | node_modules
2 | coverage
3 | .tern-port
4 |
--------------------------------------------------------------------------------
/src/prod/node_modules/ultron/.travis.yml:
--------------------------------------------------------------------------------
1 | sudo: false
2 | language: node_js
3 | node_js:
4 | - "0.12"
5 | - "0.10"
6 | - "0.8"
7 | - "iojs"
8 | before_install:
9 | - 'if [ "${TRAVIS_NODE_VERSION}" == "0.8" ]; then npm install -g npm@2.11.1; fi'
10 | script:
11 | - "npm run test-travis"
12 | after_script:
13 | - "npm install coveralls@2.11.x && cat coverage/lcov.info | coveralls"
14 | matrix:
15 | fast_finish: true
16 | notifications:
17 | irc:
18 | channels:
19 | - "irc.freenode.org#unshift"
20 | on_success: change
21 | on_failure: change
22 |
--------------------------------------------------------------------------------
/src/prod/node_modules/ultron/LICENSE:
--------------------------------------------------------------------------------
1 | The MIT License (MIT)
2 |
3 | Copyright (c) 2015 Unshift.io, Arnout Kazemier, the Contributors.
4 |
5 | Permission is hereby granted, free of charge, to any person obtaining a copy
6 | of this software and associated documentation files (the "Software"), to deal
7 | in the Software without restriction, including without limitation the rights
8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9 | copies of the Software, and to permit persons to whom the Software is
10 | furnished to do so, subject to the following conditions:
11 |
12 | The above copyright notice and this permission notice shall be included in all
13 | copies or substantial portions of the Software.
14 |
15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21 | SOFTWARE.
22 |
23 |
--------------------------------------------------------------------------------
/src/prod/node_modules/ws/.npmignore:
--------------------------------------------------------------------------------
1 | npm-debug.log
2 | node_modules
3 | .*.swp
4 | .lock-*
5 | build
6 |
7 | bench
8 | doc
9 | examples
10 | test
11 |
12 |
--------------------------------------------------------------------------------
/src/prod/node_modules/ws/.travis.yml:
--------------------------------------------------------------------------------
1 | language: node_js
2 | sudo: false
3 | node_js:
4 | - "5"
5 | - "4"
6 | - "0.12"
7 | addons:
8 | apt:
9 | sources:
10 | - ubuntu-toolchain-r-test
11 | packages:
12 | - gcc-4.9
13 | - g++-4.9
14 | before_install:
15 | - export CC="gcc-4.9" CXX="g++-4.9"
16 |
--------------------------------------------------------------------------------
/src/prod/node_modules/ws/Makefile:
--------------------------------------------------------------------------------
1 | ALL_TESTS = $(shell find test/ -name '*.test.js')
2 | ALL_INTEGRATION = $(shell find test/ -name '*.integration.js')
3 |
4 | run-tests:
5 | @./node_modules/.bin/mocha \
6 | -t 5000 \
7 | -s 2400 \
8 | $(TESTFLAGS) \
9 | $(TESTS)
10 |
11 | run-integrationtests:
12 | @./node_modules/.bin/mocha \
13 | -t 5000 \
14 | -s 6000 \
15 | $(TESTFLAGS) \
16 | $(TESTS)
17 |
18 | run-coverage:
19 | @./node_modules/.bin/istanbul cover --report html \
20 | ./node_modules/.bin/_mocha -- \
21 | -t 5000 \
22 | -s 6000 \
23 | $(TESTFLAGS) \
24 | $(TESTS)
25 |
26 | test:
27 | @$(MAKE) NODE_TLS_REJECT_UNAUTHORIZED=0 NODE_PATH=lib TESTS="$(ALL_TESTS)" run-tests
28 |
29 | integrationtest:
30 | @$(MAKE) NODE_TLS_REJECT_UNAUTHORIZED=0 NODE_PATH=lib TESTS="$(ALL_INTEGRATION)" run-integrationtests
31 |
32 | coverage:
33 | @$(MAKE) NODE_TLS_REJECT_UNAUTHORIZED=0 NODE_PATH=lib TESTS="$(ALL_TESTS)" run-coverage
34 |
35 | benchmark:
36 | @node bench/sender.benchmark.js
37 | @node bench/parser.benchmark.js
38 |
39 | autobahn:
40 | @NODE_PATH=lib node test/autobahn.js
41 |
42 | autobahn-server:
43 | @NODE_PATH=lib node test/autobahn-server.js
44 |
45 | .PHONY: test coverage
46 |
--------------------------------------------------------------------------------
/src/prod/node_modules/ws/SECURITY.md:
--------------------------------------------------------------------------------
1 | # Security Guidelines
2 |
3 | Please contact us directly at **security@3rd-Eden.com** for any bug that might
4 | impact the security of this project. Please prefix the subject of your email
5 | with `[security]` in lowercase and square brackets. Our email filters will
6 | automatically prevent these messages from being moved to our spam box.
7 |
8 | You will receive an acknowledgement of your report within **24 hours**.
9 |
10 | All emails that do not include security vulnerabilities will be removed and
11 | blocked instantly.
12 |
13 | ## Exceptions
14 |
15 | If you do not receive an acknowledgement within the said time frame please give
16 | us the benefit of the doubt as it's possible that we haven't seen it yet. In
17 | this case please send us a message **without details** using one of the
18 | following methods:
19 |
20 | - Contact the lead developers of this project on their personal e-mails. You
21 | can find the e-mails in the git logs, for example using the following command:
22 | `git --no-pager show -s --format='%an <%ae>' ` where `` is the
23 | SHA1 of their latest commit in the project.
24 | - Create a GitHub issue stating contact details and the severity of the issue.
25 |
26 | Once we have acknowledged receipt of your report and confirmed the bug
27 | ourselves we will work with you to fix the vulnerability and publicly acknowledge
28 | your responsible disclosure, if you wish. In addition to that we will report
29 | all vulnerabilities to the [Node Security Project](https://nodesecurity.io/).
30 |
31 | ## History
32 |
33 | 04 Jan 2016: [Buffer vulnerablity](https://github.com/websockets/ws/releases/tag/1.0.1)
34 |
--------------------------------------------------------------------------------
/src/prod/node_modules/ws/index.js:
--------------------------------------------------------------------------------
1 | 'use strict';
2 |
3 | /*!
4 | * ws: a node.js websocket client
5 | * Copyright(c) 2011 Einar Otto Stangvik
6 | * MIT Licensed
7 | */
8 |
9 | var WS = module.exports = require('./lib/WebSocket');
10 |
11 | WS.Server = require('./lib/WebSocketServer');
12 | WS.Sender = require('./lib/Sender');
13 | WS.Receiver = require('./lib/Receiver');
14 |
15 | /**
16 | * Create a new WebSocket server.
17 | *
18 | * @param {Object} options Server options
19 | * @param {Function} fn Optional connection listener.
20 | * @returns {WS.Server}
21 | * @api public
22 | */
23 | WS.createServer = function createServer(options, fn) {
24 | var server = new WS.Server(options);
25 |
26 | if (typeof fn === 'function') {
27 | server.on('connection', fn);
28 | }
29 |
30 | return server;
31 | };
32 |
33 | /**
34 | * Create a new WebSocket connection.
35 | *
36 | * @param {String} address The URL/address we need to connect to.
37 | * @param {Function} fn Open listener.
38 | * @returns {WS}
39 | * @api public
40 | */
41 | WS.connect = WS.createConnection = function connect(address, fn) {
42 | var client = new WS(address);
43 |
44 | if (typeof fn === 'function') {
45 | client.on('open', fn);
46 | }
47 |
48 | return client;
49 | };
50 |
--------------------------------------------------------------------------------
/src/prod/node_modules/ws/lib/BufferPool.js:
--------------------------------------------------------------------------------
1 | /*!
2 | * ws: a node.js websocket client
3 | * Copyright(c) 2011 Einar Otto Stangvik
4 | * MIT Licensed
5 | */
6 |
7 | var util = require('util');
8 |
9 | function BufferPool(initialSize, growStrategy, shrinkStrategy) {
10 | if (this instanceof BufferPool === false) {
11 | throw new TypeError("Classes can't be function-called");
12 | }
13 |
14 | if (typeof initialSize === 'function') {
15 | shrinkStrategy = growStrategy;
16 | growStrategy = initialSize;
17 | initialSize = 0;
18 | }
19 | else if (typeof initialSize === 'undefined') {
20 | initialSize = 0;
21 | }
22 | this._growStrategy = (growStrategy || function(db, size) {
23 | return db.used + size;
24 | }).bind(null, this);
25 | this._shrinkStrategy = (shrinkStrategy || function(db) {
26 | return initialSize;
27 | }).bind(null, this);
28 | this._buffer = initialSize ? new Buffer(initialSize) : null;
29 | this._offset = 0;
30 | this._used = 0;
31 | this._changeFactor = 0;
32 | this.__defineGetter__('size', function(){
33 | return this._buffer == null ? 0 : this._buffer.length;
34 | });
35 | this.__defineGetter__('used', function(){
36 | return this._used;
37 | });
38 | }
39 |
40 | BufferPool.prototype.get = function(length) {
41 | if (this._buffer == null || this._offset + length > this._buffer.length) {
42 | var newBuf = new Buffer(this._growStrategy(length));
43 | this._buffer = newBuf;
44 | this._offset = 0;
45 | }
46 | this._used += length;
47 | var buf = this._buffer.slice(this._offset, this._offset + length);
48 | this._offset += length;
49 | return buf;
50 | }
51 |
52 | BufferPool.prototype.reset = function(forceNewBuffer) {
53 | var len = this._shrinkStrategy();
54 | if (len < this.size) this._changeFactor -= 1;
55 | if (forceNewBuffer || this._changeFactor < -2) {
56 | this._changeFactor = 0;
57 | this._buffer = len ? new Buffer(len) : null;
58 | }
59 | this._offset = 0;
60 | this._used = 0;
61 | }
62 |
63 | module.exports = BufferPool;
64 |
--------------------------------------------------------------------------------
/src/prod/node_modules/ws/lib/BufferUtil.fallback.js:
--------------------------------------------------------------------------------
1 | /*!
2 | * ws: a node.js websocket client
3 | * Copyright(c) 2011 Einar Otto Stangvik
4 | * MIT Licensed
5 | */
6 |
7 | exports.BufferUtil = {
8 | merge: function(mergedBuffer, buffers) {
9 | var offset = 0;
10 | for (var i = 0, l = buffers.length; i < l; ++i) {
11 | var buf = buffers[i];
12 | buf.copy(mergedBuffer, offset);
13 | offset += buf.length;
14 | }
15 | },
16 | mask: function(source, mask, output, offset, length) {
17 | var maskNum = mask.readUInt32LE(0, true);
18 | var i = 0;
19 | for (; i < length - 3; i += 4) {
20 | var num = maskNum ^ source.readUInt32LE(i, true);
21 | if (num < 0) num = 4294967296 + num;
22 | output.writeUInt32LE(num, offset + i, true);
23 | }
24 | switch (length % 4) {
25 | case 3: output[offset + i + 2] = source[i + 2] ^ mask[2];
26 | case 2: output[offset + i + 1] = source[i + 1] ^ mask[1];
27 | case 1: output[offset + i] = source[i] ^ mask[0];
28 | case 0:;
29 | }
30 | },
31 | unmask: function(data, mask) {
32 | var maskNum = mask.readUInt32LE(0, true);
33 | var length = data.length;
34 | var i = 0;
35 | for (; i < length - 3; i += 4) {
36 | var num = maskNum ^ data.readUInt32LE(i, true);
37 | if (num < 0) num = 4294967296 + num;
38 | data.writeUInt32LE(num, i, true);
39 | }
40 | switch (length % 4) {
41 | case 3: data[i + 2] = data[i + 2] ^ mask[2];
42 | case 2: data[i + 1] = data[i + 1] ^ mask[1];
43 | case 1: data[i] = data[i] ^ mask[0];
44 | case 0:;
45 | }
46 | }
47 | }
48 |
--------------------------------------------------------------------------------
/src/prod/node_modules/ws/lib/BufferUtil.js:
--------------------------------------------------------------------------------
1 | 'use strict';
2 |
3 | /*!
4 | * ws: a node.js websocket client
5 | * Copyright(c) 2011 Einar Otto Stangvik
6 | * MIT Licensed
7 | */
8 |
9 | try {
10 | module.exports = require('bufferutil');
11 | } catch (e) {
12 | module.exports = require('./BufferUtil.fallback');
13 | }
14 |
--------------------------------------------------------------------------------
/src/prod/node_modules/ws/lib/ErrorCodes.js:
--------------------------------------------------------------------------------
1 | /*!
2 | * ws: a node.js websocket client
3 | * Copyright(c) 2011 Einar Otto Stangvik
4 | * MIT Licensed
5 | */
6 |
7 | module.exports = {
8 | isValidErrorCode: function(code) {
9 | return (code >= 1000 && code <= 1011 && code != 1004 && code != 1005 && code != 1006) ||
10 | (code >= 3000 && code <= 4999);
11 | },
12 | 1000: 'normal',
13 | 1001: 'going away',
14 | 1002: 'protocol error',
15 | 1003: 'unsupported data',
16 | 1004: 'reserved',
17 | 1005: 'reserved for extensions',
18 | 1006: 'reserved for extensions',
19 | 1007: 'inconsistent or invalid data',
20 | 1008: 'policy violation',
21 | 1009: 'message too big',
22 | 1010: 'extension handshake missing',
23 | 1011: 'an unexpected condition prevented the request from being fulfilled',
24 | };
--------------------------------------------------------------------------------
/src/prod/node_modules/ws/lib/Extensions.js:
--------------------------------------------------------------------------------
1 |
2 | var util = require('util');
3 |
4 | /**
5 | * Module exports.
6 | */
7 |
8 | exports.parse = parse;
9 | exports.format = format;
10 |
11 | /**
12 | * Parse extensions header value
13 | */
14 |
15 | function parse(value) {
16 | value = value || '';
17 |
18 | var extensions = {};
19 |
20 | value.split(',').forEach(function(v) {
21 | var params = v.split(';');
22 | var token = params.shift().trim();
23 | var paramsList = extensions[token] = extensions[token] || [];
24 | var parsedParams = {};
25 |
26 | params.forEach(function(param) {
27 | var parts = param.trim().split('=');
28 | var key = parts[0];
29 | var value = parts[1];
30 | if (typeof value === 'undefined') {
31 | value = true;
32 | } else {
33 | // unquote value
34 | if (value[0] === '"') {
35 | value = value.slice(1);
36 | }
37 | if (value[value.length - 1] === '"') {
38 | value = value.slice(0, value.length - 1);
39 | }
40 | }
41 | (parsedParams[key] = parsedParams[key] || []).push(value);
42 | });
43 |
44 | paramsList.push(parsedParams);
45 | });
46 |
47 | return extensions;
48 | }
49 |
50 | /**
51 | * Format extensions header value
52 | */
53 |
54 | function format(value) {
55 | return Object.keys(value).map(function(token) {
56 | var paramsList = value[token];
57 | if (!util.isArray(paramsList)) {
58 | paramsList = [paramsList];
59 | }
60 | return paramsList.map(function(params) {
61 | return [token].concat(Object.keys(params).map(function(k) {
62 | var p = params[k];
63 | if (!util.isArray(p)) p = [p];
64 | return p.map(function(v) {
65 | return v === true ? k : k + '=' + v;
66 | }).join('; ');
67 | })).join('; ');
68 | }).join(', ');
69 | }).join(', ');
70 | }
71 |
--------------------------------------------------------------------------------
/src/prod/node_modules/ws/lib/Validation.fallback.js:
--------------------------------------------------------------------------------
1 | /*!
2 | * ws: a node.js websocket client
3 | * Copyright(c) 2011 Einar Otto Stangvik
4 | * MIT Licensed
5 | */
6 |
7 | exports.Validation = {
8 | isValidUTF8: function(buffer) {
9 | return true;
10 | }
11 | };
12 |
--------------------------------------------------------------------------------
/src/prod/node_modules/ws/lib/Validation.js:
--------------------------------------------------------------------------------
1 | 'use strict';
2 |
3 | /*!
4 | * ws: a node.js websocket client
5 | * Copyright(c) 2011 Einar Otto Stangvik
6 | * MIT Licensed
7 | */
8 |
9 | try {
10 | module.exports = require('utf-8-validate');
11 | } catch (e) {
12 | module.exports = require('./Validation.fallback');
13 | }
14 |
--------------------------------------------------------------------------------
/src/prod/package.json:
--------------------------------------------------------------------------------
1 | {
2 | "name": "Horizontally-Scaling-Node.js-Websockets-Talk",
3 | "description": "Talk about horizontally scaling node.js and WebSockets given at Connect.Tech 2016 and Thunder Plains 2016.",
4 | "author": "James Simpson (http://goldfirestudios.com)",
5 | "repository": {
6 | "type": "git",
7 | "url": "git://github.com/goldfire/Horizontally-Scaling-Node.js-Websockets-Talk.git"
8 | },
9 | "dependencies": {
10 | "submono": "*",
11 | "ws": "*",
12 | "redis": "*",
13 | "primus": "*"
14 | }
15 | }
--------------------------------------------------------------------------------
/src/prod/server.js:
--------------------------------------------------------------------------------
1 | var port = parseInt(process.argv[2], 10);
2 | var Primus = require('primus');
3 | var primus = new Primus.createServer({port: port, transformer: 'websockets'});
4 | var redis = require('redis');
5 | var pub = redis.createClient();
6 | var sub = redis.createClient();
7 | var color = 'blue';
8 |
9 | switch (port) {
10 | case 2001:
11 | color = 'red';
12 | break;
13 |
14 | case 2002:
15 | color = 'green';
16 | break;
17 |
18 | case 2003:
19 | color = 'purple';
20 | break;
21 | }
22 |
23 | sub.subscribe('global');
24 | sub.on('message', function(channel, msg) {
25 | if (channel === 'global') {
26 | primus.write(JSON.parse(msg));
27 | }
28 | });
29 |
30 | primus.on('connection', function(ws) {
31 | ws.on('data', function(msg) {
32 | msg.color = color;
33 | pub.publish('global', JSON.stringify(msg));
34 | });
35 | });
--------------------------------------------------------------------------------
/src/v1/assets/js/main.js:
--------------------------------------------------------------------------------
1 | // DOM Reference.
2 | var clickArea = document.querySelector('.click-area');
3 | var introText = document.querySelector('.intro-text');
4 | var audioContext = (typeof AudioContext !== 'undefined') ? new AudioContext() : new webkitAudioContext();
5 |
6 | // Handle all clicks on the click area.
7 | clickArea.addEventListener('click', function onClick(event) {
8 | unlockMobile();
9 |
10 | // Place color dot in this location.
11 | playAudioVisual(event.x, event.y, 'blue');
12 |
13 | // Hide the intro text.
14 | introText.className = 'intro-text hide';
15 | }, false);
16 |
17 | /**
18 | * Display the clicked/touched spot and play the associated tone.
19 | * @param {Number} x The x-coordinate clicked.
20 | * @param {Number} y The y-cooridnate clicked.
21 | * @param {String} color Color to rende the dot.
22 | */
23 | function playAudioVisual(x, y, color) {
24 | // Adjust the location by the radius of the circle.
25 | x -= 25;
26 | y -= 25;
27 |
28 | // Setup the base DOM element.
29 | var div = document.createElement('div');
30 | div.className = 'color-dot show ' + color;
31 | div.style.left = x + 'px';
32 | div.style.top = y + 'px';
33 | clickArea.appendChild(div);
34 |
35 | // Play the tone based on its location relative to the screen.
36 | var sounds = [280, 320, 350, 370, 400, 440, 470, 520, 540, 560, 590, 610, 640];
37 | synth.pitch(sounds[Math.round((x / window.innerWidth) * sounds.length)]);
38 | synth.start();
39 |
40 | // Fade out the circle.
41 | setTimeout(function() {
42 | synth.stop();
43 | div.className = 'color-dot hide ' + color;
44 | }, 2000);
45 |
46 | // Remove the circle from the DOM.
47 | setTimeout(function() {
48 | clickArea.removeChild(div);
49 | }, 3000);
50 | }
51 |
52 | /**
53 | * Unlock Web Audio on mobile devices.
54 | */
55 | function unlockMobile() {
56 | if (!unlocked) {
57 | var source = audioContext.createBufferSource();
58 | source.buffer = audioContext.createBuffer(1, 1, 22050);
59 | source.connect(audioContext.destination);
60 | source.start(0);
61 | source.onended = function() {
62 | unlocked = true;
63 | source.disconnect(0);
64 | };
65 | }
66 | }
67 |
68 | // Setup submono so that we can play a range of tones.
69 | var synth = new Monosynth(audioContext);
70 | var unlocked = false;
--------------------------------------------------------------------------------
/src/v1/index.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 | Horizontally Scaling Node.js & Websockets Demo
7 |
8 |
9 |
10 |
11 |
12 |
Click or touch window to play.
13 |
14 |
15 |
16 |
17 |
18 |
19 |
--------------------------------------------------------------------------------
/src/v1/node_modules/submono/LICENSE:
--------------------------------------------------------------------------------
1 | The MIT License (MIT)
2 |
3 | Copyright (c) 2015 Benji Kay
4 |
5 | Permission is hereby granted, free of charge, to any person obtaining a copy
6 | of this software and associated documentation files (the "Software"), to deal
7 | in the Software without restriction, including without limitation the rights
8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9 | copies of the Software, and to permit persons to whom the Software is
10 | furnished to do so, subject to the following conditions:
11 |
12 | The above copyright notice and this permission notice shall be included in all
13 | copies or substantial portions of the Software.
14 |
15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21 | SOFTWARE.
22 |
--------------------------------------------------------------------------------
/src/v1/node_modules/submono/README.md:
--------------------------------------------------------------------------------
1 | # submono
2 | A Web Audio subtractive, monophonic synthesizer. Looking for polyphony? Check out [subpoly](https://github.com/okaybenji/subpoly)!
3 |
4 | ### Create a synth.
5 | ```
6 | var audioCtx = new AudioContext();
7 | var synth = new Monosynth(audioCtx);
8 | ```
9 |
10 | ### Play a note.
11 | `synth.start();`
12 |
13 | ### Stop playing.
14 | `synth.stop();`
15 |
16 | ### Use methods to access pitch and waveform...
17 | ```
18 | synth.pitch(440); // in hertz
19 | console.log(synth.waveform()); // 'sawtooth' (or sine, triangle, square)
20 | ```
21 |
22 | ### ...get or set any other properties directly.
23 | ```
24 | synth.maxGain = 0.5; // out of 1
25 | synth.attack = 1.0; // in seconds
26 | ```
27 |
28 | ### Configure any or all the properties on initialization.
29 | ```
30 | var config = {
31 | waveform: 'sawtooth', // or sine, triangle, square
32 | pitch: 440, // in hertz
33 | maxGain: 0.5, // out of 1
34 | attack: 0.1, // in seconds
35 | decay: 0.0, // in seconds
36 | sustain: 1.0, // out of 1
37 | release: 0.8, // in seconds
38 | cutoff: {
39 | maxFrequency: 7500, // in hertz
40 | attack: 0.1, // in seconds
41 | decay: 2.5, // in seconds
42 | sustain: 0.2 // 0-5; maxFrequency multiplied by this
43 | }
44 | };
45 |
46 | var synth = new Monosynth(audioCtx, config);
47 | ```
48 |
49 | ### Demo
50 | [Tiles: a musical, multiplayer web toy](http://okaybenji.github.io/tiles-client/)
51 |
--------------------------------------------------------------------------------
/src/v1/package.json:
--------------------------------------------------------------------------------
1 | {
2 | "name": "Horizontally-Scaling-Node.js-Websockets-Talk",
3 | "description": "Talk about horizontally scaling node.js and WebSockets given at Connect.Tech 2016 and Thunder Plains 2016.",
4 | "author": "James Simpson (http://goldfirestudios.com)",
5 | "repository": {
6 | "type": "git",
7 | "url": "git://github.com/goldfire/Horizontally-Scaling-Node.js-Websockets-Talk.git"
8 | },
9 | "dependencies": {
10 | "submono": "*"
11 | }
12 | }
--------------------------------------------------------------------------------
/src/v2/index.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 | Horizontally Scaling Node.js & Websockets Demo
7 |
8 |
9 |
10 |
11 |
12 |
Click or touch window to play.
13 |
14 |
15 |
16 |
17 |
18 |
19 |
--------------------------------------------------------------------------------
/src/v2/node_modules/options/.npmignore:
--------------------------------------------------------------------------------
1 | npm-debug.log
2 | node_modules
3 | .*.swp
4 | .lock-*
5 | build/
6 |
7 | test
8 |
--------------------------------------------------------------------------------
/src/v2/node_modules/options/Makefile:
--------------------------------------------------------------------------------
1 | ALL_TESTS = $(shell find test/ -name '*.test.js')
2 |
3 | run-tests:
4 | @./node_modules/.bin/mocha \
5 | -t 2000 \
6 | $(TESTFLAGS) \
7 | $(TESTS)
8 |
9 | test:
10 | @$(MAKE) NODE_PATH=lib TESTS="$(ALL_TESTS)" run-tests
11 |
12 | .PHONY: test
13 |
--------------------------------------------------------------------------------
/src/v2/node_modules/options/README.md:
--------------------------------------------------------------------------------
1 | # options.js #
2 |
3 | A very light-weight in-code option parsers for node.js.
4 |
5 | ## Usage ##
6 |
7 | ``` js
8 | var Options = require("options");
9 |
10 | // Create an Options object
11 | function foo(options) {
12 | var default_options = {
13 | foo : "bar"
14 | };
15 |
16 | // Create an option object with default value
17 | var opts = new Options(default_options);
18 |
19 | // Merge options
20 | opts = opts.merge(options);
21 |
22 | // Reset to default value
23 | opts.reset();
24 |
25 | // Copy selected attributes out
26 | var seled_att = opts.copy("foo");
27 |
28 | // Read json options from a file.
29 | opts.read("options.file"); // Sync
30 | opts.read("options.file", function(err){ // Async
31 | if(err){ // If error occurs
32 | console.log("File error.");
33 | }else{
34 | // No error
35 | }
36 | });
37 |
38 | // Attributes defined or not
39 | opts.isDefinedAndNonNull("foobar");
40 | opts.isDefined("foobar");
41 | }
42 |
43 | ```
44 |
45 |
46 | ## License ##
47 |
48 | (The MIT License)
49 |
50 | Copyright (c) 2012 Einar Otto Stangvik <einaros@gmail.com>
51 |
52 | Permission is hereby granted, free of charge, to any person obtaining
53 | a copy of this software and associated documentation files (the
54 | 'Software'), to deal in the Software without restriction, including
55 | without limitation the rights to use, copy, modify, merge, publish,
56 | distribute, sublicense, and/or sell copies of the Software, and to
57 | permit persons to whom the Software is furnished to do so, subject to
58 | the following conditions:
59 |
60 | The above copyright notice and this permission notice shall be
61 | included in all copies or substantial portions of the Software.
62 |
63 | THE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND,
64 | EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
65 | MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
66 | IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
67 | CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
68 | TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
69 | SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
70 |
--------------------------------------------------------------------------------
/src/v2/node_modules/submono/LICENSE:
--------------------------------------------------------------------------------
1 | The MIT License (MIT)
2 |
3 | Copyright (c) 2015 Benji Kay
4 |
5 | Permission is hereby granted, free of charge, to any person obtaining a copy
6 | of this software and associated documentation files (the "Software"), to deal
7 | in the Software without restriction, including without limitation the rights
8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9 | copies of the Software, and to permit persons to whom the Software is
10 | furnished to do so, subject to the following conditions:
11 |
12 | The above copyright notice and this permission notice shall be included in all
13 | copies or substantial portions of the Software.
14 |
15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21 | SOFTWARE.
22 |
--------------------------------------------------------------------------------
/src/v2/node_modules/submono/README.md:
--------------------------------------------------------------------------------
1 | # submono
2 | A Web Audio subtractive, monophonic synthesizer. Looking for polyphony? Check out [subpoly](https://github.com/okaybenji/subpoly)!
3 |
4 | ### Create a synth.
5 | ```
6 | var audioCtx = new AudioContext();
7 | var synth = new Monosynth(audioCtx);
8 | ```
9 |
10 | ### Play a note.
11 | `synth.start();`
12 |
13 | ### Stop playing.
14 | `synth.stop();`
15 |
16 | ### Use methods to access pitch and waveform...
17 | ```
18 | synth.pitch(440); // in hertz
19 | console.log(synth.waveform()); // 'sawtooth' (or sine, triangle, square)
20 | ```
21 |
22 | ### ...get or set any other properties directly.
23 | ```
24 | synth.maxGain = 0.5; // out of 1
25 | synth.attack = 1.0; // in seconds
26 | ```
27 |
28 | ### Configure any or all the properties on initialization.
29 | ```
30 | var config = {
31 | waveform: 'sawtooth', // or sine, triangle, square
32 | pitch: 440, // in hertz
33 | maxGain: 0.5, // out of 1
34 | attack: 0.1, // in seconds
35 | decay: 0.0, // in seconds
36 | sustain: 1.0, // out of 1
37 | release: 0.8, // in seconds
38 | cutoff: {
39 | maxFrequency: 7500, // in hertz
40 | attack: 0.1, // in seconds
41 | decay: 2.5, // in seconds
42 | sustain: 0.2 // 0-5; maxFrequency multiplied by this
43 | }
44 | };
45 |
46 | var synth = new Monosynth(audioCtx, config);
47 | ```
48 |
49 | ### Demo
50 | [Tiles: a musical, multiplayer web toy](http://okaybenji.github.io/tiles-client/)
51 |
--------------------------------------------------------------------------------
/src/v2/node_modules/ultron/.npmignore:
--------------------------------------------------------------------------------
1 | node_modules
2 | coverage
3 | .tern-port
4 |
--------------------------------------------------------------------------------
/src/v2/node_modules/ultron/.travis.yml:
--------------------------------------------------------------------------------
1 | sudo: false
2 | language: node_js
3 | node_js:
4 | - "0.12"
5 | - "0.10"
6 | - "0.8"
7 | - "iojs"
8 | before_install:
9 | - 'if [ "${TRAVIS_NODE_VERSION}" == "0.8" ]; then npm install -g npm@2.11.1; fi'
10 | script:
11 | - "npm run test-travis"
12 | after_script:
13 | - "npm install coveralls@2.11.x && cat coverage/lcov.info | coveralls"
14 | matrix:
15 | fast_finish: true
16 | notifications:
17 | irc:
18 | channels:
19 | - "irc.freenode.org#unshift"
20 | on_success: change
21 | on_failure: change
22 |
--------------------------------------------------------------------------------
/src/v2/node_modules/ultron/LICENSE:
--------------------------------------------------------------------------------
1 | The MIT License (MIT)
2 |
3 | Copyright (c) 2015 Unshift.io, Arnout Kazemier, the Contributors.
4 |
5 | Permission is hereby granted, free of charge, to any person obtaining a copy
6 | of this software and associated documentation files (the "Software"), to deal
7 | in the Software without restriction, including without limitation the rights
8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9 | copies of the Software, and to permit persons to whom the Software is
10 | furnished to do so, subject to the following conditions:
11 |
12 | The above copyright notice and this permission notice shall be included in all
13 | copies or substantial portions of the Software.
14 |
15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21 | SOFTWARE.
22 |
23 |
--------------------------------------------------------------------------------
/src/v2/node_modules/ws/.npmignore:
--------------------------------------------------------------------------------
1 | npm-debug.log
2 | node_modules
3 | .*.swp
4 | .lock-*
5 | build
6 |
7 | bench
8 | doc
9 | examples
10 | test
11 |
12 |
--------------------------------------------------------------------------------
/src/v2/node_modules/ws/.travis.yml:
--------------------------------------------------------------------------------
1 | language: node_js
2 | sudo: false
3 | node_js:
4 | - "5"
5 | - "4"
6 | - "0.12"
7 | addons:
8 | apt:
9 | sources:
10 | - ubuntu-toolchain-r-test
11 | packages:
12 | - gcc-4.9
13 | - g++-4.9
14 | before_install:
15 | - export CC="gcc-4.9" CXX="g++-4.9"
16 |
--------------------------------------------------------------------------------
/src/v2/node_modules/ws/Makefile:
--------------------------------------------------------------------------------
1 | ALL_TESTS = $(shell find test/ -name '*.test.js')
2 | ALL_INTEGRATION = $(shell find test/ -name '*.integration.js')
3 |
4 | run-tests:
5 | @./node_modules/.bin/mocha \
6 | -t 5000 \
7 | -s 2400 \
8 | $(TESTFLAGS) \
9 | $(TESTS)
10 |
11 | run-integrationtests:
12 | @./node_modules/.bin/mocha \
13 | -t 5000 \
14 | -s 6000 \
15 | $(TESTFLAGS) \
16 | $(TESTS)
17 |
18 | run-coverage:
19 | @./node_modules/.bin/istanbul cover --report html \
20 | ./node_modules/.bin/_mocha -- \
21 | -t 5000 \
22 | -s 6000 \
23 | $(TESTFLAGS) \
24 | $(TESTS)
25 |
26 | test:
27 | @$(MAKE) NODE_TLS_REJECT_UNAUTHORIZED=0 NODE_PATH=lib TESTS="$(ALL_TESTS)" run-tests
28 |
29 | integrationtest:
30 | @$(MAKE) NODE_TLS_REJECT_UNAUTHORIZED=0 NODE_PATH=lib TESTS="$(ALL_INTEGRATION)" run-integrationtests
31 |
32 | coverage:
33 | @$(MAKE) NODE_TLS_REJECT_UNAUTHORIZED=0 NODE_PATH=lib TESTS="$(ALL_TESTS)" run-coverage
34 |
35 | benchmark:
36 | @node bench/sender.benchmark.js
37 | @node bench/parser.benchmark.js
38 |
39 | autobahn:
40 | @NODE_PATH=lib node test/autobahn.js
41 |
42 | autobahn-server:
43 | @NODE_PATH=lib node test/autobahn-server.js
44 |
45 | .PHONY: test coverage
46 |
--------------------------------------------------------------------------------
/src/v2/node_modules/ws/SECURITY.md:
--------------------------------------------------------------------------------
1 | # Security Guidelines
2 |
3 | Please contact us directly at **security@3rd-Eden.com** for any bug that might
4 | impact the security of this project. Please prefix the subject of your email
5 | with `[security]` in lowercase and square brackets. Our email filters will
6 | automatically prevent these messages from being moved to our spam box.
7 |
8 | You will receive an acknowledgement of your report within **24 hours**.
9 |
10 | All emails that do not include security vulnerabilities will be removed and
11 | blocked instantly.
12 |
13 | ## Exceptions
14 |
15 | If you do not receive an acknowledgement within the said time frame please give
16 | us the benefit of the doubt as it's possible that we haven't seen it yet. In
17 | this case please send us a message **without details** using one of the
18 | following methods:
19 |
20 | - Contact the lead developers of this project on their personal e-mails. You
21 | can find the e-mails in the git logs, for example using the following command:
22 | `git --no-pager show -s --format='%an <%ae>' ` where `` is the
23 | SHA1 of their latest commit in the project.
24 | - Create a GitHub issue stating contact details and the severity of the issue.
25 |
26 | Once we have acknowledged receipt of your report and confirmed the bug
27 | ourselves we will work with you to fix the vulnerability and publicly acknowledge
28 | your responsible disclosure, if you wish. In addition to that we will report
29 | all vulnerabilities to the [Node Security Project](https://nodesecurity.io/).
30 |
31 | ## History
32 |
33 | 04 Jan 2016: [Buffer vulnerablity](https://github.com/websockets/ws/releases/tag/1.0.1)
34 |
--------------------------------------------------------------------------------
/src/v2/node_modules/ws/index.js:
--------------------------------------------------------------------------------
1 | 'use strict';
2 |
3 | /*!
4 | * ws: a node.js websocket client
5 | * Copyright(c) 2011 Einar Otto Stangvik
6 | * MIT Licensed
7 | */
8 |
9 | var WS = module.exports = require('./lib/WebSocket');
10 |
11 | WS.Server = require('./lib/WebSocketServer');
12 | WS.Sender = require('./lib/Sender');
13 | WS.Receiver = require('./lib/Receiver');
14 |
15 | /**
16 | * Create a new WebSocket server.
17 | *
18 | * @param {Object} options Server options
19 | * @param {Function} fn Optional connection listener.
20 | * @returns {WS.Server}
21 | * @api public
22 | */
23 | WS.createServer = function createServer(options, fn) {
24 | var server = new WS.Server(options);
25 |
26 | if (typeof fn === 'function') {
27 | server.on('connection', fn);
28 | }
29 |
30 | return server;
31 | };
32 |
33 | /**
34 | * Create a new WebSocket connection.
35 | *
36 | * @param {String} address The URL/address we need to connect to.
37 | * @param {Function} fn Open listener.
38 | * @returns {WS}
39 | * @api public
40 | */
41 | WS.connect = WS.createConnection = function connect(address, fn) {
42 | var client = new WS(address);
43 |
44 | if (typeof fn === 'function') {
45 | client.on('open', fn);
46 | }
47 |
48 | return client;
49 | };
50 |
--------------------------------------------------------------------------------
/src/v2/node_modules/ws/lib/BufferPool.js:
--------------------------------------------------------------------------------
1 | /*!
2 | * ws: a node.js websocket client
3 | * Copyright(c) 2011 Einar Otto Stangvik
4 | * MIT Licensed
5 | */
6 |
7 | var util = require('util');
8 |
9 | function BufferPool(initialSize, growStrategy, shrinkStrategy) {
10 | if (this instanceof BufferPool === false) {
11 | throw new TypeError("Classes can't be function-called");
12 | }
13 |
14 | if (typeof initialSize === 'function') {
15 | shrinkStrategy = growStrategy;
16 | growStrategy = initialSize;
17 | initialSize = 0;
18 | }
19 | else if (typeof initialSize === 'undefined') {
20 | initialSize = 0;
21 | }
22 | this._growStrategy = (growStrategy || function(db, size) {
23 | return db.used + size;
24 | }).bind(null, this);
25 | this._shrinkStrategy = (shrinkStrategy || function(db) {
26 | return initialSize;
27 | }).bind(null, this);
28 | this._buffer = initialSize ? new Buffer(initialSize) : null;
29 | this._offset = 0;
30 | this._used = 0;
31 | this._changeFactor = 0;
32 | this.__defineGetter__('size', function(){
33 | return this._buffer == null ? 0 : this._buffer.length;
34 | });
35 | this.__defineGetter__('used', function(){
36 | return this._used;
37 | });
38 | }
39 |
40 | BufferPool.prototype.get = function(length) {
41 | if (this._buffer == null || this._offset + length > this._buffer.length) {
42 | var newBuf = new Buffer(this._growStrategy(length));
43 | this._buffer = newBuf;
44 | this._offset = 0;
45 | }
46 | this._used += length;
47 | var buf = this._buffer.slice(this._offset, this._offset + length);
48 | this._offset += length;
49 | return buf;
50 | }
51 |
52 | BufferPool.prototype.reset = function(forceNewBuffer) {
53 | var len = this._shrinkStrategy();
54 | if (len < this.size) this._changeFactor -= 1;
55 | if (forceNewBuffer || this._changeFactor < -2) {
56 | this._changeFactor = 0;
57 | this._buffer = len ? new Buffer(len) : null;
58 | }
59 | this._offset = 0;
60 | this._used = 0;
61 | }
62 |
63 | module.exports = BufferPool;
64 |
--------------------------------------------------------------------------------
/src/v2/node_modules/ws/lib/BufferUtil.fallback.js:
--------------------------------------------------------------------------------
1 | /*!
2 | * ws: a node.js websocket client
3 | * Copyright(c) 2011 Einar Otto Stangvik
4 | * MIT Licensed
5 | */
6 |
7 | exports.BufferUtil = {
8 | merge: function(mergedBuffer, buffers) {
9 | var offset = 0;
10 | for (var i = 0, l = buffers.length; i < l; ++i) {
11 | var buf = buffers[i];
12 | buf.copy(mergedBuffer, offset);
13 | offset += buf.length;
14 | }
15 | },
16 | mask: function(source, mask, output, offset, length) {
17 | var maskNum = mask.readUInt32LE(0, true);
18 | var i = 0;
19 | for (; i < length - 3; i += 4) {
20 | var num = maskNum ^ source.readUInt32LE(i, true);
21 | if (num < 0) num = 4294967296 + num;
22 | output.writeUInt32LE(num, offset + i, true);
23 | }
24 | switch (length % 4) {
25 | case 3: output[offset + i + 2] = source[i + 2] ^ mask[2];
26 | case 2: output[offset + i + 1] = source[i + 1] ^ mask[1];
27 | case 1: output[offset + i] = source[i] ^ mask[0];
28 | case 0:;
29 | }
30 | },
31 | unmask: function(data, mask) {
32 | var maskNum = mask.readUInt32LE(0, true);
33 | var length = data.length;
34 | var i = 0;
35 | for (; i < length - 3; i += 4) {
36 | var num = maskNum ^ data.readUInt32LE(i, true);
37 | if (num < 0) num = 4294967296 + num;
38 | data.writeUInt32LE(num, i, true);
39 | }
40 | switch (length % 4) {
41 | case 3: data[i + 2] = data[i + 2] ^ mask[2];
42 | case 2: data[i + 1] = data[i + 1] ^ mask[1];
43 | case 1: data[i] = data[i] ^ mask[0];
44 | case 0:;
45 | }
46 | }
47 | }
48 |
--------------------------------------------------------------------------------
/src/v2/node_modules/ws/lib/BufferUtil.js:
--------------------------------------------------------------------------------
1 | 'use strict';
2 |
3 | /*!
4 | * ws: a node.js websocket client
5 | * Copyright(c) 2011 Einar Otto Stangvik
6 | * MIT Licensed
7 | */
8 |
9 | try {
10 | module.exports = require('bufferutil');
11 | } catch (e) {
12 | module.exports = require('./BufferUtil.fallback');
13 | }
14 |
--------------------------------------------------------------------------------
/src/v2/node_modules/ws/lib/ErrorCodes.js:
--------------------------------------------------------------------------------
1 | /*!
2 | * ws: a node.js websocket client
3 | * Copyright(c) 2011 Einar Otto Stangvik
4 | * MIT Licensed
5 | */
6 |
7 | module.exports = {
8 | isValidErrorCode: function(code) {
9 | return (code >= 1000 && code <= 1011 && code != 1004 && code != 1005 && code != 1006) ||
10 | (code >= 3000 && code <= 4999);
11 | },
12 | 1000: 'normal',
13 | 1001: 'going away',
14 | 1002: 'protocol error',
15 | 1003: 'unsupported data',
16 | 1004: 'reserved',
17 | 1005: 'reserved for extensions',
18 | 1006: 'reserved for extensions',
19 | 1007: 'inconsistent or invalid data',
20 | 1008: 'policy violation',
21 | 1009: 'message too big',
22 | 1010: 'extension handshake missing',
23 | 1011: 'an unexpected condition prevented the request from being fulfilled',
24 | };
--------------------------------------------------------------------------------
/src/v2/node_modules/ws/lib/Extensions.js:
--------------------------------------------------------------------------------
1 |
2 | var util = require('util');
3 |
4 | /**
5 | * Module exports.
6 | */
7 |
8 | exports.parse = parse;
9 | exports.format = format;
10 |
11 | /**
12 | * Parse extensions header value
13 | */
14 |
15 | function parse(value) {
16 | value = value || '';
17 |
18 | var extensions = {};
19 |
20 | value.split(',').forEach(function(v) {
21 | var params = v.split(';');
22 | var token = params.shift().trim();
23 | var paramsList = extensions[token] = extensions[token] || [];
24 | var parsedParams = {};
25 |
26 | params.forEach(function(param) {
27 | var parts = param.trim().split('=');
28 | var key = parts[0];
29 | var value = parts[1];
30 | if (typeof value === 'undefined') {
31 | value = true;
32 | } else {
33 | // unquote value
34 | if (value[0] === '"') {
35 | value = value.slice(1);
36 | }
37 | if (value[value.length - 1] === '"') {
38 | value = value.slice(0, value.length - 1);
39 | }
40 | }
41 | (parsedParams[key] = parsedParams[key] || []).push(value);
42 | });
43 |
44 | paramsList.push(parsedParams);
45 | });
46 |
47 | return extensions;
48 | }
49 |
50 | /**
51 | * Format extensions header value
52 | */
53 |
54 | function format(value) {
55 | return Object.keys(value).map(function(token) {
56 | var paramsList = value[token];
57 | if (!util.isArray(paramsList)) {
58 | paramsList = [paramsList];
59 | }
60 | return paramsList.map(function(params) {
61 | return [token].concat(Object.keys(params).map(function(k) {
62 | var p = params[k];
63 | if (!util.isArray(p)) p = [p];
64 | return p.map(function(v) {
65 | return v === true ? k : k + '=' + v;
66 | }).join('; ');
67 | })).join('; ');
68 | }).join(', ');
69 | }).join(', ');
70 | }
71 |
--------------------------------------------------------------------------------
/src/v2/node_modules/ws/lib/Validation.fallback.js:
--------------------------------------------------------------------------------
1 | /*!
2 | * ws: a node.js websocket client
3 | * Copyright(c) 2011 Einar Otto Stangvik
4 | * MIT Licensed
5 | */
6 |
7 | exports.Validation = {
8 | isValidUTF8: function(buffer) {
9 | return true;
10 | }
11 | };
12 |
--------------------------------------------------------------------------------
/src/v2/node_modules/ws/lib/Validation.js:
--------------------------------------------------------------------------------
1 | 'use strict';
2 |
3 | /*!
4 | * ws: a node.js websocket client
5 | * Copyright(c) 2011 Einar Otto Stangvik
6 | * MIT Licensed
7 | */
8 |
9 | try {
10 | module.exports = require('utf-8-validate');
11 | } catch (e) {
12 | module.exports = require('./Validation.fallback');
13 | }
14 |
--------------------------------------------------------------------------------
/src/v2/package.json:
--------------------------------------------------------------------------------
1 | {
2 | "name": "Horizontally-Scaling-Node.js-Websockets-Talk",
3 | "description": "Talk about horizontally scaling node.js and WebSockets given at Connect.Tech 2016 and Thunder Plains 2016.",
4 | "author": "James Simpson (http://goldfirestudios.com)",
5 | "repository": {
6 | "type": "git",
7 | "url": "git://github.com/goldfire/Horizontally-Scaling-Node.js-Websockets-Talk.git"
8 | },
9 | "dependencies": {
10 | "submono": "*",
11 | "ws": "*"
12 | }
13 | }
--------------------------------------------------------------------------------
/src/v2/server.js:
--------------------------------------------------------------------------------
1 | var WebSocketServer = require('ws').Server;
2 | var wss = new WebSocketServer({port: 2000});
3 |
4 | wss.on('connection', function(ws) {
5 | ws.on('message', function(msg) {
6 | wss.clients.forEach(function(client) {
7 | client.send(msg);
8 | });
9 | });
10 | });
--------------------------------------------------------------------------------
/src/v3/index.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 | Horizontally Scaling Node.js & Websockets Demo
7 |
8 |
9 |
10 |
11 |
12 |
Click or touch window to play.
13 |
14 |
15 |
16 |
17 |
18 |
19 |
--------------------------------------------------------------------------------
/src/v3/node_modules/double-ended-queue/.npmignore:
--------------------------------------------------------------------------------
1 | node_modules/*
2 | todo.txt
3 | npm-debug.log
4 | test/*
5 | benchmark/*
6 | browser/*
7 | src/*
8 | async
9 | sync
10 | mixed
11 | bench.json
12 | js/browser
13 | js/browser/*
14 | js/debug
15 | js/debug/*
16 | reader.js
17 | read.txt
18 | bench
19 | .editorconfig
20 | .jshintrc
21 | ast_passes.js
22 | mocharun.js
23 | throwaway.js
24 | throwaway.html
25 | deque.sublime-workspace
26 | deque.sublime-project
27 | changelog.js
28 | .travis.yml
29 | sauce_connect.log
30 | nodex64.exe
31 | bump.js
32 |
--------------------------------------------------------------------------------
/src/v3/node_modules/double-ended-queue/LICENSE:
--------------------------------------------------------------------------------
1 | Copyright (c) 2013 Petka Antonov
2 |
3 | Permission is hereby granted, free of charge, to any person obtaining a copy
4 | of this software and associated documentation files (the "Software"), to deal
5 | in the Software without restriction, including without limitation the rights
6 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
7 | copies of the Software, and to permit persons to whom the Software is
8 | furnished to do so, subject to the following conditions:
9 |
10 | The above copyright notice and this permission notice shall be included in
11 | all copies or substantial portions of the Software.
12 |
13 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
14 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
15 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
16 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
17 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
18 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
19 | THE SOFTWARE.
--------------------------------------------------------------------------------
/src/v3/node_modules/options/.npmignore:
--------------------------------------------------------------------------------
1 | npm-debug.log
2 | node_modules
3 | .*.swp
4 | .lock-*
5 | build/
6 |
7 | test
8 |
--------------------------------------------------------------------------------
/src/v3/node_modules/options/Makefile:
--------------------------------------------------------------------------------
1 | ALL_TESTS = $(shell find test/ -name '*.test.js')
2 |
3 | run-tests:
4 | @./node_modules/.bin/mocha \
5 | -t 2000 \
6 | $(TESTFLAGS) \
7 | $(TESTS)
8 |
9 | test:
10 | @$(MAKE) NODE_PATH=lib TESTS="$(ALL_TESTS)" run-tests
11 |
12 | .PHONY: test
13 |
--------------------------------------------------------------------------------
/src/v3/node_modules/options/README.md:
--------------------------------------------------------------------------------
1 | # options.js #
2 |
3 | A very light-weight in-code option parsers for node.js.
4 |
5 | ## Usage ##
6 |
7 | ``` js
8 | var Options = require("options");
9 |
10 | // Create an Options object
11 | function foo(options) {
12 | var default_options = {
13 | foo : "bar"
14 | };
15 |
16 | // Create an option object with default value
17 | var opts = new Options(default_options);
18 |
19 | // Merge options
20 | opts = opts.merge(options);
21 |
22 | // Reset to default value
23 | opts.reset();
24 |
25 | // Copy selected attributes out
26 | var seled_att = opts.copy("foo");
27 |
28 | // Read json options from a file.
29 | opts.read("options.file"); // Sync
30 | opts.read("options.file", function(err){ // Async
31 | if(err){ // If error occurs
32 | console.log("File error.");
33 | }else{
34 | // No error
35 | }
36 | });
37 |
38 | // Attributes defined or not
39 | opts.isDefinedAndNonNull("foobar");
40 | opts.isDefined("foobar");
41 | }
42 |
43 | ```
44 |
45 |
46 | ## License ##
47 |
48 | (The MIT License)
49 |
50 | Copyright (c) 2012 Einar Otto Stangvik <einaros@gmail.com>
51 |
52 | Permission is hereby granted, free of charge, to any person obtaining
53 | a copy of this software and associated documentation files (the
54 | 'Software'), to deal in the Software without restriction, including
55 | without limitation the rights to use, copy, modify, merge, publish,
56 | distribute, sublicense, and/or sell copies of the Software, and to
57 | permit persons to whom the Software is furnished to do so, subject to
58 | the following conditions:
59 |
60 | The above copyright notice and this permission notice shall be
61 | included in all copies or substantial portions of the Software.
62 |
63 | THE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND,
64 | EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
65 | MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
66 | IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
67 | CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
68 | TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
69 | SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
70 |
--------------------------------------------------------------------------------
/src/v3/node_modules/redis-commands/.npmignore:
--------------------------------------------------------------------------------
1 | # Logs
2 | logs
3 | *.log
4 |
5 | # Runtime data
6 | pids
7 | *.pid
8 | *.seed
9 | *.rdb
10 |
11 | # Directory for instrumented libs generated by jscoverage/JSCover
12 | lib-cov
13 |
14 | # Coverage directory used by tools like istanbul
15 | coverage
16 |
17 | # Grunt intermediate storage (http://gruntjs.com/creating-plugins#storing-task-files)
18 | .grunt
19 |
20 | # Compiled binary addons (http://nodejs.org/api/addons.html)
21 | build/Release
22 |
23 | # Dependency directory
24 | # Commenting this out is preferred by some people, see
25 | # https://www.npmjs.org/doc/misc/npm-faq.html#should-i-check-my-node_modules-folder-into-git-
26 | node_modules
27 |
28 | # Users Environment Variables
29 | .lock-wscript
30 |
--------------------------------------------------------------------------------
/src/v3/node_modules/redis-commands/.travis.yml:
--------------------------------------------------------------------------------
1 | language: node_js
2 | sudo: false
3 | node_js:
4 | - "0.10"
5 | - "0.12"
6 | - "4"
7 | - "5"
8 | after_success:
9 | - CODECLIMATE_REPO_TOKEN=b57723fafcf0516f275d6b380cd506fd082ea88d86507eb82c8abd489b9b9a09 node ./node_modules/.bin/codeclimate-test-reporter < coverage/lcov.info
10 |
--------------------------------------------------------------------------------
/src/v3/node_modules/redis-commands/LICENSE:
--------------------------------------------------------------------------------
1 | The MIT License (MIT)
2 |
3 | Copyright (c) 2015 NodeRedis
4 |
5 | Permission is hereby granted, free of charge, to any person obtaining a copy
6 | of this software and associated documentation files (the "Software"), to deal
7 | in the Software without restriction, including without limitation the rights
8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9 | copies of the Software, and to permit persons to whom the Software is
10 | furnished to do so, subject to the following conditions:
11 |
12 | The above copyright notice and this permission notice shall be included in all
13 | copies or substantial portions of the Software.
14 |
15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21 | SOFTWARE.
22 |
23 |
--------------------------------------------------------------------------------
/src/v3/node_modules/redis-commands/README.md:
--------------------------------------------------------------------------------
1 | # Redis Commands
2 |
3 | [](https://travis-ci.org/NodeRedis/redis-commands)
4 | [](https://codeclimate.com/github/NodeRedis/redis-commands)
5 | [](https://codeclimate.com/github/NodeRedis/redis-commands/coverage)
6 |
7 | This module exports all the commands that Redis supports.
8 |
9 | ## Install
10 |
11 | ```shell
12 | $ npm install redis-commands
13 | ```
14 |
15 | ## Usage
16 |
17 | ```javascript
18 | var commands = require('redis-commands');
19 | ```
20 |
21 | `.list` is an array contains all the lowercased commands:
22 |
23 | ```javascript
24 | commands.list.forEach(function (command) {
25 | console.log(command);
26 | });
27 | ```
28 |
29 | `.exists()` is used to check if the command exists:
30 |
31 | ```javascript
32 | commands.exists('set') // true
33 | commands.exists('other-command') // false
34 | ```
35 |
36 | `.hasFlag()` is used to check if the command has the flag:
37 |
38 | ```javascript
39 | commands.hasFlag('set', 'readonly') // false
40 | ```
41 |
42 | `.getKeyIndexes()` is used to get the indexes of keys in the command arguments:
43 |
44 | ```javascript
45 | commands.getKeyIndexes('set', ['key', 'value']) // [0]
46 | commands.getKeyIndexes('mget', ['key1', 'key2']) // [0, 1]
47 | ```
48 |
49 | ## Acknowledgment
50 |
51 | Thank [@Yuan Chuan](https://github.com/yuanchuan) for the package name. The original redis-commands is renamed to [@yuanchuan/redis-commands](https://www.npmjs.com/package/@yuanchuan/redis-commands).
52 |
--------------------------------------------------------------------------------
/src/v3/node_modules/redis-commands/changelog.md:
--------------------------------------------------------------------------------
1 | ## v.1.2.0 - 21 Apr, 2016
2 |
3 | Features
4 |
5 | - Added support for `MIGRATE [...] KEYS key1, key2` (Redis >= v.3.0.6)
6 | - Added build sanity check for unhandled commands with moveable keys
7 | - Rebuild the commands with the newest unstable release
8 | - Improved performance of .getKeyIndexes()
9 |
10 | Bugfix
11 |
12 | - Fixed command command returning the wrong arity due to a Redis bug
13 | - Fixed brpop command returning the wrong keystop due to a Redis bug
14 |
15 | ## v.1.1.0 - 09 Feb, 2016
16 |
17 | Features
18 |
19 | - Added .exists() to check for command existence
20 | - Improved performance of .hasFlag()
21 |
--------------------------------------------------------------------------------
/src/v3/node_modules/redis-commands/tools/build.js:
--------------------------------------------------------------------------------
1 | var fs = require('fs');
2 | var path = require('path');
3 | var stringify = require('json-stable-stringify');
4 | var commandPath = path.join(__dirname, '..', 'commands.json');
5 | var redisCommands = require('../');
6 |
7 | var Redis = require('ioredis');
8 | var redis = new Redis(process.env.REDIS_URI);
9 |
10 | redis.command().then(function (res) {
11 | redis.disconnect();
12 |
13 | // Find all special handled cases
14 | var movableKeys = String(redisCommands.getKeyIndexes).match(/case '[a-z-]+':/g).map(function (entry) {
15 | return entry.replace(/^case \'|\':$/g, '');
16 | });
17 |
18 | var commands = res.reduce(function (prev, current) {
19 | var currentCommandPos = movableKeys.indexOf(current[0]);
20 | if (currentCommandPos !== -1 && current[2].indexOf('movablekeys') !== -1) {
21 | movableKeys.splice(currentCommandPos, 1);
22 | }
23 | // https://github.com/antirez/redis/issues/2598
24 | if (current[0] === 'brpop' && current[4] === 1) {
25 | current[4] = -2;
26 | }
27 | prev[current[0]] = {
28 | arity: current[1] || 1, // https://github.com/antirez/redis/pull/2986
29 | flags: current[2],
30 | keyStart: current[3],
31 | keyStop: current[4],
32 | step: current[5]
33 | };
34 | return prev;
35 | }, {});
36 |
37 | // Future proof. Redis might implement this at some point
38 | // https://github.com/antirez/redis/pull/2982
39 | if (!commands.quit) {
40 | commands.quit = {
41 | arity: 1,
42 | flags: [
43 | 'loading',
44 | 'stale',
45 | 'readonly'
46 | ],
47 | keyStart: 0,
48 | keyStop: 0,
49 | step: 0
50 | }
51 | }
52 |
53 | if (movableKeys.length !== 0) {
54 | throw new Error('Not all commands (\'' + movableKeys.join('\', \'') + '\') with the "movablekeys" flag are handled in the code');
55 | }
56 |
57 | // Use json-stable-stringify instead fo JSON.stringify
58 | // for easier diffing
59 | var content = stringify(commands, { space: ' ' });
60 |
61 | fs.writeFile(commandPath, content);
62 | });
63 |
--------------------------------------------------------------------------------
/src/v3/node_modules/redis-parser/.codeclimate.yml:
--------------------------------------------------------------------------------
1 | languages:
2 | JavaScript: true
3 | exclude_paths:
4 | - "benchmark/index.js"
5 | - "benchmark/old/javascript.js"
6 | - "test/parsers.spec.js"
7 |
--------------------------------------------------------------------------------
/src/v3/node_modules/redis-parser/.npmignore:
--------------------------------------------------------------------------------
1 | # IntelliJ project files
2 | .idea
3 | *.iml
4 | out
5 | gen
6 |
7 | # Unrelevant files and folders
8 | benchmark
9 | coverage
10 | test
11 | .travis.yml
12 | .gitignore
13 |
--------------------------------------------------------------------------------
/src/v3/node_modules/redis-parser/LICENSE:
--------------------------------------------------------------------------------
1 | The MIT License (MIT)
2 |
3 | Copyright (c) 2015 NodeRedis
4 |
5 | Permission is hereby granted, free of charge, to any person obtaining a copy
6 | of this software and associated documentation files (the "Software"), to deal
7 | in the Software without restriction, including without limitation the rights
8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9 | copies of the Software, and to permit persons to whom the Software is
10 | furnished to do so, subject to the following conditions:
11 |
12 | The above copyright notice and this permission notice shall be included in all
13 | copies or substantial portions of the Software.
14 |
15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21 | SOFTWARE.
22 |
23 |
--------------------------------------------------------------------------------
/src/v3/node_modules/redis-parser/changelog.md:
--------------------------------------------------------------------------------
1 | ## v.2.0.4 - 21 Jul, 2016
2 |
3 | Bugfixes
4 |
5 | - Fixed multi byte characters getting corrupted
6 |
7 | ## v.2.0.3 - 17 Jun, 2016
8 |
9 | Bugfixes
10 |
11 | - Fixed parser not working with huge buffers (e.g. 300 MB)
12 |
13 | ## v.2.0.2 - 08 Jun, 2016
14 |
15 | Bugfixes
16 |
17 | - Fixed parser with returnBuffers option returning corrupted data
18 |
19 | ## v.2.0.1 - 04 Jun, 2016
20 |
21 | Bugfixes
22 |
23 | - Fixed multiple parsers working concurrently resulting in faulty data in some cases
24 |
25 | ## v.2.0.0 - 29 May, 2016
26 |
27 | The javascript parser got completly rewritten by [Michael Diarmid](https://github.com/Salakar) and [Ruben Bridgewater](https://github.com/BridgeAR) and is now a lot faster than the hiredis parser.
28 | Therefore the hiredis parser was deprecated and should only be used for testing purposes and benchmarking comparison.
29 |
30 | All Errors returned by the parser are from now on of class ReplyError
31 |
32 | Features
33 |
34 | - Improved performance by up to 15x as fast as before
35 | - Improved options validation
36 | - Added ReplyError Class
37 | - Added parser benchmark
38 | - Switched default parser from hiredis to JS, no matter if hiredis is installed or not
39 |
40 | Removed
41 |
42 | - Deprecated hiredis support
43 |
44 | ## v.1.3.0 - 27 Mar, 2016
45 |
46 | Features
47 |
48 | - Added `auto` as parser name option to check what parser is available
49 | - Non existing requested parsers falls back into auto mode instead of always choosing the JS parser
50 |
51 | ## v.1.2.0 - 27 Mar, 2016
52 |
53 | Features
54 |
55 | - Added `stringNumbers` option to make sure all numbers are returned as string instead of a js number for precision
56 | - The parser is from now on going to print warnings if a parser is explicitly requested that does not exist and gracefully chooses the JS parser
57 |
58 | ## v.1.1.0 - 26 Jan, 2016
59 |
60 | Features
61 |
62 | - The parser is from now on going to reset itself on protocol errors
63 |
--------------------------------------------------------------------------------
/src/v3/node_modules/redis-parser/index.js:
--------------------------------------------------------------------------------
1 | 'use strict'
2 |
3 | module.exports = require('./lib/parser')
4 | module.exports.ReplyError = require('./lib/replyError')
5 |
--------------------------------------------------------------------------------
/src/v3/node_modules/redis-parser/lib/hiredis.js:
--------------------------------------------------------------------------------
1 | 'use strict'
2 |
3 | var hiredis = require('hiredis')
4 | var ReplyError = require('../lib/replyError')
5 |
6 | /**
7 | * Parse data
8 | * @param parser
9 | * @returns {*}
10 | */
11 | function parseData (parser) {
12 | try {
13 | return parser.reader.get()
14 | } catch (err) {
15 | // Protocol errors land here
16 | // Reset the parser. Otherwise new commands can't be processed properly
17 | parser.reader = new hiredis.Reader(parser.options)
18 | parser.returnFatalError(new ReplyError(err.message))
19 | }
20 | }
21 |
22 | /**
23 | * Hiredis Parser
24 | * @param options
25 | * @constructor
26 | */
27 | function HiredisReplyParser (options) {
28 | this.returnError = options.returnError
29 | this.returnFatalError = options.returnFatalError || options.returnError
30 | this.returnReply = options.returnReply
31 | this.name = 'hiredis'
32 | this.options = {
33 | return_buffers: !!options.returnBuffers
34 | }
35 | this.reader = new hiredis.Reader(this.options)
36 | }
37 |
38 | HiredisReplyParser.prototype.execute = function (data) {
39 | this.reader.feed(data)
40 | var reply = parseData(this)
41 |
42 | while (reply !== undefined) {
43 | if (reply && reply.name === 'Error') {
44 | this.returnError(new ReplyError(reply.message))
45 | } else {
46 | this.returnReply(reply)
47 | }
48 | reply = parseData(this)
49 | }
50 | }
51 |
52 | module.exports = HiredisReplyParser
53 |
--------------------------------------------------------------------------------
/src/v3/node_modules/redis-parser/lib/replyError.js:
--------------------------------------------------------------------------------
1 | 'use strict'
2 |
3 | var util = require('util')
4 |
5 | function ReplyError (message) {
6 | var limit = Error.stackTraceLimit
7 | Error.stackTraceLimit = 2
8 | Error.captureStackTrace(this, this.constructor)
9 | Error.stackTraceLimit = limit
10 | Object.defineProperty(this, 'message', {
11 | value: message || '',
12 | writable: true
13 | })
14 | }
15 |
16 | util.inherits(ReplyError, Error)
17 |
18 | Object.defineProperty(ReplyError.prototype, 'name', {
19 | value: 'ReplyError',
20 | writable: true
21 | })
22 |
23 | module.exports = ReplyError
24 |
--------------------------------------------------------------------------------
/src/v3/node_modules/redis/.eslintignore:
--------------------------------------------------------------------------------
1 | node_modules/**
2 | coverage/**
3 | **.md
4 | **.log
5 |
--------------------------------------------------------------------------------
/src/v3/node_modules/redis/.github/ISSUE_TEMPLATE.md:
--------------------------------------------------------------------------------
1 | _Thanks for wanting to report an issue you've found in node_redis. Please delete
2 | this text and fill in the template below. Please note that the issue tracker is only
3 | for bug reports or feature requests. If you have a question, please ask that on [gitter].
4 | If unsure about something, just do as best as you're able._
5 |
6 | _Note that it will be much easier to fix the issue if a test case that reproduces
7 | the problem is provided. It is of course not always possible to reduce your code
8 | to a small test case, but it's highly appreciated to have as much data as possible.
9 | Thank you!_
10 |
11 | * **Version**: What node_redis and what redis version is the issue happening on?
12 | * **Platform**: What platform / version? (For example Node.js 0.10 or Node.js 5.7.0 on Windows 7 / Ubuntu 15.10 / Azure)
13 | * **Description**: Description of your issue, stack traces from errors and code that reproduces the issue
14 |
15 | [gitter]: https://gitter.im/NodeRedis/node_redis?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge
--------------------------------------------------------------------------------
/src/v3/node_modules/redis/.github/PULL_REQUEST_TEMPLATE.md:
--------------------------------------------------------------------------------
1 | ### Pull Request check-list
2 |
3 | _Please make sure to review and check all of these items:_
4 |
5 | - [ ] Does `npm test` pass with this change (including linting)?
6 | - [ ] Is the new or changed code fully tested?
7 | - [ ] Is a documentation update included (if this change modifies existing APIs, or introduces new ones)?
8 |
9 | _NOTE: these things are not required to open a PR and can be done
10 | afterwards / while the PR is open._
11 |
12 | ### Description of change
13 |
14 | _Please provide a description of the change here._
--------------------------------------------------------------------------------
/src/v3/node_modules/redis/.npmignore:
--------------------------------------------------------------------------------
1 | examples/
2 | benchmarks/
3 | test/
4 | .nyc_output/
5 | coverage/
6 | .tern-port
7 | *.log
8 | *.rdb
9 | *.out
10 | *.yml
11 |
--------------------------------------------------------------------------------
/src/v3/node_modules/redis/LICENSE:
--------------------------------------------------------------------------------
1 | LICENSE - "MIT License"
2 |
3 | Copyright (c) 2016 by NodeRedis
4 |
5 | Permission is hereby granted, free of charge, to any person
6 | obtaining a copy of this software and associated documentation
7 | files (the "Software"), to deal in the Software without
8 | restriction, including without limitation the rights to use,
9 | copy, modify, merge, publish, distribute, sublicense, and/or sell
10 | copies of the Software, and to permit persons to whom the
11 | Software is furnished to do so, subject to the following
12 | conditions:
13 |
14 | The above copyright notice and this permission notice shall be
15 | included in all copies or substantial portions of the Software.
16 |
17 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
18 | EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
19 | OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
20 | NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
21 | HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
22 | WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
23 | FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
24 | OTHER DEALINGS IN THE SOFTWARE.
--------------------------------------------------------------------------------
/src/v3/node_modules/redis/lib/command.js:
--------------------------------------------------------------------------------
1 | 'use strict';
2 |
3 | var betterStackTraces = /development/i.test(process.env.NODE_ENV) || /\bredis\b/i.test(process.env.NODE_DEBUG);
4 |
5 | function Command (command, args, callback, call_on_write) {
6 | this.command = command;
7 | this.args = args;
8 | this.buffer_args = false;
9 | this.callback = callback;
10 | this.call_on_write = call_on_write;
11 | if (betterStackTraces) {
12 | this.error = new Error();
13 | }
14 | }
15 |
16 | module.exports = Command;
17 |
--------------------------------------------------------------------------------
/src/v3/node_modules/redis/lib/customErrors.js:
--------------------------------------------------------------------------------
1 | 'use strict';
2 |
3 | var util = require('util');
4 |
5 | function AbortError (obj) {
6 | Error.captureStackTrace(this, this.constructor);
7 | Object.defineProperty(this, 'message', {
8 | value: obj.message || '',
9 | configurable: true,
10 | writable: true
11 | });
12 | for (var keys = Object.keys(obj), key = keys.pop(); key; key = keys.pop()) {
13 | this[key] = obj[key];
14 | }
15 | }
16 |
17 | function AggregateError (obj) {
18 | Error.captureStackTrace(this, this.constructor);
19 | Object.defineProperty(this, 'message', {
20 | value: obj.message || '',
21 | configurable: true,
22 | writable: true
23 | });
24 | for (var keys = Object.keys(obj), key = keys.pop(); key; key = keys.pop()) {
25 | this[key] = obj[key];
26 | }
27 | }
28 |
29 | util.inherits(AbortError, Error);
30 | util.inherits(AggregateError, AbortError);
31 |
32 | Object.defineProperty(AbortError.prototype, 'name', {
33 | value: 'AbortError',
34 | // configurable: true,
35 | writable: true
36 | });
37 | Object.defineProperty(AggregateError.prototype, 'name', {
38 | value: 'AggregateError',
39 | // configurable: true,
40 | writable: true
41 | });
42 |
43 | module.exports = {
44 | AbortError: AbortError,
45 | AggregateError: AggregateError
46 | };
47 |
--------------------------------------------------------------------------------
/src/v3/node_modules/redis/lib/debug.js:
--------------------------------------------------------------------------------
1 | 'use strict';
2 |
3 | var index = require('../');
4 |
5 | function debug () {
6 | if (index.debug_mode) {
7 | console.error.apply(null, arguments);
8 | }
9 | }
10 |
11 | module.exports = debug;
12 |
--------------------------------------------------------------------------------
/src/v3/node_modules/submono/LICENSE:
--------------------------------------------------------------------------------
1 | The MIT License (MIT)
2 |
3 | Copyright (c) 2015 Benji Kay
4 |
5 | Permission is hereby granted, free of charge, to any person obtaining a copy
6 | of this software and associated documentation files (the "Software"), to deal
7 | in the Software without restriction, including without limitation the rights
8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9 | copies of the Software, and to permit persons to whom the Software is
10 | furnished to do so, subject to the following conditions:
11 |
12 | The above copyright notice and this permission notice shall be included in all
13 | copies or substantial portions of the Software.
14 |
15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21 | SOFTWARE.
22 |
--------------------------------------------------------------------------------
/src/v3/node_modules/submono/README.md:
--------------------------------------------------------------------------------
1 | # submono
2 | A Web Audio subtractive, monophonic synthesizer. Looking for polyphony? Check out [subpoly](https://github.com/okaybenji/subpoly)!
3 |
4 | ### Create a synth.
5 | ```
6 | var audioCtx = new AudioContext();
7 | var synth = new Monosynth(audioCtx);
8 | ```
9 |
10 | ### Play a note.
11 | `synth.start();`
12 |
13 | ### Stop playing.
14 | `synth.stop();`
15 |
16 | ### Use methods to access pitch and waveform...
17 | ```
18 | synth.pitch(440); // in hertz
19 | console.log(synth.waveform()); // 'sawtooth' (or sine, triangle, square)
20 | ```
21 |
22 | ### ...get or set any other properties directly.
23 | ```
24 | synth.maxGain = 0.5; // out of 1
25 | synth.attack = 1.0; // in seconds
26 | ```
27 |
28 | ### Configure any or all the properties on initialization.
29 | ```
30 | var config = {
31 | waveform: 'sawtooth', // or sine, triangle, square
32 | pitch: 440, // in hertz
33 | maxGain: 0.5, // out of 1
34 | attack: 0.1, // in seconds
35 | decay: 0.0, // in seconds
36 | sustain: 1.0, // out of 1
37 | release: 0.8, // in seconds
38 | cutoff: {
39 | maxFrequency: 7500, // in hertz
40 | attack: 0.1, // in seconds
41 | decay: 2.5, // in seconds
42 | sustain: 0.2 // 0-5; maxFrequency multiplied by this
43 | }
44 | };
45 |
46 | var synth = new Monosynth(audioCtx, config);
47 | ```
48 |
49 | ### Demo
50 | [Tiles: a musical, multiplayer web toy](http://okaybenji.github.io/tiles-client/)
51 |
--------------------------------------------------------------------------------
/src/v3/node_modules/ultron/.npmignore:
--------------------------------------------------------------------------------
1 | node_modules
2 | coverage
3 | .tern-port
4 |
--------------------------------------------------------------------------------
/src/v3/node_modules/ultron/.travis.yml:
--------------------------------------------------------------------------------
1 | sudo: false
2 | language: node_js
3 | node_js:
4 | - "0.12"
5 | - "0.10"
6 | - "0.8"
7 | - "iojs"
8 | before_install:
9 | - 'if [ "${TRAVIS_NODE_VERSION}" == "0.8" ]; then npm install -g npm@2.11.1; fi'
10 | script:
11 | - "npm run test-travis"
12 | after_script:
13 | - "npm install coveralls@2.11.x && cat coverage/lcov.info | coveralls"
14 | matrix:
15 | fast_finish: true
16 | notifications:
17 | irc:
18 | channels:
19 | - "irc.freenode.org#unshift"
20 | on_success: change
21 | on_failure: change
22 |
--------------------------------------------------------------------------------
/src/v3/node_modules/ultron/LICENSE:
--------------------------------------------------------------------------------
1 | The MIT License (MIT)
2 |
3 | Copyright (c) 2015 Unshift.io, Arnout Kazemier, the Contributors.
4 |
5 | Permission is hereby granted, free of charge, to any person obtaining a copy
6 | of this software and associated documentation files (the "Software"), to deal
7 | in the Software without restriction, including without limitation the rights
8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9 | copies of the Software, and to permit persons to whom the Software is
10 | furnished to do so, subject to the following conditions:
11 |
12 | The above copyright notice and this permission notice shall be included in all
13 | copies or substantial portions of the Software.
14 |
15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21 | SOFTWARE.
22 |
23 |
--------------------------------------------------------------------------------
/src/v3/node_modules/ws/.npmignore:
--------------------------------------------------------------------------------
1 | npm-debug.log
2 | node_modules
3 | .*.swp
4 | .lock-*
5 | build
6 |
7 | bench
8 | doc
9 | examples
10 | test
11 |
12 |
--------------------------------------------------------------------------------
/src/v3/node_modules/ws/.travis.yml:
--------------------------------------------------------------------------------
1 | language: node_js
2 | sudo: false
3 | node_js:
4 | - "5"
5 | - "4"
6 | - "0.12"
7 | addons:
8 | apt:
9 | sources:
10 | - ubuntu-toolchain-r-test
11 | packages:
12 | - gcc-4.9
13 | - g++-4.9
14 | before_install:
15 | - export CC="gcc-4.9" CXX="g++-4.9"
16 |
--------------------------------------------------------------------------------
/src/v3/node_modules/ws/Makefile:
--------------------------------------------------------------------------------
1 | ALL_TESTS = $(shell find test/ -name '*.test.js')
2 | ALL_INTEGRATION = $(shell find test/ -name '*.integration.js')
3 |
4 | run-tests:
5 | @./node_modules/.bin/mocha \
6 | -t 5000 \
7 | -s 2400 \
8 | $(TESTFLAGS) \
9 | $(TESTS)
10 |
11 | run-integrationtests:
12 | @./node_modules/.bin/mocha \
13 | -t 5000 \
14 | -s 6000 \
15 | $(TESTFLAGS) \
16 | $(TESTS)
17 |
18 | run-coverage:
19 | @./node_modules/.bin/istanbul cover --report html \
20 | ./node_modules/.bin/_mocha -- \
21 | -t 5000 \
22 | -s 6000 \
23 | $(TESTFLAGS) \
24 | $(TESTS)
25 |
26 | test:
27 | @$(MAKE) NODE_TLS_REJECT_UNAUTHORIZED=0 NODE_PATH=lib TESTS="$(ALL_TESTS)" run-tests
28 |
29 | integrationtest:
30 | @$(MAKE) NODE_TLS_REJECT_UNAUTHORIZED=0 NODE_PATH=lib TESTS="$(ALL_INTEGRATION)" run-integrationtests
31 |
32 | coverage:
33 | @$(MAKE) NODE_TLS_REJECT_UNAUTHORIZED=0 NODE_PATH=lib TESTS="$(ALL_TESTS)" run-coverage
34 |
35 | benchmark:
36 | @node bench/sender.benchmark.js
37 | @node bench/parser.benchmark.js
38 |
39 | autobahn:
40 | @NODE_PATH=lib node test/autobahn.js
41 |
42 | autobahn-server:
43 | @NODE_PATH=lib node test/autobahn-server.js
44 |
45 | .PHONY: test coverage
46 |
--------------------------------------------------------------------------------
/src/v3/node_modules/ws/SECURITY.md:
--------------------------------------------------------------------------------
1 | # Security Guidelines
2 |
3 | Please contact us directly at **security@3rd-Eden.com** for any bug that might
4 | impact the security of this project. Please prefix the subject of your email
5 | with `[security]` in lowercase and square brackets. Our email filters will
6 | automatically prevent these messages from being moved to our spam box.
7 |
8 | You will receive an acknowledgement of your report within **24 hours**.
9 |
10 | All emails that do not include security vulnerabilities will be removed and
11 | blocked instantly.
12 |
13 | ## Exceptions
14 |
15 | If you do not receive an acknowledgement within the said time frame please give
16 | us the benefit of the doubt as it's possible that we haven't seen it yet. In
17 | this case please send us a message **without details** using one of the
18 | following methods:
19 |
20 | - Contact the lead developers of this project on their personal e-mails. You
21 | can find the e-mails in the git logs, for example using the following command:
22 | `git --no-pager show -s --format='%an <%ae>' ` where `` is the
23 | SHA1 of their latest commit in the project.
24 | - Create a GitHub issue stating contact details and the severity of the issue.
25 |
26 | Once we have acknowledged receipt of your report and confirmed the bug
27 | ourselves we will work with you to fix the vulnerability and publicly acknowledge
28 | your responsible disclosure, if you wish. In addition to that we will report
29 | all vulnerabilities to the [Node Security Project](https://nodesecurity.io/).
30 |
31 | ## History
32 |
33 | 04 Jan 2016: [Buffer vulnerablity](https://github.com/websockets/ws/releases/tag/1.0.1)
34 |
--------------------------------------------------------------------------------
/src/v3/node_modules/ws/index.js:
--------------------------------------------------------------------------------
1 | 'use strict';
2 |
3 | /*!
4 | * ws: a node.js websocket client
5 | * Copyright(c) 2011 Einar Otto Stangvik
6 | * MIT Licensed
7 | */
8 |
9 | var WS = module.exports = require('./lib/WebSocket');
10 |
11 | WS.Server = require('./lib/WebSocketServer');
12 | WS.Sender = require('./lib/Sender');
13 | WS.Receiver = require('./lib/Receiver');
14 |
15 | /**
16 | * Create a new WebSocket server.
17 | *
18 | * @param {Object} options Server options
19 | * @param {Function} fn Optional connection listener.
20 | * @returns {WS.Server}
21 | * @api public
22 | */
23 | WS.createServer = function createServer(options, fn) {
24 | var server = new WS.Server(options);
25 |
26 | if (typeof fn === 'function') {
27 | server.on('connection', fn);
28 | }
29 |
30 | return server;
31 | };
32 |
33 | /**
34 | * Create a new WebSocket connection.
35 | *
36 | * @param {String} address The URL/address we need to connect to.
37 | * @param {Function} fn Open listener.
38 | * @returns {WS}
39 | * @api public
40 | */
41 | WS.connect = WS.createConnection = function connect(address, fn) {
42 | var client = new WS(address);
43 |
44 | if (typeof fn === 'function') {
45 | client.on('open', fn);
46 | }
47 |
48 | return client;
49 | };
50 |
--------------------------------------------------------------------------------
/src/v3/node_modules/ws/lib/BufferPool.js:
--------------------------------------------------------------------------------
1 | /*!
2 | * ws: a node.js websocket client
3 | * Copyright(c) 2011 Einar Otto Stangvik
4 | * MIT Licensed
5 | */
6 |
7 | var util = require('util');
8 |
9 | function BufferPool(initialSize, growStrategy, shrinkStrategy) {
10 | if (this instanceof BufferPool === false) {
11 | throw new TypeError("Classes can't be function-called");
12 | }
13 |
14 | if (typeof initialSize === 'function') {
15 | shrinkStrategy = growStrategy;
16 | growStrategy = initialSize;
17 | initialSize = 0;
18 | }
19 | else if (typeof initialSize === 'undefined') {
20 | initialSize = 0;
21 | }
22 | this._growStrategy = (growStrategy || function(db, size) {
23 | return db.used + size;
24 | }).bind(null, this);
25 | this._shrinkStrategy = (shrinkStrategy || function(db) {
26 | return initialSize;
27 | }).bind(null, this);
28 | this._buffer = initialSize ? new Buffer(initialSize) : null;
29 | this._offset = 0;
30 | this._used = 0;
31 | this._changeFactor = 0;
32 | this.__defineGetter__('size', function(){
33 | return this._buffer == null ? 0 : this._buffer.length;
34 | });
35 | this.__defineGetter__('used', function(){
36 | return this._used;
37 | });
38 | }
39 |
40 | BufferPool.prototype.get = function(length) {
41 | if (this._buffer == null || this._offset + length > this._buffer.length) {
42 | var newBuf = new Buffer(this._growStrategy(length));
43 | this._buffer = newBuf;
44 | this._offset = 0;
45 | }
46 | this._used += length;
47 | var buf = this._buffer.slice(this._offset, this._offset + length);
48 | this._offset += length;
49 | return buf;
50 | }
51 |
52 | BufferPool.prototype.reset = function(forceNewBuffer) {
53 | var len = this._shrinkStrategy();
54 | if (len < this.size) this._changeFactor -= 1;
55 | if (forceNewBuffer || this._changeFactor < -2) {
56 | this._changeFactor = 0;
57 | this._buffer = len ? new Buffer(len) : null;
58 | }
59 | this._offset = 0;
60 | this._used = 0;
61 | }
62 |
63 | module.exports = BufferPool;
64 |
--------------------------------------------------------------------------------
/src/v3/node_modules/ws/lib/BufferUtil.fallback.js:
--------------------------------------------------------------------------------
1 | /*!
2 | * ws: a node.js websocket client
3 | * Copyright(c) 2011 Einar Otto Stangvik
4 | * MIT Licensed
5 | */
6 |
7 | exports.BufferUtil = {
8 | merge: function(mergedBuffer, buffers) {
9 | var offset = 0;
10 | for (var i = 0, l = buffers.length; i < l; ++i) {
11 | var buf = buffers[i];
12 | buf.copy(mergedBuffer, offset);
13 | offset += buf.length;
14 | }
15 | },
16 | mask: function(source, mask, output, offset, length) {
17 | var maskNum = mask.readUInt32LE(0, true);
18 | var i = 0;
19 | for (; i < length - 3; i += 4) {
20 | var num = maskNum ^ source.readUInt32LE(i, true);
21 | if (num < 0) num = 4294967296 + num;
22 | output.writeUInt32LE(num, offset + i, true);
23 | }
24 | switch (length % 4) {
25 | case 3: output[offset + i + 2] = source[i + 2] ^ mask[2];
26 | case 2: output[offset + i + 1] = source[i + 1] ^ mask[1];
27 | case 1: output[offset + i] = source[i] ^ mask[0];
28 | case 0:;
29 | }
30 | },
31 | unmask: function(data, mask) {
32 | var maskNum = mask.readUInt32LE(0, true);
33 | var length = data.length;
34 | var i = 0;
35 | for (; i < length - 3; i += 4) {
36 | var num = maskNum ^ data.readUInt32LE(i, true);
37 | if (num < 0) num = 4294967296 + num;
38 | data.writeUInt32LE(num, i, true);
39 | }
40 | switch (length % 4) {
41 | case 3: data[i + 2] = data[i + 2] ^ mask[2];
42 | case 2: data[i + 1] = data[i + 1] ^ mask[1];
43 | case 1: data[i] = data[i] ^ mask[0];
44 | case 0:;
45 | }
46 | }
47 | }
48 |
--------------------------------------------------------------------------------
/src/v3/node_modules/ws/lib/BufferUtil.js:
--------------------------------------------------------------------------------
1 | 'use strict';
2 |
3 | /*!
4 | * ws: a node.js websocket client
5 | * Copyright(c) 2011 Einar Otto Stangvik
6 | * MIT Licensed
7 | */
8 |
9 | try {
10 | module.exports = require('bufferutil');
11 | } catch (e) {
12 | module.exports = require('./BufferUtil.fallback');
13 | }
14 |
--------------------------------------------------------------------------------
/src/v3/node_modules/ws/lib/ErrorCodes.js:
--------------------------------------------------------------------------------
1 | /*!
2 | * ws: a node.js websocket client
3 | * Copyright(c) 2011 Einar Otto Stangvik
4 | * MIT Licensed
5 | */
6 |
7 | module.exports = {
8 | isValidErrorCode: function(code) {
9 | return (code >= 1000 && code <= 1011 && code != 1004 && code != 1005 && code != 1006) ||
10 | (code >= 3000 && code <= 4999);
11 | },
12 | 1000: 'normal',
13 | 1001: 'going away',
14 | 1002: 'protocol error',
15 | 1003: 'unsupported data',
16 | 1004: 'reserved',
17 | 1005: 'reserved for extensions',
18 | 1006: 'reserved for extensions',
19 | 1007: 'inconsistent or invalid data',
20 | 1008: 'policy violation',
21 | 1009: 'message too big',
22 | 1010: 'extension handshake missing',
23 | 1011: 'an unexpected condition prevented the request from being fulfilled',
24 | };
--------------------------------------------------------------------------------
/src/v3/node_modules/ws/lib/Extensions.js:
--------------------------------------------------------------------------------
1 |
2 | var util = require('util');
3 |
4 | /**
5 | * Module exports.
6 | */
7 |
8 | exports.parse = parse;
9 | exports.format = format;
10 |
11 | /**
12 | * Parse extensions header value
13 | */
14 |
15 | function parse(value) {
16 | value = value || '';
17 |
18 | var extensions = {};
19 |
20 | value.split(',').forEach(function(v) {
21 | var params = v.split(';');
22 | var token = params.shift().trim();
23 | var paramsList = extensions[token] = extensions[token] || [];
24 | var parsedParams = {};
25 |
26 | params.forEach(function(param) {
27 | var parts = param.trim().split('=');
28 | var key = parts[0];
29 | var value = parts[1];
30 | if (typeof value === 'undefined') {
31 | value = true;
32 | } else {
33 | // unquote value
34 | if (value[0] === '"') {
35 | value = value.slice(1);
36 | }
37 | if (value[value.length - 1] === '"') {
38 | value = value.slice(0, value.length - 1);
39 | }
40 | }
41 | (parsedParams[key] = parsedParams[key] || []).push(value);
42 | });
43 |
44 | paramsList.push(parsedParams);
45 | });
46 |
47 | return extensions;
48 | }
49 |
50 | /**
51 | * Format extensions header value
52 | */
53 |
54 | function format(value) {
55 | return Object.keys(value).map(function(token) {
56 | var paramsList = value[token];
57 | if (!util.isArray(paramsList)) {
58 | paramsList = [paramsList];
59 | }
60 | return paramsList.map(function(params) {
61 | return [token].concat(Object.keys(params).map(function(k) {
62 | var p = params[k];
63 | if (!util.isArray(p)) p = [p];
64 | return p.map(function(v) {
65 | return v === true ? k : k + '=' + v;
66 | }).join('; ');
67 | })).join('; ');
68 | }).join(', ');
69 | }).join(', ');
70 | }
71 |
--------------------------------------------------------------------------------
/src/v3/node_modules/ws/lib/Validation.fallback.js:
--------------------------------------------------------------------------------
1 | /*!
2 | * ws: a node.js websocket client
3 | * Copyright(c) 2011 Einar Otto Stangvik
4 | * MIT Licensed
5 | */
6 |
7 | exports.Validation = {
8 | isValidUTF8: function(buffer) {
9 | return true;
10 | }
11 | };
12 |
--------------------------------------------------------------------------------
/src/v3/node_modules/ws/lib/Validation.js:
--------------------------------------------------------------------------------
1 | 'use strict';
2 |
3 | /*!
4 | * ws: a node.js websocket client
5 | * Copyright(c) 2011 Einar Otto Stangvik
6 | * MIT Licensed
7 | */
8 |
9 | try {
10 | module.exports = require('utf-8-validate');
11 | } catch (e) {
12 | module.exports = require('./Validation.fallback');
13 | }
14 |
--------------------------------------------------------------------------------
/src/v3/package.json:
--------------------------------------------------------------------------------
1 | {
2 | "name": "Horizontally-Scaling-Node.js-Websockets-Talk",
3 | "description": "Talk about horizontally scaling node.js and WebSockets given at Connect.Tech 2016 and Thunder Plains 2016.",
4 | "author": "James Simpson (http://goldfirestudios.com)",
5 | "repository": {
6 | "type": "git",
7 | "url": "git://github.com/goldfire/Horizontally-Scaling-Node.js-Websockets-Talk.git"
8 | },
9 | "dependencies": {
10 | "submono": "*",
11 | "ws": "*",
12 | "redis": "*"
13 | }
14 | }
--------------------------------------------------------------------------------
/src/v3/server.js:
--------------------------------------------------------------------------------
1 | var port = parseInt(process.argv[2], 10);
2 | var WebSocketServer = require('ws').Server;
3 | var wss = new WebSocketServer({port: port});
4 | var redis = require('redis');
5 | var pub = redis.createClient();
6 | var sub = redis.createClient();
7 |
8 | sub.subscribe('global');
9 | sub.on('message', function(channel, msg) {
10 | if (channel === 'global') {
11 | wss.clients.forEach(function(client) {
12 | client.send(msg);
13 | });
14 | }
15 | });
16 |
17 | wss.on('connection', function(ws) {
18 | ws.on('message', function(msg) {
19 | pub.publish('global', msg);
20 | });
21 | });
--------------------------------------------------------------------------------
/src/v4/haproxy.cfg:
--------------------------------------------------------------------------------
1 | frontend all
2 | bind 0.0.0.0:8000
3 | default_backend sockets
4 |
5 | backend sockets
6 | balance leastconn
7 | server srv1 127.0.0.1:2000 check
8 | server srv2 127.0.0.1:2001 check
--------------------------------------------------------------------------------
/src/v4/index.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 | Horizontally Scaling Node.js & Websockets Demo
7 |
8 |
9 |
10 |
11 |
12 |
Click or touch window to play.
13 |
14 |
15 |
16 |
17 |
18 |
19 |
--------------------------------------------------------------------------------
/src/v4/node_modules/double-ended-queue/.npmignore:
--------------------------------------------------------------------------------
1 | node_modules/*
2 | todo.txt
3 | npm-debug.log
4 | test/*
5 | benchmark/*
6 | browser/*
7 | src/*
8 | async
9 | sync
10 | mixed
11 | bench.json
12 | js/browser
13 | js/browser/*
14 | js/debug
15 | js/debug/*
16 | reader.js
17 | read.txt
18 | bench
19 | .editorconfig
20 | .jshintrc
21 | ast_passes.js
22 | mocharun.js
23 | throwaway.js
24 | throwaway.html
25 | deque.sublime-workspace
26 | deque.sublime-project
27 | changelog.js
28 | .travis.yml
29 | sauce_connect.log
30 | nodex64.exe
31 | bump.js
32 |
--------------------------------------------------------------------------------
/src/v4/node_modules/double-ended-queue/LICENSE:
--------------------------------------------------------------------------------
1 | Copyright (c) 2013 Petka Antonov
2 |
3 | Permission is hereby granted, free of charge, to any person obtaining a copy
4 | of this software and associated documentation files (the "Software"), to deal
5 | in the Software without restriction, including without limitation the rights
6 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
7 | copies of the Software, and to permit persons to whom the Software is
8 | furnished to do so, subject to the following conditions:
9 |
10 | The above copyright notice and this permission notice shall be included in
11 | all copies or substantial portions of the Software.
12 |
13 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
14 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
15 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
16 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
17 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
18 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
19 | THE SOFTWARE.
--------------------------------------------------------------------------------
/src/v4/node_modules/options/.npmignore:
--------------------------------------------------------------------------------
1 | npm-debug.log
2 | node_modules
3 | .*.swp
4 | .lock-*
5 | build/
6 |
7 | test
8 |
--------------------------------------------------------------------------------
/src/v4/node_modules/options/Makefile:
--------------------------------------------------------------------------------
1 | ALL_TESTS = $(shell find test/ -name '*.test.js')
2 |
3 | run-tests:
4 | @./node_modules/.bin/mocha \
5 | -t 2000 \
6 | $(TESTFLAGS) \
7 | $(TESTS)
8 |
9 | test:
10 | @$(MAKE) NODE_PATH=lib TESTS="$(ALL_TESTS)" run-tests
11 |
12 | .PHONY: test
13 |
--------------------------------------------------------------------------------
/src/v4/node_modules/options/README.md:
--------------------------------------------------------------------------------
1 | # options.js #
2 |
3 | A very light-weight in-code option parsers for node.js.
4 |
5 | ## Usage ##
6 |
7 | ``` js
8 | var Options = require("options");
9 |
10 | // Create an Options object
11 | function foo(options) {
12 | var default_options = {
13 | foo : "bar"
14 | };
15 |
16 | // Create an option object with default value
17 | var opts = new Options(default_options);
18 |
19 | // Merge options
20 | opts = opts.merge(options);
21 |
22 | // Reset to default value
23 | opts.reset();
24 |
25 | // Copy selected attributes out
26 | var seled_att = opts.copy("foo");
27 |
28 | // Read json options from a file.
29 | opts.read("options.file"); // Sync
30 | opts.read("options.file", function(err){ // Async
31 | if(err){ // If error occurs
32 | console.log("File error.");
33 | }else{
34 | // No error
35 | }
36 | });
37 |
38 | // Attributes defined or not
39 | opts.isDefinedAndNonNull("foobar");
40 | opts.isDefined("foobar");
41 | }
42 |
43 | ```
44 |
45 |
46 | ## License ##
47 |
48 | (The MIT License)
49 |
50 | Copyright (c) 2012 Einar Otto Stangvik <einaros@gmail.com>
51 |
52 | Permission is hereby granted, free of charge, to any person obtaining
53 | a copy of this software and associated documentation files (the
54 | 'Software'), to deal in the Software without restriction, including
55 | without limitation the rights to use, copy, modify, merge, publish,
56 | distribute, sublicense, and/or sell copies of the Software, and to
57 | permit persons to whom the Software is furnished to do so, subject to
58 | the following conditions:
59 |
60 | The above copyright notice and this permission notice shall be
61 | included in all copies or substantial portions of the Software.
62 |
63 | THE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND,
64 | EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
65 | MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
66 | IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
67 | CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
68 | TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
69 | SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
70 |
--------------------------------------------------------------------------------
/src/v4/node_modules/redis-commands/.npmignore:
--------------------------------------------------------------------------------
1 | # Logs
2 | logs
3 | *.log
4 |
5 | # Runtime data
6 | pids
7 | *.pid
8 | *.seed
9 | *.rdb
10 |
11 | # Directory for instrumented libs generated by jscoverage/JSCover
12 | lib-cov
13 |
14 | # Coverage directory used by tools like istanbul
15 | coverage
16 |
17 | # Grunt intermediate storage (http://gruntjs.com/creating-plugins#storing-task-files)
18 | .grunt
19 |
20 | # Compiled binary addons (http://nodejs.org/api/addons.html)
21 | build/Release
22 |
23 | # Dependency directory
24 | # Commenting this out is preferred by some people, see
25 | # https://www.npmjs.org/doc/misc/npm-faq.html#should-i-check-my-node_modules-folder-into-git-
26 | node_modules
27 |
28 | # Users Environment Variables
29 | .lock-wscript
30 |
--------------------------------------------------------------------------------
/src/v4/node_modules/redis-commands/.travis.yml:
--------------------------------------------------------------------------------
1 | language: node_js
2 | sudo: false
3 | node_js:
4 | - "0.10"
5 | - "0.12"
6 | - "4"
7 | - "5"
8 | after_success:
9 | - CODECLIMATE_REPO_TOKEN=b57723fafcf0516f275d6b380cd506fd082ea88d86507eb82c8abd489b9b9a09 node ./node_modules/.bin/codeclimate-test-reporter < coverage/lcov.info
10 |
--------------------------------------------------------------------------------
/src/v4/node_modules/redis-commands/LICENSE:
--------------------------------------------------------------------------------
1 | The MIT License (MIT)
2 |
3 | Copyright (c) 2015 NodeRedis
4 |
5 | Permission is hereby granted, free of charge, to any person obtaining a copy
6 | of this software and associated documentation files (the "Software"), to deal
7 | in the Software without restriction, including without limitation the rights
8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9 | copies of the Software, and to permit persons to whom the Software is
10 | furnished to do so, subject to the following conditions:
11 |
12 | The above copyright notice and this permission notice shall be included in all
13 | copies or substantial portions of the Software.
14 |
15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21 | SOFTWARE.
22 |
23 |
--------------------------------------------------------------------------------
/src/v4/node_modules/redis-commands/README.md:
--------------------------------------------------------------------------------
1 | # Redis Commands
2 |
3 | [](https://travis-ci.org/NodeRedis/redis-commands)
4 | [](https://codeclimate.com/github/NodeRedis/redis-commands)
5 | [](https://codeclimate.com/github/NodeRedis/redis-commands/coverage)
6 |
7 | This module exports all the commands that Redis supports.
8 |
9 | ## Install
10 |
11 | ```shell
12 | $ npm install redis-commands
13 | ```
14 |
15 | ## Usage
16 |
17 | ```javascript
18 | var commands = require('redis-commands');
19 | ```
20 |
21 | `.list` is an array contains all the lowercased commands:
22 |
23 | ```javascript
24 | commands.list.forEach(function (command) {
25 | console.log(command);
26 | });
27 | ```
28 |
29 | `.exists()` is used to check if the command exists:
30 |
31 | ```javascript
32 | commands.exists('set') // true
33 | commands.exists('other-command') // false
34 | ```
35 |
36 | `.hasFlag()` is used to check if the command has the flag:
37 |
38 | ```javascript
39 | commands.hasFlag('set', 'readonly') // false
40 | ```
41 |
42 | `.getKeyIndexes()` is used to get the indexes of keys in the command arguments:
43 |
44 | ```javascript
45 | commands.getKeyIndexes('set', ['key', 'value']) // [0]
46 | commands.getKeyIndexes('mget', ['key1', 'key2']) // [0, 1]
47 | ```
48 |
49 | ## Acknowledgment
50 |
51 | Thank [@Yuan Chuan](https://github.com/yuanchuan) for the package name. The original redis-commands is renamed to [@yuanchuan/redis-commands](https://www.npmjs.com/package/@yuanchuan/redis-commands).
52 |
--------------------------------------------------------------------------------
/src/v4/node_modules/redis-commands/changelog.md:
--------------------------------------------------------------------------------
1 | ## v.1.2.0 - 21 Apr, 2016
2 |
3 | Features
4 |
5 | - Added support for `MIGRATE [...] KEYS key1, key2` (Redis >= v.3.0.6)
6 | - Added build sanity check for unhandled commands with moveable keys
7 | - Rebuild the commands with the newest unstable release
8 | - Improved performance of .getKeyIndexes()
9 |
10 | Bugfix
11 |
12 | - Fixed command command returning the wrong arity due to a Redis bug
13 | - Fixed brpop command returning the wrong keystop due to a Redis bug
14 |
15 | ## v.1.1.0 - 09 Feb, 2016
16 |
17 | Features
18 |
19 | - Added .exists() to check for command existence
20 | - Improved performance of .hasFlag()
21 |
--------------------------------------------------------------------------------
/src/v4/node_modules/redis-commands/tools/build.js:
--------------------------------------------------------------------------------
1 | var fs = require('fs');
2 | var path = require('path');
3 | var stringify = require('json-stable-stringify');
4 | var commandPath = path.join(__dirname, '..', 'commands.json');
5 | var redisCommands = require('../');
6 |
7 | var Redis = require('ioredis');
8 | var redis = new Redis(process.env.REDIS_URI);
9 |
10 | redis.command().then(function (res) {
11 | redis.disconnect();
12 |
13 | // Find all special handled cases
14 | var movableKeys = String(redisCommands.getKeyIndexes).match(/case '[a-z-]+':/g).map(function (entry) {
15 | return entry.replace(/^case \'|\':$/g, '');
16 | });
17 |
18 | var commands = res.reduce(function (prev, current) {
19 | var currentCommandPos = movableKeys.indexOf(current[0]);
20 | if (currentCommandPos !== -1 && current[2].indexOf('movablekeys') !== -1) {
21 | movableKeys.splice(currentCommandPos, 1);
22 | }
23 | // https://github.com/antirez/redis/issues/2598
24 | if (current[0] === 'brpop' && current[4] === 1) {
25 | current[4] = -2;
26 | }
27 | prev[current[0]] = {
28 | arity: current[1] || 1, // https://github.com/antirez/redis/pull/2986
29 | flags: current[2],
30 | keyStart: current[3],
31 | keyStop: current[4],
32 | step: current[5]
33 | };
34 | return prev;
35 | }, {});
36 |
37 | // Future proof. Redis might implement this at some point
38 | // https://github.com/antirez/redis/pull/2982
39 | if (!commands.quit) {
40 | commands.quit = {
41 | arity: 1,
42 | flags: [
43 | 'loading',
44 | 'stale',
45 | 'readonly'
46 | ],
47 | keyStart: 0,
48 | keyStop: 0,
49 | step: 0
50 | }
51 | }
52 |
53 | if (movableKeys.length !== 0) {
54 | throw new Error('Not all commands (\'' + movableKeys.join('\', \'') + '\') with the "movablekeys" flag are handled in the code');
55 | }
56 |
57 | // Use json-stable-stringify instead fo JSON.stringify
58 | // for easier diffing
59 | var content = stringify(commands, { space: ' ' });
60 |
61 | fs.writeFile(commandPath, content);
62 | });
63 |
--------------------------------------------------------------------------------
/src/v4/node_modules/redis-parser/.codeclimate.yml:
--------------------------------------------------------------------------------
1 | languages:
2 | JavaScript: true
3 | exclude_paths:
4 | - "benchmark/index.js"
5 | - "benchmark/old/javascript.js"
6 | - "test/parsers.spec.js"
7 |
--------------------------------------------------------------------------------
/src/v4/node_modules/redis-parser/.npmignore:
--------------------------------------------------------------------------------
1 | # IntelliJ project files
2 | .idea
3 | *.iml
4 | out
5 | gen
6 |
7 | # Unrelevant files and folders
8 | benchmark
9 | coverage
10 | test
11 | .travis.yml
12 | .gitignore
13 |
--------------------------------------------------------------------------------
/src/v4/node_modules/redis-parser/LICENSE:
--------------------------------------------------------------------------------
1 | The MIT License (MIT)
2 |
3 | Copyright (c) 2015 NodeRedis
4 |
5 | Permission is hereby granted, free of charge, to any person obtaining a copy
6 | of this software and associated documentation files (the "Software"), to deal
7 | in the Software without restriction, including without limitation the rights
8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9 | copies of the Software, and to permit persons to whom the Software is
10 | furnished to do so, subject to the following conditions:
11 |
12 | The above copyright notice and this permission notice shall be included in all
13 | copies or substantial portions of the Software.
14 |
15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21 | SOFTWARE.
22 |
23 |
--------------------------------------------------------------------------------
/src/v4/node_modules/redis-parser/changelog.md:
--------------------------------------------------------------------------------
1 | ## v.2.0.4 - 21 Jul, 2016
2 |
3 | Bugfixes
4 |
5 | - Fixed multi byte characters getting corrupted
6 |
7 | ## v.2.0.3 - 17 Jun, 2016
8 |
9 | Bugfixes
10 |
11 | - Fixed parser not working with huge buffers (e.g. 300 MB)
12 |
13 | ## v.2.0.2 - 08 Jun, 2016
14 |
15 | Bugfixes
16 |
17 | - Fixed parser with returnBuffers option returning corrupted data
18 |
19 | ## v.2.0.1 - 04 Jun, 2016
20 |
21 | Bugfixes
22 |
23 | - Fixed multiple parsers working concurrently resulting in faulty data in some cases
24 |
25 | ## v.2.0.0 - 29 May, 2016
26 |
27 | The javascript parser got completly rewritten by [Michael Diarmid](https://github.com/Salakar) and [Ruben Bridgewater](https://github.com/BridgeAR) and is now a lot faster than the hiredis parser.
28 | Therefore the hiredis parser was deprecated and should only be used for testing purposes and benchmarking comparison.
29 |
30 | All Errors returned by the parser are from now on of class ReplyError
31 |
32 | Features
33 |
34 | - Improved performance by up to 15x as fast as before
35 | - Improved options validation
36 | - Added ReplyError Class
37 | - Added parser benchmark
38 | - Switched default parser from hiredis to JS, no matter if hiredis is installed or not
39 |
40 | Removed
41 |
42 | - Deprecated hiredis support
43 |
44 | ## v.1.3.0 - 27 Mar, 2016
45 |
46 | Features
47 |
48 | - Added `auto` as parser name option to check what parser is available
49 | - Non existing requested parsers falls back into auto mode instead of always choosing the JS parser
50 |
51 | ## v.1.2.0 - 27 Mar, 2016
52 |
53 | Features
54 |
55 | - Added `stringNumbers` option to make sure all numbers are returned as string instead of a js number for precision
56 | - The parser is from now on going to print warnings if a parser is explicitly requested that does not exist and gracefully chooses the JS parser
57 |
58 | ## v.1.1.0 - 26 Jan, 2016
59 |
60 | Features
61 |
62 | - The parser is from now on going to reset itself on protocol errors
63 |
--------------------------------------------------------------------------------
/src/v4/node_modules/redis-parser/index.js:
--------------------------------------------------------------------------------
1 | 'use strict'
2 |
3 | module.exports = require('./lib/parser')
4 | module.exports.ReplyError = require('./lib/replyError')
5 |
--------------------------------------------------------------------------------
/src/v4/node_modules/redis-parser/lib/hiredis.js:
--------------------------------------------------------------------------------
1 | 'use strict'
2 |
3 | var hiredis = require('hiredis')
4 | var ReplyError = require('../lib/replyError')
5 |
6 | /**
7 | * Parse data
8 | * @param parser
9 | * @returns {*}
10 | */
11 | function parseData (parser) {
12 | try {
13 | return parser.reader.get()
14 | } catch (err) {
15 | // Protocol errors land here
16 | // Reset the parser. Otherwise new commands can't be processed properly
17 | parser.reader = new hiredis.Reader(parser.options)
18 | parser.returnFatalError(new ReplyError(err.message))
19 | }
20 | }
21 |
22 | /**
23 | * Hiredis Parser
24 | * @param options
25 | * @constructor
26 | */
27 | function HiredisReplyParser (options) {
28 | this.returnError = options.returnError
29 | this.returnFatalError = options.returnFatalError || options.returnError
30 | this.returnReply = options.returnReply
31 | this.name = 'hiredis'
32 | this.options = {
33 | return_buffers: !!options.returnBuffers
34 | }
35 | this.reader = new hiredis.Reader(this.options)
36 | }
37 |
38 | HiredisReplyParser.prototype.execute = function (data) {
39 | this.reader.feed(data)
40 | var reply = parseData(this)
41 |
42 | while (reply !== undefined) {
43 | if (reply && reply.name === 'Error') {
44 | this.returnError(new ReplyError(reply.message))
45 | } else {
46 | this.returnReply(reply)
47 | }
48 | reply = parseData(this)
49 | }
50 | }
51 |
52 | module.exports = HiredisReplyParser
53 |
--------------------------------------------------------------------------------
/src/v4/node_modules/redis-parser/lib/replyError.js:
--------------------------------------------------------------------------------
1 | 'use strict'
2 |
3 | var util = require('util')
4 |
5 | function ReplyError (message) {
6 | var limit = Error.stackTraceLimit
7 | Error.stackTraceLimit = 2
8 | Error.captureStackTrace(this, this.constructor)
9 | Error.stackTraceLimit = limit
10 | Object.defineProperty(this, 'message', {
11 | value: message || '',
12 | writable: true
13 | })
14 | }
15 |
16 | util.inherits(ReplyError, Error)
17 |
18 | Object.defineProperty(ReplyError.prototype, 'name', {
19 | value: 'ReplyError',
20 | writable: true
21 | })
22 |
23 | module.exports = ReplyError
24 |
--------------------------------------------------------------------------------
/src/v4/node_modules/redis/.eslintignore:
--------------------------------------------------------------------------------
1 | node_modules/**
2 | coverage/**
3 | **.md
4 | **.log
5 |
--------------------------------------------------------------------------------
/src/v4/node_modules/redis/.github/ISSUE_TEMPLATE.md:
--------------------------------------------------------------------------------
1 | _Thanks for wanting to report an issue you've found in node_redis. Please delete
2 | this text and fill in the template below. Please note that the issue tracker is only
3 | for bug reports or feature requests. If you have a question, please ask that on [gitter].
4 | If unsure about something, just do as best as you're able._
5 |
6 | _Note that it will be much easier to fix the issue if a test case that reproduces
7 | the problem is provided. It is of course not always possible to reduce your code
8 | to a small test case, but it's highly appreciated to have as much data as possible.
9 | Thank you!_
10 |
11 | * **Version**: What node_redis and what redis version is the issue happening on?
12 | * **Platform**: What platform / version? (For example Node.js 0.10 or Node.js 5.7.0 on Windows 7 / Ubuntu 15.10 / Azure)
13 | * **Description**: Description of your issue, stack traces from errors and code that reproduces the issue
14 |
15 | [gitter]: https://gitter.im/NodeRedis/node_redis?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge
--------------------------------------------------------------------------------
/src/v4/node_modules/redis/.github/PULL_REQUEST_TEMPLATE.md:
--------------------------------------------------------------------------------
1 | ### Pull Request check-list
2 |
3 | _Please make sure to review and check all of these items:_
4 |
5 | - [ ] Does `npm test` pass with this change (including linting)?
6 | - [ ] Is the new or changed code fully tested?
7 | - [ ] Is a documentation update included (if this change modifies existing APIs, or introduces new ones)?
8 |
9 | _NOTE: these things are not required to open a PR and can be done
10 | afterwards / while the PR is open._
11 |
12 | ### Description of change
13 |
14 | _Please provide a description of the change here._
--------------------------------------------------------------------------------
/src/v4/node_modules/redis/.npmignore:
--------------------------------------------------------------------------------
1 | examples/
2 | benchmarks/
3 | test/
4 | .nyc_output/
5 | coverage/
6 | .tern-port
7 | *.log
8 | *.rdb
9 | *.out
10 | *.yml
11 |
--------------------------------------------------------------------------------
/src/v4/node_modules/redis/LICENSE:
--------------------------------------------------------------------------------
1 | LICENSE - "MIT License"
2 |
3 | Copyright (c) 2016 by NodeRedis
4 |
5 | Permission is hereby granted, free of charge, to any person
6 | obtaining a copy of this software and associated documentation
7 | files (the "Software"), to deal in the Software without
8 | restriction, including without limitation the rights to use,
9 | copy, modify, merge, publish, distribute, sublicense, and/or sell
10 | copies of the Software, and to permit persons to whom the
11 | Software is furnished to do so, subject to the following
12 | conditions:
13 |
14 | The above copyright notice and this permission notice shall be
15 | included in all copies or substantial portions of the Software.
16 |
17 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
18 | EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
19 | OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
20 | NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
21 | HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
22 | WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
23 | FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
24 | OTHER DEALINGS IN THE SOFTWARE.
--------------------------------------------------------------------------------
/src/v4/node_modules/redis/lib/command.js:
--------------------------------------------------------------------------------
1 | 'use strict';
2 |
3 | var betterStackTraces = /development/i.test(process.env.NODE_ENV) || /\bredis\b/i.test(process.env.NODE_DEBUG);
4 |
5 | function Command (command, args, callback, call_on_write) {
6 | this.command = command;
7 | this.args = args;
8 | this.buffer_args = false;
9 | this.callback = callback;
10 | this.call_on_write = call_on_write;
11 | if (betterStackTraces) {
12 | this.error = new Error();
13 | }
14 | }
15 |
16 | module.exports = Command;
17 |
--------------------------------------------------------------------------------
/src/v4/node_modules/redis/lib/customErrors.js:
--------------------------------------------------------------------------------
1 | 'use strict';
2 |
3 | var util = require('util');
4 |
5 | function AbortError (obj) {
6 | Error.captureStackTrace(this, this.constructor);
7 | Object.defineProperty(this, 'message', {
8 | value: obj.message || '',
9 | configurable: true,
10 | writable: true
11 | });
12 | for (var keys = Object.keys(obj), key = keys.pop(); key; key = keys.pop()) {
13 | this[key] = obj[key];
14 | }
15 | }
16 |
17 | function AggregateError (obj) {
18 | Error.captureStackTrace(this, this.constructor);
19 | Object.defineProperty(this, 'message', {
20 | value: obj.message || '',
21 | configurable: true,
22 | writable: true
23 | });
24 | for (var keys = Object.keys(obj), key = keys.pop(); key; key = keys.pop()) {
25 | this[key] = obj[key];
26 | }
27 | }
28 |
29 | util.inherits(AbortError, Error);
30 | util.inherits(AggregateError, AbortError);
31 |
32 | Object.defineProperty(AbortError.prototype, 'name', {
33 | value: 'AbortError',
34 | // configurable: true,
35 | writable: true
36 | });
37 | Object.defineProperty(AggregateError.prototype, 'name', {
38 | value: 'AggregateError',
39 | // configurable: true,
40 | writable: true
41 | });
42 |
43 | module.exports = {
44 | AbortError: AbortError,
45 | AggregateError: AggregateError
46 | };
47 |
--------------------------------------------------------------------------------
/src/v4/node_modules/redis/lib/debug.js:
--------------------------------------------------------------------------------
1 | 'use strict';
2 |
3 | var index = require('../');
4 |
5 | function debug () {
6 | if (index.debug_mode) {
7 | console.error.apply(null, arguments);
8 | }
9 | }
10 |
11 | module.exports = debug;
12 |
--------------------------------------------------------------------------------
/src/v4/node_modules/submono/LICENSE:
--------------------------------------------------------------------------------
1 | The MIT License (MIT)
2 |
3 | Copyright (c) 2015 Benji Kay
4 |
5 | Permission is hereby granted, free of charge, to any person obtaining a copy
6 | of this software and associated documentation files (the "Software"), to deal
7 | in the Software without restriction, including without limitation the rights
8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9 | copies of the Software, and to permit persons to whom the Software is
10 | furnished to do so, subject to the following conditions:
11 |
12 | The above copyright notice and this permission notice shall be included in all
13 | copies or substantial portions of the Software.
14 |
15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21 | SOFTWARE.
22 |
--------------------------------------------------------------------------------
/src/v4/node_modules/submono/README.md:
--------------------------------------------------------------------------------
1 | # submono
2 | A Web Audio subtractive, monophonic synthesizer. Looking for polyphony? Check out [subpoly](https://github.com/okaybenji/subpoly)!
3 |
4 | ### Create a synth.
5 | ```
6 | var audioCtx = new AudioContext();
7 | var synth = new Monosynth(audioCtx);
8 | ```
9 |
10 | ### Play a note.
11 | `synth.start();`
12 |
13 | ### Stop playing.
14 | `synth.stop();`
15 |
16 | ### Use methods to access pitch and waveform...
17 | ```
18 | synth.pitch(440); // in hertz
19 | console.log(synth.waveform()); // 'sawtooth' (or sine, triangle, square)
20 | ```
21 |
22 | ### ...get or set any other properties directly.
23 | ```
24 | synth.maxGain = 0.5; // out of 1
25 | synth.attack = 1.0; // in seconds
26 | ```
27 |
28 | ### Configure any or all the properties on initialization.
29 | ```
30 | var config = {
31 | waveform: 'sawtooth', // or sine, triangle, square
32 | pitch: 440, // in hertz
33 | maxGain: 0.5, // out of 1
34 | attack: 0.1, // in seconds
35 | decay: 0.0, // in seconds
36 | sustain: 1.0, // out of 1
37 | release: 0.8, // in seconds
38 | cutoff: {
39 | maxFrequency: 7500, // in hertz
40 | attack: 0.1, // in seconds
41 | decay: 2.5, // in seconds
42 | sustain: 0.2 // 0-5; maxFrequency multiplied by this
43 | }
44 | };
45 |
46 | var synth = new Monosynth(audioCtx, config);
47 | ```
48 |
49 | ### Demo
50 | [Tiles: a musical, multiplayer web toy](http://okaybenji.github.io/tiles-client/)
51 |
--------------------------------------------------------------------------------
/src/v4/node_modules/ultron/.npmignore:
--------------------------------------------------------------------------------
1 | node_modules
2 | coverage
3 | .tern-port
4 |
--------------------------------------------------------------------------------
/src/v4/node_modules/ultron/.travis.yml:
--------------------------------------------------------------------------------
1 | sudo: false
2 | language: node_js
3 | node_js:
4 | - "0.12"
5 | - "0.10"
6 | - "0.8"
7 | - "iojs"
8 | before_install:
9 | - 'if [ "${TRAVIS_NODE_VERSION}" == "0.8" ]; then npm install -g npm@2.11.1; fi'
10 | script:
11 | - "npm run test-travis"
12 | after_script:
13 | - "npm install coveralls@2.11.x && cat coverage/lcov.info | coveralls"
14 | matrix:
15 | fast_finish: true
16 | notifications:
17 | irc:
18 | channels:
19 | - "irc.freenode.org#unshift"
20 | on_success: change
21 | on_failure: change
22 |
--------------------------------------------------------------------------------
/src/v4/node_modules/ultron/LICENSE:
--------------------------------------------------------------------------------
1 | The MIT License (MIT)
2 |
3 | Copyright (c) 2015 Unshift.io, Arnout Kazemier, the Contributors.
4 |
5 | Permission is hereby granted, free of charge, to any person obtaining a copy
6 | of this software and associated documentation files (the "Software"), to deal
7 | in the Software without restriction, including without limitation the rights
8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9 | copies of the Software, and to permit persons to whom the Software is
10 | furnished to do so, subject to the following conditions:
11 |
12 | The above copyright notice and this permission notice shall be included in all
13 | copies or substantial portions of the Software.
14 |
15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21 | SOFTWARE.
22 |
23 |
--------------------------------------------------------------------------------
/src/v4/node_modules/ws/.npmignore:
--------------------------------------------------------------------------------
1 | npm-debug.log
2 | node_modules
3 | .*.swp
4 | .lock-*
5 | build
6 |
7 | bench
8 | doc
9 | examples
10 | test
11 |
12 |
--------------------------------------------------------------------------------
/src/v4/node_modules/ws/.travis.yml:
--------------------------------------------------------------------------------
1 | language: node_js
2 | sudo: false
3 | node_js:
4 | - "5"
5 | - "4"
6 | - "0.12"
7 | addons:
8 | apt:
9 | sources:
10 | - ubuntu-toolchain-r-test
11 | packages:
12 | - gcc-4.9
13 | - g++-4.9
14 | before_install:
15 | - export CC="gcc-4.9" CXX="g++-4.9"
16 |
--------------------------------------------------------------------------------
/src/v4/node_modules/ws/Makefile:
--------------------------------------------------------------------------------
1 | ALL_TESTS = $(shell find test/ -name '*.test.js')
2 | ALL_INTEGRATION = $(shell find test/ -name '*.integration.js')
3 |
4 | run-tests:
5 | @./node_modules/.bin/mocha \
6 | -t 5000 \
7 | -s 2400 \
8 | $(TESTFLAGS) \
9 | $(TESTS)
10 |
11 | run-integrationtests:
12 | @./node_modules/.bin/mocha \
13 | -t 5000 \
14 | -s 6000 \
15 | $(TESTFLAGS) \
16 | $(TESTS)
17 |
18 | run-coverage:
19 | @./node_modules/.bin/istanbul cover --report html \
20 | ./node_modules/.bin/_mocha -- \
21 | -t 5000 \
22 | -s 6000 \
23 | $(TESTFLAGS) \
24 | $(TESTS)
25 |
26 | test:
27 | @$(MAKE) NODE_TLS_REJECT_UNAUTHORIZED=0 NODE_PATH=lib TESTS="$(ALL_TESTS)" run-tests
28 |
29 | integrationtest:
30 | @$(MAKE) NODE_TLS_REJECT_UNAUTHORIZED=0 NODE_PATH=lib TESTS="$(ALL_INTEGRATION)" run-integrationtests
31 |
32 | coverage:
33 | @$(MAKE) NODE_TLS_REJECT_UNAUTHORIZED=0 NODE_PATH=lib TESTS="$(ALL_TESTS)" run-coverage
34 |
35 | benchmark:
36 | @node bench/sender.benchmark.js
37 | @node bench/parser.benchmark.js
38 |
39 | autobahn:
40 | @NODE_PATH=lib node test/autobahn.js
41 |
42 | autobahn-server:
43 | @NODE_PATH=lib node test/autobahn-server.js
44 |
45 | .PHONY: test coverage
46 |
--------------------------------------------------------------------------------
/src/v4/node_modules/ws/SECURITY.md:
--------------------------------------------------------------------------------
1 | # Security Guidelines
2 |
3 | Please contact us directly at **security@3rd-Eden.com** for any bug that might
4 | impact the security of this project. Please prefix the subject of your email
5 | with `[security]` in lowercase and square brackets. Our email filters will
6 | automatically prevent these messages from being moved to our spam box.
7 |
8 | You will receive an acknowledgement of your report within **24 hours**.
9 |
10 | All emails that do not include security vulnerabilities will be removed and
11 | blocked instantly.
12 |
13 | ## Exceptions
14 |
15 | If you do not receive an acknowledgement within the said time frame please give
16 | us the benefit of the doubt as it's possible that we haven't seen it yet. In
17 | this case please send us a message **without details** using one of the
18 | following methods:
19 |
20 | - Contact the lead developers of this project on their personal e-mails. You
21 | can find the e-mails in the git logs, for example using the following command:
22 | `git --no-pager show -s --format='%an <%ae>' ` where `` is the
23 | SHA1 of their latest commit in the project.
24 | - Create a GitHub issue stating contact details and the severity of the issue.
25 |
26 | Once we have acknowledged receipt of your report and confirmed the bug
27 | ourselves we will work with you to fix the vulnerability and publicly acknowledge
28 | your responsible disclosure, if you wish. In addition to that we will report
29 | all vulnerabilities to the [Node Security Project](https://nodesecurity.io/).
30 |
31 | ## History
32 |
33 | 04 Jan 2016: [Buffer vulnerablity](https://github.com/websockets/ws/releases/tag/1.0.1)
34 |
--------------------------------------------------------------------------------
/src/v4/node_modules/ws/index.js:
--------------------------------------------------------------------------------
1 | 'use strict';
2 |
3 | /*!
4 | * ws: a node.js websocket client
5 | * Copyright(c) 2011 Einar Otto Stangvik
6 | * MIT Licensed
7 | */
8 |
9 | var WS = module.exports = require('./lib/WebSocket');
10 |
11 | WS.Server = require('./lib/WebSocketServer');
12 | WS.Sender = require('./lib/Sender');
13 | WS.Receiver = require('./lib/Receiver');
14 |
15 | /**
16 | * Create a new WebSocket server.
17 | *
18 | * @param {Object} options Server options
19 | * @param {Function} fn Optional connection listener.
20 | * @returns {WS.Server}
21 | * @api public
22 | */
23 | WS.createServer = function createServer(options, fn) {
24 | var server = new WS.Server(options);
25 |
26 | if (typeof fn === 'function') {
27 | server.on('connection', fn);
28 | }
29 |
30 | return server;
31 | };
32 |
33 | /**
34 | * Create a new WebSocket connection.
35 | *
36 | * @param {String} address The URL/address we need to connect to.
37 | * @param {Function} fn Open listener.
38 | * @returns {WS}
39 | * @api public
40 | */
41 | WS.connect = WS.createConnection = function connect(address, fn) {
42 | var client = new WS(address);
43 |
44 | if (typeof fn === 'function') {
45 | client.on('open', fn);
46 | }
47 |
48 | return client;
49 | };
50 |
--------------------------------------------------------------------------------
/src/v4/node_modules/ws/lib/BufferPool.js:
--------------------------------------------------------------------------------
1 | /*!
2 | * ws: a node.js websocket client
3 | * Copyright(c) 2011 Einar Otto Stangvik
4 | * MIT Licensed
5 | */
6 |
7 | var util = require('util');
8 |
9 | function BufferPool(initialSize, growStrategy, shrinkStrategy) {
10 | if (this instanceof BufferPool === false) {
11 | throw new TypeError("Classes can't be function-called");
12 | }
13 |
14 | if (typeof initialSize === 'function') {
15 | shrinkStrategy = growStrategy;
16 | growStrategy = initialSize;
17 | initialSize = 0;
18 | }
19 | else if (typeof initialSize === 'undefined') {
20 | initialSize = 0;
21 | }
22 | this._growStrategy = (growStrategy || function(db, size) {
23 | return db.used + size;
24 | }).bind(null, this);
25 | this._shrinkStrategy = (shrinkStrategy || function(db) {
26 | return initialSize;
27 | }).bind(null, this);
28 | this._buffer = initialSize ? new Buffer(initialSize) : null;
29 | this._offset = 0;
30 | this._used = 0;
31 | this._changeFactor = 0;
32 | this.__defineGetter__('size', function(){
33 | return this._buffer == null ? 0 : this._buffer.length;
34 | });
35 | this.__defineGetter__('used', function(){
36 | return this._used;
37 | });
38 | }
39 |
40 | BufferPool.prototype.get = function(length) {
41 | if (this._buffer == null || this._offset + length > this._buffer.length) {
42 | var newBuf = new Buffer(this._growStrategy(length));
43 | this._buffer = newBuf;
44 | this._offset = 0;
45 | }
46 | this._used += length;
47 | var buf = this._buffer.slice(this._offset, this._offset + length);
48 | this._offset += length;
49 | return buf;
50 | }
51 |
52 | BufferPool.prototype.reset = function(forceNewBuffer) {
53 | var len = this._shrinkStrategy();
54 | if (len < this.size) this._changeFactor -= 1;
55 | if (forceNewBuffer || this._changeFactor < -2) {
56 | this._changeFactor = 0;
57 | this._buffer = len ? new Buffer(len) : null;
58 | }
59 | this._offset = 0;
60 | this._used = 0;
61 | }
62 |
63 | module.exports = BufferPool;
64 |
--------------------------------------------------------------------------------
/src/v4/node_modules/ws/lib/BufferUtil.fallback.js:
--------------------------------------------------------------------------------
1 | /*!
2 | * ws: a node.js websocket client
3 | * Copyright(c) 2011 Einar Otto Stangvik
4 | * MIT Licensed
5 | */
6 |
7 | exports.BufferUtil = {
8 | merge: function(mergedBuffer, buffers) {
9 | var offset = 0;
10 | for (var i = 0, l = buffers.length; i < l; ++i) {
11 | var buf = buffers[i];
12 | buf.copy(mergedBuffer, offset);
13 | offset += buf.length;
14 | }
15 | },
16 | mask: function(source, mask, output, offset, length) {
17 | var maskNum = mask.readUInt32LE(0, true);
18 | var i = 0;
19 | for (; i < length - 3; i += 4) {
20 | var num = maskNum ^ source.readUInt32LE(i, true);
21 | if (num < 0) num = 4294967296 + num;
22 | output.writeUInt32LE(num, offset + i, true);
23 | }
24 | switch (length % 4) {
25 | case 3: output[offset + i + 2] = source[i + 2] ^ mask[2];
26 | case 2: output[offset + i + 1] = source[i + 1] ^ mask[1];
27 | case 1: output[offset + i] = source[i] ^ mask[0];
28 | case 0:;
29 | }
30 | },
31 | unmask: function(data, mask) {
32 | var maskNum = mask.readUInt32LE(0, true);
33 | var length = data.length;
34 | var i = 0;
35 | for (; i < length - 3; i += 4) {
36 | var num = maskNum ^ data.readUInt32LE(i, true);
37 | if (num < 0) num = 4294967296 + num;
38 | data.writeUInt32LE(num, i, true);
39 | }
40 | switch (length % 4) {
41 | case 3: data[i + 2] = data[i + 2] ^ mask[2];
42 | case 2: data[i + 1] = data[i + 1] ^ mask[1];
43 | case 1: data[i] = data[i] ^ mask[0];
44 | case 0:;
45 | }
46 | }
47 | }
48 |
--------------------------------------------------------------------------------
/src/v4/node_modules/ws/lib/BufferUtil.js:
--------------------------------------------------------------------------------
1 | 'use strict';
2 |
3 | /*!
4 | * ws: a node.js websocket client
5 | * Copyright(c) 2011 Einar Otto Stangvik
6 | * MIT Licensed
7 | */
8 |
9 | try {
10 | module.exports = require('bufferutil');
11 | } catch (e) {
12 | module.exports = require('./BufferUtil.fallback');
13 | }
14 |
--------------------------------------------------------------------------------
/src/v4/node_modules/ws/lib/ErrorCodes.js:
--------------------------------------------------------------------------------
1 | /*!
2 | * ws: a node.js websocket client
3 | * Copyright(c) 2011 Einar Otto Stangvik
4 | * MIT Licensed
5 | */
6 |
7 | module.exports = {
8 | isValidErrorCode: function(code) {
9 | return (code >= 1000 && code <= 1011 && code != 1004 && code != 1005 && code != 1006) ||
10 | (code >= 3000 && code <= 4999);
11 | },
12 | 1000: 'normal',
13 | 1001: 'going away',
14 | 1002: 'protocol error',
15 | 1003: 'unsupported data',
16 | 1004: 'reserved',
17 | 1005: 'reserved for extensions',
18 | 1006: 'reserved for extensions',
19 | 1007: 'inconsistent or invalid data',
20 | 1008: 'policy violation',
21 | 1009: 'message too big',
22 | 1010: 'extension handshake missing',
23 | 1011: 'an unexpected condition prevented the request from being fulfilled',
24 | };
--------------------------------------------------------------------------------
/src/v4/node_modules/ws/lib/Extensions.js:
--------------------------------------------------------------------------------
1 |
2 | var util = require('util');
3 |
4 | /**
5 | * Module exports.
6 | */
7 |
8 | exports.parse = parse;
9 | exports.format = format;
10 |
11 | /**
12 | * Parse extensions header value
13 | */
14 |
15 | function parse(value) {
16 | value = value || '';
17 |
18 | var extensions = {};
19 |
20 | value.split(',').forEach(function(v) {
21 | var params = v.split(';');
22 | var token = params.shift().trim();
23 | var paramsList = extensions[token] = extensions[token] || [];
24 | var parsedParams = {};
25 |
26 | params.forEach(function(param) {
27 | var parts = param.trim().split('=');
28 | var key = parts[0];
29 | var value = parts[1];
30 | if (typeof value === 'undefined') {
31 | value = true;
32 | } else {
33 | // unquote value
34 | if (value[0] === '"') {
35 | value = value.slice(1);
36 | }
37 | if (value[value.length - 1] === '"') {
38 | value = value.slice(0, value.length - 1);
39 | }
40 | }
41 | (parsedParams[key] = parsedParams[key] || []).push(value);
42 | });
43 |
44 | paramsList.push(parsedParams);
45 | });
46 |
47 | return extensions;
48 | }
49 |
50 | /**
51 | * Format extensions header value
52 | */
53 |
54 | function format(value) {
55 | return Object.keys(value).map(function(token) {
56 | var paramsList = value[token];
57 | if (!util.isArray(paramsList)) {
58 | paramsList = [paramsList];
59 | }
60 | return paramsList.map(function(params) {
61 | return [token].concat(Object.keys(params).map(function(k) {
62 | var p = params[k];
63 | if (!util.isArray(p)) p = [p];
64 | return p.map(function(v) {
65 | return v === true ? k : k + '=' + v;
66 | }).join('; ');
67 | })).join('; ');
68 | }).join(', ');
69 | }).join(', ');
70 | }
71 |
--------------------------------------------------------------------------------
/src/v4/node_modules/ws/lib/Validation.fallback.js:
--------------------------------------------------------------------------------
1 | /*!
2 | * ws: a node.js websocket client
3 | * Copyright(c) 2011 Einar Otto Stangvik
4 | * MIT Licensed
5 | */
6 |
7 | exports.Validation = {
8 | isValidUTF8: function(buffer) {
9 | return true;
10 | }
11 | };
12 |
--------------------------------------------------------------------------------
/src/v4/node_modules/ws/lib/Validation.js:
--------------------------------------------------------------------------------
1 | 'use strict';
2 |
3 | /*!
4 | * ws: a node.js websocket client
5 | * Copyright(c) 2011 Einar Otto Stangvik
6 | * MIT Licensed
7 | */
8 |
9 | try {
10 | module.exports = require('utf-8-validate');
11 | } catch (e) {
12 | module.exports = require('./Validation.fallback');
13 | }
14 |
--------------------------------------------------------------------------------
/src/v4/package.json:
--------------------------------------------------------------------------------
1 | {
2 | "name": "Horizontally-Scaling-Node.js-Websockets-Talk",
3 | "description": "Talk about horizontally scaling node.js and WebSockets given at Connect.Tech 2016 and Thunder Plains 2016.",
4 | "author": "James Simpson (http://goldfirestudios.com)",
5 | "repository": {
6 | "type": "git",
7 | "url": "git://github.com/goldfire/Horizontally-Scaling-Node.js-Websockets-Talk.git"
8 | },
9 | "dependencies": {
10 | "submono": "*",
11 | "ws": "*",
12 | "redis": "*"
13 | }
14 | }
--------------------------------------------------------------------------------
/src/v4/server.js:
--------------------------------------------------------------------------------
1 | var port = parseInt(process.argv[2], 10);
2 | var WebSocketServer = require('ws').Server;
3 | var wss = new WebSocketServer({port: port});
4 | var redis = require('redis');
5 | var pub = redis.createClient();
6 | var sub = redis.createClient();
7 | var color = 'blue';
8 |
9 | switch (port) {
10 | case 2001:
11 | color = 'red';
12 | break;
13 |
14 | case 2002:
15 | color = 'green';
16 | break;
17 |
18 | case 2003:
19 | color = 'purple';
20 | break;
21 | }
22 |
23 | sub.subscribe('global');
24 | sub.on('message', function(channel, msg) {
25 | if (channel === 'global') {
26 | wss.clients.forEach(function(client) {
27 | client.send(msg);
28 | });
29 | }
30 | });
31 |
32 | wss.on('connection', function(ws) {
33 | ws.on('message', function(msg) {
34 | msg = JSON.parse(msg);
35 | msg.color = color;
36 | pub.publish('global', JSON.stringify(msg));
37 | });
38 | });
--------------------------------------------------------------------------------
/src/v5/haproxy.cfg:
--------------------------------------------------------------------------------
1 | frontend all
2 | bind 0.0.0.0:8000
3 | default_backend sockets
4 |
5 | backend sockets
6 | balance leastconn
7 | server srv1 127.0.0.1:2000 check
8 | server srv2 127.0.0.1:2001 check
--------------------------------------------------------------------------------
/src/v5/index.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 | Horizontally Scaling Node.js & Websockets Demo
7 |
8 |
9 |
10 |
11 |