├── .gitignore ├── 01_HelloWorld ├── README.md └── hello.js ├── 02_Convention_Error ├── README.md ├── file_mv_err.js └── file_rd_err.js ├── 03_Convention_Callback ├── README.md ├── file_rd_err.js └── server.js ├── 04_Nested_Callbacks ├── README.md ├── async_sol.js ├── nested_cbs.js └── promise_sol.js ├── 05_Streams ├── README.md └── hello_world_stream.js ├── 06_Cluster ├── README.md └── cluster.js ├── 07_Sockets ├── README.md ├── tcp.js └── udp.js ├── 08_Async_Errors ├── README.md ├── domain.js └── try_catch.js ├── LICENSE ├── README.md ├── node_modules ├── async │ ├── .travis.yml │ ├── LICENSE │ ├── README.md │ ├── component.json │ ├── lib │ │ └── async.js │ └── package.json └── bluebird │ ├── LICENSE │ ├── README.md │ ├── js │ ├── browser │ │ └── bluebird.js │ ├── main │ │ ├── any.js │ │ ├── assert.js │ │ ├── async.js │ │ ├── bluebird.js │ │ ├── call_get.js │ │ ├── cancel.js │ │ ├── captured_trace.js │ │ ├── catch_filter.js │ │ ├── direct_resolve.js │ │ ├── each.js │ │ ├── errors.js │ │ ├── errors_api_rejection.js │ │ ├── es5.js │ │ ├── filter.js │ │ ├── finally.js │ │ ├── generators.js │ │ ├── join.js │ │ ├── map.js │ │ ├── nodeify.js │ │ ├── progress.js │ │ ├── promise.js │ │ ├── promise_array.js │ │ ├── promise_resolver.js │ │ ├── promisify.js │ │ ├── props.js │ │ ├── queue.js │ │ ├── race.js │ │ ├── reduce.js │ │ ├── schedule.js │ │ ├── settle.js │ │ ├── some.js │ │ ├── synchronous_inspection.js │ │ ├── thenables.js │ │ ├── timers.js │ │ ├── using.js │ │ └── util.js │ └── zalgo │ │ ├── any.js │ │ ├── assert.js │ │ ├── async.js │ │ ├── bluebird.js │ │ ├── call_get.js │ │ ├── cancel.js │ │ ├── captured_trace.js │ │ ├── catch_filter.js │ │ ├── direct_resolve.js │ │ ├── each.js │ │ ├── errors.js │ │ ├── errors_api_rejection.js │ │ ├── es5.js │ │ ├── filter.js │ │ ├── finally.js │ │ ├── generators.js │ │ ├── join.js │ │ ├── map.js │ │ ├── nodeify.js │ │ ├── progress.js │ │ ├── promise.js │ │ ├── promise_array.js │ │ ├── promise_resolver.js │ │ ├── promisify.js │ │ ├── props.js │ │ ├── queue.js │ │ ├── race.js │ │ ├── reduce.js │ │ ├── schedule.js │ │ ├── settle.js │ │ ├── some.js │ │ ├── synchronous_inspection.js │ │ ├── thenables.js │ │ ├── timers.js │ │ ├── using.js │ │ └── util.js │ └── package.json ├── package.json └── slides └── NodeIn20Min.pdf /.gitignore: -------------------------------------------------------------------------------- 1 | # Logs 2 | logs 3 | *.log 4 | 5 | # Runtime data 6 | pids 7 | *.pid 8 | *.seed 9 | 10 | # Directory for instrumented libs generated by jscoverage/JSCover 11 | lib-cov 12 | 13 | # Coverage directory used by tools like istanbul 14 | coverage 15 | 16 | # Grunt intermediate storage (http://gruntjs.com/creating-plugins#storing-task-files) 17 | .grunt 18 | 19 | # Compiled binary addons (http://nodejs.org/api/addons.html) 20 | build/Release 21 | 22 | # Users Environment Variables 23 | .lock-wscript 24 | -------------------------------------------------------------------------------- /01_HelloWorld/README.md: -------------------------------------------------------------------------------- 1 | # Hello World 2 | 3 | Here is the hello world example for Node.js from the [Node.js](http://nodejs.org/) website. 4 | 5 | To run this example, just type at the command line: 6 | 7 | $ node hello.js 8 | 9 | To test this server, type, from the command line: 10 | 11 | $ curl http://127.0.0.1:1337/ 12 | 13 | ## What's Going On? 14 | 15 | 1. The http module is loaded via require loading the http varible with the 16 | module's exports. 17 | 2. The exported `createServer` function on the http object is called. 18 | 1. The argument to the `createServer` function is a callback. 19 | 2. Node calls callback upon every new connection with a request and response 20 | object. 21 | 3. In the callback, we: 22 | 1. set the header to text plain 23 | 2. Return the text body with 'Hello World\n' (the HTTP status is 24 | implicitly 200). 25 | 3. The `createServer` function returns a server object and we use that object to 26 | invoke its `listen` function, instructing it to listen on port 1337 bound to 27 | the localhost interface. 28 | 29 | -------------------------------------------------------------------------------- /01_HelloWorld/hello.js: -------------------------------------------------------------------------------- 1 | // The hello world example from the http://node.js.org/ website. 2 | 3 | var http = require('http'); 4 | 5 | http.createServer(function (req, res) { 6 | res.writeHead(200, {'Content-Type': 'text/plain'}); 7 | res.end('Hello World\n'); 8 | }).listen(1337, '127.0.0.1'); 9 | 10 | console.log('Server running at http://127.0.0.1:1337/'); 11 | -------------------------------------------------------------------------------- /02_Convention_Error/README.md: -------------------------------------------------------------------------------- 1 | # Convention - Error First 2 | 3 | Having the error first in a callback is a convention. Node.js is 100% strict 4 | about this in its own interfaces, but it's a clear way to communicate failure in 5 | an asynchronous function. It's a friendly prompt to handle your error as the first 6 | thing you do in your callback. 7 | 8 | ## File Move Example 9 | 10 | ```javascript 11 | var fs = require('fs'); 12 | fs.rename('/tmp/hello', '/tmp/world', function (err) { 13 | if (err) throw err; 14 | console.log('renamed complete'); 15 | }); 16 | ``` 17 | 18 | The previous example shows the `fs.rename` callback with one argument, an error. 19 | Though the error is thrown, you send an error to a log file, standard error, do 20 | nothing or whatever makes sense for your application. 21 | 22 | ## File Read Example 23 | 24 | ```javascript 25 | var fs = require('fs'); 26 | fs.readFile('/etc/no.such.file', function (err, data) { 27 | if (err) throw err; 28 | console.log(data.toString()); 29 | }); 30 | ``` 31 | 32 | Again, the `fs` module, but with `readFile`. Here, the error is only defined where 33 | the read failed. 34 | 35 | 36 | -------------------------------------------------------------------------------- /02_Convention_Error/file_mv_err.js: -------------------------------------------------------------------------------- 1 | var fs = require('fs'); 2 | fs.rename('/tmp/hello', '/tmp/world', function (err) { 3 | if (err) throw err; 4 | console.log('renamed complete'); 5 | }); 6 | -------------------------------------------------------------------------------- /02_Convention_Error/file_rd_err.js: -------------------------------------------------------------------------------- 1 | var fs = require('fs'); 2 | fs.readFile('/etc/no.such.file', function (err, data) { 3 | if (err) throw err; 4 | console.log(data.toString()); 5 | }); 6 | -------------------------------------------------------------------------------- /03_Convention_Callback/README.md: -------------------------------------------------------------------------------- 1 | # Convention - Callback Last 2 | 3 | Having the callback last is convenient when you have a small callback with a few 4 | lines and an anonymous function will suffice. Of course, if nested more than a 5 | few times, your code will be hard to read. But it's a convention you should 6 | adhere to. 7 | 8 | ## File Read Example 9 | 10 | ```javascript 11 | var fs = require('fs'); 12 | fs.readFile('/etc/no.such.file', function (err, data) { 13 | if (err) throw err; 14 | console.log(data.toString()); 15 | }); 16 | ``` 17 | 18 | Again, the `readFile` example with the callback as the last argument to the 19 | `readFile` function. 20 | 21 | ## Server Example 22 | 23 | ```javascript 24 | var net = require('net'); 25 | var server = net.createServer(function(c) { 26 | c.write('hello world\r\n'); 27 | c.pipe(c); 28 | }); 29 | server.listen(8000, function() { 30 | console.log('server bound'); 31 | }); 32 | ``` 33 | 34 | Here, we create a TCP echo server. In the `createServer` and the `listen` functions, 35 | the callback is the last (and in the example, the only) parameter. 36 | 37 | -------------------------------------------------------------------------------- /03_Convention_Callback/file_rd_err.js: -------------------------------------------------------------------------------- 1 | var fs = require('fs'); 2 | fs.readFile('/etc/no.such.file', function (err, data) { 3 | if (err) throw err; 4 | console.log(data.toString()); 5 | }); 6 | -------------------------------------------------------------------------------- /03_Convention_Callback/server.js: -------------------------------------------------------------------------------- 1 | var net = require('net'); 2 | var server = net.createServer(function(c) { 3 | c.write('hello world\r\n'); 4 | c.pipe(c); 5 | }); 6 | server.listen(8000, function() { 7 | console.log('server bound'); 8 | }); 9 | -------------------------------------------------------------------------------- /04_Nested_Callbacks/README.md: -------------------------------------------------------------------------------- 1 | # Nested Callbacks 2 | 3 | Guaranteeing the order of operations in asynchronous can lead developers to nest asynchronous functions. When one asynchronous function completes, place the next step in the callback and so on. This works on a limited scale, but once you have many steps (imagine 10 or more), the code becomes confusing to look at. Below is an example of nested callbacks to ensure order of operation: 4 | 5 | ```javascript 6 | var fs = require('fs'); 7 | var filename = './nested_cbs.js'; 8 | 9 | fs.readFile(filename, function(err, data) { 10 | if (err) 11 | return console.error('Error reading the file:',filename+'\n' + 12 | err.stack); 13 | var str = data.toString(); 14 | str = str.replace(/var/g, 'banana'); 15 | fs.writeFile(filename+'.new', str, function(err) { 16 | if (err) return console.error(err.stack); 17 | console.log(filename+'.new written.'); 18 | }); 19 | }); 20 | ``` 21 | 22 | The file is asynchronously read, its contents changed and then is written. Again, imagine if you had a dozen steps ordered this way. The solution is to a control flow library and the options use either callbacks or promises. Which is as devisive as tabs versus spaces or emacs versus vi. 23 | 24 | ## Control flow with the async module 25 | 26 | ```javascript 27 | var fs = require('fs'); 28 | var filename = './async_sol.js'; 29 | var async = require('async'); 30 | async.waterfall([ 31 | function(cb) { 32 | fs.readFile(filename, function(err, data) { 33 | if (err) return cb(err); 34 | var str = data.toString(); 35 | str = str.replace(/var/g, 'banana'); 36 | cb(null, str); 37 | }); 38 | }, 39 | function(fContents, cb) { 40 | fs.writeFile(filename+'.new', fContents, function(err) { 41 | if (err) return cb(err); 42 | console.log(filename+'.new written.'); 43 | cb(); 44 | }); 45 | }], 46 | function(err) { 47 | if (err) return console.error(err.stack); 48 | console.log('Done'); 49 | } 50 | ); 51 | ``` 52 | 53 | The above code solves the same problem as the initial code, but uses the async module. Here, the waterfall method takes the output of one step and passes it as the input to the next step. The steps are done sequentially and passed in an array. 54 | 55 | It works, won't result in callback hell (many nested callbacks), but the async module is hard to understand at first. It's powerful, but when you first see it, it can be confusing. 56 | 57 | ## Control flow with promises 58 | 59 | An alternative form of control is promises. The two most popular promise libraries are q and bluebird. Here, I use bluebird to solve the same problem: 60 | 61 | ```javascript 62 | var filename = './promise_sol.js'; 63 | var promise = require('bluebird'); 64 | var fs = require('fs'); 65 | promise.promisifyAll(fs); 66 | 67 | fs.readFileAsync(filename) 68 | .then(function(data) { 69 | var str = data.toString(); 70 | str = str.replace(/var/g, 'banana'); 71 | return str; 72 | }) 73 | .then(function(str) { 74 | return fs.writeFileAsync(filename+'.new', str); 75 | }) 76 | .catch(function(err) { 77 | return console.error('File Error:',filename+'\n' + err.stack); 78 | }) 79 | .done(function() { console.log('done!'); }); 80 | ``` 81 | 82 | The trick, or minor drawback with promises is that Node.js does not support promises. Here, bluebird wraps each method is the fs module with a promise. Then, the example uses the promisified versions of the fs functions. Though I'm biased towards async, I have to acknowlege the elegance of promises. 83 | -------------------------------------------------------------------------------- /04_Nested_Callbacks/async_sol.js: -------------------------------------------------------------------------------- 1 | var fs = require('fs'); 2 | var filename = './async_sol.js'; 3 | var async = require('async'); 4 | async.waterfall([ 5 | function(cb) { 6 | fs.readFile(filename, function(err, data) { 7 | if (err) return cb(err); 8 | var str = data.toString(); 9 | str = str.replace(/var/g, 'banana'); 10 | cb(null, str); 11 | }); 12 | }, 13 | function(fContents, cb) { 14 | fs.writeFile(filename+'.new', fContents, function(err) { 15 | if (err) return cb(err); 16 | console.log(filename+'.new written.'); 17 | cb(); 18 | }); 19 | }], 20 | function(err) { 21 | if (err) return console.error(err.stack); 22 | console.log('Done'); 23 | } 24 | ); 25 | -------------------------------------------------------------------------------- /04_Nested_Callbacks/nested_cbs.js: -------------------------------------------------------------------------------- 1 | var fs = require('fs'); 2 | var filename = './nested_cbs.js'; 3 | 4 | fs.readFile(filename, function(err, data) { 5 | if (err) 6 | return console.error('Error reading the file:',filename+'\n' + 7 | err.stack); 8 | var str = data.toString(); 9 | str = str.replace(/var/g, 'banana'); 10 | fs.writeFile(filename+'.new', str, function(err) { 11 | if (err) return console.error(err.stack); 12 | console.log(filename+'.new written.'); 13 | }); 14 | }); 15 | -------------------------------------------------------------------------------- /04_Nested_Callbacks/promise_sol.js: -------------------------------------------------------------------------------- 1 | var filename = './promise_sol.js'; 2 | var promise = require('bluebird'); 3 | var fs = require('fs'); 4 | promise.promisifyAll(fs); 5 | 6 | fs.readFileAsync(filename) 7 | .then(function(data) { 8 | var str = data.toString(); 9 | str = str.replace(/var/g, 'banana'); 10 | return str; 11 | }) 12 | .then(function(str) { 13 | return fs.writeFileAsync(filename+'.new', str); 14 | }) 15 | .catch(function(err) { 16 | return console.error('File Error:',filename+'\n' + err.stack); 17 | }) 18 | .done(function() { console.log('done!'); }); 19 | -------------------------------------------------------------------------------- /05_Streams/README.md: -------------------------------------------------------------------------------- 1 | # Streams 2 | 3 | Streams are powerful and efficient. This is just an introduction to streams. I 4 | suggest that, if you are serious about Node.js, to take a few hours and acquaint 5 | yourself with the power of what streams can do. 6 | 7 | ## Hello World Using Req Stream 8 | 9 | ```javascript 10 | var http = require('http'); 11 | 12 | http.createServer(function (req, res) { 13 | getBody(req, function(err, body) { 14 | if (err) throw err; 15 | console.log('Body: '+body); 16 | res.writeHead(200, {'Content-Type': 'text/plain'}); 17 | res.end('Hello World\n'); 18 | }); 19 | }).listen(1337, '127.0.0.1', function() { 20 | console.log('Server running at http://127.0.0.1:1337/'); 21 | }); 22 | 23 | function getBody(req, cb) { 24 | var body = ''; 25 | 26 | // collect the body in buf; 27 | req.on('data', function (data) { body += data.toString(); }); 28 | 29 | // we have the body & header, now process. 30 | req.on('end', function () { 31 | req.body = body; 32 | cb(null, body); 33 | }); 34 | } 35 | ``` 36 | 37 | This is the hello world example from the [http://nodejs.org](nodejs.org 38 | website). However, this time we read the body of the request using streaming 39 | events. The HTTP request object is an input stream with the usual input stream 40 | events. 41 | 42 | In the function `getBody`, we accumulate the body text using the `data` event 43 | and, once the `end` event arrives, we know we have the entire message body. 44 | 45 | To run this, first start the node server: 46 | 47 | $ node hello_world_stream.js 48 | 49 | Then, using curl, send a POST request with a body: 50 | 51 | $ curl -i -H "X-HTTP-Method-Override: PUT" -X POST -d "value":"30","type":"Tip 3","targetModule":"Target 3","version":0,"systemId":3,"active":true http://localhost:1337/ 52 | 53 | 54 | -------------------------------------------------------------------------------- /05_Streams/hello_world_stream.js: -------------------------------------------------------------------------------- 1 | // The hello world example from the http://node.js.org/ website. 2 | 3 | var http = require('http'); 4 | 5 | http.createServer(function (req, res) { 6 | getBody(req, function(err, body) { 7 | if (err) throw err; 8 | console.log('Body: '+body); 9 | res.writeHead(200, {'Content-Type': 'text/plain'}); 10 | res.end('Hello World\n'); 11 | }); 12 | }).listen(1337, '127.0.0.1', function() { 13 | console.log('Server running at http://127.0.0.1:1337/'); 14 | }); 15 | 16 | function getBody(req, cb) { 17 | var body = ''; 18 | 19 | // collect the body 20 | req.on('data', function (data) { 21 | body += data.toString(); 22 | }); 23 | 24 | // we have the body & header, now process. 25 | req.on('end', function () { 26 | req.body = body; 27 | cb(undefined, body); 28 | }); 29 | } 30 | -------------------------------------------------------------------------------- /06_Cluster/README.md: -------------------------------------------------------------------------------- 1 | # Cluster 2 | 3 | Just because JavaScript is single-threaded doesn't mean Node.js can't scale up to 4 | take advantage of your computer's multiple CPUs. 5 | 6 | Cluster is an elegant abstraction of the Unix fork/exec. A master process 7 | creates the workers, and the listening socket, managed by the master, 8 | sends the received responses to the workers. 9 | 10 | ## Hello World Using Cluster 11 | 12 | ```javascript 13 | var cluster = require('cluster'); 14 | var http = require('http'); 15 | 16 | if (cluster.isMaster) { 17 | for (var i=0; i<3; i++) cluster.fork(); 18 | 19 | cluster.on('listening', function(worker, address) { 20 | console.log('Worker '+worker.id+ 21 | ' is now listening on port', address.port); 22 | }); 23 | } else { 24 | http.createServer(function(req, res) { 25 | res.writeHead(200); 26 | res.end('Hello world from: '+cluster.worker.id+'\n'); 27 | }).listen(8000); 28 | } 29 | ``` 30 | 31 | This is the hello world example from the [http://nodejs.org](nodejs.org 32 | website) with cluster. To run the program: 33 | 34 | $ node cluster.js 35 | Worker 1 is now listening on port 8000 36 | Worker 2 is now listening on port 8000 37 | Worker 3 is now listening on port 8000 38 | 39 | To test the program from the command line: 40 | 41 | $ curl http://localhost:8000 42 | Hello world from: 3 43 | 44 | ## What's Happening? 45 | 46 | Each time, the program calls `cluster.fork()` node 47 | creates a child process. Additionally, there is the master process, which, 48 | if any child process listens on a socket, the master process listens and then 49 | dispatches the input to one of the children listening on the socket's port. The 50 | children respond by sending the output back to the master process which 51 | forwards it onto the socket in response. 52 | 53 | -------------------------------------------------------------------------------- /06_Cluster/cluster.js: -------------------------------------------------------------------------------- 1 | var cluster = require('cluster'); 2 | var http = require('http'); 3 | 4 | if (cluster.isMaster) { 5 | for (var i=0; i<3; i++) cluster.fork(); 6 | 7 | cluster.on('listening', function(worker, address) { 8 | console.log('Worker '+worker.id+ 9 | ' is now listening on port', address.port); 10 | }); 11 | } else { 12 | http.createServer(function(req, res) { 13 | res.writeHead(200); 14 | res.end('Hello world from: '+cluster.worker.id+'\n'); 15 | }).listen(8000); 16 | } 17 | -------------------------------------------------------------------------------- /07_Sockets/README.md: -------------------------------------------------------------------------------- 1 | # Sockets 2 | 3 | Beyond supporting HTTP/HTTPS, Node.js has support for TCP and UDP sockets. Like 4 | every other feature in Node.js they're designed around asynchronous I/O. 5 | 6 | 7 | ## A Chat Server using TCP 8 | 9 | ```javascript 10 | var net = require('net'); 11 | var conn = {}; 12 | var server = net.createServer(function(c) { 13 | conn[c._handle.fd] = c; 14 | c.on('end', function() { 15 | delete conn[c._handle.fd]; 16 | }); 17 | c.on('data', function(buf) { 18 | for (var i in conn) { 19 | if (Number(i) !== c._handle.fd) 20 | conn[i].write(buf); 21 | } 22 | }); 23 | }); 24 | server.listen(3000); 25 | ``` 26 | 27 | The TCP example program illusrates a chat server. To run the server type, at the 28 | command prompt: 29 | 30 | $ node tcp.js 31 | 32 | Then, to "talk", you can use telnet at the command prompt: 33 | 34 | $ telnet localhost 3000 35 | 36 | How does it work? We call `createServer` with a connection listener callback. 37 | After every client connect to the server a connected socket is the parameter to 38 | the callback. When we receive the socket, we set up an `end` event to handle 39 | ungraceful disconnects and a `data` event for input. Once we receive data, we forward 40 | that input to every other socket connection. 41 | 42 | ## Hello World using UDP 43 | 44 | ```javascript 45 | var dgram = require('dgram'); 46 | var socket = dgram.createSocket('udp4'); 47 | var port = 4102; 48 | 49 | socket.on('message', function (msg, rinfo) { 50 | console.log('received: ' + msg + ' from ' + 51 | rinfo.address + ':' + rinfo.port); 52 | }); 53 | 54 | socket.bind(port, function() { 55 | socket.setBroadcast(true); 56 | }); 57 | 58 | setInterval(function() { 59 | var msg = new Buffer('Hello world!'); 60 | socket.send(msg, 0, msg.length, port, '255.255.255.255', function(err) { 61 | if (err) return console.error(err.stack); 62 | }); 63 | }, 1000); 64 | ``` 65 | 66 | The UDP example shows how an application using UDP is neither client nor server. 67 | It's just a set of peers. Here, we create the UDP socket, handle `message` 68 | (input) events, then bind the port to listen and, once bound, set the socket to 69 | broadcast. 70 | 71 | Then, every second, we send "Hello world!" to the broadcast address 72 | (255.255.255.255). 73 | -------------------------------------------------------------------------------- /07_Sockets/tcp.js: -------------------------------------------------------------------------------- 1 | var net = require('net'); 2 | var conn = {}; 3 | var server = net.createServer(function(c) { 4 | conn[c._handle.fd] = c; 5 | c.on('end', function() { 6 | delete conn[c._handle.fd]; 7 | }); 8 | c.on('data', function(buf) { 9 | for (var i in conn) { 10 | if (Number(i) !== c._handle.fd) 11 | conn[i].write(buf); 12 | } 13 | }); 14 | }); 15 | server.listen(3000); 16 | -------------------------------------------------------------------------------- /07_Sockets/udp.js: -------------------------------------------------------------------------------- 1 | var dgram = require('dgram'); 2 | var socket = dgram.createSocket('udp4'); 3 | var port = 4102; 4 | 5 | socket.on('message', function (msg, rinfo) { 6 | console.log('received: ' + msg + ' from ' + 7 | rinfo.address + ':' + rinfo.port); 8 | }); 9 | 10 | socket.bind(port, function() { 11 | socket.setBroadcast(true); 12 | }); 13 | 14 | setInterval(function() { 15 | var msg = new Buffer('Hello world!'); 16 | socket.send(msg, 0, msg.length, port, '255.255.255.255', function(err) { 17 | if (err) return console.error(err.stack); 18 | }); 19 | }, 1000); 20 | -------------------------------------------------------------------------------- /08_Async_Errors/README.md: -------------------------------------------------------------------------------- 1 | # Async Errors 2 | 3 | Node.js being designed around asynchronous I/O had an achilles heel around error 4 | handling and asynchronous errors. Specifically with exceptions thrown in 5 | callbacks. 6 | 7 | 8 | ## Try/Catch Doesn't Always Work 9 | 10 | ```javascript 11 | try { 12 | setTimeout(function() { 13 | console.log('Timeout!'); 14 | throw new Error('Timeout err!'); 15 | }, 1); 16 | } catch(err) { 17 | console.log('We will never see this.'); 18 | } 19 | ``` 20 | 21 | The previous code sample shows an exception being thrown in an asynchronous 22 | callback. The catch clause will always fail to pick up the exception, because 23 | the async callback has a different thread of execution that's not related to the 24 | try/catch. 25 | 26 | In a complex program dealing with a large amount of asynchronous input and 27 | output, this could be difficult. 28 | 29 | 30 | ## Node.js Domains Catch Async Errors 31 | 32 | ```javascript 33 | var domain = require('domain'); 34 | var d = domain.create(); 35 | 36 | d.once('error', function(err) { 37 | console.error('error caught by domain:', '\n', err.stack); 38 | process.exit(1); 39 | }); 40 | 41 | d.run(function() { 42 | setTimeout(function() { 43 | console.log('Timeout exception!'); 44 | throw new Error('Timeout err!'); 45 | }, 1); 46 | }); 47 | ``` 48 | 49 | This is a simplified example of a domain error handler. Here, we create the 50 | domain and the, create an event listener that will listen for the `error` event 51 | (only once), display the error and then exit with the error code '1'. 52 | -------------------------------------------------------------------------------- /08_Async_Errors/domain.js: -------------------------------------------------------------------------------- 1 | var domain = require('domain'); 2 | var d = domain.create(); 3 | 4 | d.on('error', function(err) { 5 | console.error('error caught by domain:', '\n', err.stack); 6 | }); 7 | 8 | d.run(function() { 9 | setTimeout(function() { 10 | console.log('Timeout exception!'); 11 | throw new Error('Timeout err!'); 12 | }, 1); 13 | }); 14 | -------------------------------------------------------------------------------- /08_Async_Errors/try_catch.js: -------------------------------------------------------------------------------- 1 | try { 2 | setTimeout(function() { 3 | console.log('Timeout!'); 4 | throw new Error('Timeout err!'); 5 | }, 1); 6 | } catch(err) { 7 | console.log('We will never see this.'); 8 | } 9 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | The MIT License (MIT) 2 | 3 | Copyright (c) 2014 Edmond Meinfelder 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 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # Node.js in 20 Minutes 2 | 3 | A short code-focused presentation of Node.js that takes about 20 minutes to present. 4 | 5 | This presentation is for people who know how to program, but are new to Node.js. 6 | It's assumed that JavaScript is known, but if you know some other high-level 7 | language, you should be able to follow along. At the conclusion, you should have 8 | a feel for some of the capabilities of Node.js. 9 | 10 | The presentation has the following sections: 11 | 12 | * [Hello World](https://github.com/stdarg/Node20Min/tree/master/01_HelloWorld) - 13 | the canonical "Hello World!" from the [nodejs.org](http://nodejs.org) website. 14 | * [Convention - Error First](https://github.com/stdarg/Node20Min/tree/master/02_Convention_Error) - 15 | an explanation of the callback conventions around returning errors 16 | * [Convention - Callback Last](https://github.com/stdarg/Node20Min/tree/master/03_Convention_Callback) - 17 | an explanation of the covention around placing the callback last. 18 | * [Nested Callback](https://github.com/stdarg/Node20Min/tree/master/04_Nested_Callbacks) - 19 | dicussion around teh issue of nested callbacks and flow control. 20 | * [Streams](https://github.com/stdarg/Node20Min/tree/master/05_Streams) - 21 | brief explanation of streams with an example of reading from a stream. 22 | * [Cluster](https://github.com/stdarg/Node20Min/tree/master/06_Cluster) - 23 | an explanation of cluster with an illustrative example. 24 | * [Sockets](https://github.com/stdarg/Node20Min/tree/master/07_Sockets) - 25 | examples of TCP and UDP sockets in use. 26 | * [Async Errors](https://github.com/stdarg/Node20Min/tree/master/08_Async_Errors) - 27 | An explanation of Node.js domains. 28 | 29 | Additionally, you can [view the slides](https://github.com/stdarg/Node20Min/blob/master/slides/NodeIn20Min.pdf) in PDF. 30 | -------------------------------------------------------------------------------- /node_modules/async/.travis.yml: -------------------------------------------------------------------------------- 1 | language: node_js 2 | node_js: 3 | - "0.10" 4 | -------------------------------------------------------------------------------- /node_modules/async/LICENSE: -------------------------------------------------------------------------------- 1 | Copyright (c) 2010-2014 Caolan McMahon 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. 20 | -------------------------------------------------------------------------------- /node_modules/async/component.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "async", 3 | "repo": "caolan/async", 4 | "description": "Higher-order functions and common patterns for asynchronous code", 5 | "version": "0.1.23", 6 | "keywords": [], 7 | "dependencies": {}, 8 | "development": {}, 9 | "main": "lib/async.js", 10 | "scripts": [ "lib/async.js" ] 11 | } 12 | -------------------------------------------------------------------------------- /node_modules/bluebird/LICENSE: -------------------------------------------------------------------------------- 1 | The MIT License (MIT) 2 | 3 | Copyright (c) 2014 Petka Antonov 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 13 | all 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 21 | THE SOFTWARE. 22 | -------------------------------------------------------------------------------- /node_modules/bluebird/js/main/any.js: -------------------------------------------------------------------------------- 1 | /** 2 | * The MIT License (MIT) 3 | * 4 | * Copyright (c) 2014 Petka Antonov 5 | * 6 | * Permission is hereby granted, free of charge, to any person obtaining a copy 7 | * of this software and associated documentation files (the "Software"), to deal 8 | * in the Software without restriction, including without limitation the rights 9 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 10 | * copies of the Software, and to permit persons to whom the Software is 11 | * furnished to do so, subject to the following conditions:

12 | * 13 | * The above copyright notice and this permission notice shall be included in 14 | * all copies or substantial portions of the Software. 15 | * 16 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 17 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 18 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 19 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 20 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 21 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 22 | * THE SOFTWARE. 23 | * 24 | */ 25 | "use strict"; 26 | module.exports = function(Promise) { 27 | var SomePromiseArray = Promise._SomePromiseArray; 28 | function Promise$_Any(promises) { 29 | var ret = new SomePromiseArray(promises); 30 | var promise = ret.promise(); 31 | if (promise.isRejected()) { 32 | return promise; 33 | } 34 | ret.setHowMany(1); 35 | ret.setUnwrap(); 36 | ret.init(); 37 | return promise; 38 | } 39 | 40 | Promise.any = function Promise$Any(promises) { 41 | return Promise$_Any(promises); 42 | }; 43 | 44 | Promise.prototype.any = function Promise$any() { 45 | return Promise$_Any(this); 46 | }; 47 | 48 | }; 49 | -------------------------------------------------------------------------------- /node_modules/bluebird/js/main/assert.js: -------------------------------------------------------------------------------- 1 | /** 2 | * The MIT License (MIT) 3 | * 4 | * Copyright (c) 2014 Petka Antonov 5 | * 6 | * Permission is hereby granted, free of charge, to any person obtaining a copy 7 | * of this software and associated documentation files (the "Software"), to deal 8 | * in the Software without restriction, including without limitation the rights 9 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 10 | * copies of the Software, and to permit persons to whom the Software is 11 | * furnished to do so, subject to the following conditions:

12 | * 13 | * The above copyright notice and this permission notice shall be included in 14 | * all copies or substantial portions of the Software. 15 | * 16 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 17 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 18 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 19 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 20 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 21 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 22 | * THE SOFTWARE. 23 | * 24 | */ 25 | "use strict"; 26 | module.exports = (function(){ 27 | var AssertionError = (function() { 28 | function AssertionError(a) { 29 | this.constructor$(a); 30 | this.message = a; 31 | this.name = "AssertionError"; 32 | } 33 | AssertionError.prototype = new Error(); 34 | AssertionError.prototype.constructor = AssertionError; 35 | AssertionError.prototype.constructor$ = Error; 36 | return AssertionError; 37 | })(); 38 | 39 | function getParams(args) { 40 | var params = []; 41 | for (var i = 0; i < args.length; ++i) params.push("arg" + i); 42 | return params; 43 | } 44 | 45 | function nativeAssert(callName, args, expect) { 46 | try { 47 | var params = getParams(args); 48 | var constructorArgs = params; 49 | constructorArgs.push("return " + 50 | callName + "("+ params.join(",") + ");"); 51 | var fn = Function.apply(null, constructorArgs); 52 | return fn.apply(null, args); 53 | } catch (e) { 54 | if (!(e instanceof SyntaxError)) { 55 | throw e; 56 | } else { 57 | return expect; 58 | } 59 | } 60 | } 61 | 62 | return function assert(boolExpr, message) { 63 | if (boolExpr === true) return; 64 | 65 | if (typeof boolExpr === "string" && 66 | boolExpr.charAt(0) === "%") { 67 | var nativeCallName = boolExpr; 68 | var $_len = arguments.length;var args = new Array($_len - 2); for(var $_i = 2; $_i < $_len; ++$_i) {args[$_i - 2] = arguments[$_i];} 69 | if (nativeAssert(nativeCallName, args, message) === message) return; 70 | message = (nativeCallName + " !== " + message); 71 | } 72 | 73 | var ret = new AssertionError(message); 74 | if (Error.captureStackTrace) { 75 | Error.captureStackTrace(ret, assert); 76 | } 77 | if (console && console.error) { 78 | console.error(ret.stack + ""); 79 | } 80 | throw ret; 81 | 82 | }; 83 | })(); 84 | -------------------------------------------------------------------------------- /node_modules/bluebird/js/main/async.js: -------------------------------------------------------------------------------- 1 | /** 2 | * The MIT License (MIT) 3 | * 4 | * Copyright (c) 2014 Petka Antonov 5 | * 6 | * Permission is hereby granted, free of charge, to any person obtaining a copy 7 | * of this software and associated documentation files (the "Software"), to deal 8 | * in the Software without restriction, including without limitation the rights 9 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 10 | * copies of the Software, and to permit persons to whom the Software is 11 | * furnished to do so, subject to the following conditions:

12 | * 13 | * The above copyright notice and this permission notice shall be included in 14 | * all copies or substantial portions of the Software. 15 | * 16 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 17 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 18 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 19 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 20 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 21 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 22 | * THE SOFTWARE. 23 | * 24 | */ 25 | "use strict"; 26 | var schedule = require("./schedule.js"); 27 | var Queue = require("./queue.js"); 28 | var errorObj = require("./util.js").errorObj; 29 | var tryCatch1 = require("./util.js").tryCatch1; 30 | var _process = typeof process !== "undefined" ? process : void 0; 31 | 32 | function Async() { 33 | this._isTickUsed = false; 34 | this._schedule = schedule; 35 | this._length = 0; 36 | this._lateBuffer = new Queue(16); 37 | this._functionBuffer = new Queue(65536); 38 | var self = this; 39 | this.consumeFunctionBuffer = function Async$consumeFunctionBuffer() { 40 | self._consumeFunctionBuffer(); 41 | }; 42 | } 43 | 44 | Async.prototype.haveItemsQueued = function Async$haveItemsQueued() { 45 | return this._length > 0; 46 | }; 47 | 48 | Async.prototype.invokeLater = function Async$invokeLater(fn, receiver, arg) { 49 | if (_process !== void 0 && 50 | _process.domain != null && 51 | !fn.domain) { 52 | fn = _process.domain.bind(fn); 53 | } 54 | this._lateBuffer.push(fn, receiver, arg); 55 | this._queueTick(); 56 | }; 57 | 58 | Async.prototype.invoke = function Async$invoke(fn, receiver, arg) { 59 | if (_process !== void 0 && 60 | _process.domain != null && 61 | !fn.domain) { 62 | fn = _process.domain.bind(fn); 63 | } 64 | var functionBuffer = this._functionBuffer; 65 | functionBuffer.push(fn, receiver, arg); 66 | this._length = functionBuffer.length(); 67 | this._queueTick(); 68 | }; 69 | 70 | Async.prototype._consumeFunctionBuffer = 71 | function Async$_consumeFunctionBuffer() { 72 | var functionBuffer = this._functionBuffer; 73 | while (functionBuffer.length() > 0) { 74 | var fn = functionBuffer.shift(); 75 | var receiver = functionBuffer.shift(); 76 | var arg = functionBuffer.shift(); 77 | fn.call(receiver, arg); 78 | } 79 | this._reset(); 80 | this._consumeLateBuffer(); 81 | }; 82 | 83 | Async.prototype._consumeLateBuffer = function Async$_consumeLateBuffer() { 84 | var buffer = this._lateBuffer; 85 | while(buffer.length() > 0) { 86 | var fn = buffer.shift(); 87 | var receiver = buffer.shift(); 88 | var arg = buffer.shift(); 89 | var res = tryCatch1(fn, receiver, arg); 90 | if (res === errorObj) { 91 | this._queueTick(); 92 | if (fn.domain != null) { 93 | fn.domain.emit("error", res.e); 94 | } else { 95 | throw res.e; 96 | } 97 | } 98 | } 99 | }; 100 | 101 | Async.prototype._queueTick = function Async$_queue() { 102 | if (!this._isTickUsed) { 103 | this._schedule(this.consumeFunctionBuffer); 104 | this._isTickUsed = true; 105 | } 106 | }; 107 | 108 | Async.prototype._reset = function Async$_reset() { 109 | this._isTickUsed = false; 110 | this._length = 0; 111 | }; 112 | 113 | module.exports = new Async(); 114 | -------------------------------------------------------------------------------- /node_modules/bluebird/js/main/bluebird.js: -------------------------------------------------------------------------------- 1 | /** 2 | * The MIT License (MIT) 3 | * 4 | * Copyright (c) 2014 Petka Antonov 5 | * 6 | * Permission is hereby granted, free of charge, to any person obtaining a copy 7 | * of this software and associated documentation files (the "Software"), to deal 8 | * in the Software without restriction, including without limitation the rights 9 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 10 | * copies of the Software, and to permit persons to whom the Software is 11 | * furnished to do so, subject to the following conditions:

12 | * 13 | * The above copyright notice and this permission notice shall be included in 14 | * all copies or substantial portions of the Software. 15 | * 16 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 17 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 18 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 19 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 20 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 21 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 22 | * THE SOFTWARE. 23 | * 24 | */ 25 | "use strict"; 26 | var Promise = require("./promise.js")(); 27 | module.exports = Promise; -------------------------------------------------------------------------------- /node_modules/bluebird/js/main/call_get.js: -------------------------------------------------------------------------------- 1 | /** 2 | * The MIT License (MIT) 3 | * 4 | * Copyright (c) 2014 Petka Antonov 5 | * 6 | * Permission is hereby granted, free of charge, to any person obtaining a copy 7 | * of this software and associated documentation files (the "Software"), to deal 8 | * in the Software without restriction, including without limitation the rights 9 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 10 | * copies of the Software, and to permit persons to whom the Software is 11 | * furnished to do so, subject to the following conditions:

12 | * 13 | * The above copyright notice and this permission notice shall be included in 14 | * all copies or substantial portions of the Software. 15 | * 16 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 17 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 18 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 19 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 20 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 21 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 22 | * THE SOFTWARE. 23 | * 24 | */ 25 | "use strict"; 26 | var cr = Object.create; 27 | if (cr) { 28 | var callerCache = cr(null); 29 | var getterCache = cr(null); 30 | callerCache[" size"] = getterCache[" size"] = 0; 31 | } 32 | 33 | module.exports = function(Promise) { 34 | var util = require("./util.js"); 35 | var canEvaluate = util.canEvaluate; 36 | var isIdentifier = util.isIdentifier; 37 | 38 | function makeMethodCaller (methodName) { 39 | return new Function("obj", " \n\ 40 | 'use strict' \n\ 41 | var len = this.length; \n\ 42 | switch(len) { \n\ 43 | case 1: return obj.methodName(this[0]); \n\ 44 | case 2: return obj.methodName(this[0], this[1]); \n\ 45 | case 3: return obj.methodName(this[0], this[1], this[2]); \n\ 46 | case 0: return obj.methodName(); \n\ 47 | default: return obj.methodName.apply(obj, this); \n\ 48 | } \n\ 49 | ".replace(/methodName/g, methodName)); 50 | } 51 | 52 | function makeGetter (propertyName) { 53 | return new Function("obj", " \n\ 54 | 'use strict'; \n\ 55 | return obj.propertyName; \n\ 56 | ".replace("propertyName", propertyName)); 57 | } 58 | 59 | function getCompiled(name, compiler, cache) { 60 | var ret = cache[name]; 61 | if (typeof ret !== "function") { 62 | if (!isIdentifier(name)) { 63 | return null; 64 | } 65 | ret = compiler(name); 66 | cache[name] = ret; 67 | cache[" size"]++; 68 | if (cache[" size"] > 512) { 69 | var keys = Object.keys(cache); 70 | for (var i = 0; i < 256; ++i) delete cache[keys[i]]; 71 | cache[" size"] = keys.length - 256; 72 | } 73 | } 74 | return ret; 75 | } 76 | 77 | function getMethodCaller(name) { 78 | return getCompiled(name, makeMethodCaller, callerCache); 79 | } 80 | 81 | function getGetter(name) { 82 | return getCompiled(name, makeGetter, getterCache); 83 | } 84 | 85 | function caller(obj) { 86 | return obj[this.pop()].apply(obj, this); 87 | } 88 | Promise.prototype.call = function Promise$call(methodName) { 89 | var $_len = arguments.length;var args = new Array($_len - 1); for(var $_i = 1; $_i < $_len; ++$_i) {args[$_i - 1] = arguments[$_i];} 90 | if (canEvaluate) { 91 | var maybeCaller = getMethodCaller(methodName); 92 | if (maybeCaller !== null) { 93 | return this._then(maybeCaller, void 0, void 0, args, void 0); 94 | } 95 | } 96 | args.push(methodName); 97 | return this._then(caller, void 0, void 0, args, void 0); 98 | }; 99 | 100 | function namedGetter(obj) { 101 | return obj[this]; 102 | } 103 | function indexedGetter(obj) { 104 | return obj[this]; 105 | } 106 | Promise.prototype.get = function Promise$get(propertyName) { 107 | var isIndex = (typeof propertyName === "number"); 108 | var getter; 109 | if (!isIndex) { 110 | if (canEvaluate) { 111 | var maybeGetter = getGetter(propertyName); 112 | getter = maybeGetter !== null ? maybeGetter : namedGetter; 113 | } else { 114 | getter = namedGetter; 115 | } 116 | } else { 117 | getter = indexedGetter; 118 | } 119 | return this._then(getter, void 0, void 0, propertyName, void 0); 120 | }; 121 | }; 122 | -------------------------------------------------------------------------------- /node_modules/bluebird/js/main/cancel.js: -------------------------------------------------------------------------------- 1 | /** 2 | * The MIT License (MIT) 3 | * 4 | * Copyright (c) 2014 Petka Antonov 5 | * 6 | * Permission is hereby granted, free of charge, to any person obtaining a copy 7 | * of this software and associated documentation files (the "Software"), to deal 8 | * in the Software without restriction, including without limitation the rights 9 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 10 | * copies of the Software, and to permit persons to whom the Software is 11 | * furnished to do so, subject to the following conditions:

12 | * 13 | * The above copyright notice and this permission notice shall be included in 14 | * all copies or substantial portions of the Software. 15 | * 16 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 17 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 18 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 19 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 20 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 21 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 22 | * THE SOFTWARE. 23 | * 24 | */ 25 | "use strict"; 26 | module.exports = function(Promise, INTERNAL) { 27 | var errors = require("./errors.js"); 28 | var canAttach = errors.canAttach; 29 | var async = require("./async.js"); 30 | var CancellationError = errors.CancellationError; 31 | 32 | Promise.prototype._cancel = function Promise$_cancel(reason) { 33 | if (!this.isCancellable()) return this; 34 | var parent; 35 | var promiseToReject = this; 36 | while ((parent = promiseToReject._cancellationParent) !== void 0 && 37 | parent.isCancellable()) { 38 | promiseToReject = parent; 39 | } 40 | this._unsetCancellable(); 41 | promiseToReject._attachExtraTrace(reason); 42 | promiseToReject._rejectUnchecked(reason); 43 | }; 44 | 45 | Promise.prototype.cancel = function Promise$cancel(reason) { 46 | if (!this.isCancellable()) return this; 47 | reason = reason !== void 0 48 | ? (canAttach(reason) ? reason : new Error(reason + "")) 49 | : new CancellationError(); 50 | async.invokeLater(this._cancel, this, reason); 51 | return this; 52 | }; 53 | 54 | Promise.prototype.cancellable = function Promise$cancellable() { 55 | if (this._cancellable()) return this; 56 | this._setCancellable(); 57 | this._cancellationParent = void 0; 58 | return this; 59 | }; 60 | 61 | Promise.prototype.uncancellable = function Promise$uncancellable() { 62 | var ret = new Promise(INTERNAL); 63 | ret._propagateFrom(this, 2 | 4); 64 | ret._follow(this); 65 | ret._unsetCancellable(); 66 | return ret; 67 | }; 68 | 69 | Promise.prototype.fork = 70 | function Promise$fork(didFulfill, didReject, didProgress) { 71 | var ret = this._then(didFulfill, didReject, didProgress, 72 | void 0, void 0); 73 | 74 | ret._setCancellable(); 75 | ret._cancellationParent = void 0; 76 | return ret; 77 | }; 78 | }; 79 | -------------------------------------------------------------------------------- /node_modules/bluebird/js/main/catch_filter.js: -------------------------------------------------------------------------------- 1 | /** 2 | * The MIT License (MIT) 3 | * 4 | * Copyright (c) 2014 Petka Antonov 5 | * 6 | * Permission is hereby granted, free of charge, to any person obtaining a copy 7 | * of this software and associated documentation files (the "Software"), to deal 8 | * in the Software without restriction, including without limitation the rights 9 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 10 | * copies of the Software, and to permit persons to whom the Software is 11 | * furnished to do so, subject to the following conditions:

12 | * 13 | * The above copyright notice and this permission notice shall be included in 14 | * all copies or substantial portions of the Software. 15 | * 16 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 17 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 18 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 19 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 20 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 21 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 22 | * THE SOFTWARE. 23 | * 24 | */ 25 | "use strict"; 26 | module.exports = function(NEXT_FILTER) { 27 | var util = require("./util.js"); 28 | var errors = require("./errors.js"); 29 | var tryCatch1 = util.tryCatch1; 30 | var errorObj = util.errorObj; 31 | var keys = require("./es5.js").keys; 32 | var TypeError = errors.TypeError; 33 | 34 | function CatchFilter(instances, callback, promise) { 35 | this._instances = instances; 36 | this._callback = callback; 37 | this._promise = promise; 38 | } 39 | 40 | function CatchFilter$_safePredicate(predicate, e) { 41 | var safeObject = {}; 42 | var retfilter = tryCatch1(predicate, safeObject, e); 43 | 44 | if (retfilter === errorObj) return retfilter; 45 | 46 | var safeKeys = keys(safeObject); 47 | if (safeKeys.length) { 48 | errorObj.e = new TypeError( 49 | "Catch filter must inherit from Error " 50 | + "or be a simple predicate function"); 51 | return errorObj; 52 | } 53 | return retfilter; 54 | } 55 | 56 | CatchFilter.prototype.doFilter = function CatchFilter$_doFilter(e) { 57 | var cb = this._callback; 58 | var promise = this._promise; 59 | var boundTo = promise._boundTo; 60 | for (var i = 0, len = this._instances.length; i < len; ++i) { 61 | var item = this._instances[i]; 62 | var itemIsErrorType = item === Error || 63 | (item != null && item.prototype instanceof Error); 64 | 65 | if (itemIsErrorType && e instanceof item) { 66 | var ret = tryCatch1(cb, boundTo, e); 67 | if (ret === errorObj) { 68 | NEXT_FILTER.e = ret.e; 69 | return NEXT_FILTER; 70 | } 71 | return ret; 72 | } else if (typeof item === "function" && !itemIsErrorType) { 73 | var shouldHandle = CatchFilter$_safePredicate(item, e); 74 | if (shouldHandle === errorObj) { 75 | var trace = errors.canAttach(errorObj.e) 76 | ? errorObj.e 77 | : new Error(errorObj.e + ""); 78 | this._promise._attachExtraTrace(trace); 79 | e = errorObj.e; 80 | break; 81 | } else if (shouldHandle) { 82 | var ret = tryCatch1(cb, boundTo, e); 83 | if (ret === errorObj) { 84 | NEXT_FILTER.e = ret.e; 85 | return NEXT_FILTER; 86 | } 87 | return ret; 88 | } 89 | } 90 | } 91 | NEXT_FILTER.e = e; 92 | return NEXT_FILTER; 93 | }; 94 | 95 | return CatchFilter; 96 | }; 97 | -------------------------------------------------------------------------------- /node_modules/bluebird/js/main/direct_resolve.js: -------------------------------------------------------------------------------- 1 | /** 2 | * The MIT License (MIT) 3 | * 4 | * Copyright (c) 2014 Petka Antonov 5 | * 6 | * Permission is hereby granted, free of charge, to any person obtaining a copy 7 | * of this software and associated documentation files (the "Software"), to deal 8 | * in the Software without restriction, including without limitation the rights 9 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 10 | * copies of the Software, and to permit persons to whom the Software is 11 | * furnished to do so, subject to the following conditions:

12 | * 13 | * The above copyright notice and this permission notice shall be included in 14 | * all copies or substantial portions of the Software. 15 | * 16 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 17 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 18 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 19 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 20 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 21 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 22 | * THE SOFTWARE. 23 | * 24 | */ 25 | "use strict"; 26 | var util = require("./util.js"); 27 | var isPrimitive = util.isPrimitive; 28 | var wrapsPrimitiveReceiver = util.wrapsPrimitiveReceiver; 29 | 30 | module.exports = function(Promise) { 31 | var returner = function Promise$_returner() { 32 | return this; 33 | }; 34 | var thrower = function Promise$_thrower() { 35 | throw this; 36 | }; 37 | 38 | var wrapper = function Promise$_wrapper(value, action) { 39 | if (action === 1) { 40 | return function Promise$_thrower() { 41 | throw value; 42 | }; 43 | } else if (action === 2) { 44 | return function Promise$_returner() { 45 | return value; 46 | }; 47 | } 48 | }; 49 | 50 | 51 | Promise.prototype["return"] = 52 | Promise.prototype.thenReturn = 53 | function Promise$thenReturn(value) { 54 | if (wrapsPrimitiveReceiver && isPrimitive(value)) { 55 | return this._then( 56 | wrapper(value, 2), 57 | void 0, 58 | void 0, 59 | void 0, 60 | void 0 61 | ); 62 | } 63 | return this._then(returner, void 0, void 0, value, void 0); 64 | }; 65 | 66 | Promise.prototype["throw"] = 67 | Promise.prototype.thenThrow = 68 | function Promise$thenThrow(reason) { 69 | if (wrapsPrimitiveReceiver && isPrimitive(reason)) { 70 | return this._then( 71 | wrapper(reason, 1), 72 | void 0, 73 | void 0, 74 | void 0, 75 | void 0 76 | ); 77 | } 78 | return this._then(thrower, void 0, void 0, reason, void 0); 79 | }; 80 | }; 81 | -------------------------------------------------------------------------------- /node_modules/bluebird/js/main/each.js: -------------------------------------------------------------------------------- 1 | /** 2 | * The MIT License (MIT) 3 | * 4 | * Copyright (c) 2014 Petka Antonov 5 | * 6 | * Permission is hereby granted, free of charge, to any person obtaining a copy 7 | * of this software and associated documentation files (the "Software"), to deal 8 | * in the Software without restriction, including without limitation the rights 9 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 10 | * copies of the Software, and to permit persons to whom the Software is 11 | * furnished to do so, subject to the following conditions:

12 | * 13 | * The above copyright notice and this permission notice shall be included in 14 | * all copies or substantial portions of the Software. 15 | * 16 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 17 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 18 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 19 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 20 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 21 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 22 | * THE SOFTWARE. 23 | * 24 | */ 25 | "use strict"; 26 | module.exports = function(Promise, INTERNAL) { 27 | var PromiseReduce = Promise.reduce; 28 | 29 | Promise.prototype.each = function Promise$each(fn) { 30 | return PromiseReduce(this, fn, null, INTERNAL); 31 | }; 32 | 33 | Promise.each = function Promise$Each(promises, fn) { 34 | return PromiseReduce(promises, fn, null, INTERNAL); 35 | }; 36 | }; 37 | -------------------------------------------------------------------------------- /node_modules/bluebird/js/main/errors.js: -------------------------------------------------------------------------------- 1 | /** 2 | * The MIT License (MIT) 3 | * 4 | * Copyright (c) 2014 Petka Antonov 5 | * 6 | * Permission is hereby granted, free of charge, to any person obtaining a copy 7 | * of this software and associated documentation files (the "Software"), to deal 8 | * in the Software without restriction, including without limitation the rights 9 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 10 | * copies of the Software, and to permit persons to whom the Software is 11 | * furnished to do so, subject to the following conditions:

12 | * 13 | * The above copyright notice and this permission notice shall be included in 14 | * all copies or substantial portions of the Software. 15 | * 16 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 17 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 18 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 19 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 20 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 21 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 22 | * THE SOFTWARE. 23 | * 24 | */ 25 | "use strict"; 26 | var Objectfreeze = require("./es5.js").freeze; 27 | var util = require("./util.js"); 28 | var inherits = util.inherits; 29 | var notEnumerableProp = util.notEnumerableProp; 30 | 31 | function markAsOriginatingFromRejection(e) { 32 | try { 33 | notEnumerableProp(e, "isOperational", true); 34 | } 35 | catch(ignore) {} 36 | } 37 | 38 | function originatesFromRejection(e) { 39 | if (e == null) return false; 40 | return ((e instanceof OperationalError) || 41 | e["isOperational"] === true); 42 | } 43 | 44 | function isError(obj) { 45 | return obj instanceof Error; 46 | } 47 | 48 | function canAttach(obj) { 49 | return isError(obj); 50 | } 51 | 52 | function subError(nameProperty, defaultMessage) { 53 | function SubError(message) { 54 | if (!(this instanceof SubError)) return new SubError(message); 55 | this.message = typeof message === "string" ? message : defaultMessage; 56 | this.name = nameProperty; 57 | if (Error.captureStackTrace) { 58 | Error.captureStackTrace(this, this.constructor); 59 | } 60 | } 61 | inherits(SubError, Error); 62 | return SubError; 63 | } 64 | 65 | var _TypeError, _RangeError; 66 | var CancellationError = subError("CancellationError", "cancellation error"); 67 | var TimeoutError = subError("TimeoutError", "timeout error"); 68 | var AggregateError = subError("AggregateError", "aggregate error"); 69 | try { 70 | _TypeError = TypeError; 71 | _RangeError = RangeError; 72 | } catch(e) { 73 | _TypeError = subError("TypeError", "type error"); 74 | _RangeError = subError("RangeError", "range error"); 75 | } 76 | 77 | var methods = ("join pop push shift unshift slice filter forEach some " + 78 | "every map indexOf lastIndexOf reduce reduceRight sort reverse").split(" "); 79 | 80 | for (var i = 0; i < methods.length; ++i) { 81 | if (typeof Array.prototype[methods[i]] === "function") { 82 | AggregateError.prototype[methods[i]] = Array.prototype[methods[i]]; 83 | } 84 | } 85 | 86 | AggregateError.prototype.length = 0; 87 | AggregateError.prototype["isOperational"] = true; 88 | var level = 0; 89 | AggregateError.prototype.toString = function() { 90 | var indent = Array(level * 4 + 1).join(" "); 91 | var ret = "\n" + indent + "AggregateError of:" + "\n"; 92 | level++; 93 | indent = Array(level * 4 + 1).join(" "); 94 | for (var i = 0; i < this.length; ++i) { 95 | var str = this[i] === this ? "[Circular AggregateError]" : this[i] + ""; 96 | var lines = str.split("\n"); 97 | for (var j = 0; j < lines.length; ++j) { 98 | lines[j] = indent + lines[j]; 99 | } 100 | str = lines.join("\n"); 101 | ret += str + "\n"; 102 | } 103 | level--; 104 | return ret; 105 | }; 106 | 107 | function OperationalError(message) { 108 | this.name = "OperationalError"; 109 | this.message = message; 110 | this.cause = message; 111 | this["isOperational"] = true; 112 | 113 | if (message instanceof Error) { 114 | this.message = message.message; 115 | this.stack = message.stack; 116 | } else if (Error.captureStackTrace) { 117 | Error.captureStackTrace(this, this.constructor); 118 | } 119 | 120 | } 121 | inherits(OperationalError, Error); 122 | 123 | var key = "__BluebirdErrorTypes__"; 124 | var errorTypes = Error[key]; 125 | if (!errorTypes) { 126 | errorTypes = Objectfreeze({ 127 | CancellationError: CancellationError, 128 | TimeoutError: TimeoutError, 129 | OperationalError: OperationalError, 130 | RejectionError: OperationalError, 131 | AggregateError: AggregateError 132 | }); 133 | notEnumerableProp(Error, key, errorTypes); 134 | } 135 | 136 | module.exports = { 137 | Error: Error, 138 | TypeError: _TypeError, 139 | RangeError: _RangeError, 140 | CancellationError: errorTypes.CancellationError, 141 | OperationalError: errorTypes.OperationalError, 142 | TimeoutError: errorTypes.TimeoutError, 143 | AggregateError: errorTypes.AggregateError, 144 | originatesFromRejection: originatesFromRejection, 145 | markAsOriginatingFromRejection: markAsOriginatingFromRejection, 146 | canAttach: canAttach 147 | }; 148 | -------------------------------------------------------------------------------- /node_modules/bluebird/js/main/errors_api_rejection.js: -------------------------------------------------------------------------------- 1 | /** 2 | * The MIT License (MIT) 3 | * 4 | * Copyright (c) 2014 Petka Antonov 5 | * 6 | * Permission is hereby granted, free of charge, to any person obtaining a copy 7 | * of this software and associated documentation files (the "Software"), to deal 8 | * in the Software without restriction, including without limitation the rights 9 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 10 | * copies of the Software, and to permit persons to whom the Software is 11 | * furnished to do so, subject to the following conditions:

12 | * 13 | * The above copyright notice and this permission notice shall be included in 14 | * all copies or substantial portions of the Software. 15 | * 16 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 17 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 18 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 19 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 20 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 21 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 22 | * THE SOFTWARE. 23 | * 24 | */ 25 | "use strict"; 26 | module.exports = function(Promise) { 27 | var TypeError = require('./errors.js').TypeError; 28 | 29 | function apiRejection(msg) { 30 | var error = new TypeError(msg); 31 | var ret = Promise.rejected(error); 32 | var parent = ret._peekContext(); 33 | if (parent != null) { 34 | parent._attachExtraTrace(error); 35 | } 36 | return ret; 37 | } 38 | 39 | return apiRejection; 40 | }; 41 | -------------------------------------------------------------------------------- /node_modules/bluebird/js/main/es5.js: -------------------------------------------------------------------------------- 1 | /** 2 | * The MIT License (MIT) 3 | * 4 | * Copyright (c) 2014 Petka Antonov 5 | * 6 | * Permission is hereby granted, free of charge, to any person obtaining a copy 7 | * of this software and associated documentation files (the "Software"), to deal 8 | * in the Software without restriction, including without limitation the rights 9 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 10 | * copies of the Software, and to permit persons to whom the Software is 11 | * furnished to do so, subject to the following conditions:

12 | * 13 | * The above copyright notice and this permission notice shall be included in 14 | * all copies or substantial portions of the Software. 15 | * 16 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 17 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 18 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 19 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 20 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 21 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 22 | * THE SOFTWARE. 23 | * 24 | */ 25 | var isES5 = (function(){ 26 | "use strict"; 27 | return this === void 0; 28 | })(); 29 | 30 | if (isES5) { 31 | module.exports = { 32 | freeze: Object.freeze, 33 | defineProperty: Object.defineProperty, 34 | keys: Object.keys, 35 | getPrototypeOf: Object.getPrototypeOf, 36 | isArray: Array.isArray, 37 | isES5: isES5 38 | }; 39 | } else { 40 | var has = {}.hasOwnProperty; 41 | var str = {}.toString; 42 | var proto = {}.constructor.prototype; 43 | 44 | var ObjectKeys = function ObjectKeys(o) { 45 | var ret = []; 46 | for (var key in o) { 47 | if (has.call(o, key)) { 48 | ret.push(key); 49 | } 50 | } 51 | return ret; 52 | } 53 | 54 | var ObjectDefineProperty = function ObjectDefineProperty(o, key, desc) { 55 | o[key] = desc.value; 56 | return o; 57 | } 58 | 59 | var ObjectFreeze = function ObjectFreeze(obj) { 60 | return obj; 61 | } 62 | 63 | var ObjectGetPrototypeOf = function ObjectGetPrototypeOf(obj) { 64 | try { 65 | return Object(obj).constructor.prototype; 66 | } 67 | catch (e) { 68 | return proto; 69 | } 70 | } 71 | 72 | var ArrayIsArray = function ArrayIsArray(obj) { 73 | try { 74 | return str.call(obj) === "[object Array]"; 75 | } 76 | catch(e) { 77 | return false; 78 | } 79 | } 80 | 81 | module.exports = { 82 | isArray: ArrayIsArray, 83 | keys: ObjectKeys, 84 | defineProperty: ObjectDefineProperty, 85 | freeze: ObjectFreeze, 86 | getPrototypeOf: ObjectGetPrototypeOf, 87 | isES5: isES5 88 | }; 89 | } 90 | -------------------------------------------------------------------------------- /node_modules/bluebird/js/main/filter.js: -------------------------------------------------------------------------------- 1 | /** 2 | * The MIT License (MIT) 3 | * 4 | * Copyright (c) 2014 Petka Antonov 5 | * 6 | * Permission is hereby granted, free of charge, to any person obtaining a copy 7 | * of this software and associated documentation files (the "Software"), to deal 8 | * in the Software without restriction, including without limitation the rights 9 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 10 | * copies of the Software, and to permit persons to whom the Software is 11 | * furnished to do so, subject to the following conditions:

12 | * 13 | * The above copyright notice and this permission notice shall be included in 14 | * all copies or substantial portions of the Software. 15 | * 16 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 17 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 18 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 19 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 20 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 21 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 22 | * THE SOFTWARE. 23 | * 24 | */ 25 | "use strict"; 26 | module.exports = function(Promise, INTERNAL) { 27 | var PromiseMap = Promise.map; 28 | 29 | Promise.prototype.filter = function Promise$filter(fn, options) { 30 | return PromiseMap(this, fn, options, INTERNAL); 31 | }; 32 | 33 | Promise.filter = function Promise$Filter(promises, fn, options) { 34 | return PromiseMap(promises, fn, options, INTERNAL); 35 | }; 36 | }; 37 | -------------------------------------------------------------------------------- /node_modules/bluebird/js/main/finally.js: -------------------------------------------------------------------------------- 1 | /** 2 | * The MIT License (MIT) 3 | * 4 | * Copyright (c) 2014 Petka Antonov 5 | * 6 | * Permission is hereby granted, free of charge, to any person obtaining a copy 7 | * of this software and associated documentation files (the "Software"), to deal 8 | * in the Software without restriction, including without limitation the rights 9 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 10 | * copies of the Software, and to permit persons to whom the Software is 11 | * furnished to do so, subject to the following conditions:

12 | * 13 | * The above copyright notice and this permission notice shall be included in 14 | * all copies or substantial portions of the Software. 15 | * 16 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 17 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 18 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 19 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 20 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 21 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 22 | * THE SOFTWARE. 23 | * 24 | */ 25 | "use strict"; 26 | module.exports = function(Promise, NEXT_FILTER, cast) { 27 | var util = require("./util.js"); 28 | var wrapsPrimitiveReceiver = util.wrapsPrimitiveReceiver; 29 | var isPrimitive = util.isPrimitive; 30 | var thrower = util.thrower; 31 | 32 | function returnThis() { 33 | return this; 34 | } 35 | function throwThis() { 36 | throw this; 37 | } 38 | function return$(r) { 39 | return function Promise$_returner() { 40 | return r; 41 | }; 42 | } 43 | function throw$(r) { 44 | return function Promise$_thrower() { 45 | throw r; 46 | }; 47 | } 48 | function promisedFinally(ret, reasonOrValue, isFulfilled) { 49 | var then; 50 | if (wrapsPrimitiveReceiver && isPrimitive(reasonOrValue)) { 51 | then = isFulfilled ? return$(reasonOrValue) : throw$(reasonOrValue); 52 | } else { 53 | then = isFulfilled ? returnThis : throwThis; 54 | } 55 | return ret._then(then, thrower, void 0, reasonOrValue, void 0); 56 | } 57 | 58 | function finallyHandler(reasonOrValue) { 59 | var promise = this.promise; 60 | var handler = this.handler; 61 | 62 | var ret = promise._isBound() 63 | ? handler.call(promise._boundTo) 64 | : handler(); 65 | 66 | if (ret !== void 0) { 67 | var maybePromise = cast(ret, void 0); 68 | if (maybePromise instanceof Promise) { 69 | return promisedFinally(maybePromise, reasonOrValue, 70 | promise.isFulfilled()); 71 | } 72 | } 73 | 74 | if (promise.isRejected()) { 75 | NEXT_FILTER.e = reasonOrValue; 76 | return NEXT_FILTER; 77 | } else { 78 | return reasonOrValue; 79 | } 80 | } 81 | 82 | function tapHandler(value) { 83 | var promise = this.promise; 84 | var handler = this.handler; 85 | 86 | var ret = promise._isBound() 87 | ? handler.call(promise._boundTo, value) 88 | : handler(value); 89 | 90 | if (ret !== void 0) { 91 | var maybePromise = cast(ret, void 0); 92 | if (maybePromise instanceof Promise) { 93 | return promisedFinally(maybePromise, value, true); 94 | } 95 | } 96 | return value; 97 | } 98 | 99 | Promise.prototype._passThroughHandler = 100 | function Promise$_passThroughHandler(handler, isFinally) { 101 | if (typeof handler !== "function") return this.then(); 102 | 103 | var promiseAndHandler = { 104 | promise: this, 105 | handler: handler 106 | }; 107 | 108 | return this._then( 109 | isFinally ? finallyHandler : tapHandler, 110 | isFinally ? finallyHandler : void 0, void 0, 111 | promiseAndHandler, void 0); 112 | }; 113 | 114 | Promise.prototype.lastly = 115 | Promise.prototype["finally"] = function Promise$finally(handler) { 116 | return this._passThroughHandler(handler, true); 117 | }; 118 | 119 | Promise.prototype.tap = function Promise$tap(handler) { 120 | return this._passThroughHandler(handler, false); 121 | }; 122 | }; 123 | -------------------------------------------------------------------------------- /node_modules/bluebird/js/main/generators.js: -------------------------------------------------------------------------------- 1 | /** 2 | * The MIT License (MIT) 3 | * 4 | * Copyright (c) 2014 Petka Antonov 5 | * 6 | * Permission is hereby granted, free of charge, to any person obtaining a copy 7 | * of this software and associated documentation files (the "Software"), to deal 8 | * in the Software without restriction, including without limitation the rights 9 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 10 | * copies of the Software, and to permit persons to whom the Software is 11 | * furnished to do so, subject to the following conditions:

12 | * 13 | * The above copyright notice and this permission notice shall be included in 14 | * all copies or substantial portions of the Software. 15 | * 16 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 17 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 18 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 19 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 20 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 21 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 22 | * THE SOFTWARE. 23 | * 24 | */ 25 | "use strict"; 26 | module.exports = function(Promise, apiRejection, INTERNAL, cast) { 27 | var errors = require("./errors.js"); 28 | var TypeError = errors.TypeError; 29 | var deprecated = require("./util.js").deprecated; 30 | var util = require("./util.js"); 31 | var errorObj = util.errorObj; 32 | var tryCatch1 = util.tryCatch1; 33 | var yieldHandlers = []; 34 | 35 | function promiseFromYieldHandler(value, yieldHandlers) { 36 | var _errorObj = errorObj; 37 | var _Promise = Promise; 38 | var len = yieldHandlers.length; 39 | for (var i = 0; i < len; ++i) { 40 | var result = tryCatch1(yieldHandlers[i], void 0, value); 41 | if (result === _errorObj) { 42 | return _Promise.reject(_errorObj.e); 43 | } 44 | var maybePromise = cast(result, promiseFromYieldHandler); 45 | if (maybePromise instanceof _Promise) return maybePromise; 46 | } 47 | return null; 48 | } 49 | 50 | function PromiseSpawn(generatorFunction, receiver, yieldHandler) { 51 | var promise = this._promise = new Promise(INTERNAL); 52 | promise._setTrace(void 0); 53 | this._generatorFunction = generatorFunction; 54 | this._receiver = receiver; 55 | this._generator = void 0; 56 | this._yieldHandlers = typeof yieldHandler === "function" 57 | ? [yieldHandler].concat(yieldHandlers) 58 | : yieldHandlers; 59 | } 60 | 61 | PromiseSpawn.prototype.promise = function PromiseSpawn$promise() { 62 | return this._promise; 63 | }; 64 | 65 | PromiseSpawn.prototype._run = function PromiseSpawn$_run() { 66 | this._generator = this._generatorFunction.call(this._receiver); 67 | this._receiver = 68 | this._generatorFunction = void 0; 69 | this._next(void 0); 70 | }; 71 | 72 | PromiseSpawn.prototype._continue = function PromiseSpawn$_continue(result) { 73 | if (result === errorObj) { 74 | this._generator = void 0; 75 | var trace = errors.canAttach(result.e) 76 | ? result.e : new Error(result.e + ""); 77 | this._promise._attachExtraTrace(trace); 78 | this._promise._reject(result.e, trace); 79 | return; 80 | } 81 | 82 | var value = result.value; 83 | if (result.done === true) { 84 | this._generator = void 0; 85 | if (!this._promise._tryFollow(value)) { 86 | this._promise._fulfill(value); 87 | } 88 | } else { 89 | var maybePromise = cast(value, void 0); 90 | if (!(maybePromise instanceof Promise)) { 91 | maybePromise = 92 | promiseFromYieldHandler(maybePromise, this._yieldHandlers); 93 | if (maybePromise === null) { 94 | this._throw(new TypeError("A value was yielded that could not be treated as a promise")); 95 | return; 96 | } 97 | } 98 | maybePromise._then( 99 | this._next, 100 | this._throw, 101 | void 0, 102 | this, 103 | null 104 | ); 105 | } 106 | }; 107 | 108 | PromiseSpawn.prototype._throw = function PromiseSpawn$_throw(reason) { 109 | if (errors.canAttach(reason)) 110 | this._promise._attachExtraTrace(reason); 111 | this._continue( 112 | tryCatch1(this._generator["throw"], this._generator, reason) 113 | ); 114 | }; 115 | 116 | PromiseSpawn.prototype._next = function PromiseSpawn$_next(value) { 117 | this._continue( 118 | tryCatch1(this._generator.next, this._generator, value) 119 | ); 120 | }; 121 | 122 | Promise.coroutine = 123 | function Promise$Coroutine(generatorFunction, options) { 124 | if (typeof generatorFunction !== "function") { 125 | throw new TypeError("generatorFunction must be a function"); 126 | } 127 | var yieldHandler = Object(options).yieldHandler; 128 | var PromiseSpawn$ = PromiseSpawn; 129 | return function () { 130 | var generator = generatorFunction.apply(this, arguments); 131 | var spawn = new PromiseSpawn$(void 0, void 0, yieldHandler); 132 | spawn._generator = generator; 133 | spawn._next(void 0); 134 | return spawn.promise(); 135 | }; 136 | }; 137 | 138 | Promise.coroutine.addYieldHandler = function(fn) { 139 | if (typeof fn !== "function") throw new TypeError("fn must be a function"); 140 | yieldHandlers.push(fn); 141 | }; 142 | 143 | Promise.spawn = function Promise$Spawn(generatorFunction) { 144 | deprecated("Promise.spawn is deprecated. Use Promise.coroutine instead."); 145 | if (typeof generatorFunction !== "function") { 146 | return apiRejection("generatorFunction must be a function"); 147 | } 148 | var spawn = new PromiseSpawn(generatorFunction, this); 149 | var ret = spawn.promise(); 150 | spawn._run(Promise.spawn); 151 | return ret; 152 | }; 153 | }; 154 | -------------------------------------------------------------------------------- /node_modules/bluebird/js/main/join.js: -------------------------------------------------------------------------------- 1 | /** 2 | * The MIT License (MIT) 3 | * 4 | * Copyright (c) 2014 Petka Antonov 5 | * 6 | * Permission is hereby granted, free of charge, to any person obtaining a copy 7 | * of this software and associated documentation files (the "Software"), to deal 8 | * in the Software without restriction, including without limitation the rights 9 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 10 | * copies of the Software, and to permit persons to whom the Software is 11 | * furnished to do so, subject to the following conditions:

12 | * 13 | * The above copyright notice and this permission notice shall be included in 14 | * all copies or substantial portions of the Software. 15 | * 16 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 17 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 18 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 19 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 20 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 21 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 22 | * THE SOFTWARE. 23 | * 24 | */ 25 | "use strict"; 26 | module.exports = 27 | function(Promise, PromiseArray, cast, INTERNAL) { 28 | var util = require("./util.js"); 29 | var canEvaluate = util.canEvaluate; 30 | var tryCatch1 = util.tryCatch1; 31 | var errorObj = util.errorObj; 32 | 33 | 34 | if (canEvaluate) { 35 | var thenCallback = function(i) { 36 | return new Function("value", "holder", " \n\ 37 | 'use strict'; \n\ 38 | holder.pIndex = value; \n\ 39 | holder.checkFulfillment(this); \n\ 40 | ".replace(/Index/g, i)); 41 | }; 42 | 43 | var caller = function(count) { 44 | var values = []; 45 | for (var i = 1; i <= count; ++i) values.push("holder.p" + i); 46 | return new Function("holder", " \n\ 47 | 'use strict'; \n\ 48 | var callback = holder.fn; \n\ 49 | return callback(values); \n\ 50 | ".replace(/values/g, values.join(", "))); 51 | }; 52 | var thenCallbacks = []; 53 | var callers = [void 0]; 54 | for (var i = 1; i <= 5; ++i) { 55 | thenCallbacks.push(thenCallback(i)); 56 | callers.push(caller(i)); 57 | } 58 | 59 | var Holder = function(total, fn) { 60 | this.p1 = this.p2 = this.p3 = this.p4 = this.p5 = null; 61 | this.fn = fn; 62 | this.total = total; 63 | this.now = 0; 64 | }; 65 | 66 | Holder.prototype.callers = callers; 67 | Holder.prototype.checkFulfillment = function(promise) { 68 | var now = this.now; 69 | now++; 70 | var total = this.total; 71 | if (now >= total) { 72 | var handler = this.callers[total]; 73 | var ret = tryCatch1(handler, void 0, this); 74 | if (ret === errorObj) { 75 | promise._rejectUnchecked(ret.e); 76 | } else if (!promise._tryFollow(ret)) { 77 | promise._fulfillUnchecked(ret); 78 | } 79 | } else { 80 | this.now = now; 81 | } 82 | }; 83 | } 84 | 85 | 86 | 87 | 88 | Promise.join = function Promise$Join() { 89 | var last = arguments.length - 1; 90 | var fn; 91 | if (last > 0 && typeof arguments[last] === "function") { 92 | fn = arguments[last]; 93 | if (last < 6 && canEvaluate) { 94 | var ret = new Promise(INTERNAL); 95 | ret._setTrace(void 0); 96 | var holder = new Holder(last, fn); 97 | var reject = ret._reject; 98 | var callbacks = thenCallbacks; 99 | for (var i = 0; i < last; ++i) { 100 | var maybePromise = cast(arguments[i], void 0); 101 | if (maybePromise instanceof Promise) { 102 | if (maybePromise.isPending()) { 103 | maybePromise._then(callbacks[i], reject, 104 | void 0, ret, holder); 105 | } else if (maybePromise.isFulfilled()) { 106 | callbacks[i].call(ret, 107 | maybePromise._settledValue, holder); 108 | } else { 109 | ret._reject(maybePromise._settledValue); 110 | maybePromise._unsetRejectionIsUnhandled(); 111 | } 112 | } else { 113 | callbacks[i].call(ret, maybePromise, holder); 114 | } 115 | } 116 | return ret; 117 | } 118 | } 119 | var $_len = arguments.length;var args = new Array($_len); for(var $_i = 0; $_i < $_len; ++$_i) {args[$_i] = arguments[$_i];} 120 | var ret = new PromiseArray(args).promise(); 121 | return fn !== void 0 ? ret.spread(fn) : ret; 122 | }; 123 | 124 | }; 125 | -------------------------------------------------------------------------------- /node_modules/bluebird/js/main/map.js: -------------------------------------------------------------------------------- 1 | /** 2 | * The MIT License (MIT) 3 | * 4 | * Copyright (c) 2014 Petka Antonov 5 | * 6 | * Permission is hereby granted, free of charge, to any person obtaining a copy 7 | * of this software and associated documentation files (the "Software"), to deal 8 | * in the Software without restriction, including without limitation the rights 9 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 10 | * copies of the Software, and to permit persons to whom the Software is 11 | * furnished to do so, subject to the following conditions:

12 | * 13 | * The above copyright notice and this permission notice shall be included in 14 | * all copies or substantial portions of the Software. 15 | * 16 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 17 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 18 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 19 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 20 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 21 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 22 | * THE SOFTWARE. 23 | * 24 | */ 25 | "use strict"; 26 | module.exports = function(Promise, PromiseArray, apiRejection, cast, INTERNAL) { 27 | var util = require("./util.js"); 28 | var tryCatch3 = util.tryCatch3; 29 | var errorObj = util.errorObj; 30 | var PENDING = {}; 31 | var EMPTY_ARRAY = []; 32 | 33 | function MappingPromiseArray(promises, fn, limit, _filter) { 34 | this.constructor$(promises); 35 | this._callback = fn; 36 | this._preservedValues = _filter === INTERNAL 37 | ? new Array(this.length()) 38 | : null; 39 | this._limit = limit; 40 | this._inFlight = 0; 41 | this._queue = limit >= 1 ? [] : EMPTY_ARRAY; 42 | this._init$(void 0, -2); 43 | } 44 | util.inherits(MappingPromiseArray, PromiseArray); 45 | 46 | MappingPromiseArray.prototype._init = function MappingPromiseArray$_init() {}; 47 | 48 | MappingPromiseArray.prototype._promiseFulfilled = 49 | function MappingPromiseArray$_promiseFulfilled(value, index) { 50 | var values = this._values; 51 | if (values === null) return; 52 | 53 | var length = this.length(); 54 | var preservedValues = this._preservedValues; 55 | var limit = this._limit; 56 | if (values[index] === PENDING) { 57 | values[index] = value; 58 | if (limit >= 1) { 59 | this._inFlight--; 60 | this._drainQueue(); 61 | if (this._isResolved()) return; 62 | } 63 | } else { 64 | if (limit >= 1 && this._inFlight >= limit) { 65 | values[index] = value; 66 | this._queue.push(index); 67 | return; 68 | } 69 | if (preservedValues !== null) preservedValues[index] = value; 70 | 71 | var callback = this._callback; 72 | var receiver = this._promise._boundTo; 73 | var ret = tryCatch3(callback, receiver, value, index, length); 74 | if (ret === errorObj) return this._reject(ret.e); 75 | 76 | var maybePromise = cast(ret, void 0); 77 | if (maybePromise instanceof Promise) { 78 | if (maybePromise.isPending()) { 79 | if (limit >= 1) this._inFlight++; 80 | values[index] = PENDING; 81 | return maybePromise._proxyPromiseArray(this, index); 82 | } else if (maybePromise.isFulfilled()) { 83 | ret = maybePromise.value(); 84 | } else { 85 | maybePromise._unsetRejectionIsUnhandled(); 86 | return this._reject(maybePromise.reason()); 87 | } 88 | } 89 | values[index] = ret; 90 | } 91 | var totalResolved = ++this._totalResolved; 92 | if (totalResolved >= length) { 93 | if (preservedValues !== null) { 94 | this._filter(values, preservedValues); 95 | } else { 96 | this._resolve(values); 97 | } 98 | 99 | } 100 | }; 101 | 102 | MappingPromiseArray.prototype._drainQueue = 103 | function MappingPromiseArray$_drainQueue() { 104 | var queue = this._queue; 105 | var limit = this._limit; 106 | var values = this._values; 107 | while (queue.length > 0 && this._inFlight < limit) { 108 | var index = queue.pop(); 109 | this._promiseFulfilled(values[index], index); 110 | } 111 | }; 112 | 113 | MappingPromiseArray.prototype._filter = 114 | function MappingPromiseArray$_filter(booleans, values) { 115 | var len = values.length; 116 | var ret = new Array(len); 117 | var j = 0; 118 | for (var i = 0; i < len; ++i) { 119 | if (booleans[i]) ret[j++] = values[i]; 120 | } 121 | ret.length = j; 122 | this._resolve(ret); 123 | }; 124 | 125 | MappingPromiseArray.prototype.preservedValues = 126 | function MappingPromiseArray$preserveValues() { 127 | return this._preservedValues; 128 | }; 129 | 130 | function map(promises, fn, options, _filter) { 131 | var limit = typeof options === "object" && options !== null 132 | ? options.concurrency 133 | : 0; 134 | limit = typeof limit === "number" && 135 | isFinite(limit) && limit >= 1 ? limit : 0; 136 | return new MappingPromiseArray(promises, fn, limit, _filter); 137 | } 138 | 139 | Promise.prototype.map = function Promise$map(fn, options) { 140 | if (typeof fn !== "function") return apiRejection("fn must be a function"); 141 | 142 | return map(this, fn, options, null).promise(); 143 | }; 144 | 145 | Promise.map = function Promise$Map(promises, fn, options, _filter) { 146 | if (typeof fn !== "function") return apiRejection("fn must be a function"); 147 | return map(promises, fn, options, _filter).promise(); 148 | }; 149 | 150 | 151 | }; 152 | -------------------------------------------------------------------------------- /node_modules/bluebird/js/main/nodeify.js: -------------------------------------------------------------------------------- 1 | /** 2 | * The MIT License (MIT) 3 | * 4 | * Copyright (c) 2014 Petka Antonov 5 | * 6 | * Permission is hereby granted, free of charge, to any person obtaining a copy 7 | * of this software and associated documentation files (the "Software"), to deal 8 | * in the Software without restriction, including without limitation the rights 9 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 10 | * copies of the Software, and to permit persons to whom the Software is 11 | * furnished to do so, subject to the following conditions:

12 | * 13 | * The above copyright notice and this permission notice shall be included in 14 | * all copies or substantial portions of the Software. 15 | * 16 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 17 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 18 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 19 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 20 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 21 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 22 | * THE SOFTWARE. 23 | * 24 | */ 25 | "use strict"; 26 | module.exports = function(Promise) { 27 | var util = require("./util.js"); 28 | var async = require("./async.js"); 29 | var tryCatch2 = util.tryCatch2; 30 | var tryCatch1 = util.tryCatch1; 31 | var errorObj = util.errorObj; 32 | 33 | function thrower(r) { 34 | throw r; 35 | } 36 | 37 | function Promise$_spreadAdapter(val, receiver) { 38 | if (!util.isArray(val)) return Promise$_successAdapter(val, receiver); 39 | var ret = util.tryCatchApply(this, [null].concat(val), receiver); 40 | if (ret === errorObj) { 41 | async.invokeLater(thrower, void 0, ret.e); 42 | } 43 | } 44 | 45 | function Promise$_successAdapter(val, receiver) { 46 | var nodeback = this; 47 | var ret = val === void 0 48 | ? tryCatch1(nodeback, receiver, null) 49 | : tryCatch2(nodeback, receiver, null, val); 50 | if (ret === errorObj) { 51 | async.invokeLater(thrower, void 0, ret.e); 52 | } 53 | } 54 | function Promise$_errorAdapter(reason, receiver) { 55 | var nodeback = this; 56 | var ret = tryCatch1(nodeback, receiver, reason); 57 | if (ret === errorObj) { 58 | async.invokeLater(thrower, void 0, ret.e); 59 | } 60 | } 61 | 62 | Promise.prototype.nodeify = function Promise$nodeify(nodeback, options) { 63 | if (typeof nodeback == "function") { 64 | var adapter = Promise$_successAdapter; 65 | if (options !== void 0 && Object(options).spread) { 66 | adapter = Promise$_spreadAdapter; 67 | } 68 | this._then( 69 | adapter, 70 | Promise$_errorAdapter, 71 | void 0, 72 | nodeback, 73 | this._boundTo 74 | ); 75 | } 76 | return this; 77 | }; 78 | }; 79 | -------------------------------------------------------------------------------- /node_modules/bluebird/js/main/progress.js: -------------------------------------------------------------------------------- 1 | /** 2 | * The MIT License (MIT) 3 | * 4 | * Copyright (c) 2014 Petka Antonov 5 | * 6 | * Permission is hereby granted, free of charge, to any person obtaining a copy 7 | * of this software and associated documentation files (the "Software"), to deal 8 | * in the Software without restriction, including without limitation the rights 9 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 10 | * copies of the Software, and to permit persons to whom the Software is 11 | * furnished to do so, subject to the following conditions:

12 | * 13 | * The above copyright notice and this permission notice shall be included in 14 | * all copies or substantial portions of the Software. 15 | * 16 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 17 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 18 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 19 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 20 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 21 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 22 | * THE SOFTWARE. 23 | * 24 | */ 25 | "use strict"; 26 | module.exports = function(Promise, PromiseArray) { 27 | var util = require("./util.js"); 28 | var async = require("./async.js"); 29 | var errors = require("./errors.js"); 30 | var tryCatch1 = util.tryCatch1; 31 | var errorObj = util.errorObj; 32 | 33 | Promise.prototype.progressed = function Promise$progressed(handler) { 34 | return this._then(void 0, void 0, handler, void 0, void 0); 35 | }; 36 | 37 | Promise.prototype._progress = function Promise$_progress(progressValue) { 38 | if (this._isFollowingOrFulfilledOrRejected()) return; 39 | this._progressUnchecked(progressValue); 40 | 41 | }; 42 | 43 | Promise.prototype._clearFirstHandlerData$Base = 44 | Promise.prototype._clearFirstHandlerData; 45 | Promise.prototype._clearFirstHandlerData = 46 | function Promise$_clearFirstHandlerData() { 47 | this._clearFirstHandlerData$Base(); 48 | this._progressHandler0 = void 0; 49 | }; 50 | 51 | Promise.prototype._progressHandlerAt = 52 | function Promise$_progressHandlerAt(index) { 53 | return index === 0 54 | ? this._progressHandler0 55 | : this[(index << 2) + index - 5 + 2]; 56 | }; 57 | 58 | Promise.prototype._doProgressWith = 59 | function Promise$_doProgressWith(progression) { 60 | var progressValue = progression.value; 61 | var handler = progression.handler; 62 | var promise = progression.promise; 63 | var receiver = progression.receiver; 64 | 65 | var ret = tryCatch1(handler, receiver, progressValue); 66 | if (ret === errorObj) { 67 | if (ret.e != null && 68 | ret.e.name !== "StopProgressPropagation") { 69 | var trace = errors.canAttach(ret.e) 70 | ? ret.e : new Error(ret.e + ""); 71 | promise._attachExtraTrace(trace); 72 | promise._progress(ret.e); 73 | } 74 | } else if (ret instanceof Promise) { 75 | ret._then(promise._progress, null, null, promise, void 0); 76 | } else { 77 | promise._progress(ret); 78 | } 79 | }; 80 | 81 | 82 | Promise.prototype._progressUnchecked = 83 | function Promise$_progressUnchecked(progressValue) { 84 | if (!this.isPending()) return; 85 | var len = this._length(); 86 | var progress = this._progress; 87 | for (var i = 0; i < len; i++) { 88 | var handler = this._progressHandlerAt(i); 89 | var promise = this._promiseAt(i); 90 | if (!(promise instanceof Promise)) { 91 | var receiver = this._receiverAt(i); 92 | if (typeof handler === "function") { 93 | handler.call(receiver, progressValue, promise); 94 | } else if (receiver instanceof Promise && receiver._isProxied()) { 95 | receiver._progressUnchecked(progressValue); 96 | } else if (receiver instanceof PromiseArray) { 97 | receiver._promiseProgressed(progressValue, promise); 98 | } 99 | continue; 100 | } 101 | 102 | if (typeof handler === "function") { 103 | async.invoke(this._doProgressWith, this, { 104 | handler: handler, 105 | promise: promise, 106 | receiver: this._receiverAt(i), 107 | value: progressValue 108 | }); 109 | } else { 110 | async.invoke(progress, promise, progressValue); 111 | } 112 | } 113 | }; 114 | }; 115 | -------------------------------------------------------------------------------- /node_modules/bluebird/js/main/props.js: -------------------------------------------------------------------------------- 1 | /** 2 | * The MIT License (MIT) 3 | * 4 | * Copyright (c) 2014 Petka Antonov 5 | * 6 | * Permission is hereby granted, free of charge, to any person obtaining a copy 7 | * of this software and associated documentation files (the "Software"), to deal 8 | * in the Software without restriction, including without limitation the rights 9 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 10 | * copies of the Software, and to permit persons to whom the Software is 11 | * furnished to do so, subject to the following conditions:

12 | * 13 | * The above copyright notice and this permission notice shall be included in 14 | * all copies or substantial portions of the Software. 15 | * 16 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 17 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 18 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 19 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 20 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 21 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 22 | * THE SOFTWARE. 23 | * 24 | */ 25 | "use strict"; 26 | module.exports = function(Promise, PromiseArray, cast) { 27 | var util = require("./util.js"); 28 | var apiRejection = require("./errors_api_rejection")(Promise); 29 | var isObject = util.isObject; 30 | var es5 = require("./es5.js"); 31 | 32 | function PropertiesPromiseArray(obj) { 33 | var keys = es5.keys(obj); 34 | var len = keys.length; 35 | var values = new Array(len * 2); 36 | for (var i = 0; i < len; ++i) { 37 | var key = keys[i]; 38 | values[i] = obj[key]; 39 | values[i + len] = key; 40 | } 41 | this.constructor$(values); 42 | } 43 | util.inherits(PropertiesPromiseArray, PromiseArray); 44 | 45 | PropertiesPromiseArray.prototype._init = 46 | function PropertiesPromiseArray$_init() { 47 | this._init$(void 0, -3) ; 48 | }; 49 | 50 | PropertiesPromiseArray.prototype._promiseFulfilled = 51 | function PropertiesPromiseArray$_promiseFulfilled(value, index) { 52 | if (this._isResolved()) return; 53 | this._values[index] = value; 54 | var totalResolved = ++this._totalResolved; 55 | if (totalResolved >= this._length) { 56 | var val = {}; 57 | var keyOffset = this.length(); 58 | for (var i = 0, len = this.length(); i < len; ++i) { 59 | val[this._values[i + keyOffset]] = this._values[i]; 60 | } 61 | this._resolve(val); 62 | } 63 | }; 64 | 65 | PropertiesPromiseArray.prototype._promiseProgressed = 66 | function PropertiesPromiseArray$_promiseProgressed(value, index) { 67 | if (this._isResolved()) return; 68 | 69 | this._promise._progress({ 70 | key: this._values[index + this.length()], 71 | value: value 72 | }); 73 | }; 74 | 75 | PropertiesPromiseArray.prototype.shouldCopyValues = 76 | function PropertiesPromiseArray$_shouldCopyValues() { 77 | return false; 78 | }; 79 | 80 | PropertiesPromiseArray.prototype.getActualLength = 81 | function PropertiesPromiseArray$getActualLength(len) { 82 | return len >> 1; 83 | }; 84 | 85 | function Promise$_Props(promises) { 86 | var ret; 87 | var castValue = cast(promises, void 0); 88 | 89 | if (!isObject(castValue)) { 90 | return apiRejection("cannot await properties of a non-object"); 91 | } else if (castValue instanceof Promise) { 92 | ret = castValue._then(Promise.props, void 0, void 0, void 0, void 0); 93 | } else { 94 | ret = new PropertiesPromiseArray(castValue).promise(); 95 | } 96 | 97 | if (castValue instanceof Promise) { 98 | ret._propagateFrom(castValue, 4); 99 | } 100 | return ret; 101 | } 102 | 103 | Promise.prototype.props = function Promise$props() { 104 | return Promise$_Props(this); 105 | }; 106 | 107 | Promise.props = function Promise$Props(promises) { 108 | return Promise$_Props(promises); 109 | }; 110 | }; 111 | -------------------------------------------------------------------------------- /node_modules/bluebird/js/main/queue.js: -------------------------------------------------------------------------------- 1 | /** 2 | * The MIT License (MIT) 3 | * 4 | * Copyright (c) 2014 Petka Antonov 5 | * 6 | * Permission is hereby granted, free of charge, to any person obtaining a copy 7 | * of this software and associated documentation files (the "Software"), to deal 8 | * in the Software without restriction, including without limitation the rights 9 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 10 | * copies of the Software, and to permit persons to whom the Software is 11 | * furnished to do so, subject to the following conditions:

12 | * 13 | * The above copyright notice and this permission notice shall be included in 14 | * all copies or substantial portions of the Software. 15 | * 16 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 17 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 18 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 19 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 20 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 21 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 22 | * THE SOFTWARE. 23 | * 24 | */ 25 | "use strict"; 26 | function arrayCopy(src, srcIndex, dst, dstIndex, len) { 27 | for (var j = 0; j < len; ++j) { 28 | dst[j + dstIndex] = src[j + srcIndex]; 29 | } 30 | } 31 | 32 | function Queue(capacity) { 33 | this._capacity = capacity; 34 | this._length = 0; 35 | this._front = 0; 36 | this._makeCapacity(); 37 | } 38 | 39 | Queue.prototype._willBeOverCapacity = 40 | function Queue$_willBeOverCapacity(size) { 41 | return this._capacity < size; 42 | }; 43 | 44 | Queue.prototype._pushOne = function Queue$_pushOne(arg) { 45 | var length = this.length(); 46 | this._checkCapacity(length + 1); 47 | var i = (this._front + length) & (this._capacity - 1); 48 | this[i] = arg; 49 | this._length = length + 1; 50 | }; 51 | 52 | Queue.prototype.push = function Queue$push(fn, receiver, arg) { 53 | var length = this.length() + 3; 54 | if (this._willBeOverCapacity(length)) { 55 | this._pushOne(fn); 56 | this._pushOne(receiver); 57 | this._pushOne(arg); 58 | return; 59 | } 60 | var j = this._front + length - 3; 61 | this._checkCapacity(length); 62 | var wrapMask = this._capacity - 1; 63 | this[(j + 0) & wrapMask] = fn; 64 | this[(j + 1) & wrapMask] = receiver; 65 | this[(j + 2) & wrapMask] = arg; 66 | this._length = length; 67 | }; 68 | 69 | Queue.prototype.shift = function Queue$shift() { 70 | var front = this._front, 71 | ret = this[front]; 72 | 73 | this[front] = void 0; 74 | this._front = (front + 1) & (this._capacity - 1); 75 | this._length--; 76 | return ret; 77 | }; 78 | 79 | Queue.prototype.length = function Queue$length() { 80 | return this._length; 81 | }; 82 | 83 | Queue.prototype._makeCapacity = function Queue$_makeCapacity() { 84 | var len = this._capacity; 85 | for (var i = 0; i < len; ++i) { 86 | this[i] = void 0; 87 | } 88 | }; 89 | 90 | Queue.prototype._checkCapacity = function Queue$_checkCapacity(size) { 91 | if (this._capacity < size) { 92 | this._resizeTo(this._capacity << 3); 93 | } 94 | }; 95 | 96 | Queue.prototype._resizeTo = function Queue$_resizeTo(capacity) { 97 | var oldFront = this._front; 98 | var oldCapacity = this._capacity; 99 | var oldQueue = new Array(oldCapacity); 100 | var length = this.length(); 101 | 102 | arrayCopy(this, 0, oldQueue, 0, oldCapacity); 103 | this._capacity = capacity; 104 | this._makeCapacity(); 105 | this._front = 0; 106 | if (oldFront + length <= oldCapacity) { 107 | arrayCopy(oldQueue, oldFront, this, 0, length); 108 | } else { var lengthBeforeWrapping = 109 | length - ((oldFront + length) & (oldCapacity - 1)); 110 | 111 | arrayCopy(oldQueue, oldFront, this, 0, lengthBeforeWrapping); 112 | arrayCopy(oldQueue, 0, this, lengthBeforeWrapping, 113 | length - lengthBeforeWrapping); 114 | } 115 | }; 116 | 117 | module.exports = Queue; 118 | -------------------------------------------------------------------------------- /node_modules/bluebird/js/main/race.js: -------------------------------------------------------------------------------- 1 | /** 2 | * The MIT License (MIT) 3 | * 4 | * Copyright (c) 2014 Petka Antonov 5 | * 6 | * Permission is hereby granted, free of charge, to any person obtaining a copy 7 | * of this software and associated documentation files (the "Software"), to deal 8 | * in the Software without restriction, including without limitation the rights 9 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 10 | * copies of the Software, and to permit persons to whom the Software is 11 | * furnished to do so, subject to the following conditions:

12 | * 13 | * The above copyright notice and this permission notice shall be included in 14 | * all copies or substantial portions of the Software. 15 | * 16 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 17 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 18 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 19 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 20 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 21 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 22 | * THE SOFTWARE. 23 | * 24 | */ 25 | "use strict"; 26 | module.exports = function(Promise, INTERNAL, cast) { 27 | var apiRejection = require("./errors_api_rejection.js")(Promise); 28 | var isArray = require("./util.js").isArray; 29 | 30 | var raceLater = function Promise$_raceLater(promise) { 31 | return promise.then(function(array) { 32 | return Promise$_Race(array, promise); 33 | }); 34 | }; 35 | 36 | var hasOwn = {}.hasOwnProperty; 37 | function Promise$_Race(promises, parent) { 38 | var maybePromise = cast(promises, void 0); 39 | 40 | if (maybePromise instanceof Promise) { 41 | return raceLater(maybePromise); 42 | } else if (!isArray(promises)) { 43 | return apiRejection("expecting an array, a promise or a thenable"); 44 | } 45 | 46 | var ret = new Promise(INTERNAL); 47 | if (parent !== void 0) { 48 | ret._propagateFrom(parent, 7); 49 | } else { 50 | ret._setTrace(void 0); 51 | } 52 | var fulfill = ret._fulfill; 53 | var reject = ret._reject; 54 | for (var i = 0, len = promises.length; i < len; ++i) { 55 | var val = promises[i]; 56 | 57 | if (val === void 0 && !(hasOwn.call(promises, i))) { 58 | continue; 59 | } 60 | 61 | Promise.cast(val)._then(fulfill, reject, void 0, ret, null); 62 | } 63 | return ret; 64 | } 65 | 66 | Promise.race = function Promise$Race(promises) { 67 | return Promise$_Race(promises, void 0); 68 | }; 69 | 70 | Promise.prototype.race = function Promise$race() { 71 | return Promise$_Race(this, void 0); 72 | }; 73 | 74 | }; 75 | -------------------------------------------------------------------------------- /node_modules/bluebird/js/main/schedule.js: -------------------------------------------------------------------------------- 1 | /** 2 | * The MIT License (MIT) 3 | * 4 | * Copyright (c) 2014 Petka Antonov 5 | * 6 | * Permission is hereby granted, free of charge, to any person obtaining a copy 7 | * of this software and associated documentation files (the "Software"), to deal 8 | * in the Software without restriction, including without limitation the rights 9 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 10 | * copies of the Software, and to permit persons to whom the Software is 11 | * furnished to do so, subject to the following conditions:

12 | * 13 | * The above copyright notice and this permission notice shall be included in 14 | * all copies or substantial portions of the Software. 15 | * 16 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 17 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 18 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 19 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 20 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 21 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 22 | * THE SOFTWARE. 23 | * 24 | */ 25 | "use strict"; 26 | var schedule; 27 | var _MutationObserver; 28 | if (typeof process === "object" && typeof process.version === "string") { 29 | schedule = function Promise$_Scheduler(fn) { 30 | process.nextTick(fn); 31 | }; 32 | } 33 | else if ((typeof MutationObserver !== "undefined" && 34 | (_MutationObserver = MutationObserver)) || 35 | (typeof WebKitMutationObserver !== "undefined" && 36 | (_MutationObserver = WebKitMutationObserver))) { 37 | schedule = (function() { 38 | var div = document.createElement("div"); 39 | var queuedFn = void 0; 40 | var observer = new _MutationObserver( 41 | function Promise$_Scheduler() { 42 | var fn = queuedFn; 43 | queuedFn = void 0; 44 | fn(); 45 | } 46 | ); 47 | observer.observe(div, { 48 | attributes: true 49 | }); 50 | return function Promise$_Scheduler(fn) { 51 | queuedFn = fn; 52 | div.classList.toggle("foo"); 53 | }; 54 | 55 | })(); 56 | } 57 | else if (typeof setTimeout !== "undefined") { 58 | schedule = function Promise$_Scheduler(fn) { 59 | setTimeout(fn, 0); 60 | }; 61 | } 62 | else throw new Error("no async scheduler available"); 63 | module.exports = schedule; 64 | -------------------------------------------------------------------------------- /node_modules/bluebird/js/main/settle.js: -------------------------------------------------------------------------------- 1 | /** 2 | * The MIT License (MIT) 3 | * 4 | * Copyright (c) 2014 Petka Antonov 5 | * 6 | * Permission is hereby granted, free of charge, to any person obtaining a copy 7 | * of this software and associated documentation files (the "Software"), to deal 8 | * in the Software without restriction, including without limitation the rights 9 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 10 | * copies of the Software, and to permit persons to whom the Software is 11 | * furnished to do so, subject to the following conditions:

12 | * 13 | * The above copyright notice and this permission notice shall be included in 14 | * all copies or substantial portions of the Software. 15 | * 16 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 17 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 18 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 19 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 20 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 21 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 22 | * THE SOFTWARE. 23 | * 24 | */ 25 | "use strict"; 26 | module.exports = 27 | function(Promise, PromiseArray) { 28 | var PromiseInspection = Promise.PromiseInspection; 29 | var util = require("./util.js"); 30 | 31 | function SettledPromiseArray(values) { 32 | this.constructor$(values); 33 | } 34 | util.inherits(SettledPromiseArray, PromiseArray); 35 | 36 | SettledPromiseArray.prototype._promiseResolved = 37 | function SettledPromiseArray$_promiseResolved(index, inspection) { 38 | this._values[index] = inspection; 39 | var totalResolved = ++this._totalResolved; 40 | if (totalResolved >= this._length) { 41 | this._resolve(this._values); 42 | } 43 | }; 44 | 45 | SettledPromiseArray.prototype._promiseFulfilled = 46 | function SettledPromiseArray$_promiseFulfilled(value, index) { 47 | if (this._isResolved()) return; 48 | var ret = new PromiseInspection(); 49 | ret._bitField = 268435456; 50 | ret._settledValue = value; 51 | this._promiseResolved(index, ret); 52 | }; 53 | SettledPromiseArray.prototype._promiseRejected = 54 | function SettledPromiseArray$_promiseRejected(reason, index) { 55 | if (this._isResolved()) return; 56 | var ret = new PromiseInspection(); 57 | ret._bitField = 134217728; 58 | ret._settledValue = reason; 59 | this._promiseResolved(index, ret); 60 | }; 61 | 62 | Promise.settle = function Promise$Settle(promises) { 63 | return new SettledPromiseArray(promises).promise(); 64 | }; 65 | 66 | Promise.prototype.settle = function Promise$settle() { 67 | return new SettledPromiseArray(this).promise(); 68 | }; 69 | }; 70 | -------------------------------------------------------------------------------- /node_modules/bluebird/js/main/some.js: -------------------------------------------------------------------------------- 1 | /** 2 | * The MIT License (MIT) 3 | * 4 | * Copyright (c) 2014 Petka Antonov 5 | * 6 | * Permission is hereby granted, free of charge, to any person obtaining a copy 7 | * of this software and associated documentation files (the "Software"), to deal 8 | * in the Software without restriction, including without limitation the rights 9 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 10 | * copies of the Software, and to permit persons to whom the Software is 11 | * furnished to do so, subject to the following conditions:

12 | * 13 | * The above copyright notice and this permission notice shall be included in 14 | * all copies or substantial portions of the Software. 15 | * 16 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 17 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 18 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 19 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 20 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 21 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 22 | * THE SOFTWARE. 23 | * 24 | */ 25 | "use strict"; 26 | module.exports = 27 | function(Promise, PromiseArray, apiRejection) { 28 | var util = require("./util.js"); 29 | var RangeError = require("./errors.js").RangeError; 30 | var AggregateError = require("./errors.js").AggregateError; 31 | var isArray = util.isArray; 32 | 33 | 34 | function SomePromiseArray(values) { 35 | this.constructor$(values); 36 | this._howMany = 0; 37 | this._unwrap = false; 38 | this._initialized = false; 39 | } 40 | util.inherits(SomePromiseArray, PromiseArray); 41 | 42 | SomePromiseArray.prototype._init = function SomePromiseArray$_init() { 43 | if (!this._initialized) { 44 | return; 45 | } 46 | if (this._howMany === 0) { 47 | this._resolve([]); 48 | return; 49 | } 50 | this._init$(void 0, -5); 51 | var isArrayResolved = isArray(this._values); 52 | if (!this._isResolved() && 53 | isArrayResolved && 54 | this._howMany > this._canPossiblyFulfill()) { 55 | this._reject(this._getRangeError(this.length())); 56 | } 57 | }; 58 | 59 | SomePromiseArray.prototype.init = function SomePromiseArray$init() { 60 | this._initialized = true; 61 | this._init(); 62 | }; 63 | 64 | SomePromiseArray.prototype.setUnwrap = function SomePromiseArray$setUnwrap() { 65 | this._unwrap = true; 66 | }; 67 | 68 | SomePromiseArray.prototype.howMany = function SomePromiseArray$howMany() { 69 | return this._howMany; 70 | }; 71 | 72 | SomePromiseArray.prototype.setHowMany = 73 | function SomePromiseArray$setHowMany(count) { 74 | if (this._isResolved()) return; 75 | this._howMany = count; 76 | }; 77 | 78 | SomePromiseArray.prototype._promiseFulfilled = 79 | function SomePromiseArray$_promiseFulfilled(value) { 80 | if (this._isResolved()) return; 81 | this._addFulfilled(value); 82 | if (this._fulfilled() === this.howMany()) { 83 | this._values.length = this.howMany(); 84 | if (this.howMany() === 1 && this._unwrap) { 85 | this._resolve(this._values[0]); 86 | } else { 87 | this._resolve(this._values); 88 | } 89 | } 90 | 91 | }; 92 | SomePromiseArray.prototype._promiseRejected = 93 | function SomePromiseArray$_promiseRejected(reason) { 94 | if (this._isResolved()) return; 95 | this._addRejected(reason); 96 | if (this.howMany() > this._canPossiblyFulfill()) { 97 | var e = new AggregateError(); 98 | for (var i = this.length(); i < this._values.length; ++i) { 99 | e.push(this._values[i]); 100 | } 101 | this._reject(e); 102 | } 103 | }; 104 | 105 | SomePromiseArray.prototype._fulfilled = function SomePromiseArray$_fulfilled() { 106 | return this._totalResolved; 107 | }; 108 | 109 | SomePromiseArray.prototype._rejected = function SomePromiseArray$_rejected() { 110 | return this._values.length - this.length(); 111 | }; 112 | 113 | SomePromiseArray.prototype._addRejected = 114 | function SomePromiseArray$_addRejected(reason) { 115 | this._values.push(reason); 116 | }; 117 | 118 | SomePromiseArray.prototype._addFulfilled = 119 | function SomePromiseArray$_addFulfilled(value) { 120 | this._values[this._totalResolved++] = value; 121 | }; 122 | 123 | SomePromiseArray.prototype._canPossiblyFulfill = 124 | function SomePromiseArray$_canPossiblyFulfill() { 125 | return this.length() - this._rejected(); 126 | }; 127 | 128 | SomePromiseArray.prototype._getRangeError = 129 | function SomePromiseArray$_getRangeError(count) { 130 | var message = "Input array must contain at least " + 131 | this._howMany + " items but contains only " + count + " items"; 132 | return new RangeError(message); 133 | }; 134 | 135 | SomePromiseArray.prototype._resolveEmptyArray = 136 | function SomePromiseArray$_resolveEmptyArray() { 137 | this._reject(this._getRangeError(0)); 138 | }; 139 | 140 | function Promise$_Some(promises, howMany) { 141 | if ((howMany | 0) !== howMany || howMany < 0) { 142 | return apiRejection("expecting a positive integer"); 143 | } 144 | var ret = new SomePromiseArray(promises); 145 | var promise = ret.promise(); 146 | if (promise.isRejected()) { 147 | return promise; 148 | } 149 | ret.setHowMany(howMany); 150 | ret.init(); 151 | return promise; 152 | } 153 | 154 | Promise.some = function Promise$Some(promises, howMany) { 155 | return Promise$_Some(promises, howMany); 156 | }; 157 | 158 | Promise.prototype.some = function Promise$some(howMany) { 159 | return Promise$_Some(this, howMany); 160 | }; 161 | 162 | Promise._SomePromiseArray = SomePromiseArray; 163 | }; 164 | -------------------------------------------------------------------------------- /node_modules/bluebird/js/main/synchronous_inspection.js: -------------------------------------------------------------------------------- 1 | /** 2 | * The MIT License (MIT) 3 | * 4 | * Copyright (c) 2014 Petka Antonov 5 | * 6 | * Permission is hereby granted, free of charge, to any person obtaining a copy 7 | * of this software and associated documentation files (the "Software"), to deal 8 | * in the Software without restriction, including without limitation the rights 9 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 10 | * copies of the Software, and to permit persons to whom the Software is 11 | * furnished to do so, subject to the following conditions:

12 | * 13 | * The above copyright notice and this permission notice shall be included in 14 | * all copies or substantial portions of the Software. 15 | * 16 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 17 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 18 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 19 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 20 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 21 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 22 | * THE SOFTWARE. 23 | * 24 | */ 25 | "use strict"; 26 | module.exports = function(Promise) { 27 | function PromiseInspection(promise) { 28 | if (promise !== void 0) { 29 | this._bitField = promise._bitField; 30 | this._settledValue = promise.isResolved() 31 | ? promise._settledValue 32 | : void 0; 33 | } 34 | else { 35 | this._bitField = 0; 36 | this._settledValue = void 0; 37 | } 38 | } 39 | 40 | PromiseInspection.prototype.isFulfilled = 41 | Promise.prototype.isFulfilled = function Promise$isFulfilled() { 42 | return (this._bitField & 268435456) > 0; 43 | }; 44 | 45 | PromiseInspection.prototype.isRejected = 46 | Promise.prototype.isRejected = function Promise$isRejected() { 47 | return (this._bitField & 134217728) > 0; 48 | }; 49 | 50 | PromiseInspection.prototype.isPending = 51 | Promise.prototype.isPending = function Promise$isPending() { 52 | return (this._bitField & 402653184) === 0; 53 | }; 54 | 55 | PromiseInspection.prototype.value = 56 | Promise.prototype.value = function Promise$value() { 57 | if (!this.isFulfilled()) { 58 | throw new TypeError("cannot get fulfillment value of a non-fulfilled promise"); 59 | } 60 | return this._settledValue; 61 | }; 62 | 63 | PromiseInspection.prototype.error = 64 | PromiseInspection.prototype.reason = 65 | Promise.prototype.reason = function Promise$reason() { 66 | if (!this.isRejected()) { 67 | throw new TypeError("cannot get rejection reason of a non-rejected promise"); 68 | } 69 | return this._settledValue; 70 | }; 71 | 72 | PromiseInspection.prototype.isResolved = 73 | Promise.prototype.isResolved = function Promise$isResolved() { 74 | return (this._bitField & 402653184) > 0; 75 | }; 76 | 77 | Promise.PromiseInspection = PromiseInspection; 78 | }; 79 | -------------------------------------------------------------------------------- /node_modules/bluebird/js/main/thenables.js: -------------------------------------------------------------------------------- 1 | /** 2 | * The MIT License (MIT) 3 | * 4 | * Copyright (c) 2014 Petka Antonov 5 | * 6 | * Permission is hereby granted, free of charge, to any person obtaining a copy 7 | * of this software and associated documentation files (the "Software"), to deal 8 | * in the Software without restriction, including without limitation the rights 9 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 10 | * copies of the Software, and to permit persons to whom the Software is 11 | * furnished to do so, subject to the following conditions:

12 | * 13 | * The above copyright notice and this permission notice shall be included in 14 | * all copies or substantial portions of the Software. 15 | * 16 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 17 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 18 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 19 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 20 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 21 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 22 | * THE SOFTWARE. 23 | * 24 | */ 25 | "use strict"; 26 | module.exports = function(Promise, INTERNAL) { 27 | var util = require("./util.js"); 28 | var canAttach = require("./errors.js").canAttach; 29 | var errorObj = util.errorObj; 30 | var isObject = util.isObject; 31 | 32 | function getThen(obj) { 33 | try { 34 | return obj.then; 35 | } 36 | catch(e) { 37 | errorObj.e = e; 38 | return errorObj; 39 | } 40 | } 41 | 42 | function Promise$_Cast(obj, originalPromise) { 43 | if (isObject(obj)) { 44 | if (obj instanceof Promise) { 45 | return obj; 46 | } 47 | else if (isAnyBluebirdPromise(obj)) { 48 | var ret = new Promise(INTERNAL); 49 | ret._setTrace(void 0); 50 | obj._then( 51 | ret._fulfillUnchecked, 52 | ret._rejectUncheckedCheckError, 53 | ret._progressUnchecked, 54 | ret, 55 | null 56 | ); 57 | ret._setFollowing(); 58 | return ret; 59 | } 60 | var then = getThen(obj); 61 | if (then === errorObj) { 62 | if (originalPromise !== void 0 && canAttach(then.e)) { 63 | originalPromise._attachExtraTrace(then.e); 64 | } 65 | return Promise.reject(then.e); 66 | } else if (typeof then === "function") { 67 | return Promise$_doThenable(obj, then, originalPromise); 68 | } 69 | } 70 | return obj; 71 | } 72 | 73 | var hasProp = {}.hasOwnProperty; 74 | function isAnyBluebirdPromise(obj) { 75 | return hasProp.call(obj, "_promise0"); 76 | } 77 | 78 | function Promise$_doThenable(x, then, originalPromise) { 79 | var resolver = Promise.defer(); 80 | var called = false; 81 | try { 82 | then.call( 83 | x, 84 | Promise$_resolveFromThenable, 85 | Promise$_rejectFromThenable, 86 | Promise$_progressFromThenable 87 | ); 88 | } catch(e) { 89 | if (!called) { 90 | called = true; 91 | var trace = canAttach(e) ? e : new Error(e + ""); 92 | if (originalPromise !== void 0) { 93 | originalPromise._attachExtraTrace(trace); 94 | } 95 | resolver.promise._reject(e, trace); 96 | } 97 | } 98 | return resolver.promise; 99 | 100 | function Promise$_resolveFromThenable(y) { 101 | if (called) return; 102 | called = true; 103 | 104 | if (x === y) { 105 | var e = Promise._makeSelfResolutionError(); 106 | if (originalPromise !== void 0) { 107 | originalPromise._attachExtraTrace(e); 108 | } 109 | resolver.promise._reject(e, void 0); 110 | return; 111 | } 112 | resolver.resolve(y); 113 | } 114 | 115 | function Promise$_rejectFromThenable(r) { 116 | if (called) return; 117 | called = true; 118 | var trace = canAttach(r) ? r : new Error(r + ""); 119 | if (originalPromise !== void 0) { 120 | originalPromise._attachExtraTrace(trace); 121 | } 122 | resolver.promise._reject(r, trace); 123 | } 124 | 125 | function Promise$_progressFromThenable(v) { 126 | if (called) return; 127 | var promise = resolver.promise; 128 | if (typeof promise._progress === "function") { 129 | promise._progress(v); 130 | } 131 | } 132 | } 133 | 134 | return Promise$_Cast; 135 | }; 136 | -------------------------------------------------------------------------------- /node_modules/bluebird/js/main/timers.js: -------------------------------------------------------------------------------- 1 | /** 2 | * The MIT License (MIT) 3 | * 4 | * Copyright (c) 2014 Petka Antonov 5 | * 6 | * Permission is hereby granted, free of charge, to any person obtaining a copy 7 | * of this software and associated documentation files (the "Software"), to deal 8 | * in the Software without restriction, including without limitation the rights 9 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 10 | * copies of the Software, and to permit persons to whom the Software is 11 | * furnished to do so, subject to the following conditions:

12 | * 13 | * The above copyright notice and this permission notice shall be included in 14 | * all copies or substantial portions of the Software. 15 | * 16 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 17 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 18 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 19 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 20 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 21 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 22 | * THE SOFTWARE. 23 | * 24 | */ 25 | "use strict"; 26 | var _setTimeout = function(fn, ms) { 27 | var len = arguments.length; 28 | var arg0 = arguments[2]; 29 | var arg1 = arguments[3]; 30 | var arg2 = len >= 5 ? arguments[4] : void 0; 31 | setTimeout(function() { 32 | fn(arg0, arg1, arg2); 33 | }, ms|0); 34 | }; 35 | 36 | module.exports = function(Promise, INTERNAL, cast) { 37 | var util = require("./util.js"); 38 | var errors = require("./errors.js"); 39 | var apiRejection = require("./errors_api_rejection")(Promise); 40 | var TimeoutError = Promise.TimeoutError; 41 | 42 | var afterTimeout = function Promise$_afterTimeout(promise, message, ms) { 43 | if (!promise.isPending()) return; 44 | if (typeof message !== "string") { 45 | message = "operation timed out after" + " " + ms + " ms" 46 | } 47 | var err = new TimeoutError(message); 48 | errors.markAsOriginatingFromRejection(err); 49 | promise._attachExtraTrace(err); 50 | promise._cancel(err); 51 | }; 52 | 53 | var afterDelay = function Promise$_afterDelay(value, promise) { 54 | promise._fulfill(value); 55 | }; 56 | 57 | var delay = Promise.delay = function Promise$Delay(value, ms) { 58 | if (ms === void 0) { 59 | ms = value; 60 | value = void 0; 61 | } 62 | ms = +ms; 63 | var maybePromise = cast(value, void 0); 64 | var promise = new Promise(INTERNAL); 65 | 66 | if (maybePromise instanceof Promise) { 67 | promise._propagateFrom(maybePromise, 7); 68 | promise._follow(maybePromise); 69 | return promise.then(function(value) { 70 | return Promise.delay(value, ms); 71 | }); 72 | } else { 73 | promise._setTrace(void 0); 74 | _setTimeout(afterDelay, ms, value, promise); 75 | } 76 | return promise; 77 | }; 78 | 79 | Promise.prototype.delay = function Promise$delay(ms) { 80 | return delay(this, ms); 81 | }; 82 | 83 | Promise.prototype.timeout = function Promise$timeout(ms, message) { 84 | ms = +ms; 85 | 86 | var ret = new Promise(INTERNAL); 87 | ret._propagateFrom(this, 7); 88 | ret._follow(this); 89 | _setTimeout(afterTimeout, ms, ret, message, ms); 90 | return ret.cancellable(); 91 | }; 92 | 93 | }; 94 | -------------------------------------------------------------------------------- /node_modules/bluebird/js/zalgo/any.js: -------------------------------------------------------------------------------- 1 | /** 2 | * The MIT License (MIT) 3 | * 4 | * Copyright (c) 2014 Petka Antonov 5 | * 6 | * Permission is hereby granted, free of charge, to any person obtaining a copy 7 | * of this software and associated documentation files (the "Software"), to deal 8 | * in the Software without restriction, including without limitation the rights 9 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 10 | * copies of the Software, and to permit persons to whom the Software is 11 | * furnished to do so, subject to the following conditions:

12 | * 13 | * The above copyright notice and this permission notice shall be included in 14 | * all copies or substantial portions of the Software. 15 | * 16 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 17 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 18 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 19 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 20 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 21 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 22 | * THE SOFTWARE. 23 | * 24 | */ 25 | "use strict"; 26 | module.exports = function(Promise) { 27 | var SomePromiseArray = Promise._SomePromiseArray; 28 | function Promise$_Any(promises) { 29 | var ret = new SomePromiseArray(promises); 30 | var promise = ret.promise(); 31 | if (promise.isRejected()) { 32 | return promise; 33 | } 34 | ret.setHowMany(1); 35 | ret.setUnwrap(); 36 | ret.init(); 37 | return promise; 38 | } 39 | 40 | Promise.any = function Promise$Any(promises) { 41 | return Promise$_Any(promises); 42 | }; 43 | 44 | Promise.prototype.any = function Promise$any() { 45 | return Promise$_Any(this); 46 | }; 47 | 48 | }; 49 | -------------------------------------------------------------------------------- /node_modules/bluebird/js/zalgo/assert.js: -------------------------------------------------------------------------------- 1 | /** 2 | * The MIT License (MIT) 3 | * 4 | * Copyright (c) 2014 Petka Antonov 5 | * 6 | * Permission is hereby granted, free of charge, to any person obtaining a copy 7 | * of this software and associated documentation files (the "Software"), to deal 8 | * in the Software without restriction, including without limitation the rights 9 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 10 | * copies of the Software, and to permit persons to whom the Software is 11 | * furnished to do so, subject to the following conditions:

12 | * 13 | * The above copyright notice and this permission notice shall be included in 14 | * all copies or substantial portions of the Software. 15 | * 16 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 17 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 18 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 19 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 20 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 21 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 22 | * THE SOFTWARE. 23 | * 24 | */ 25 | "use strict"; 26 | module.exports = (function(){ 27 | var AssertionError = (function() { 28 | function AssertionError(a) { 29 | this.constructor$(a); 30 | this.message = a; 31 | this.name = "AssertionError"; 32 | } 33 | AssertionError.prototype = new Error(); 34 | AssertionError.prototype.constructor = AssertionError; 35 | AssertionError.prototype.constructor$ = Error; 36 | return AssertionError; 37 | })(); 38 | 39 | function getParams(args) { 40 | var params = []; 41 | for (var i = 0; i < args.length; ++i) params.push("arg" + i); 42 | return params; 43 | } 44 | 45 | function nativeAssert(callName, args, expect) { 46 | try { 47 | var params = getParams(args); 48 | var constructorArgs = params; 49 | constructorArgs.push("return " + 50 | callName + "("+ params.join(",") + ");"); 51 | var fn = Function.apply(null, constructorArgs); 52 | return fn.apply(null, args); 53 | } catch (e) { 54 | if (!(e instanceof SyntaxError)) { 55 | throw e; 56 | } else { 57 | return expect; 58 | } 59 | } 60 | } 61 | 62 | return function assert(boolExpr, message) { 63 | if (boolExpr === true) return; 64 | 65 | if (typeof boolExpr === "string" && 66 | boolExpr.charAt(0) === "%") { 67 | var nativeCallName = boolExpr; 68 | var $_len = arguments.length;var args = new Array($_len - 2); for(var $_i = 2; $_i < $_len; ++$_i) {args[$_i - 2] = arguments[$_i];} 69 | if (nativeAssert(nativeCallName, args, message) === message) return; 70 | message = (nativeCallName + " !== " + message); 71 | } 72 | 73 | var ret = new AssertionError(message); 74 | if (Error.captureStackTrace) { 75 | Error.captureStackTrace(ret, assert); 76 | } 77 | if (console && console.error) { 78 | console.error(ret.stack + ""); 79 | } 80 | throw ret; 81 | 82 | }; 83 | })(); 84 | -------------------------------------------------------------------------------- /node_modules/bluebird/js/zalgo/async.js: -------------------------------------------------------------------------------- 1 | /** 2 | * The MIT License (MIT) 3 | * 4 | * Copyright (c) 2014 Petka Antonov 5 | * 6 | * Permission is hereby granted, free of charge, to any person obtaining a copy 7 | * of this software and associated documentation files (the "Software"), to deal 8 | * in the Software without restriction, including without limitation the rights 9 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 10 | * copies of the Software, and to permit persons to whom the Software is 11 | * furnished to do so, subject to the following conditions:

12 | * 13 | * The above copyright notice and this permission notice shall be included in 14 | * all copies or substantial portions of the Software. 15 | * 16 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 17 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 18 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 19 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 20 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 21 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 22 | * THE SOFTWARE. 23 | * 24 | */ 25 | "use strict"; 26 | var schedule = require("./schedule.js"); 27 | var Queue = require("./queue.js"); 28 | var errorObj = require("./util.js").errorObj; 29 | var tryCatch1 = require("./util.js").tryCatch1; 30 | var _process = typeof process !== "undefined" ? process : void 0; 31 | 32 | function Async() { 33 | this._isTickUsed = false; 34 | this._schedule = schedule; 35 | this._length = 0; 36 | this._lateBuffer = new Queue(16); 37 | this._functionBuffer = new Queue(65536); 38 | var self = this; 39 | this.consumeFunctionBuffer = function Async$consumeFunctionBuffer() { 40 | self._consumeFunctionBuffer(); 41 | }; 42 | } 43 | 44 | Async.prototype.haveItemsQueued = function Async$haveItemsQueued() { 45 | return this._length > 0; 46 | }; 47 | 48 | Async.prototype.invokeLater = function Async$invokeLater(fn, receiver, arg) { 49 | if (_process !== void 0 && 50 | _process.domain != null && 51 | !fn.domain) { 52 | fn = _process.domain.bind(fn); 53 | } 54 | this._lateBuffer.push(fn, receiver, arg); 55 | this._queueTick(); 56 | }; 57 | 58 | Async.prototype.invoke = function Async$invoke(fn, receiver, arg) { 59 | if (_process !== void 0 && 60 | _process.domain != null && 61 | !fn.domain) { 62 | fn = _process.domain.bind(fn); 63 | } 64 | var functionBuffer = this._functionBuffer; 65 | functionBuffer.push(fn, receiver, arg); 66 | this._length = functionBuffer.length(); 67 | this._queueTick(); 68 | }; 69 | 70 | Async.prototype._consumeFunctionBuffer = 71 | function Async$_consumeFunctionBuffer() { 72 | var functionBuffer = this._functionBuffer; 73 | while (functionBuffer.length() > 0) { 74 | var fn = functionBuffer.shift(); 75 | var receiver = functionBuffer.shift(); 76 | var arg = functionBuffer.shift(); 77 | fn.call(receiver, arg); 78 | } 79 | this._reset(); 80 | this._consumeLateBuffer(); 81 | }; 82 | 83 | Async.prototype._consumeLateBuffer = function Async$_consumeLateBuffer() { 84 | var buffer = this._lateBuffer; 85 | while(buffer.length() > 0) { 86 | var fn = buffer.shift(); 87 | var receiver = buffer.shift(); 88 | var arg = buffer.shift(); 89 | var res = tryCatch1(fn, receiver, arg); 90 | if (res === errorObj) { 91 | this._queueTick(); 92 | if (fn.domain != null) { 93 | fn.domain.emit("error", res.e); 94 | } else { 95 | throw res.e; 96 | } 97 | } 98 | } 99 | }; 100 | 101 | Async.prototype._queueTick = function Async$_queue() { 102 | if (!this._isTickUsed) { 103 | this._schedule(this.consumeFunctionBuffer); 104 | this._isTickUsed = true; 105 | } 106 | }; 107 | 108 | Async.prototype._reset = function Async$_reset() { 109 | this._isTickUsed = false; 110 | this._length = 0; 111 | }; 112 | 113 | module.exports = new Async(); 114 | -------------------------------------------------------------------------------- /node_modules/bluebird/js/zalgo/bluebird.js: -------------------------------------------------------------------------------- 1 | /** 2 | * The MIT License (MIT) 3 | * 4 | * Copyright (c) 2014 Petka Antonov 5 | * 6 | * Permission is hereby granted, free of charge, to any person obtaining a copy 7 | * of this software and associated documentation files (the "Software"), to deal 8 | * in the Software without restriction, including without limitation the rights 9 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 10 | * copies of the Software, and to permit persons to whom the Software is 11 | * furnished to do so, subject to the following conditions:

12 | * 13 | * The above copyright notice and this permission notice shall be included in 14 | * all copies or substantial portions of the Software. 15 | * 16 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 17 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 18 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 19 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 20 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 21 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 22 | * THE SOFTWARE. 23 | * 24 | */ 25 | "use strict"; 26 | var Promise = require("./promise.js")(); 27 | module.exports = Promise; -------------------------------------------------------------------------------- /node_modules/bluebird/js/zalgo/call_get.js: -------------------------------------------------------------------------------- 1 | /** 2 | * The MIT License (MIT) 3 | * 4 | * Copyright (c) 2014 Petka Antonov 5 | * 6 | * Permission is hereby granted, free of charge, to any person obtaining a copy 7 | * of this software and associated documentation files (the "Software"), to deal 8 | * in the Software without restriction, including without limitation the rights 9 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 10 | * copies of the Software, and to permit persons to whom the Software is 11 | * furnished to do so, subject to the following conditions:

12 | * 13 | * The above copyright notice and this permission notice shall be included in 14 | * all copies or substantial portions of the Software. 15 | * 16 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 17 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 18 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 19 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 20 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 21 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 22 | * THE SOFTWARE. 23 | * 24 | */ 25 | "use strict"; 26 | var cr = Object.create; 27 | if (cr) { 28 | var callerCache = cr(null); 29 | var getterCache = cr(null); 30 | callerCache[" size"] = getterCache[" size"] = 0; 31 | } 32 | 33 | module.exports = function(Promise) { 34 | var util = require("./util.js"); 35 | var canEvaluate = util.canEvaluate; 36 | var isIdentifier = util.isIdentifier; 37 | 38 | function makeMethodCaller (methodName) { 39 | return new Function("obj", " \n\ 40 | 'use strict' \n\ 41 | var len = this.length; \n\ 42 | switch(len) { \n\ 43 | case 1: return obj.methodName(this[0]); \n\ 44 | case 2: return obj.methodName(this[0], this[1]); \n\ 45 | case 3: return obj.methodName(this[0], this[1], this[2]); \n\ 46 | case 0: return obj.methodName(); \n\ 47 | default: return obj.methodName.apply(obj, this); \n\ 48 | } \n\ 49 | ".replace(/methodName/g, methodName)); 50 | } 51 | 52 | function makeGetter (propertyName) { 53 | return new Function("obj", " \n\ 54 | 'use strict'; \n\ 55 | return obj.propertyName; \n\ 56 | ".replace("propertyName", propertyName)); 57 | } 58 | 59 | function getCompiled(name, compiler, cache) { 60 | var ret = cache[name]; 61 | if (typeof ret !== "function") { 62 | if (!isIdentifier(name)) { 63 | return null; 64 | } 65 | ret = compiler(name); 66 | cache[name] = ret; 67 | cache[" size"]++; 68 | if (cache[" size"] > 512) { 69 | var keys = Object.keys(cache); 70 | for (var i = 0; i < 256; ++i) delete cache[keys[i]]; 71 | cache[" size"] = keys.length - 256; 72 | } 73 | } 74 | return ret; 75 | } 76 | 77 | function getMethodCaller(name) { 78 | return getCompiled(name, makeMethodCaller, callerCache); 79 | } 80 | 81 | function getGetter(name) { 82 | return getCompiled(name, makeGetter, getterCache); 83 | } 84 | 85 | function caller(obj) { 86 | return obj[this.pop()].apply(obj, this); 87 | } 88 | Promise.prototype.call = function Promise$call(methodName) { 89 | var $_len = arguments.length;var args = new Array($_len - 1); for(var $_i = 1; $_i < $_len; ++$_i) {args[$_i - 1] = arguments[$_i];} 90 | if (canEvaluate) { 91 | var maybeCaller = getMethodCaller(methodName); 92 | if (maybeCaller !== null) { 93 | return this._then(maybeCaller, void 0, void 0, args, void 0); 94 | } 95 | } 96 | args.push(methodName); 97 | return this._then(caller, void 0, void 0, args, void 0); 98 | }; 99 | 100 | function namedGetter(obj) { 101 | return obj[this]; 102 | } 103 | function indexedGetter(obj) { 104 | return obj[this]; 105 | } 106 | Promise.prototype.get = function Promise$get(propertyName) { 107 | var isIndex = (typeof propertyName === "number"); 108 | var getter; 109 | if (!isIndex) { 110 | if (canEvaluate) { 111 | var maybeGetter = getGetter(propertyName); 112 | getter = maybeGetter !== null ? maybeGetter : namedGetter; 113 | } else { 114 | getter = namedGetter; 115 | } 116 | } else { 117 | getter = indexedGetter; 118 | } 119 | return this._then(getter, void 0, void 0, propertyName, void 0); 120 | }; 121 | }; 122 | -------------------------------------------------------------------------------- /node_modules/bluebird/js/zalgo/cancel.js: -------------------------------------------------------------------------------- 1 | /** 2 | * The MIT License (MIT) 3 | * 4 | * Copyright (c) 2014 Petka Antonov 5 | * 6 | * Permission is hereby granted, free of charge, to any person obtaining a copy 7 | * of this software and associated documentation files (the "Software"), to deal 8 | * in the Software without restriction, including without limitation the rights 9 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 10 | * copies of the Software, and to permit persons to whom the Software is 11 | * furnished to do so, subject to the following conditions:

12 | * 13 | * The above copyright notice and this permission notice shall be included in 14 | * all copies or substantial portions of the Software. 15 | * 16 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 17 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 18 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 19 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 20 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 21 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 22 | * THE SOFTWARE. 23 | * 24 | */ 25 | "use strict"; 26 | module.exports = function(Promise, INTERNAL) { 27 | var errors = require("./errors.js"); 28 | var canAttach = errors.canAttach; 29 | var async = require("./async.js"); 30 | var CancellationError = errors.CancellationError; 31 | 32 | Promise.prototype._cancel = function Promise$_cancel(reason) { 33 | if (!this.isCancellable()) return this; 34 | var parent; 35 | var promiseToReject = this; 36 | while ((parent = promiseToReject._cancellationParent) !== void 0 && 37 | parent.isCancellable()) { 38 | promiseToReject = parent; 39 | } 40 | this._unsetCancellable(); 41 | promiseToReject._attachExtraTrace(reason); 42 | promiseToReject._rejectUnchecked(reason); 43 | }; 44 | 45 | Promise.prototype.cancel = function Promise$cancel(reason) { 46 | if (!this.isCancellable()) return this; 47 | reason = reason !== void 0 48 | ? (canAttach(reason) ? reason : new Error(reason + "")) 49 | : new CancellationError(); 50 | async.invokeLater(this._cancel, this, reason); 51 | return this; 52 | }; 53 | 54 | Promise.prototype.cancellable = function Promise$cancellable() { 55 | if (this._cancellable()) return this; 56 | this._setCancellable(); 57 | this._cancellationParent = void 0; 58 | return this; 59 | }; 60 | 61 | Promise.prototype.uncancellable = function Promise$uncancellable() { 62 | var ret = new Promise(INTERNAL); 63 | ret._propagateFrom(this, 2 | 4); 64 | ret._follow(this); 65 | ret._unsetCancellable(); 66 | return ret; 67 | }; 68 | 69 | Promise.prototype.fork = 70 | function Promise$fork(didFulfill, didReject, didProgress) { 71 | var ret = this._then(didFulfill, didReject, didProgress, 72 | void 0, void 0); 73 | 74 | ret._setCancellable(); 75 | ret._cancellationParent = void 0; 76 | return ret; 77 | }; 78 | }; 79 | -------------------------------------------------------------------------------- /node_modules/bluebird/js/zalgo/catch_filter.js: -------------------------------------------------------------------------------- 1 | /** 2 | * The MIT License (MIT) 3 | * 4 | * Copyright (c) 2014 Petka Antonov 5 | * 6 | * Permission is hereby granted, free of charge, to any person obtaining a copy 7 | * of this software and associated documentation files (the "Software"), to deal 8 | * in the Software without restriction, including without limitation the rights 9 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 10 | * copies of the Software, and to permit persons to whom the Software is 11 | * furnished to do so, subject to the following conditions:

12 | * 13 | * The above copyright notice and this permission notice shall be included in 14 | * all copies or substantial portions of the Software. 15 | * 16 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 17 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 18 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 19 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 20 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 21 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 22 | * THE SOFTWARE. 23 | * 24 | */ 25 | "use strict"; 26 | module.exports = function(NEXT_FILTER) { 27 | var util = require("./util.js"); 28 | var errors = require("./errors.js"); 29 | var tryCatch1 = util.tryCatch1; 30 | var errorObj = util.errorObj; 31 | var keys = require("./es5.js").keys; 32 | var TypeError = errors.TypeError; 33 | 34 | function CatchFilter(instances, callback, promise) { 35 | this._instances = instances; 36 | this._callback = callback; 37 | this._promise = promise; 38 | } 39 | 40 | function CatchFilter$_safePredicate(predicate, e) { 41 | var safeObject = {}; 42 | var retfilter = tryCatch1(predicate, safeObject, e); 43 | 44 | if (retfilter === errorObj) return retfilter; 45 | 46 | var safeKeys = keys(safeObject); 47 | if (safeKeys.length) { 48 | errorObj.e = new TypeError( 49 | "Catch filter must inherit from Error " 50 | + "or be a simple predicate function"); 51 | return errorObj; 52 | } 53 | return retfilter; 54 | } 55 | 56 | CatchFilter.prototype.doFilter = function CatchFilter$_doFilter(e) { 57 | var cb = this._callback; 58 | var promise = this._promise; 59 | var boundTo = promise._boundTo; 60 | for (var i = 0, len = this._instances.length; i < len; ++i) { 61 | var item = this._instances[i]; 62 | var itemIsErrorType = item === Error || 63 | (item != null && item.prototype instanceof Error); 64 | 65 | if (itemIsErrorType && e instanceof item) { 66 | var ret = tryCatch1(cb, boundTo, e); 67 | if (ret === errorObj) { 68 | NEXT_FILTER.e = ret.e; 69 | return NEXT_FILTER; 70 | } 71 | return ret; 72 | } else if (typeof item === "function" && !itemIsErrorType) { 73 | var shouldHandle = CatchFilter$_safePredicate(item, e); 74 | if (shouldHandle === errorObj) { 75 | var trace = errors.canAttach(errorObj.e) 76 | ? errorObj.e 77 | : new Error(errorObj.e + ""); 78 | this._promise._attachExtraTrace(trace); 79 | e = errorObj.e; 80 | break; 81 | } else if (shouldHandle) { 82 | var ret = tryCatch1(cb, boundTo, e); 83 | if (ret === errorObj) { 84 | NEXT_FILTER.e = ret.e; 85 | return NEXT_FILTER; 86 | } 87 | return ret; 88 | } 89 | } 90 | } 91 | NEXT_FILTER.e = e; 92 | return NEXT_FILTER; 93 | }; 94 | 95 | return CatchFilter; 96 | }; 97 | -------------------------------------------------------------------------------- /node_modules/bluebird/js/zalgo/direct_resolve.js: -------------------------------------------------------------------------------- 1 | /** 2 | * The MIT License (MIT) 3 | * 4 | * Copyright (c) 2014 Petka Antonov 5 | * 6 | * Permission is hereby granted, free of charge, to any person obtaining a copy 7 | * of this software and associated documentation files (the "Software"), to deal 8 | * in the Software without restriction, including without limitation the rights 9 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 10 | * copies of the Software, and to permit persons to whom the Software is 11 | * furnished to do so, subject to the following conditions:

12 | * 13 | * The above copyright notice and this permission notice shall be included in 14 | * all copies or substantial portions of the Software. 15 | * 16 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 17 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 18 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 19 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 20 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 21 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 22 | * THE SOFTWARE. 23 | * 24 | */ 25 | "use strict"; 26 | var util = require("./util.js"); 27 | var isPrimitive = util.isPrimitive; 28 | var wrapsPrimitiveReceiver = util.wrapsPrimitiveReceiver; 29 | 30 | module.exports = function(Promise) { 31 | var returner = function Promise$_returner() { 32 | return this; 33 | }; 34 | var thrower = function Promise$_thrower() { 35 | throw this; 36 | }; 37 | 38 | var wrapper = function Promise$_wrapper(value, action) { 39 | if (action === 1) { 40 | return function Promise$_thrower() { 41 | throw value; 42 | }; 43 | } else if (action === 2) { 44 | return function Promise$_returner() { 45 | return value; 46 | }; 47 | } 48 | }; 49 | 50 | 51 | Promise.prototype["return"] = 52 | Promise.prototype.thenReturn = 53 | function Promise$thenReturn(value) { 54 | if (wrapsPrimitiveReceiver && isPrimitive(value)) { 55 | return this._then( 56 | wrapper(value, 2), 57 | void 0, 58 | void 0, 59 | void 0, 60 | void 0 61 | ); 62 | } 63 | return this._then(returner, void 0, void 0, value, void 0); 64 | }; 65 | 66 | Promise.prototype["throw"] = 67 | Promise.prototype.thenThrow = 68 | function Promise$thenThrow(reason) { 69 | if (wrapsPrimitiveReceiver && isPrimitive(reason)) { 70 | return this._then( 71 | wrapper(reason, 1), 72 | void 0, 73 | void 0, 74 | void 0, 75 | void 0 76 | ); 77 | } 78 | return this._then(thrower, void 0, void 0, reason, void 0); 79 | }; 80 | }; 81 | -------------------------------------------------------------------------------- /node_modules/bluebird/js/zalgo/each.js: -------------------------------------------------------------------------------- 1 | /** 2 | * The MIT License (MIT) 3 | * 4 | * Copyright (c) 2014 Petka Antonov 5 | * 6 | * Permission is hereby granted, free of charge, to any person obtaining a copy 7 | * of this software and associated documentation files (the "Software"), to deal 8 | * in the Software without restriction, including without limitation the rights 9 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 10 | * copies of the Software, and to permit persons to whom the Software is 11 | * furnished to do so, subject to the following conditions:

12 | * 13 | * The above copyright notice and this permission notice shall be included in 14 | * all copies or substantial portions of the Software. 15 | * 16 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 17 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 18 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 19 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 20 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 21 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 22 | * THE SOFTWARE. 23 | * 24 | */ 25 | "use strict"; 26 | module.exports = function(Promise, INTERNAL) { 27 | var PromiseReduce = Promise.reduce; 28 | 29 | Promise.prototype.each = function Promise$each(fn) { 30 | return PromiseReduce(this, fn, null, INTERNAL); 31 | }; 32 | 33 | Promise.each = function Promise$Each(promises, fn) { 34 | return PromiseReduce(promises, fn, null, INTERNAL); 35 | }; 36 | }; 37 | -------------------------------------------------------------------------------- /node_modules/bluebird/js/zalgo/errors.js: -------------------------------------------------------------------------------- 1 | /** 2 | * The MIT License (MIT) 3 | * 4 | * Copyright (c) 2014 Petka Antonov 5 | * 6 | * Permission is hereby granted, free of charge, to any person obtaining a copy 7 | * of this software and associated documentation files (the "Software"), to deal 8 | * in the Software without restriction, including without limitation the rights 9 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 10 | * copies of the Software, and to permit persons to whom the Software is 11 | * furnished to do so, subject to the following conditions:

12 | * 13 | * The above copyright notice and this permission notice shall be included in 14 | * all copies or substantial portions of the Software. 15 | * 16 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 17 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 18 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 19 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 20 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 21 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 22 | * THE SOFTWARE. 23 | * 24 | */ 25 | "use strict"; 26 | var Objectfreeze = require("./es5.js").freeze; 27 | var util = require("./util.js"); 28 | var inherits = util.inherits; 29 | var notEnumerableProp = util.notEnumerableProp; 30 | 31 | function markAsOriginatingFromRejection(e) { 32 | try { 33 | notEnumerableProp(e, "isOperational", true); 34 | } 35 | catch(ignore) {} 36 | } 37 | 38 | function originatesFromRejection(e) { 39 | if (e == null) return false; 40 | return ((e instanceof OperationalError) || 41 | e["isOperational"] === true); 42 | } 43 | 44 | function isError(obj) { 45 | return obj instanceof Error; 46 | } 47 | 48 | function canAttach(obj) { 49 | return isError(obj); 50 | } 51 | 52 | function subError(nameProperty, defaultMessage) { 53 | function SubError(message) { 54 | if (!(this instanceof SubError)) return new SubError(message); 55 | this.message = typeof message === "string" ? message : defaultMessage; 56 | this.name = nameProperty; 57 | if (Error.captureStackTrace) { 58 | Error.captureStackTrace(this, this.constructor); 59 | } 60 | } 61 | inherits(SubError, Error); 62 | return SubError; 63 | } 64 | 65 | var _TypeError, _RangeError; 66 | var CancellationError = subError("CancellationError", "cancellation error"); 67 | var TimeoutError = subError("TimeoutError", "timeout error"); 68 | var AggregateError = subError("AggregateError", "aggregate error"); 69 | try { 70 | _TypeError = TypeError; 71 | _RangeError = RangeError; 72 | } catch(e) { 73 | _TypeError = subError("TypeError", "type error"); 74 | _RangeError = subError("RangeError", "range error"); 75 | } 76 | 77 | var methods = ("join pop push shift unshift slice filter forEach some " + 78 | "every map indexOf lastIndexOf reduce reduceRight sort reverse").split(" "); 79 | 80 | for (var i = 0; i < methods.length; ++i) { 81 | if (typeof Array.prototype[methods[i]] === "function") { 82 | AggregateError.prototype[methods[i]] = Array.prototype[methods[i]]; 83 | } 84 | } 85 | 86 | AggregateError.prototype.length = 0; 87 | AggregateError.prototype["isOperational"] = true; 88 | var level = 0; 89 | AggregateError.prototype.toString = function() { 90 | var indent = Array(level * 4 + 1).join(" "); 91 | var ret = "\n" + indent + "AggregateError of:" + "\n"; 92 | level++; 93 | indent = Array(level * 4 + 1).join(" "); 94 | for (var i = 0; i < this.length; ++i) { 95 | var str = this[i] === this ? "[Circular AggregateError]" : this[i] + ""; 96 | var lines = str.split("\n"); 97 | for (var j = 0; j < lines.length; ++j) { 98 | lines[j] = indent + lines[j]; 99 | } 100 | str = lines.join("\n"); 101 | ret += str + "\n"; 102 | } 103 | level--; 104 | return ret; 105 | }; 106 | 107 | function OperationalError(message) { 108 | this.name = "OperationalError"; 109 | this.message = message; 110 | this.cause = message; 111 | this["isOperational"] = true; 112 | 113 | if (message instanceof Error) { 114 | this.message = message.message; 115 | this.stack = message.stack; 116 | } else if (Error.captureStackTrace) { 117 | Error.captureStackTrace(this, this.constructor); 118 | } 119 | 120 | } 121 | inherits(OperationalError, Error); 122 | 123 | var key = "__BluebirdErrorTypes__"; 124 | var errorTypes = Error[key]; 125 | if (!errorTypes) { 126 | errorTypes = Objectfreeze({ 127 | CancellationError: CancellationError, 128 | TimeoutError: TimeoutError, 129 | OperationalError: OperationalError, 130 | RejectionError: OperationalError, 131 | AggregateError: AggregateError 132 | }); 133 | notEnumerableProp(Error, key, errorTypes); 134 | } 135 | 136 | module.exports = { 137 | Error: Error, 138 | TypeError: _TypeError, 139 | RangeError: _RangeError, 140 | CancellationError: errorTypes.CancellationError, 141 | OperationalError: errorTypes.OperationalError, 142 | TimeoutError: errorTypes.TimeoutError, 143 | AggregateError: errorTypes.AggregateError, 144 | originatesFromRejection: originatesFromRejection, 145 | markAsOriginatingFromRejection: markAsOriginatingFromRejection, 146 | canAttach: canAttach 147 | }; 148 | -------------------------------------------------------------------------------- /node_modules/bluebird/js/zalgo/errors_api_rejection.js: -------------------------------------------------------------------------------- 1 | /** 2 | * The MIT License (MIT) 3 | * 4 | * Copyright (c) 2014 Petka Antonov 5 | * 6 | * Permission is hereby granted, free of charge, to any person obtaining a copy 7 | * of this software and associated documentation files (the "Software"), to deal 8 | * in the Software without restriction, including without limitation the rights 9 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 10 | * copies of the Software, and to permit persons to whom the Software is 11 | * furnished to do so, subject to the following conditions:

12 | * 13 | * The above copyright notice and this permission notice shall be included in 14 | * all copies or substantial portions of the Software. 15 | * 16 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 17 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 18 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 19 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 20 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 21 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 22 | * THE SOFTWARE. 23 | * 24 | */ 25 | "use strict"; 26 | module.exports = function(Promise) { 27 | var TypeError = require('./errors.js').TypeError; 28 | 29 | function apiRejection(msg) { 30 | var error = new TypeError(msg); 31 | var ret = Promise.rejected(error); 32 | var parent = ret._peekContext(); 33 | if (parent != null) { 34 | parent._attachExtraTrace(error); 35 | } 36 | return ret; 37 | } 38 | 39 | return apiRejection; 40 | }; 41 | -------------------------------------------------------------------------------- /node_modules/bluebird/js/zalgo/es5.js: -------------------------------------------------------------------------------- 1 | /** 2 | * The MIT License (MIT) 3 | * 4 | * Copyright (c) 2014 Petka Antonov 5 | * 6 | * Permission is hereby granted, free of charge, to any person obtaining a copy 7 | * of this software and associated documentation files (the "Software"), to deal 8 | * in the Software without restriction, including without limitation the rights 9 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 10 | * copies of the Software, and to permit persons to whom the Software is 11 | * furnished to do so, subject to the following conditions:

12 | * 13 | * The above copyright notice and this permission notice shall be included in 14 | * all copies or substantial portions of the Software. 15 | * 16 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 17 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 18 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 19 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 20 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 21 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 22 | * THE SOFTWARE. 23 | * 24 | */ 25 | var isES5 = (function(){ 26 | "use strict"; 27 | return this === void 0; 28 | })(); 29 | 30 | if (isES5) { 31 | module.exports = { 32 | freeze: Object.freeze, 33 | defineProperty: Object.defineProperty, 34 | keys: Object.keys, 35 | getPrototypeOf: Object.getPrototypeOf, 36 | isArray: Array.isArray, 37 | isES5: isES5 38 | }; 39 | } else { 40 | var has = {}.hasOwnProperty; 41 | var str = {}.toString; 42 | var proto = {}.constructor.prototype; 43 | 44 | var ObjectKeys = function ObjectKeys(o) { 45 | var ret = []; 46 | for (var key in o) { 47 | if (has.call(o, key)) { 48 | ret.push(key); 49 | } 50 | } 51 | return ret; 52 | } 53 | 54 | var ObjectDefineProperty = function ObjectDefineProperty(o, key, desc) { 55 | o[key] = desc.value; 56 | return o; 57 | } 58 | 59 | var ObjectFreeze = function ObjectFreeze(obj) { 60 | return obj; 61 | } 62 | 63 | var ObjectGetPrototypeOf = function ObjectGetPrototypeOf(obj) { 64 | try { 65 | return Object(obj).constructor.prototype; 66 | } 67 | catch (e) { 68 | return proto; 69 | } 70 | } 71 | 72 | var ArrayIsArray = function ArrayIsArray(obj) { 73 | try { 74 | return str.call(obj) === "[object Array]"; 75 | } 76 | catch(e) { 77 | return false; 78 | } 79 | } 80 | 81 | module.exports = { 82 | isArray: ArrayIsArray, 83 | keys: ObjectKeys, 84 | defineProperty: ObjectDefineProperty, 85 | freeze: ObjectFreeze, 86 | getPrototypeOf: ObjectGetPrototypeOf, 87 | isES5: isES5 88 | }; 89 | } 90 | -------------------------------------------------------------------------------- /node_modules/bluebird/js/zalgo/filter.js: -------------------------------------------------------------------------------- 1 | /** 2 | * The MIT License (MIT) 3 | * 4 | * Copyright (c) 2014 Petka Antonov 5 | * 6 | * Permission is hereby granted, free of charge, to any person obtaining a copy 7 | * of this software and associated documentation files (the "Software"), to deal 8 | * in the Software without restriction, including without limitation the rights 9 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 10 | * copies of the Software, and to permit persons to whom the Software is 11 | * furnished to do so, subject to the following conditions:

12 | * 13 | * The above copyright notice and this permission notice shall be included in 14 | * all copies or substantial portions of the Software. 15 | * 16 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 17 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 18 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 19 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 20 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 21 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 22 | * THE SOFTWARE. 23 | * 24 | */ 25 | "use strict"; 26 | module.exports = function(Promise, INTERNAL) { 27 | var PromiseMap = Promise.map; 28 | 29 | Promise.prototype.filter = function Promise$filter(fn, options) { 30 | return PromiseMap(this, fn, options, INTERNAL); 31 | }; 32 | 33 | Promise.filter = function Promise$Filter(promises, fn, options) { 34 | return PromiseMap(promises, fn, options, INTERNAL); 35 | }; 36 | }; 37 | -------------------------------------------------------------------------------- /node_modules/bluebird/js/zalgo/finally.js: -------------------------------------------------------------------------------- 1 | /** 2 | * The MIT License (MIT) 3 | * 4 | * Copyright (c) 2014 Petka Antonov 5 | * 6 | * Permission is hereby granted, free of charge, to any person obtaining a copy 7 | * of this software and associated documentation files (the "Software"), to deal 8 | * in the Software without restriction, including without limitation the rights 9 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 10 | * copies of the Software, and to permit persons to whom the Software is 11 | * furnished to do so, subject to the following conditions:

12 | * 13 | * The above copyright notice and this permission notice shall be included in 14 | * all copies or substantial portions of the Software. 15 | * 16 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 17 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 18 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 19 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 20 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 21 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 22 | * THE SOFTWARE. 23 | * 24 | */ 25 | "use strict"; 26 | module.exports = function(Promise, NEXT_FILTER, cast) { 27 | var util = require("./util.js"); 28 | var wrapsPrimitiveReceiver = util.wrapsPrimitiveReceiver; 29 | var isPrimitive = util.isPrimitive; 30 | var thrower = util.thrower; 31 | 32 | function returnThis() { 33 | return this; 34 | } 35 | function throwThis() { 36 | throw this; 37 | } 38 | function return$(r) { 39 | return function Promise$_returner() { 40 | return r; 41 | }; 42 | } 43 | function throw$(r) { 44 | return function Promise$_thrower() { 45 | throw r; 46 | }; 47 | } 48 | function promisedFinally(ret, reasonOrValue, isFulfilled) { 49 | var then; 50 | if (wrapsPrimitiveReceiver && isPrimitive(reasonOrValue)) { 51 | then = isFulfilled ? return$(reasonOrValue) : throw$(reasonOrValue); 52 | } else { 53 | then = isFulfilled ? returnThis : throwThis; 54 | } 55 | return ret._then(then, thrower, void 0, reasonOrValue, void 0); 56 | } 57 | 58 | function finallyHandler(reasonOrValue) { 59 | var promise = this.promise; 60 | var handler = this.handler; 61 | 62 | var ret = promise._isBound() 63 | ? handler.call(promise._boundTo) 64 | : handler(); 65 | 66 | if (ret !== void 0) { 67 | var maybePromise = cast(ret, void 0); 68 | if (maybePromise instanceof Promise) { 69 | return promisedFinally(maybePromise, reasonOrValue, 70 | promise.isFulfilled()); 71 | } 72 | } 73 | 74 | if (promise.isRejected()) { 75 | NEXT_FILTER.e = reasonOrValue; 76 | return NEXT_FILTER; 77 | } else { 78 | return reasonOrValue; 79 | } 80 | } 81 | 82 | function tapHandler(value) { 83 | var promise = this.promise; 84 | var handler = this.handler; 85 | 86 | var ret = promise._isBound() 87 | ? handler.call(promise._boundTo, value) 88 | : handler(value); 89 | 90 | if (ret !== void 0) { 91 | var maybePromise = cast(ret, void 0); 92 | if (maybePromise instanceof Promise) { 93 | return promisedFinally(maybePromise, value, true); 94 | } 95 | } 96 | return value; 97 | } 98 | 99 | Promise.prototype._passThroughHandler = 100 | function Promise$_passThroughHandler(handler, isFinally) { 101 | if (typeof handler !== "function") return this.then(); 102 | 103 | var promiseAndHandler = { 104 | promise: this, 105 | handler: handler 106 | }; 107 | 108 | return this._then( 109 | isFinally ? finallyHandler : tapHandler, 110 | isFinally ? finallyHandler : void 0, void 0, 111 | promiseAndHandler, void 0); 112 | }; 113 | 114 | Promise.prototype.lastly = 115 | Promise.prototype["finally"] = function Promise$finally(handler) { 116 | return this._passThroughHandler(handler, true); 117 | }; 118 | 119 | Promise.prototype.tap = function Promise$tap(handler) { 120 | return this._passThroughHandler(handler, false); 121 | }; 122 | }; 123 | -------------------------------------------------------------------------------- /node_modules/bluebird/js/zalgo/join.js: -------------------------------------------------------------------------------- 1 | /** 2 | * The MIT License (MIT) 3 | * 4 | * Copyright (c) 2014 Petka Antonov 5 | * 6 | * Permission is hereby granted, free of charge, to any person obtaining a copy 7 | * of this software and associated documentation files (the "Software"), to deal 8 | * in the Software without restriction, including without limitation the rights 9 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 10 | * copies of the Software, and to permit persons to whom the Software is 11 | * furnished to do so, subject to the following conditions:

12 | * 13 | * The above copyright notice and this permission notice shall be included in 14 | * all copies or substantial portions of the Software. 15 | * 16 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 17 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 18 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 19 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 20 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 21 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 22 | * THE SOFTWARE. 23 | * 24 | */ 25 | "use strict"; 26 | module.exports = 27 | function(Promise, PromiseArray, cast, INTERNAL) { 28 | var util = require("./util.js"); 29 | var canEvaluate = util.canEvaluate; 30 | var tryCatch1 = util.tryCatch1; 31 | var errorObj = util.errorObj; 32 | 33 | 34 | if (canEvaluate) { 35 | var thenCallback = function(i) { 36 | return new Function("value", "holder", " \n\ 37 | 'use strict'; \n\ 38 | holder.pIndex = value; \n\ 39 | holder.checkFulfillment(this); \n\ 40 | ".replace(/Index/g, i)); 41 | }; 42 | 43 | var caller = function(count) { 44 | var values = []; 45 | for (var i = 1; i <= count; ++i) values.push("holder.p" + i); 46 | return new Function("holder", " \n\ 47 | 'use strict'; \n\ 48 | var callback = holder.fn; \n\ 49 | return callback(values); \n\ 50 | ".replace(/values/g, values.join(", "))); 51 | }; 52 | var thenCallbacks = []; 53 | var callers = [void 0]; 54 | for (var i = 1; i <= 5; ++i) { 55 | thenCallbacks.push(thenCallback(i)); 56 | callers.push(caller(i)); 57 | } 58 | 59 | var Holder = function(total, fn) { 60 | this.p1 = this.p2 = this.p3 = this.p4 = this.p5 = null; 61 | this.fn = fn; 62 | this.total = total; 63 | this.now = 0; 64 | }; 65 | 66 | Holder.prototype.callers = callers; 67 | Holder.prototype.checkFulfillment = function(promise) { 68 | var now = this.now; 69 | now++; 70 | var total = this.total; 71 | if (now >= total) { 72 | var handler = this.callers[total]; 73 | var ret = tryCatch1(handler, void 0, this); 74 | if (ret === errorObj) { 75 | promise._rejectUnchecked(ret.e); 76 | } else if (!promise._tryFollow(ret)) { 77 | promise._fulfillUnchecked(ret); 78 | } 79 | } else { 80 | this.now = now; 81 | } 82 | }; 83 | } 84 | 85 | 86 | 87 | 88 | Promise.join = function Promise$Join() { 89 | var last = arguments.length - 1; 90 | var fn; 91 | if (last > 0 && typeof arguments[last] === "function") { 92 | fn = arguments[last]; 93 | if (last < 6 && canEvaluate) { 94 | var ret = new Promise(INTERNAL); 95 | ret._setTrace(void 0); 96 | var holder = new Holder(last, fn); 97 | var reject = ret._reject; 98 | var callbacks = thenCallbacks; 99 | for (var i = 0; i < last; ++i) { 100 | var maybePromise = cast(arguments[i], void 0); 101 | if (maybePromise instanceof Promise) { 102 | if (maybePromise.isPending()) { 103 | maybePromise._then(callbacks[i], reject, 104 | void 0, ret, holder); 105 | } else if (maybePromise.isFulfilled()) { 106 | callbacks[i].call(ret, 107 | maybePromise._settledValue, holder); 108 | } else { 109 | ret._reject(maybePromise._settledValue); 110 | maybePromise._unsetRejectionIsUnhandled(); 111 | } 112 | } else { 113 | callbacks[i].call(ret, maybePromise, holder); 114 | } 115 | } 116 | return ret; 117 | } 118 | } 119 | var $_len = arguments.length;var args = new Array($_len); for(var $_i = 0; $_i < $_len; ++$_i) {args[$_i] = arguments[$_i];} 120 | var ret = new PromiseArray(args).promise(); 121 | return fn !== void 0 ? ret.spread(fn) : ret; 122 | }; 123 | 124 | }; 125 | -------------------------------------------------------------------------------- /node_modules/bluebird/js/zalgo/map.js: -------------------------------------------------------------------------------- 1 | /** 2 | * The MIT License (MIT) 3 | * 4 | * Copyright (c) 2014 Petka Antonov 5 | * 6 | * Permission is hereby granted, free of charge, to any person obtaining a copy 7 | * of this software and associated documentation files (the "Software"), to deal 8 | * in the Software without restriction, including without limitation the rights 9 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 10 | * copies of the Software, and to permit persons to whom the Software is 11 | * furnished to do so, subject to the following conditions:

12 | * 13 | * The above copyright notice and this permission notice shall be included in 14 | * all copies or substantial portions of the Software. 15 | * 16 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 17 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 18 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 19 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 20 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 21 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 22 | * THE SOFTWARE. 23 | * 24 | */ 25 | "use strict"; 26 | module.exports = function(Promise, PromiseArray, apiRejection, cast, INTERNAL) { 27 | var util = require("./util.js"); 28 | var tryCatch3 = util.tryCatch3; 29 | var errorObj = util.errorObj; 30 | var PENDING = {}; 31 | var EMPTY_ARRAY = []; 32 | 33 | function MappingPromiseArray(promises, fn, limit, _filter) { 34 | this.constructor$(promises); 35 | this._callback = fn; 36 | this._preservedValues = _filter === INTERNAL 37 | ? new Array(this.length()) 38 | : null; 39 | this._limit = limit; 40 | this._inFlight = 0; 41 | this._queue = limit >= 1 ? [] : EMPTY_ARRAY; 42 | this._init$(void 0, -2); 43 | } 44 | util.inherits(MappingPromiseArray, PromiseArray); 45 | 46 | MappingPromiseArray.prototype._init = function MappingPromiseArray$_init() {}; 47 | 48 | MappingPromiseArray.prototype._promiseFulfilled = 49 | function MappingPromiseArray$_promiseFulfilled(value, index) { 50 | var values = this._values; 51 | if (values === null) return; 52 | 53 | var length = this.length(); 54 | var preservedValues = this._preservedValues; 55 | var limit = this._limit; 56 | if (values[index] === PENDING) { 57 | values[index] = value; 58 | if (limit >= 1) { 59 | this._inFlight--; 60 | this._drainQueue(); 61 | if (this._isResolved()) return; 62 | } 63 | } else { 64 | if (limit >= 1 && this._inFlight >= limit) { 65 | values[index] = value; 66 | this._queue.push(index); 67 | return; 68 | } 69 | if (preservedValues !== null) preservedValues[index] = value; 70 | 71 | var callback = this._callback; 72 | var receiver = this._promise._boundTo; 73 | var ret = tryCatch3(callback, receiver, value, index, length); 74 | if (ret === errorObj) return this._reject(ret.e); 75 | 76 | var maybePromise = cast(ret, void 0); 77 | if (maybePromise instanceof Promise) { 78 | if (maybePromise.isPending()) { 79 | if (limit >= 1) this._inFlight++; 80 | values[index] = PENDING; 81 | return maybePromise._proxyPromiseArray(this, index); 82 | } else if (maybePromise.isFulfilled()) { 83 | ret = maybePromise.value(); 84 | } else { 85 | maybePromise._unsetRejectionIsUnhandled(); 86 | return this._reject(maybePromise.reason()); 87 | } 88 | } 89 | values[index] = ret; 90 | } 91 | var totalResolved = ++this._totalResolved; 92 | if (totalResolved >= length) { 93 | if (preservedValues !== null) { 94 | this._filter(values, preservedValues); 95 | } else { 96 | this._resolve(values); 97 | } 98 | 99 | } 100 | }; 101 | 102 | MappingPromiseArray.prototype._drainQueue = 103 | function MappingPromiseArray$_drainQueue() { 104 | var queue = this._queue; 105 | var limit = this._limit; 106 | var values = this._values; 107 | while (queue.length > 0 && this._inFlight < limit) { 108 | var index = queue.pop(); 109 | this._promiseFulfilled(values[index], index); 110 | } 111 | }; 112 | 113 | MappingPromiseArray.prototype._filter = 114 | function MappingPromiseArray$_filter(booleans, values) { 115 | var len = values.length; 116 | var ret = new Array(len); 117 | var j = 0; 118 | for (var i = 0; i < len; ++i) { 119 | if (booleans[i]) ret[j++] = values[i]; 120 | } 121 | ret.length = j; 122 | this._resolve(ret); 123 | }; 124 | 125 | MappingPromiseArray.prototype.preservedValues = 126 | function MappingPromiseArray$preserveValues() { 127 | return this._preservedValues; 128 | }; 129 | 130 | function map(promises, fn, options, _filter) { 131 | var limit = typeof options === "object" && options !== null 132 | ? options.concurrency 133 | : 0; 134 | limit = typeof limit === "number" && 135 | isFinite(limit) && limit >= 1 ? limit : 0; 136 | return new MappingPromiseArray(promises, fn, limit, _filter); 137 | } 138 | 139 | Promise.prototype.map = function Promise$map(fn, options) { 140 | if (typeof fn !== "function") return apiRejection("fn must be a function"); 141 | 142 | return map(this, fn, options, null).promise(); 143 | }; 144 | 145 | Promise.map = function Promise$Map(promises, fn, options, _filter) { 146 | if (typeof fn !== "function") return apiRejection("fn must be a function"); 147 | return map(promises, fn, options, _filter).promise(); 148 | }; 149 | 150 | 151 | }; 152 | -------------------------------------------------------------------------------- /node_modules/bluebird/js/zalgo/nodeify.js: -------------------------------------------------------------------------------- 1 | /** 2 | * The MIT License (MIT) 3 | * 4 | * Copyright (c) 2014 Petka Antonov 5 | * 6 | * Permission is hereby granted, free of charge, to any person obtaining a copy 7 | * of this software and associated documentation files (the "Software"), to deal 8 | * in the Software without restriction, including without limitation the rights 9 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 10 | * copies of the Software, and to permit persons to whom the Software is 11 | * furnished to do so, subject to the following conditions:

12 | * 13 | * The above copyright notice and this permission notice shall be included in 14 | * all copies or substantial portions of the Software. 15 | * 16 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 17 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 18 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 19 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 20 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 21 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 22 | * THE SOFTWARE. 23 | * 24 | */ 25 | "use strict"; 26 | module.exports = function(Promise) { 27 | var util = require("./util.js"); 28 | var async = require("./async.js"); 29 | var tryCatch2 = util.tryCatch2; 30 | var tryCatch1 = util.tryCatch1; 31 | var errorObj = util.errorObj; 32 | 33 | function thrower(r) { 34 | throw r; 35 | } 36 | 37 | function Promise$_spreadAdapter(val, receiver) { 38 | if (!util.isArray(val)) return Promise$_successAdapter(val, receiver); 39 | var ret = util.tryCatchApply(this, [null].concat(val), receiver); 40 | if (ret === errorObj) { 41 | async.invokeLater(thrower, void 0, ret.e); 42 | } 43 | } 44 | 45 | function Promise$_successAdapter(val, receiver) { 46 | var nodeback = this; 47 | var ret = val === void 0 48 | ? tryCatch1(nodeback, receiver, null) 49 | : tryCatch2(nodeback, receiver, null, val); 50 | if (ret === errorObj) { 51 | async.invokeLater(thrower, void 0, ret.e); 52 | } 53 | } 54 | function Promise$_errorAdapter(reason, receiver) { 55 | var nodeback = this; 56 | var ret = tryCatch1(nodeback, receiver, reason); 57 | if (ret === errorObj) { 58 | async.invokeLater(thrower, void 0, ret.e); 59 | } 60 | } 61 | 62 | Promise.prototype.nodeify = function Promise$nodeify(nodeback, options) { 63 | if (typeof nodeback == "function") { 64 | var adapter = Promise$_successAdapter; 65 | if (options !== void 0 && Object(options).spread) { 66 | adapter = Promise$_spreadAdapter; 67 | } 68 | this._then( 69 | adapter, 70 | Promise$_errorAdapter, 71 | void 0, 72 | nodeback, 73 | this._boundTo 74 | ); 75 | } 76 | return this; 77 | }; 78 | }; 79 | -------------------------------------------------------------------------------- /node_modules/bluebird/js/zalgo/progress.js: -------------------------------------------------------------------------------- 1 | /** 2 | * The MIT License (MIT) 3 | * 4 | * Copyright (c) 2014 Petka Antonov 5 | * 6 | * Permission is hereby granted, free of charge, to any person obtaining a copy 7 | * of this software and associated documentation files (the "Software"), to deal 8 | * in the Software without restriction, including without limitation the rights 9 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 10 | * copies of the Software, and to permit persons to whom the Software is 11 | * furnished to do so, subject to the following conditions:

12 | * 13 | * The above copyright notice and this permission notice shall be included in 14 | * all copies or substantial portions of the Software. 15 | * 16 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 17 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 18 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 19 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 20 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 21 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 22 | * THE SOFTWARE. 23 | * 24 | */ 25 | "use strict"; 26 | module.exports = function(Promise, PromiseArray) { 27 | var util = require("./util.js"); 28 | var async = require("./async.js"); 29 | var errors = require("./errors.js"); 30 | var tryCatch1 = util.tryCatch1; 31 | var errorObj = util.errorObj; 32 | 33 | Promise.prototype.progressed = function Promise$progressed(handler) { 34 | return this._then(void 0, void 0, handler, void 0, void 0); 35 | }; 36 | 37 | Promise.prototype._progress = function Promise$_progress(progressValue) { 38 | if (this._isFollowingOrFulfilledOrRejected()) return; 39 | this._progressUnchecked(progressValue); 40 | 41 | }; 42 | 43 | Promise.prototype._clearFirstHandlerData$Base = 44 | Promise.prototype._clearFirstHandlerData; 45 | Promise.prototype._clearFirstHandlerData = 46 | function Promise$_clearFirstHandlerData() { 47 | this._clearFirstHandlerData$Base(); 48 | this._progressHandler0 = void 0; 49 | }; 50 | 51 | Promise.prototype._progressHandlerAt = 52 | function Promise$_progressHandlerAt(index) { 53 | return index === 0 54 | ? this._progressHandler0 55 | : this[(index << 2) + index - 5 + 2]; 56 | }; 57 | 58 | Promise.prototype._doProgressWith = 59 | function Promise$_doProgressWith(progression) { 60 | var progressValue = progression.value; 61 | var handler = progression.handler; 62 | var promise = progression.promise; 63 | var receiver = progression.receiver; 64 | 65 | var ret = tryCatch1(handler, receiver, progressValue); 66 | if (ret === errorObj) { 67 | if (ret.e != null && 68 | ret.e.name !== "StopProgressPropagation") { 69 | var trace = errors.canAttach(ret.e) 70 | ? ret.e : new Error(ret.e + ""); 71 | promise._attachExtraTrace(trace); 72 | promise._progress(ret.e); 73 | } 74 | } else if (ret instanceof Promise) { 75 | ret._then(promise._progress, null, null, promise, void 0); 76 | } else { 77 | promise._progress(ret); 78 | } 79 | }; 80 | 81 | 82 | Promise.prototype._progressUnchecked = 83 | function Promise$_progressUnchecked(progressValue) { 84 | if (!this.isPending()) return; 85 | var len = this._length(); 86 | var progress = this._progress; 87 | for (var i = 0; i < len; i++) { 88 | var handler = this._progressHandlerAt(i); 89 | var promise = this._promiseAt(i); 90 | if (!(promise instanceof Promise)) { 91 | var receiver = this._receiverAt(i); 92 | if (typeof handler === "function") { 93 | handler.call(receiver, progressValue, promise); 94 | } else if (receiver instanceof Promise && receiver._isProxied()) { 95 | receiver._progressUnchecked(progressValue); 96 | } else if (receiver instanceof PromiseArray) { 97 | receiver._promiseProgressed(progressValue, promise); 98 | } 99 | continue; 100 | } 101 | 102 | if (typeof handler === "function") { 103 | this._doProgressWith(({handler: handler, 104 | promise: promise, 105 | receiver: this._receiverAt(i), 106 | value: progressValue})); 107 | } else { 108 | progress.call(promise, progressValue); 109 | } 110 | } 111 | }; 112 | }; 113 | -------------------------------------------------------------------------------- /node_modules/bluebird/js/zalgo/props.js: -------------------------------------------------------------------------------- 1 | /** 2 | * The MIT License (MIT) 3 | * 4 | * Copyright (c) 2014 Petka Antonov 5 | * 6 | * Permission is hereby granted, free of charge, to any person obtaining a copy 7 | * of this software and associated documentation files (the "Software"), to deal 8 | * in the Software without restriction, including without limitation the rights 9 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 10 | * copies of the Software, and to permit persons to whom the Software is 11 | * furnished to do so, subject to the following conditions:

12 | * 13 | * The above copyright notice and this permission notice shall be included in 14 | * all copies or substantial portions of the Software. 15 | * 16 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 17 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 18 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 19 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 20 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 21 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 22 | * THE SOFTWARE. 23 | * 24 | */ 25 | "use strict"; 26 | module.exports = function(Promise, PromiseArray, cast) { 27 | var util = require("./util.js"); 28 | var apiRejection = require("./errors_api_rejection")(Promise); 29 | var isObject = util.isObject; 30 | var es5 = require("./es5.js"); 31 | 32 | function PropertiesPromiseArray(obj) { 33 | var keys = es5.keys(obj); 34 | var len = keys.length; 35 | var values = new Array(len * 2); 36 | for (var i = 0; i < len; ++i) { 37 | var key = keys[i]; 38 | values[i] = obj[key]; 39 | values[i + len] = key; 40 | } 41 | this.constructor$(values); 42 | } 43 | util.inherits(PropertiesPromiseArray, PromiseArray); 44 | 45 | PropertiesPromiseArray.prototype._init = 46 | function PropertiesPromiseArray$_init() { 47 | this._init$(void 0, -3) ; 48 | }; 49 | 50 | PropertiesPromiseArray.prototype._promiseFulfilled = 51 | function PropertiesPromiseArray$_promiseFulfilled(value, index) { 52 | if (this._isResolved()) return; 53 | this._values[index] = value; 54 | var totalResolved = ++this._totalResolved; 55 | if (totalResolved >= this._length) { 56 | var val = {}; 57 | var keyOffset = this.length(); 58 | for (var i = 0, len = this.length(); i < len; ++i) { 59 | val[this._values[i + keyOffset]] = this._values[i]; 60 | } 61 | this._resolve(val); 62 | } 63 | }; 64 | 65 | PropertiesPromiseArray.prototype._promiseProgressed = 66 | function PropertiesPromiseArray$_promiseProgressed(value, index) { 67 | if (this._isResolved()) return; 68 | 69 | this._promise._progress({ 70 | key: this._values[index + this.length()], 71 | value: value 72 | }); 73 | }; 74 | 75 | PropertiesPromiseArray.prototype.shouldCopyValues = 76 | function PropertiesPromiseArray$_shouldCopyValues() { 77 | return false; 78 | }; 79 | 80 | PropertiesPromiseArray.prototype.getActualLength = 81 | function PropertiesPromiseArray$getActualLength(len) { 82 | return len >> 1; 83 | }; 84 | 85 | function Promise$_Props(promises) { 86 | var ret; 87 | var castValue = cast(promises, void 0); 88 | 89 | if (!isObject(castValue)) { 90 | return apiRejection("cannot await properties of a non-object"); 91 | } else if (castValue instanceof Promise) { 92 | ret = castValue._then(Promise.props, void 0, void 0, void 0, void 0); 93 | } else { 94 | ret = new PropertiesPromiseArray(castValue).promise(); 95 | } 96 | 97 | if (castValue instanceof Promise) { 98 | ret._propagateFrom(castValue, 4); 99 | } 100 | return ret; 101 | } 102 | 103 | Promise.prototype.props = function Promise$props() { 104 | return Promise$_Props(this); 105 | }; 106 | 107 | Promise.props = function Promise$Props(promises) { 108 | return Promise$_Props(promises); 109 | }; 110 | }; 111 | -------------------------------------------------------------------------------- /node_modules/bluebird/js/zalgo/queue.js: -------------------------------------------------------------------------------- 1 | /** 2 | * The MIT License (MIT) 3 | * 4 | * Copyright (c) 2014 Petka Antonov 5 | * 6 | * Permission is hereby granted, free of charge, to any person obtaining a copy 7 | * of this software and associated documentation files (the "Software"), to deal 8 | * in the Software without restriction, including without limitation the rights 9 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 10 | * copies of the Software, and to permit persons to whom the Software is 11 | * furnished to do so, subject to the following conditions:

12 | * 13 | * The above copyright notice and this permission notice shall be included in 14 | * all copies or substantial portions of the Software. 15 | * 16 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 17 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 18 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 19 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 20 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 21 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 22 | * THE SOFTWARE. 23 | * 24 | */ 25 | "use strict"; 26 | function arrayCopy(src, srcIndex, dst, dstIndex, len) { 27 | for (var j = 0; j < len; ++j) { 28 | dst[j + dstIndex] = src[j + srcIndex]; 29 | } 30 | } 31 | 32 | function Queue(capacity) { 33 | this._capacity = capacity; 34 | this._length = 0; 35 | this._front = 0; 36 | this._makeCapacity(); 37 | } 38 | 39 | Queue.prototype._willBeOverCapacity = 40 | function Queue$_willBeOverCapacity(size) { 41 | return this._capacity < size; 42 | }; 43 | 44 | Queue.prototype._pushOne = function Queue$_pushOne(arg) { 45 | var length = this.length(); 46 | this._checkCapacity(length + 1); 47 | var i = (this._front + length) & (this._capacity - 1); 48 | this[i] = arg; 49 | this._length = length + 1; 50 | }; 51 | 52 | Queue.prototype.push = function Queue$push(fn, receiver, arg) { 53 | var length = this.length() + 3; 54 | if (this._willBeOverCapacity(length)) { 55 | this._pushOne(fn); 56 | this._pushOne(receiver); 57 | this._pushOne(arg); 58 | return; 59 | } 60 | var j = this._front + length - 3; 61 | this._checkCapacity(length); 62 | var wrapMask = this._capacity - 1; 63 | this[(j + 0) & wrapMask] = fn; 64 | this[(j + 1) & wrapMask] = receiver; 65 | this[(j + 2) & wrapMask] = arg; 66 | this._length = length; 67 | }; 68 | 69 | Queue.prototype.shift = function Queue$shift() { 70 | var front = this._front, 71 | ret = this[front]; 72 | 73 | this[front] = void 0; 74 | this._front = (front + 1) & (this._capacity - 1); 75 | this._length--; 76 | return ret; 77 | }; 78 | 79 | Queue.prototype.length = function Queue$length() { 80 | return this._length; 81 | }; 82 | 83 | Queue.prototype._makeCapacity = function Queue$_makeCapacity() { 84 | var len = this._capacity; 85 | for (var i = 0; i < len; ++i) { 86 | this[i] = void 0; 87 | } 88 | }; 89 | 90 | Queue.prototype._checkCapacity = function Queue$_checkCapacity(size) { 91 | if (this._capacity < size) { 92 | this._resizeTo(this._capacity << 3); 93 | } 94 | }; 95 | 96 | Queue.prototype._resizeTo = function Queue$_resizeTo(capacity) { 97 | var oldFront = this._front; 98 | var oldCapacity = this._capacity; 99 | var oldQueue = new Array(oldCapacity); 100 | var length = this.length(); 101 | 102 | arrayCopy(this, 0, oldQueue, 0, oldCapacity); 103 | this._capacity = capacity; 104 | this._makeCapacity(); 105 | this._front = 0; 106 | if (oldFront + length <= oldCapacity) { 107 | arrayCopy(oldQueue, oldFront, this, 0, length); 108 | } else { var lengthBeforeWrapping = 109 | length - ((oldFront + length) & (oldCapacity - 1)); 110 | 111 | arrayCopy(oldQueue, oldFront, this, 0, lengthBeforeWrapping); 112 | arrayCopy(oldQueue, 0, this, lengthBeforeWrapping, 113 | length - lengthBeforeWrapping); 114 | } 115 | }; 116 | 117 | module.exports = Queue; 118 | -------------------------------------------------------------------------------- /node_modules/bluebird/js/zalgo/race.js: -------------------------------------------------------------------------------- 1 | /** 2 | * The MIT License (MIT) 3 | * 4 | * Copyright (c) 2014 Petka Antonov 5 | * 6 | * Permission is hereby granted, free of charge, to any person obtaining a copy 7 | * of this software and associated documentation files (the "Software"), to deal 8 | * in the Software without restriction, including without limitation the rights 9 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 10 | * copies of the Software, and to permit persons to whom the Software is 11 | * furnished to do so, subject to the following conditions:

12 | * 13 | * The above copyright notice and this permission notice shall be included in 14 | * all copies or substantial portions of the Software. 15 | * 16 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 17 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 18 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 19 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 20 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 21 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 22 | * THE SOFTWARE. 23 | * 24 | */ 25 | "use strict"; 26 | module.exports = function(Promise, INTERNAL, cast) { 27 | var apiRejection = require("./errors_api_rejection.js")(Promise); 28 | var isArray = require("./util.js").isArray; 29 | 30 | var raceLater = function Promise$_raceLater(promise) { 31 | return promise.then(function(array) { 32 | return Promise$_Race(array, promise); 33 | }); 34 | }; 35 | 36 | var hasOwn = {}.hasOwnProperty; 37 | function Promise$_Race(promises, parent) { 38 | var maybePromise = cast(promises, void 0); 39 | 40 | if (maybePromise instanceof Promise) { 41 | return raceLater(maybePromise); 42 | } else if (!isArray(promises)) { 43 | return apiRejection("expecting an array, a promise or a thenable"); 44 | } 45 | 46 | var ret = new Promise(INTERNAL); 47 | if (parent !== void 0) { 48 | ret._propagateFrom(parent, 7); 49 | } else { 50 | ret._setTrace(void 0); 51 | } 52 | var fulfill = ret._fulfill; 53 | var reject = ret._reject; 54 | for (var i = 0, len = promises.length; i < len; ++i) { 55 | var val = promises[i]; 56 | 57 | if (val === void 0 && !(hasOwn.call(promises, i))) { 58 | continue; 59 | } 60 | 61 | Promise.cast(val)._then(fulfill, reject, void 0, ret, null); 62 | } 63 | return ret; 64 | } 65 | 66 | Promise.race = function Promise$Race(promises) { 67 | return Promise$_Race(promises, void 0); 68 | }; 69 | 70 | Promise.prototype.race = function Promise$race() { 71 | return Promise$_Race(this, void 0); 72 | }; 73 | 74 | }; 75 | -------------------------------------------------------------------------------- /node_modules/bluebird/js/zalgo/schedule.js: -------------------------------------------------------------------------------- 1 | /** 2 | * The MIT License (MIT) 3 | * 4 | * Copyright (c) 2014 Petka Antonov 5 | * 6 | * Permission is hereby granted, free of charge, to any person obtaining a copy 7 | * of this software and associated documentation files (the "Software"), to deal 8 | * in the Software without restriction, including without limitation the rights 9 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 10 | * copies of the Software, and to permit persons to whom the Software is 11 | * furnished to do so, subject to the following conditions:

12 | * 13 | * The above copyright notice and this permission notice shall be included in 14 | * all copies or substantial portions of the Software. 15 | * 16 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 17 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 18 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 19 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 20 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 21 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 22 | * THE SOFTWARE. 23 | * 24 | */ 25 | "use strict"; 26 | var schedule; 27 | var _MutationObserver; 28 | if (typeof process === "object" && typeof process.version === "string") { 29 | schedule = function Promise$_Scheduler(fn) { 30 | process.nextTick(fn); 31 | }; 32 | } 33 | else if ((typeof MutationObserver !== "undefined" && 34 | (_MutationObserver = MutationObserver)) || 35 | (typeof WebKitMutationObserver !== "undefined" && 36 | (_MutationObserver = WebKitMutationObserver))) { 37 | schedule = (function() { 38 | var div = document.createElement("div"); 39 | var queuedFn = void 0; 40 | var observer = new _MutationObserver( 41 | function Promise$_Scheduler() { 42 | var fn = queuedFn; 43 | queuedFn = void 0; 44 | fn(); 45 | } 46 | ); 47 | observer.observe(div, { 48 | attributes: true 49 | }); 50 | return function Promise$_Scheduler(fn) { 51 | queuedFn = fn; 52 | div.classList.toggle("foo"); 53 | }; 54 | 55 | })(); 56 | } 57 | else if (typeof setTimeout !== "undefined") { 58 | schedule = function Promise$_Scheduler(fn) { 59 | setTimeout(fn, 0); 60 | }; 61 | } 62 | else throw new Error("no async scheduler available"); 63 | module.exports = schedule; 64 | -------------------------------------------------------------------------------- /node_modules/bluebird/js/zalgo/settle.js: -------------------------------------------------------------------------------- 1 | /** 2 | * The MIT License (MIT) 3 | * 4 | * Copyright (c) 2014 Petka Antonov 5 | * 6 | * Permission is hereby granted, free of charge, to any person obtaining a copy 7 | * of this software and associated documentation files (the "Software"), to deal 8 | * in the Software without restriction, including without limitation the rights 9 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 10 | * copies of the Software, and to permit persons to whom the Software is 11 | * furnished to do so, subject to the following conditions:

12 | * 13 | * The above copyright notice and this permission notice shall be included in 14 | * all copies or substantial portions of the Software. 15 | * 16 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 17 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 18 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 19 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 20 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 21 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 22 | * THE SOFTWARE. 23 | * 24 | */ 25 | "use strict"; 26 | module.exports = 27 | function(Promise, PromiseArray) { 28 | var PromiseInspection = Promise.PromiseInspection; 29 | var util = require("./util.js"); 30 | 31 | function SettledPromiseArray(values) { 32 | this.constructor$(values); 33 | } 34 | util.inherits(SettledPromiseArray, PromiseArray); 35 | 36 | SettledPromiseArray.prototype._promiseResolved = 37 | function SettledPromiseArray$_promiseResolved(index, inspection) { 38 | this._values[index] = inspection; 39 | var totalResolved = ++this._totalResolved; 40 | if (totalResolved >= this._length) { 41 | this._resolve(this._values); 42 | } 43 | }; 44 | 45 | SettledPromiseArray.prototype._promiseFulfilled = 46 | function SettledPromiseArray$_promiseFulfilled(value, index) { 47 | if (this._isResolved()) return; 48 | var ret = new PromiseInspection(); 49 | ret._bitField = 268435456; 50 | ret._settledValue = value; 51 | this._promiseResolved(index, ret); 52 | }; 53 | SettledPromiseArray.prototype._promiseRejected = 54 | function SettledPromiseArray$_promiseRejected(reason, index) { 55 | if (this._isResolved()) return; 56 | var ret = new PromiseInspection(); 57 | ret._bitField = 134217728; 58 | ret._settledValue = reason; 59 | this._promiseResolved(index, ret); 60 | }; 61 | 62 | Promise.settle = function Promise$Settle(promises) { 63 | return new SettledPromiseArray(promises).promise(); 64 | }; 65 | 66 | Promise.prototype.settle = function Promise$settle() { 67 | return new SettledPromiseArray(this).promise(); 68 | }; 69 | }; 70 | -------------------------------------------------------------------------------- /node_modules/bluebird/js/zalgo/some.js: -------------------------------------------------------------------------------- 1 | /** 2 | * The MIT License (MIT) 3 | * 4 | * Copyright (c) 2014 Petka Antonov 5 | * 6 | * Permission is hereby granted, free of charge, to any person obtaining a copy 7 | * of this software and associated documentation files (the "Software"), to deal 8 | * in the Software without restriction, including without limitation the rights 9 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 10 | * copies of the Software, and to permit persons to whom the Software is 11 | * furnished to do so, subject to the following conditions:

12 | * 13 | * The above copyright notice and this permission notice shall be included in 14 | * all copies or substantial portions of the Software. 15 | * 16 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 17 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 18 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 19 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 20 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 21 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 22 | * THE SOFTWARE. 23 | * 24 | */ 25 | "use strict"; 26 | module.exports = 27 | function(Promise, PromiseArray, apiRejection) { 28 | var util = require("./util.js"); 29 | var RangeError = require("./errors.js").RangeError; 30 | var AggregateError = require("./errors.js").AggregateError; 31 | var isArray = util.isArray; 32 | 33 | 34 | function SomePromiseArray(values) { 35 | this.constructor$(values); 36 | this._howMany = 0; 37 | this._unwrap = false; 38 | this._initialized = false; 39 | } 40 | util.inherits(SomePromiseArray, PromiseArray); 41 | 42 | SomePromiseArray.prototype._init = function SomePromiseArray$_init() { 43 | if (!this._initialized) { 44 | return; 45 | } 46 | if (this._howMany === 0) { 47 | this._resolve([]); 48 | return; 49 | } 50 | this._init$(void 0, -5); 51 | var isArrayResolved = isArray(this._values); 52 | if (!this._isResolved() && 53 | isArrayResolved && 54 | this._howMany > this._canPossiblyFulfill()) { 55 | this._reject(this._getRangeError(this.length())); 56 | } 57 | }; 58 | 59 | SomePromiseArray.prototype.init = function SomePromiseArray$init() { 60 | this._initialized = true; 61 | this._init(); 62 | }; 63 | 64 | SomePromiseArray.prototype.setUnwrap = function SomePromiseArray$setUnwrap() { 65 | this._unwrap = true; 66 | }; 67 | 68 | SomePromiseArray.prototype.howMany = function SomePromiseArray$howMany() { 69 | return this._howMany; 70 | }; 71 | 72 | SomePromiseArray.prototype.setHowMany = 73 | function SomePromiseArray$setHowMany(count) { 74 | if (this._isResolved()) return; 75 | this._howMany = count; 76 | }; 77 | 78 | SomePromiseArray.prototype._promiseFulfilled = 79 | function SomePromiseArray$_promiseFulfilled(value) { 80 | if (this._isResolved()) return; 81 | this._addFulfilled(value); 82 | if (this._fulfilled() === this.howMany()) { 83 | this._values.length = this.howMany(); 84 | if (this.howMany() === 1 && this._unwrap) { 85 | this._resolve(this._values[0]); 86 | } else { 87 | this._resolve(this._values); 88 | } 89 | } 90 | 91 | }; 92 | SomePromiseArray.prototype._promiseRejected = 93 | function SomePromiseArray$_promiseRejected(reason) { 94 | if (this._isResolved()) return; 95 | this._addRejected(reason); 96 | if (this.howMany() > this._canPossiblyFulfill()) { 97 | var e = new AggregateError(); 98 | for (var i = this.length(); i < this._values.length; ++i) { 99 | e.push(this._values[i]); 100 | } 101 | this._reject(e); 102 | } 103 | }; 104 | 105 | SomePromiseArray.prototype._fulfilled = function SomePromiseArray$_fulfilled() { 106 | return this._totalResolved; 107 | }; 108 | 109 | SomePromiseArray.prototype._rejected = function SomePromiseArray$_rejected() { 110 | return this._values.length - this.length(); 111 | }; 112 | 113 | SomePromiseArray.prototype._addRejected = 114 | function SomePromiseArray$_addRejected(reason) { 115 | this._values.push(reason); 116 | }; 117 | 118 | SomePromiseArray.prototype._addFulfilled = 119 | function SomePromiseArray$_addFulfilled(value) { 120 | this._values[this._totalResolved++] = value; 121 | }; 122 | 123 | SomePromiseArray.prototype._canPossiblyFulfill = 124 | function SomePromiseArray$_canPossiblyFulfill() { 125 | return this.length() - this._rejected(); 126 | }; 127 | 128 | SomePromiseArray.prototype._getRangeError = 129 | function SomePromiseArray$_getRangeError(count) { 130 | var message = "Input array must contain at least " + 131 | this._howMany + " items but contains only " + count + " items"; 132 | return new RangeError(message); 133 | }; 134 | 135 | SomePromiseArray.prototype._resolveEmptyArray = 136 | function SomePromiseArray$_resolveEmptyArray() { 137 | this._reject(this._getRangeError(0)); 138 | }; 139 | 140 | function Promise$_Some(promises, howMany) { 141 | if ((howMany | 0) !== howMany || howMany < 0) { 142 | return apiRejection("expecting a positive integer"); 143 | } 144 | var ret = new SomePromiseArray(promises); 145 | var promise = ret.promise(); 146 | if (promise.isRejected()) { 147 | return promise; 148 | } 149 | ret.setHowMany(howMany); 150 | ret.init(); 151 | return promise; 152 | } 153 | 154 | Promise.some = function Promise$Some(promises, howMany) { 155 | return Promise$_Some(promises, howMany); 156 | }; 157 | 158 | Promise.prototype.some = function Promise$some(howMany) { 159 | return Promise$_Some(this, howMany); 160 | }; 161 | 162 | Promise._SomePromiseArray = SomePromiseArray; 163 | }; 164 | -------------------------------------------------------------------------------- /node_modules/bluebird/js/zalgo/synchronous_inspection.js: -------------------------------------------------------------------------------- 1 | /** 2 | * The MIT License (MIT) 3 | * 4 | * Copyright (c) 2014 Petka Antonov 5 | * 6 | * Permission is hereby granted, free of charge, to any person obtaining a copy 7 | * of this software and associated documentation files (the "Software"), to deal 8 | * in the Software without restriction, including without limitation the rights 9 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 10 | * copies of the Software, and to permit persons to whom the Software is 11 | * furnished to do so, subject to the following conditions:

12 | * 13 | * The above copyright notice and this permission notice shall be included in 14 | * all copies or substantial portions of the Software. 15 | * 16 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 17 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 18 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 19 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 20 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 21 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 22 | * THE SOFTWARE. 23 | * 24 | */ 25 | "use strict"; 26 | module.exports = function(Promise) { 27 | function PromiseInspection(promise) { 28 | if (promise !== void 0) { 29 | this._bitField = promise._bitField; 30 | this._settledValue = promise.isResolved() 31 | ? promise._settledValue 32 | : void 0; 33 | } 34 | else { 35 | this._bitField = 0; 36 | this._settledValue = void 0; 37 | } 38 | } 39 | 40 | PromiseInspection.prototype.isFulfilled = 41 | Promise.prototype.isFulfilled = function Promise$isFulfilled() { 42 | return (this._bitField & 268435456) > 0; 43 | }; 44 | 45 | PromiseInspection.prototype.isRejected = 46 | Promise.prototype.isRejected = function Promise$isRejected() { 47 | return (this._bitField & 134217728) > 0; 48 | }; 49 | 50 | PromiseInspection.prototype.isPending = 51 | Promise.prototype.isPending = function Promise$isPending() { 52 | return (this._bitField & 402653184) === 0; 53 | }; 54 | 55 | PromiseInspection.prototype.value = 56 | Promise.prototype.value = function Promise$value() { 57 | if (!this.isFulfilled()) { 58 | throw new TypeError("cannot get fulfillment value of a non-fulfilled promise"); 59 | } 60 | return this._settledValue; 61 | }; 62 | 63 | PromiseInspection.prototype.error = 64 | PromiseInspection.prototype.reason = 65 | Promise.prototype.reason = function Promise$reason() { 66 | if (!this.isRejected()) { 67 | throw new TypeError("cannot get rejection reason of a non-rejected promise"); 68 | } 69 | return this._settledValue; 70 | }; 71 | 72 | PromiseInspection.prototype.isResolved = 73 | Promise.prototype.isResolved = function Promise$isResolved() { 74 | return (this._bitField & 402653184) > 0; 75 | }; 76 | 77 | Promise.PromiseInspection = PromiseInspection; 78 | }; 79 | -------------------------------------------------------------------------------- /node_modules/bluebird/js/zalgo/thenables.js: -------------------------------------------------------------------------------- 1 | /** 2 | * The MIT License (MIT) 3 | * 4 | * Copyright (c) 2014 Petka Antonov 5 | * 6 | * Permission is hereby granted, free of charge, to any person obtaining a copy 7 | * of this software and associated documentation files (the "Software"), to deal 8 | * in the Software without restriction, including without limitation the rights 9 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 10 | * copies of the Software, and to permit persons to whom the Software is 11 | * furnished to do so, subject to the following conditions:

12 | * 13 | * The above copyright notice and this permission notice shall be included in 14 | * all copies or substantial portions of the Software. 15 | * 16 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 17 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 18 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 19 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 20 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 21 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 22 | * THE SOFTWARE. 23 | * 24 | */ 25 | "use strict"; 26 | module.exports = function(Promise, INTERNAL) { 27 | var util = require("./util.js"); 28 | var canAttach = require("./errors.js").canAttach; 29 | var errorObj = util.errorObj; 30 | var isObject = util.isObject; 31 | 32 | function getThen(obj) { 33 | try { 34 | return obj.then; 35 | } 36 | catch(e) { 37 | errorObj.e = e; 38 | return errorObj; 39 | } 40 | } 41 | 42 | function Promise$_Cast(obj, originalPromise) { 43 | if (isObject(obj)) { 44 | if (obj instanceof Promise) { 45 | return obj; 46 | } 47 | else if (isAnyBluebirdPromise(obj)) { 48 | var ret = new Promise(INTERNAL); 49 | ret._setTrace(void 0); 50 | obj._then( 51 | ret._fulfillUnchecked, 52 | ret._rejectUncheckedCheckError, 53 | ret._progressUnchecked, 54 | ret, 55 | null 56 | ); 57 | ret._setFollowing(); 58 | return ret; 59 | } 60 | var then = getThen(obj); 61 | if (then === errorObj) { 62 | if (originalPromise !== void 0 && canAttach(then.e)) { 63 | originalPromise._attachExtraTrace(then.e); 64 | } 65 | return Promise.reject(then.e); 66 | } else if (typeof then === "function") { 67 | return Promise$_doThenable(obj, then, originalPromise); 68 | } 69 | } 70 | return obj; 71 | } 72 | 73 | var hasProp = {}.hasOwnProperty; 74 | function isAnyBluebirdPromise(obj) { 75 | return hasProp.call(obj, "_promise0"); 76 | } 77 | 78 | function Promise$_doThenable(x, then, originalPromise) { 79 | var resolver = Promise.defer(); 80 | var called = false; 81 | try { 82 | then.call( 83 | x, 84 | Promise$_resolveFromThenable, 85 | Promise$_rejectFromThenable, 86 | Promise$_progressFromThenable 87 | ); 88 | } catch(e) { 89 | if (!called) { 90 | called = true; 91 | var trace = canAttach(e) ? e : new Error(e + ""); 92 | if (originalPromise !== void 0) { 93 | originalPromise._attachExtraTrace(trace); 94 | } 95 | resolver.promise._reject(e, trace); 96 | } 97 | } 98 | return resolver.promise; 99 | 100 | function Promise$_resolveFromThenable(y) { 101 | if (called) return; 102 | called = true; 103 | 104 | if (x === y) { 105 | var e = Promise._makeSelfResolutionError(); 106 | if (originalPromise !== void 0) { 107 | originalPromise._attachExtraTrace(e); 108 | } 109 | resolver.promise._reject(e, void 0); 110 | return; 111 | } 112 | resolver.resolve(y); 113 | } 114 | 115 | function Promise$_rejectFromThenable(r) { 116 | if (called) return; 117 | called = true; 118 | var trace = canAttach(r) ? r : new Error(r + ""); 119 | if (originalPromise !== void 0) { 120 | originalPromise._attachExtraTrace(trace); 121 | } 122 | resolver.promise._reject(r, trace); 123 | } 124 | 125 | function Promise$_progressFromThenable(v) { 126 | if (called) return; 127 | var promise = resolver.promise; 128 | if (typeof promise._progress === "function") { 129 | promise._progress(v); 130 | } 131 | } 132 | } 133 | 134 | return Promise$_Cast; 135 | }; 136 | -------------------------------------------------------------------------------- /node_modules/bluebird/js/zalgo/timers.js: -------------------------------------------------------------------------------- 1 | /** 2 | * The MIT License (MIT) 3 | * 4 | * Copyright (c) 2014 Petka Antonov 5 | * 6 | * Permission is hereby granted, free of charge, to any person obtaining a copy 7 | * of this software and associated documentation files (the "Software"), to deal 8 | * in the Software without restriction, including without limitation the rights 9 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 10 | * copies of the Software, and to permit persons to whom the Software is 11 | * furnished to do so, subject to the following conditions:

12 | * 13 | * The above copyright notice and this permission notice shall be included in 14 | * all copies or substantial portions of the Software. 15 | * 16 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 17 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 18 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 19 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 20 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 21 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 22 | * THE SOFTWARE. 23 | * 24 | */ 25 | "use strict"; 26 | var _setTimeout = function(fn, ms) { 27 | var len = arguments.length; 28 | var arg0 = arguments[2]; 29 | var arg1 = arguments[3]; 30 | var arg2 = len >= 5 ? arguments[4] : void 0; 31 | setTimeout(function() { 32 | fn(arg0, arg1, arg2); 33 | }, ms|0); 34 | }; 35 | 36 | module.exports = function(Promise, INTERNAL, cast) { 37 | var util = require("./util.js"); 38 | var errors = require("./errors.js"); 39 | var apiRejection = require("./errors_api_rejection")(Promise); 40 | var TimeoutError = Promise.TimeoutError; 41 | 42 | var afterTimeout = function Promise$_afterTimeout(promise, message, ms) { 43 | if (!promise.isPending()) return; 44 | if (typeof message !== "string") { 45 | message = "operation timed out after" + " " + ms + " ms" 46 | } 47 | var err = new TimeoutError(message); 48 | errors.markAsOriginatingFromRejection(err); 49 | promise._attachExtraTrace(err); 50 | promise._cancel(err); 51 | }; 52 | 53 | var afterDelay = function Promise$_afterDelay(value, promise) { 54 | promise._fulfill(value); 55 | }; 56 | 57 | var delay = Promise.delay = function Promise$Delay(value, ms) { 58 | if (ms === void 0) { 59 | ms = value; 60 | value = void 0; 61 | } 62 | ms = +ms; 63 | var maybePromise = cast(value, void 0); 64 | var promise = new Promise(INTERNAL); 65 | 66 | if (maybePromise instanceof Promise) { 67 | promise._propagateFrom(maybePromise, 7); 68 | promise._follow(maybePromise); 69 | return promise.then(function(value) { 70 | return Promise.delay(value, ms); 71 | }); 72 | } else { 73 | promise._setTrace(void 0); 74 | _setTimeout(afterDelay, ms, value, promise); 75 | } 76 | return promise; 77 | }; 78 | 79 | Promise.prototype.delay = function Promise$delay(ms) { 80 | return delay(this, ms); 81 | }; 82 | 83 | Promise.prototype.timeout = function Promise$timeout(ms, message) { 84 | ms = +ms; 85 | 86 | var ret = new Promise(INTERNAL); 87 | ret._propagateFrom(this, 7); 88 | ret._follow(this); 89 | _setTimeout(afterTimeout, ms, ret, message, ms); 90 | return ret.cancellable(); 91 | }; 92 | 93 | }; 94 | -------------------------------------------------------------------------------- /package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "Node20Min", 3 | "version": "0.0.1", 4 | "description": "A short code-focused introduction to Node.js", 5 | "main": "index.js", 6 | "scripts": { 7 | "test": "echo \"Error: no test specified\" && exit 1" 8 | }, 9 | "repository": { 10 | "type": "git", 11 | "url": "git://github.com/stdarg/Node20Min.git" 12 | }, 13 | "keywords": [ 14 | "presentation", 15 | "node", 16 | "reference", 17 | "tutorial" 18 | ], 19 | "author": "Edmond Meinfelder", 20 | "license": "MIT", 21 | "bugs": { 22 | "url": "https://github.com/stdarg/Node20Min/issues" 23 | }, 24 | "homepage": "https://github.com/stdarg/Node20Min", 25 | "dependencies": { 26 | "async": "0.9.0", 27 | "bluebird": "2.3.10" 28 | } 29 | } 30 | -------------------------------------------------------------------------------- /slides/NodeIn20Min.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/stdarg/Node20Min/51f55311e27976f4adc92dc5a431f0ee1d01c5a4/slides/NodeIn20Min.pdf --------------------------------------------------------------------------------