6935 changed files with 462081 additions and 0 deletions
@ -0,0 +1 @@ |
|||
node index.js |
@ -0,0 +1,17 @@ |
|||
|
|||
const express = require('express'); |
|||
const app = express(); |
|||
const http = require('http').Server(app); |
|||
const io = require('socket.io')(http); |
|||
const port = process.env.PORT || 3000; |
|||
|
|||
app.use(express.static(__dirname + '/public')); |
|||
|
|||
function onConnection(socket){ |
|||
socket.on('key', (data) => socket.broadcast.emit('key', data)); |
|||
socket.on('slidesLen', (data) => socket.broadcast.emit('slidesLen', data)); |
|||
} |
|||
|
|||
io.on('connection', onConnection); |
|||
|
|||
http.listen(port, () => console.log('listening on port ' + port)); |
@ -0,0 +1 @@ |
|||
../babylon/bin/babylon.js |
@ -0,0 +1 @@ |
|||
../loose-envify/cli.js |
@ -0,0 +1,74 @@ |
|||
1.1.4 / 2014-12-10 |
|||
================== |
|||
|
|||
* deps: mime-types@~2.0.4 |
|||
- deps: mime-db@~1.3.0 |
|||
|
|||
1.1.3 / 2014-11-09 |
|||
================== |
|||
|
|||
* deps: mime-types@~2.0.3 |
|||
- deps: mime-db@~1.2.0 |
|||
|
|||
1.1.2 / 2014-10-14 |
|||
================== |
|||
|
|||
* deps: negotiator@0.4.9 |
|||
- Fix error when media type has invalid parameter |
|||
|
|||
1.1.1 / 2014-09-28 |
|||
================== |
|||
|
|||
* deps: mime-types@~2.0.2 |
|||
- deps: mime-db@~1.1.0 |
|||
* deps: negotiator@0.4.8 |
|||
- Fix all negotiations to be case-insensitive |
|||
- Stable sort preferences of same quality according to client order |
|||
|
|||
1.1.0 / 2014-09-02 |
|||
================== |
|||
|
|||
* update `mime-types` |
|||
|
|||
1.0.7 / 2014-07-04 |
|||
================== |
|||
|
|||
* Fix wrong type returned from `type` when match after unknown extension |
|||
|
|||
1.0.6 / 2014-06-24 |
|||
================== |
|||
|
|||
* deps: negotiator@0.4.7 |
|||
|
|||
1.0.5 / 2014-06-20 |
|||
================== |
|||
|
|||
* fix crash when unknown extension given |
|||
|
|||
1.0.4 / 2014-06-19 |
|||
================== |
|||
|
|||
* use `mime-types` |
|||
|
|||
1.0.3 / 2014-06-11 |
|||
================== |
|||
|
|||
* deps: negotiator@0.4.6 |
|||
- Order by specificity when quality is the same |
|||
|
|||
1.0.2 / 2014-05-29 |
|||
================== |
|||
|
|||
* Fix interpretation when header not in request |
|||
* deps: pin negotiator@0.4.5 |
|||
|
|||
1.0.1 / 2014-01-18 |
|||
================== |
|||
|
|||
* Identity encoding isn't always acceptable |
|||
* deps: negotiator@~0.4.0 |
|||
|
|||
1.0.0 / 2013-12-27 |
|||
================== |
|||
|
|||
* Genesis |
@ -0,0 +1,22 @@ |
|||
(The MIT License) |
|||
|
|||
Copyright (c) 2014 Jonathan Ong <me@jongleberry.com> |
|||
|
|||
Permission is hereby granted, free of charge, to any person obtaining |
|||
a copy of this software and associated documentation files (the |
|||
'Software'), to deal in the Software without restriction, including |
|||
without limitation the rights to use, copy, modify, merge, publish, |
|||
distribute, sublicense, and/or sell copies of the Software, and to |
|||
permit persons to whom the Software is furnished to do so, subject to |
|||
the following conditions: |
|||
|
|||
The above copyright notice and this permission notice shall be |
|||
included in all copies or substantial portions of the Software. |
|||
|
|||
THE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND, |
|||
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF |
|||
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. |
|||
IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY |
|||
CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, |
|||
TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE |
|||
SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. |
@ -0,0 +1,94 @@ |
|||
# accepts |
|||
|
|||
[![NPM Version][npm-image]][npm-url] |
|||
[![NPM Downloads][downloads-image]][downloads-url] |
|||
[![Node.js Version][node-version-image]][node-version-url] |
|||
[![Build Status][travis-image]][travis-url] |
|||
[![Test Coverage][coveralls-image]][coveralls-url] |
|||
|
|||
Higher level content negotation based on [negotiator](https://github.com/federomero/negotiator). Extracted from [koa](https://github.com/koajs/koa) for general use. |
|||
|
|||
In addition to negotatior, it allows: |
|||
|
|||
- Allows types as an array or arguments list, ie `(['text/html', 'application/json'])` as well as `('text/html', 'application/json')`. |
|||
- Allows type shorthands such as `json`. |
|||
- Returns `false` when no types match |
|||
- Treats non-existent headers as `*` |
|||
|
|||
## API |
|||
|
|||
### var accept = new Accepts(req) |
|||
|
|||
```js |
|||
var accepts = require('accepts') |
|||
|
|||
http.createServer(function (req, res) { |
|||
var accept = accepts(req) |
|||
}) |
|||
``` |
|||
|
|||
### accept\[property\]\(\) |
|||
|
|||
Returns all the explicitly accepted content property as an array in descending priority. |
|||
|
|||
- `accept.types()` |
|||
- `accept.encodings()` |
|||
- `accept.charsets()` |
|||
- `accept.languages()` |
|||
|
|||
They are also aliased in singular form such as `accept.type()`. `accept.languages()` is also aliased as `accept.langs()`, etc. |
|||
|
|||
Note: you should almost never do this in a real app as it defeats the purpose of content negotiation. |
|||
|
|||
Example: |
|||
|
|||
```js |
|||
// in Google Chrome |
|||
var encodings = accept.encodings() // -> ['sdch', 'gzip', 'deflate'] |
|||
``` |
|||
|
|||
Since you probably don't support `sdch`, you should just supply the encodings you support: |
|||
|
|||
```js |
|||
var encoding = accept.encodings('gzip', 'deflate') // -> 'gzip', probably |
|||
``` |
|||
|
|||
### accept\[property\]\(values, ...\) |
|||
|
|||
You can either have `values` be an array or have an argument list of values. |
|||
|
|||
If the client does not accept any `values`, `false` will be returned. |
|||
If the client accepts any `values`, the preferred `value` will be return. |
|||
|
|||
For `accept.types()`, shorthand mime types are allowed. |
|||
|
|||
Example: |
|||
|
|||
```js |
|||
// req.headers.accept = 'application/json' |
|||
|
|||
accept.types('json') // -> 'json' |
|||
accept.types('html', 'json') // -> 'json' |
|||
accept.types('html') // -> false |
|||
|
|||
// req.headers.accept = '' |
|||
// which is equivalent to `*` |
|||
|
|||
accept.types() // -> [], no explicit types |
|||
accept.types('text/html', 'text/json') // -> 'text/html', since it was first |
|||
``` |
|||
|
|||
## License |
|||
|
|||
[MIT](LICENSE) |
|||
|
|||
[npm-image]: https://img.shields.io/npm/v/accepts.svg?style=flat |
|||
[npm-url]: https://npmjs.org/package/accepts |
|||
[node-version-image]: https://img.shields.io/node/v/accepts.svg?style=flat |
|||
[node-version-url]: http://nodejs.org/download/ |
|||
[travis-image]: https://img.shields.io/travis/jshttp/accepts.svg?style=flat |
|||
[travis-url]: https://travis-ci.org/jshttp/accepts |
|||
[coveralls-image]: https://img.shields.io/coveralls/jshttp/accepts.svg?style=flat |
|||
[coveralls-url]: https://coveralls.io/r/jshttp/accepts |
|||
[downloads-image]: https://img.shields.io/npm/dm/accepts.svg?style=flat |
|||
[downloads-url]: https://npmjs.org/package/accepts |
@ -0,0 +1,160 @@ |
|||
var Negotiator = require('negotiator') |
|||
var mime = require('mime-types') |
|||
|
|||
var slice = [].slice |
|||
|
|||
module.exports = Accepts |
|||
|
|||
function Accepts(req) { |
|||
if (!(this instanceof Accepts)) |
|||
return new Accepts(req) |
|||
|
|||
this.headers = req.headers |
|||
this.negotiator = Negotiator(req) |
|||
} |
|||
|
|||
/** |
|||
* Check if the given `type(s)` is acceptable, returning |
|||
* the best match when true, otherwise `undefined`, in which |
|||
* case you should respond with 406 "Not Acceptable". |
|||
* |
|||
* The `type` value may be a single mime type string |
|||
* such as "application/json", the extension name |
|||
* such as "json" or an array `["json", "html", "text/plain"]`. When a list |
|||
* or array is given the _best_ match, if any is returned. |
|||
* |
|||
* Examples: |
|||
* |
|||
* // Accept: text/html
|
|||
* this.types('html'); |
|||
* // => "html"
|
|||
* |
|||
* // Accept: text/*, application/json
|
|||
* this.types('html'); |
|||
* // => "html"
|
|||
* this.types('text/html'); |
|||
* // => "text/html"
|
|||
* this.types('json', 'text'); |
|||
* // => "json"
|
|||
* this.types('application/json'); |
|||
* // => "application/json"
|
|||
* |
|||
* // Accept: text/*, application/json
|
|||
* this.types('image/png'); |
|||
* this.types('png'); |
|||
* // => undefined
|
|||
* |
|||
* // Accept: text/*;q=.5, application/json
|
|||
* this.types(['html', 'json']); |
|||
* this.types('html', 'json'); |
|||
* // => "json"
|
|||
* |
|||
* @param {String|Array} type(s)... |
|||
* @return {String|Array|Boolean} |
|||
* @api public |
|||
*/ |
|||
|
|||
Accepts.prototype.type = |
|||
Accepts.prototype.types = function (types) { |
|||
if (!Array.isArray(types)) types = slice.call(arguments); |
|||
var n = this.negotiator; |
|||
if (!types.length) return n.mediaTypes(); |
|||
if (!this.headers.accept) return types[0]; |
|||
var mimes = types.map(extToMime); |
|||
var accepts = n.mediaTypes(mimes.filter(validMime)); |
|||
var first = accepts[0]; |
|||
if (!first) return false; |
|||
return types[mimes.indexOf(first)]; |
|||
} |
|||
|
|||
/** |
|||
* Return accepted encodings or best fit based on `encodings`. |
|||
* |
|||
* Given `Accept-Encoding: gzip, deflate` |
|||
* an array sorted by quality is returned: |
|||
* |
|||
* ['gzip', 'deflate'] |
|||
* |
|||
* @param {String|Array} encoding(s)... |
|||
* @return {String|Array} |
|||
* @api public |
|||
*/ |
|||
|
|||
Accepts.prototype.encoding = |
|||
Accepts.prototype.encodings = function (encodings) { |
|||
if (!Array.isArray(encodings)) encodings = slice.call(arguments); |
|||
var n = this.negotiator; |
|||
if (!encodings.length) return n.encodings(); |
|||
return n.encodings(encodings)[0] || false; |
|||
} |
|||
|
|||
/** |
|||
* Return accepted charsets or best fit based on `charsets`. |
|||
* |
|||
* Given `Accept-Charset: utf-8, iso-8859-1;q=0.2, utf-7;q=0.5` |
|||
* an array sorted by quality is returned: |
|||
* |
|||
* ['utf-8', 'utf-7', 'iso-8859-1'] |
|||
* |
|||
* @param {String|Array} charset(s)... |
|||
* @return {String|Array} |
|||
* @api public |
|||
*/ |
|||
|
|||
Accepts.prototype.charset = |
|||
Accepts.prototype.charsets = function (charsets) { |
|||
if (!Array.isArray(charsets)) charsets = [].slice.call(arguments); |
|||
var n = this.negotiator; |
|||
if (!charsets.length) return n.charsets(); |
|||
if (!this.headers['accept-charset']) return charsets[0]; |
|||
return n.charsets(charsets)[0] || false; |
|||
} |
|||
|
|||
/** |
|||
* Return accepted languages or best fit based on `langs`. |
|||
* |
|||
* Given `Accept-Language: en;q=0.8, es, pt` |
|||
* an array sorted by quality is returned: |
|||
* |
|||
* ['es', 'pt', 'en'] |
|||
* |
|||
* @param {String|Array} lang(s)... |
|||
* @return {Array|String} |
|||
* @api public |
|||
*/ |
|||
|
|||
Accepts.prototype.lang = |
|||
Accepts.prototype.langs = |
|||
Accepts.prototype.language = |
|||
Accepts.prototype.languages = function (langs) { |
|||
if (!Array.isArray(langs)) langs = slice.call(arguments); |
|||
var n = this.negotiator; |
|||
if (!langs.length) return n.languages(); |
|||
if (!this.headers['accept-language']) return langs[0]; |
|||
return n.languages(langs)[0] || false; |
|||
} |
|||
|
|||
/** |
|||
* Convert extnames to mime. |
|||
* |
|||
* @param {String} type |
|||
* @return {String} |
|||
* @api private |
|||
*/ |
|||
|
|||
function extToMime(type) { |
|||
if (~type.indexOf('/')) return type; |
|||
return mime.lookup(type); |
|||
} |
|||
|
|||
/** |
|||
* Check if mime is valid. |
|||
* |
|||
* @param {String} type |
|||
* @return {String} |
|||
* @api private |
|||
*/ |
|||
|
|||
function validMime(type) { |
|||
return typeof type === 'string'; |
|||
} |
@ -0,0 +1,71 @@ |
|||
{ |
|||
"_from": "accepts@~1.1.2", |
|||
"_id": "accepts@1.1.4", |
|||
"_inBundle": false, |
|||
"_integrity": "sha1-1xyW99QdD+2iw4zRToonwEFY30o=", |
|||
"_location": "/accepts", |
|||
"_phantomChildren": {}, |
|||
"_requested": { |
|||
"type": "range", |
|||
"registry": true, |
|||
"raw": "accepts@~1.1.2", |
|||
"name": "accepts", |
|||
"escapedName": "accepts", |
|||
"rawSpec": "~1.1.2", |
|||
"saveSpec": null, |
|||
"fetchSpec": "~1.1.2" |
|||
}, |
|||
"_requiredBy": [ |
|||
"/express" |
|||
], |
|||
"_resolved": "https://registry.npmjs.org/accepts/-/accepts-1.1.4.tgz", |
|||
"_shasum": "d71c96f7d41d0feda2c38cd14e8a27c04158df4a", |
|||
"_spec": "accepts@~1.1.2", |
|||
"_where": "/var/www/htdocs/coze/socket/node_modules/express", |
|||
"author": { |
|||
"name": "Jonathan Ong", |
|||
"email": "me@jongleberry.com", |
|||
"url": "http://jongleberry.com" |
|||
}, |
|||
"bugs": { |
|||
"url": "https://github.com/jshttp/accepts/issues" |
|||
}, |
|||
"bundleDependencies": false, |
|||
"dependencies": { |
|||
"mime-types": "~2.0.4", |
|||
"negotiator": "0.4.9" |
|||
}, |
|||
"deprecated": false, |
|||
"description": "Higher-level content negotiation", |
|||
"devDependencies": { |
|||
"istanbul": "~0.3.4", |
|||
"mocha": "~2.0.1" |
|||
}, |
|||
"engines": { |
|||
"node": ">= 0.8" |
|||
}, |
|||
"files": [ |
|||
"LICENSE", |
|||
"HISTORY.md", |
|||
"index.js" |
|||
], |
|||
"homepage": "https://github.com/jshttp/accepts#readme", |
|||
"keywords": [ |
|||
"content", |
|||
"negotiation", |
|||
"accept", |
|||
"accepts" |
|||
], |
|||
"license": "MIT", |
|||
"name": "accepts", |
|||
"repository": { |
|||
"type": "git", |
|||
"url": "git+https://github.com/jshttp/accepts.git" |
|||
}, |
|||
"scripts": { |
|||
"test": "mocha --reporter spec --check-leaks --bail test/", |
|||
"test-cov": "istanbul cover node_modules/mocha/bin/_mocha -- --reporter dot --check-leaks test/", |
|||
"test-travis": "istanbul cover node_modules/mocha/bin/_mocha --report lcovonly -- --reporter spec --check-leaks test/" |
|||
}, |
|||
"version": "1.1.4" |
|||
} |
@ -0,0 +1,2 @@ |
|||
node_modules |
|||
.monitor |
@ -0,0 +1,12 @@ |
|||
language: node_js |
|||
node_js: |
|||
- 0.6 |
|||
- 0.8 |
|||
- 0.9 |
|||
- 0.10 |
|||
- 0.12 |
|||
- 4.2.4 |
|||
- 5.4.1 |
|||
- iojs-1 |
|||
- iojs-2 |
|||
- iojs-3 |
@ -0,0 +1,19 @@ |
|||
Copyright (c) 2011 Raynos. |
|||
|
|||
Permission is hereby granted, free of charge, to any person obtaining a copy |
|||
of this software and associated documentation files (the "Software"), to deal |
|||
in the Software without restriction, including without limitation the rights |
|||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell |
|||
copies of the Software, and to permit persons to whom the Software is |
|||
furnished to do so, subject to the following conditions: |
|||
|
|||
The above copyright notice and this permission notice shall be included in |
|||
all copies or substantial portions of the Software. |
|||
|
|||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR |
|||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, |
|||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE |
|||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER |
|||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, |
|||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN |
|||
THE SOFTWARE. |
@ -0,0 +1,115 @@ |
|||
# After [![Build Status][1]][2] |
|||
|
|||
Invoke callback after n calls |
|||
|
|||
## Status: production ready |
|||
|
|||
## Example |
|||
|
|||
```js |
|||
var after = require("after") |
|||
var db = require("./db") // some db. |
|||
|
|||
var updateUser = function (req, res) { |
|||
// use after to run two tasks in parallel, |
|||
// namely get request body and get session |
|||
// then run updateUser with the results |
|||
var next = after(2, updateUser) |
|||
var results = {} |
|||
|
|||
getJSONBody(req, res, function (err, body) { |
|||
if (err) return next(err) |
|||
|
|||
results.body = body |
|||
next(null, results) |
|||
}) |
|||
|
|||
getSessionUser(req, res, function (err, user) { |
|||
if (err) return next(err) |
|||
|
|||
results.user = user |
|||
next(null, results) |
|||
}) |
|||
|
|||
// now do the thing! |
|||
function updateUser(err, result) { |
|||
if (err) { |
|||
res.statusCode = 500 |
|||
return res.end("Unexpected Error") |
|||
} |
|||
|
|||
if (!result.user || result.user.role !== "admin") { |
|||
res.statusCode = 403 |
|||
return res.end("Permission Denied") |
|||
} |
|||
|
|||
db.put("users:" + req.params.userId, result.body, function (err) { |
|||
if (err) { |
|||
res.statusCode = 500 |
|||
return res.end("Unexpected Error") |
|||
} |
|||
|
|||
res.statusCode = 200 |
|||
res.end("Ok") |
|||
}) |
|||
} |
|||
} |
|||
``` |
|||
|
|||
## Naive Example |
|||
|
|||
```js |
|||
var after = require("after") |
|||
, next = after(3, logItWorks) |
|||
|
|||
next() |
|||
next() |
|||
next() // it works |
|||
|
|||
function logItWorks() { |
|||
console.log("it works!") |
|||
} |
|||
``` |
|||
|
|||
## Example with error handling |
|||
|
|||
```js |
|||
var after = require("after") |
|||
, next = after(3, logError) |
|||
|
|||
next() |
|||
next(new Error("oops")) // logs oops |
|||
next() // does nothing |
|||
|
|||
// This callback is only called once. |
|||
// If there is an error the callback gets called immediately |
|||
// this avoids the situation where errors get lost. |
|||
function logError(err) { |
|||
console.log(err) |
|||
} |
|||
``` |
|||
|
|||
## Installation |
|||
|
|||
`npm install after` |
|||
|
|||
## Tests |
|||
|
|||
`npm test` |
|||
|
|||
## Contributors |
|||
|
|||
- Raynos |
|||
- defunctzombie |
|||
|
|||
## MIT Licenced |
|||
|
|||
[1]: https://secure.travis-ci.org/Raynos/after.png |
|||
[2]: http://travis-ci.org/Raynos/after |
|||
[3]: http://raynos.org/blog/2/Flow-control-in-node.js |
|||
[4]: http://stackoverflow.com/questions/6852059/determining-the-end-of-asynchronous-operations-javascript/6852307#6852307 |
|||
[5]: http://stackoverflow.com/questions/6869872/in-javascript-what-are-best-practices-for-executing-multiple-asynchronous-functi/6870031#6870031 |
|||
[6]: http://stackoverflow.com/questions/6864397/javascript-performance-long-running-tasks/6889419#6889419 |
|||
[7]: http://stackoverflow.com/questions/6597493/synchronous-database-queries-with-node-js/6620091#6620091 |
|||
[8]: http://github.com/Raynos/iterators |
|||
[9]: http://github.com/Raynos/composite |
@ -0,0 +1,28 @@ |
|||
module.exports = after |
|||
|
|||
function after(count, callback, err_cb) { |
|||
var bail = false |
|||
err_cb = err_cb || noop |
|||
proxy.count = count |
|||
|
|||
return (count === 0) ? callback() : proxy |
|||
|
|||
function proxy(err, result) { |
|||
if (proxy.count <= 0) { |
|||
throw new Error('after called too many times') |
|||
} |
|||
--proxy.count |
|||
|
|||
// after first error, rest are passed to err_cb
|
|||
if (err) { |
|||
bail = true |
|||
callback(err) |
|||
// future error callbacks will go to error handler
|
|||
callback = err_cb |
|||
} else if (proxy.count === 0 && !bail) { |
|||
callback(null, result) |
|||
} |
|||
} |
|||
} |
|||
|
|||
function noop() {} |
@ -0,0 +1,63 @@ |
|||
{ |
|||
"_from": "after@0.8.2", |
|||
"_id": "after@0.8.2", |
|||
"_inBundle": false, |
|||
"_integrity": "sha1-/ts5T58OAqqXaOcCvaI7UF+ufh8=", |
|||
"_location": "/after", |
|||
"_phantomChildren": {}, |
|||
"_requested": { |
|||
"type": "version", |
|||
"registry": true, |
|||
"raw": "after@0.8.2", |
|||
"name": "after", |
|||
"escapedName": "after", |
|||
"rawSpec": "0.8.2", |
|||
"saveSpec": null, |
|||
"fetchSpec": "0.8.2" |
|||
}, |
|||
"_requiredBy": [ |
|||
"/engine.io-parser" |
|||
], |
|||
"_resolved": "https://registry.npmjs.org/after/-/after-0.8.2.tgz", |
|||
"_shasum": "fedb394f9f0e02aa9768e702bda23b505fae7e1f", |
|||
"_spec": "after@0.8.2", |
|||
"_where": "/var/www/htdocs/coze/socket/node_modules/engine.io-parser", |
|||
"author": { |
|||
"name": "Raynos", |
|||
"email": "raynos2@gmail.com" |
|||
}, |
|||
"bugs": { |
|||
"url": "https://github.com/Raynos/after/issues" |
|||
}, |
|||
"bundleDependencies": false, |
|||
"contributors": [ |
|||
{ |
|||
"name": "Raynos", |
|||
"email": "raynos2@gmail.com", |
|||
"url": "http://raynos.org" |
|||
} |
|||
], |
|||
"deprecated": false, |
|||
"description": "after - tiny flow control", |
|||
"devDependencies": { |
|||
"mocha": "~1.8.1" |
|||
}, |
|||
"homepage": "https://github.com/Raynos/after#readme", |
|||
"keywords": [ |
|||
"flowcontrol", |
|||
"after", |
|||
"flow", |
|||
"control", |
|||
"arch" |
|||
], |
|||
"license": "MIT", |
|||
"name": "after", |
|||
"repository": { |
|||
"type": "git", |
|||
"url": "git://github.com/Raynos/after.git" |
|||
}, |
|||
"scripts": { |
|||
"test": "mocha --ui tdd --reporter spec test/*.js" |
|||
}, |
|||
"version": "0.8.2" |
|||
} |
@ -0,0 +1,120 @@ |
|||
/*global suite, test*/ |
|||
|
|||
var assert = require("assert") |
|||
, after = require("../") |
|||
|
|||
test("exists", function () { |
|||
assert(typeof after === "function", "after is not a function") |
|||
}) |
|||
|
|||
test("after when called with 0 invokes", function (done) { |
|||
after(0, done) |
|||
}); |
|||
|
|||
test("after 1", function (done) { |
|||
var next = after(1, done) |
|||
next() |
|||
}) |
|||
|
|||
test("after 5", function (done) { |
|||
var next = after(5, done) |
|||
, i = 5 |
|||
|
|||
while (i--) { |
|||
next() |
|||
} |
|||
}) |
|||
|
|||
test("manipulate count", function (done) { |
|||
var next = after(1, done) |
|||
, i = 5 |
|||
|
|||
next.count = i |
|||
while (i--) { |
|||
next() |
|||
} |
|||
}) |
|||
|
|||
test("after terminates on error", function (done) { |
|||
var next = after(2, function(err) { |
|||
assert.equal(err.message, 'test'); |
|||
done(); |
|||
}) |
|||
next(new Error('test')) |
|||
next(new Error('test2')) |
|||
}) |
|||
|
|||
test('gee', function(done) { |
|||
done = after(2, done) |
|||
|
|||
function cb(err) { |
|||
assert.equal(err.message, 1); |
|||
done() |
|||
} |
|||
|
|||
var next = after(3, cb, function(err) { |
|||
assert.equal(err.message, 2) |
|||
done() |
|||
}); |
|||
|
|||
next() |
|||
next(new Error(1)) |
|||
next(new Error(2)) |
|||
}) |
|||
|
|||
test('eee', function(done) { |
|||
done = after(3, done) |
|||
|
|||
function cb(err) { |
|||
assert.equal(err.message, 1); |
|||
done() |
|||
} |
|||
|
|||
var next = after(3, cb, function(err) { |
|||
assert.equal(err.message, 2) |
|||
done() |
|||
}); |
|||
|
|||
next(new Error(1)) |
|||
next(new Error(2)) |
|||
next(new Error(2)) |
|||
}) |
|||
|
|||
test('gge', function(done) { |
|||
function cb(err) { |
|||
assert.equal(err.message, 1); |
|||
done() |
|||
} |
|||
|
|||
var next = after(3, cb, function(err) { |
|||
// should not happen
|
|||
assert.ok(false); |
|||
}); |
|||
|
|||
next() |
|||
next() |
|||
next(new Error(1)) |
|||
}) |
|||
|
|||
test('egg', function(done) { |
|||
function cb(err) { |
|||
assert.equal(err.message, 1); |
|||
done() |
|||
} |
|||
|
|||
var next = after(3, cb, function(err) { |
|||
// should not happen
|
|||
assert.ok(false); |
|||
}); |
|||
|
|||
next(new Error(1)) |
|||
next() |
|||
next() |
|||
}) |
|||
|
|||
test('throws on too many calls', function(done) { |
|||
var next = after(1, done); |
|||
next() |
|||
assert.throws(next, /after called too many times/); |
|||
}); |
|||
|
@ -0,0 +1,4 @@ |
|||
'use strict'; |
|||
module.exports = function () { |
|||
return /[\u001b\u009b][[()#;?]*(?:[0-9]{1,4}(?:;[0-9]{0,4})*)?[0-9A-PRZcf-nqry=><]/g; |
|||
}; |
@ -0,0 +1,21 @@ |
|||
The MIT License (MIT) |
|||
|
|||
Copyright (c) Sindre Sorhus <sindresorhus@gmail.com> (sindresorhus.com) |
|||
|
|||
Permission is hereby granted, free of charge, to any person obtaining a copy |
|||
of this software and associated documentation files (the "Software"), to deal |
|||
in the Software without restriction, including without limitation the rights |
|||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell |
|||
copies of the Software, and to permit persons to whom the Software is |
|||
furnished to do so, subject to the following conditions: |
|||
|
|||
The above copyright notice and this permission notice shall be included in |
|||
all copies or substantial portions of the Software. |
|||
|
|||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR |
|||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, |
|||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE |
|||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER |
|||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, |
|||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN |
|||
THE SOFTWARE. |
@ -0,0 +1,109 @@ |
|||
{ |
|||
"_from": "ansi-regex@^2.0.0", |
|||
"_id": "ansi-regex@2.1.1", |
|||
"_inBundle": false, |
|||
"_integrity": "sha1-w7M6te42DYbg5ijwRorn7yfWVN8=", |
|||
"_location": "/ansi-regex", |
|||
"_phantomChildren": {}, |
|||
"_requested": { |
|||
"type": "range", |
|||
"registry": true, |
|||
"raw": "ansi-regex@^2.0.0", |
|||
"name": "ansi-regex", |
|||
"escapedName": "ansi-regex", |
|||
"rawSpec": "^2.0.0", |
|||
"saveSpec": null, |
|||
"fetchSpec": "^2.0.0" |
|||
}, |
|||
"_requiredBy": [ |
|||
"/has-ansi", |
|||
"/strip-ansi" |
|||
], |
|||
"_resolved": "https://registry.npmjs.org/ansi-regex/-/ansi-regex-2.1.1.tgz", |
|||
"_shasum": "c3b33ab5ee360d86e0e628f0468ae7ef27d654df", |
|||
"_spec": "ansi-regex@^2.0.0", |
|||
"_where": "/var/www/htdocs/coze/socket/node_modules/has-ansi", |
|||
"author": { |
|||
"name": "Sindre Sorhus", |
|||
"email": "sindresorhus@gmail.com", |
|||
"url": "sindresorhus.com" |
|||
}, |
|||
"bugs": { |
|||
"url": "https://github.com/chalk/ansi-regex/issues" |
|||
}, |
|||
"bundleDependencies": false, |
|||
"deprecated": false, |
|||
"description": "Regular expression for matching ANSI escape codes", |
|||
"devDependencies": { |
|||
"ava": "0.17.0", |
|||
"xo": "0.16.0" |
|||
}, |
|||
"engines": { |
|||
"node": ">=0.10.0" |
|||
}, |
|||
"files": [ |
|||
"index.js" |
|||
], |
|||
"homepage": "https://github.com/chalk/ansi-regex#readme", |
|||
"keywords": [ |
|||
"ansi", |
|||
"styles", |
|||
"color", |
|||
"colour", |
|||
"colors", |
|||
"terminal", |
|||
"console", |
|||
"cli", |
|||
"string", |
|||
"tty", |
|||
"escape", |
|||
"formatting", |
|||
"rgb", |
|||
"256", |
|||
"shell", |
|||
"xterm", |
|||
"command-line", |
|||
"text", |
|||
"regex", |
|||
"regexp", |
|||
"re", |
|||
"match", |
|||
"test", |
|||
"find", |
|||
"pattern" |
|||
], |
|||
"license": "MIT", |
|||
"maintainers": [ |
|||
{ |
|||
"name": "Sindre Sorhus", |
|||
"email": "sindresorhus@gmail.com", |
|||
"url": "sindresorhus.com" |
|||
}, |
|||
{ |
|||
"name": "Joshua Appelman", |
|||
"email": "jappelman@xebia.com", |
|||
"url": "jbnicolai.com" |
|||
}, |
|||
{ |
|||
"name": "JD Ballard", |
|||
"email": "i.am.qix@gmail.com", |
|||
"url": "github.com/qix-" |
|||
} |
|||
], |
|||
"name": "ansi-regex", |
|||
"repository": { |
|||
"type": "git", |
|||
"url": "git+https://github.com/chalk/ansi-regex.git" |
|||
}, |
|||
"scripts": { |
|||
"test": "xo && ava --verbose", |
|||
"view-supported": "node fixtures/view-codes.js" |
|||
}, |
|||
"version": "2.1.1", |
|||
"xo": { |
|||
"rules": { |
|||
"guard-for-in": 0, |
|||
"no-loop-func": 0 |
|||
} |
|||
} |
|||
} |
@ -0,0 +1,39 @@ |
|||
# ansi-regex [](https://travis-ci.org/chalk/ansi-regex) |
|||
|
|||
> Regular expression for matching [ANSI escape codes](http://en.wikipedia.org/wiki/ANSI_escape_code) |
|||
|
|||
|
|||
## Install |
|||
|
|||
``` |
|||
$ npm install --save ansi-regex |
|||
``` |
|||
|
|||
|
|||
## Usage |
|||
|
|||
```js |
|||
const ansiRegex = require('ansi-regex'); |
|||
|
|||
ansiRegex().test('\u001b[4mcake\u001b[0m'); |
|||
//=> true |
|||
|
|||
ansiRegex().test('cake'); |
|||
//=> false |
|||
|
|||
'\u001b[4mcake\u001b[0m'.match(ansiRegex()); |
|||
//=> ['\u001b[4m', '\u001b[0m'] |
|||
``` |
|||
|
|||
## FAQ |
|||
|
|||
### Why do you test for codes not in the ECMA 48 standard? |
|||
|
|||
Some of the codes we run as a test are codes that we acquired finding various lists of non-standard or manufacturer specific codes. If I recall correctly, we test for both standard and non-standard codes, as most of them follow the same or similar format and can be safely matched in strings without the risk of removing actual string content. There are a few non-standard control codes that do not follow the traditional format (i.e. they end in numbers) thus forcing us to exclude them from the test because we cannot reliably match them. |
|||
|
|||
On the historical side, those ECMA standards were established in the early 90's whereas the VT100, for example, was designed in the mid/late 70's. At that point in time, control codes were still pretty ungoverned and engineers used them for a multitude of things, namely to activate hardware ports that may have been proprietary. Somewhere else you see a similar 'anarchy' of codes is in the x86 architecture for processors; there are a ton of "interrupts" that can mean different things on certain brands of processors, most of which have been phased out. |
|||
|
|||
|
|||
## License |
|||
|
|||
MIT © [Sindre Sorhus](http://sindresorhus.com) |
@ -0,0 +1,65 @@ |
|||
'use strict'; |
|||
|
|||
function assembleStyles () { |
|||
var styles = { |
|||
modifiers: { |
|||
reset: [0, 0], |
|||
bold: [1, 22], // 21 isn't widely supported and 22 does the same thing
|
|||
dim: [2, 22], |
|||
italic: [3, 23], |
|||
underline: [4, 24], |
|||
inverse: [7, 27], |
|||
hidden: [8, 28], |
|||
strikethrough: [9, 29] |
|||
}, |
|||
colors: { |
|||
black: [30, 39], |
|||
red: [31, 39], |
|||
green: [32, 39], |
|||
yellow: [33, 39], |
|||
blue: [34, 39], |
|||
magenta: [35, 39], |
|||
cyan: [36, 39], |
|||
white: [37, 39], |
|||
gray: [90, 39] |
|||
}, |
|||
bgColors: { |
|||
bgBlack: [40, 49], |
|||
bgRed: [41, 49], |
|||
bgGreen: [42, 49], |
|||
bgYellow: [43, 49], |
|||
bgBlue: [44, 49], |
|||
bgMagenta: [45, 49], |
|||
bgCyan: [46, 49], |
|||
bgWhite: [47, 49] |
|||
} |
|||
}; |
|||
|
|||
// fix humans
|
|||
styles.colors.grey = styles.colors.gray; |
|||
|
|||
Object.keys(styles).forEach(function (groupName) { |
|||
var group = styles[groupName]; |
|||
|
|||
Object.keys(group).forEach(function (styleName) { |
|||
var style = group[styleName]; |
|||
|
|||
styles[styleName] = group[styleName] = { |
|||
open: '\u001b[' + style[0] + 'm', |
|||
close: '\u001b[' + style[1] + 'm' |
|||
}; |
|||
}); |
|||
|
|||
Object.defineProperty(styles, groupName, { |
|||
value: group, |
|||
enumerable: false |
|||
}); |
|||
}); |
|||
|
|||
return styles; |
|||
} |
|||
|
|||
Object.defineProperty(module, 'exports', { |
|||
enumerable: true, |
|||
get: assembleStyles |
|||
}); |
@ -0,0 +1,21 @@ |
|||
The MIT License (MIT) |
|||
|
|||
Copyright (c) Sindre Sorhus <sindresorhus@gmail.com> (sindresorhus.com) |
|||
|
|||
Permission is hereby granted, free of charge, to any person obtaining a copy |
|||
of this software and associated documentation files (the "Software"), to deal |
|||
in the Software without restriction, including without limitation the rights |
|||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell |
|||
copies of the Software, and to permit persons to whom the Software is |
|||
furnished to do so, subject to the following conditions: |
|||
|
|||
The above copyright notice and this permission notice shall be included in |
|||
all copies or substantial portions of the Software. |
|||
|
|||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR |
|||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, |
|||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE |
|||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER |
|||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, |
|||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN |
|||
THE SOFTWARE. |
@ -0,0 +1,90 @@ |
|||
{ |
|||
"_from": "ansi-styles@^2.2.1", |
|||
"_id": "ansi-styles@2.2.1", |
|||
"_inBundle": false, |
|||
"_integrity": "sha1-tDLdM1i2NM914eRmQ2gkBTPB3b4=", |
|||
"_location": "/ansi-styles", |
|||
"_phantomChildren": {}, |
|||
"_requested": { |
|||
"type": "range", |
|||
"registry": true, |
|||
"raw": "ansi-styles@^2.2.1", |
|||
"name": "ansi-styles", |
|||
"escapedName": "ansi-styles", |
|||
"rawSpec": "^2.2.1", |
|||
"saveSpec": null, |
|||
"fetchSpec": "^2.2.1" |
|||
}, |
|||
"_requiredBy": [ |
|||
"/chalk" |
|||
], |
|||
"_resolved": "https://registry.npmjs.org/ansi-styles/-/ansi-styles-2.2.1.tgz", |
|||
"_shasum": "b432dd3358b634cf75e1e4664368240533c1ddbe", |
|||
"_spec": "ansi-styles@^2.2.1", |
|||
"_where": "/var/www/htdocs/coze/socket/node_modules/chalk", |
|||
"author": { |
|||
"name": "Sindre Sorhus", |
|||
"email": "sindresorhus@gmail.com", |
|||
"url": "sindresorhus.com" |
|||
}, |
|||
"bugs": { |
|||
"url": "https://github.com/chalk/ansi-styles/issues" |
|||
}, |
|||
"bundleDependencies": false, |
|||
"deprecated": false, |
|||
"description": "ANSI escape codes for styling strings in the terminal", |
|||
"devDependencies": { |
|||
"mocha": "*" |
|||
}, |
|||
"engines": { |
|||
"node": ">=0.10.0" |
|||
}, |
|||
"files": [ |
|||
"index.js" |
|||
], |
|||
"homepage": "https://github.com/chalk/ansi-styles#readme", |
|||
"keywords": [ |
|||
"ansi", |
|||
"styles", |
|||
"color", |
|||
"colour", |
|||
"colors", |
|||
"terminal", |
|||
"console", |
|||
"cli", |
|||
"string", |
|||
"tty", |
|||
"escape", |
|||
"formatting", |
|||
"rgb", |
|||
"256", |
|||
"shell", |
|||
"xterm", |
|||
"log", |
|||
"logging", |
|||
"command-line", |
|||
"text" |
|||
], |
|||
"license": "MIT", |
|||
"maintainers": [ |
|||
{ |
|||
"name": "Sindre Sorhus", |
|||
"email": "sindresorhus@gmail.com", |
|||
"url": "sindresorhus.com" |
|||
}, |
|||
{ |
|||
"name": "Joshua Appelman", |
|||
"email": "jappelman@xebia.com", |
|||
"url": "jbnicolai.com" |
|||
} |
|||
], |
|||
"name": "ansi-styles", |
|||
"repository": { |
|||
"type": "git", |
|||
"url": "git+https://github.com/chalk/ansi-styles.git" |
|||
}, |
|||
"scripts": { |
|||
"test": "mocha" |
|||
}, |
|||
"version": "2.2.1" |
|||
} |
@ -0,0 +1,86 @@ |
|||
# ansi-styles [](https://travis-ci.org/chalk/ansi-styles) |
|||
|
|||
> [ANSI escape codes](http://en.wikipedia.org/wiki/ANSI_escape_code#Colors_and_Styles) for styling strings in the terminal |
|||
|
|||
You probably want the higher-level [chalk](https://github.com/chalk/chalk) module for styling your strings. |
|||
|
|||
 |
|||
|
|||
|
|||
## Install |
|||
|
|||
``` |
|||
$ npm install --save ansi-styles |
|||
``` |
|||
|
|||
|
|||
## Usage |
|||
|
|||
```js |
|||
var ansi = require('ansi-styles'); |
|||
|
|||
console.log(ansi.green.open + 'Hello world!' + ansi.green.close); |
|||
``` |
|||
|
|||
|
|||
## API |
|||
|
|||
Each style has an `open` and `close` property. |
|||
|
|||
|
|||
## Styles |
|||
|
|||
### Modifiers |
|||
|
|||
- `reset` |
|||
- `bold` |
|||
- `dim` |
|||
- `italic` *(not widely supported)* |
|||
- `underline` |
|||
- `inverse` |
|||
- `hidden` |
|||
- `strikethrough` *(not widely supported)* |
|||
|
|||
### Colors |
|||
|
|||
- `black` |
|||
- `red` |
|||
- `green` |
|||
- `yellow` |
|||
- `blue` |
|||
- `magenta` |
|||
- `cyan` |
|||
- `white` |
|||
- `gray` |
|||
|
|||
### Background colors |
|||
|
|||
- `bgBlack` |
|||
- `bgRed` |
|||
- `bgGreen` |
|||
- `bgYellow` |
|||
- `bgBlue` |
|||
- `bgMagenta` |
|||
- `bgCyan` |
|||
- `bgWhite` |
|||
|
|||
|
|||
## Advanced usage |
|||
|
|||
By default you get a map of styles, but the styles are also available as groups. They are non-enumerable so they don't show up unless you access them explicitly. This makes it easier to expose only a subset in a higher-level module. |
|||
|
|||
- `ansi.modifiers` |
|||
- `ansi.colors` |
|||
- `ansi.bgColors` |
|||
|
|||
|
|||
###### Example |
|||
|
|||
```js |
|||
console.log(ansi.colors.green.open); |
|||
``` |
|||
|
|||
|
|||
## License |
|||
|
|||
MIT © [Sindre Sorhus](http://sindresorhus.com) |
@ -0,0 +1,17 @@ |
|||
lib-cov |
|||
lcov.info |
|||
*.seed |
|||
*.log |
|||
*.csv |
|||
*.dat |
|||
*.out |
|||
*.pid |
|||
*.gz |
|||
|
|||
pids |
|||
logs |
|||
results |
|||
build |
|||
.grunt |
|||
|
|||
node_modules |
@ -0,0 +1,18 @@ |
|||
Copyright (C) 2013 Rase- |
|||
|
|||
Permission is hereby granted, free of charge, to any person obtaining a copy of |
|||
this software and associated documentation files (the "Software"), to deal in |
|||
the Software without restriction, including without limitation the rights to |
|||
use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies |
|||
of the Software, and to permit persons to whom the Software is furnished to do |
|||
so, subject to the following conditions: |
|||
|
|||
The above copyright notice and this permission notice shall be included in all |
|||
copies or substantial portions of the Software. |
|||
|
|||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR |
|||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS |
|||
FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR |
|||
COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER |
|||
IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN |
|||
CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. |
@ -0,0 +1,8 @@ |
|||
|
|||
REPORTER = dot |
|||
|
|||
test: |
|||
@./node_modules/.bin/mocha \
|
|||
--reporter $(REPORTER) |
|||
|
|||
.PHONY: test |
@ -0,0 +1,17 @@ |
|||
# How to |
|||
```javascript |
|||
var sliceBuffer = require('arraybuffer.slice'); |
|||
var ab = (new Int8Array(5)).buffer; |
|||
var sliced = sliceBuffer(ab, 1, 3); |
|||
sliced = sliceBuffer(ab, 1); |
|||
``` |
|||
|
|||
# Licence (MIT) |
|||
Copyright (C) 2013 Rase- |
|||
|
|||
|
|||
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: |
|||
|
|||
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. |
|||
|
|||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. |
@ -0,0 +1,29 @@ |
|||
/** |
|||
* An abstraction for slicing an arraybuffer even when |
|||
* ArrayBuffer.prototype.slice is not supported |
|||
* |
|||
* @api public |
|||
*/ |
|||
|
|||
module.exports = function(arraybuffer, start, end) { |
|||
var bytes = arraybuffer.byteLength; |
|||
start = start || 0; |
|||
end = end || bytes; |
|||
|
|||
if (arraybuffer.slice) { return arraybuffer.slice(start, end); } |
|||
|
|||
if (start < 0) { start += bytes; } |
|||
if (end < 0) { end += bytes; } |
|||
if (end > bytes) { end = bytes; } |
|||
|
|||
if (start >= bytes || start >= end || bytes === 0) { |
|||
return new ArrayBuffer(0); |
|||
} |
|||
|
|||
var abv = new Uint8Array(arraybuffer); |
|||
var result = new Uint8Array(end - start); |
|||
for (var i = start, ii = 0; i < end; i++, ii++) { |
|||
result[ii] = abv[i]; |
|||
} |
|||
return result.buffer; |
|||
}; |
@ -0,0 +1,44 @@ |
|||
{ |
|||
"_from": "arraybuffer.slice@~0.0.7", |
|||
"_id": "arraybuffer.slice@0.0.7", |
|||
"_inBundle": false, |
|||
"_integrity": "sha512-wGUIVQXuehL5TCqQun8OW81jGzAWycqzFF8lFp+GOM5BXLYj3bKNsYC4daB7n6XjCqxQA/qgTJ+8ANR3acjrog==", |
|||
"_location": "/arraybuffer.slice", |
|||
"_phantomChildren": {}, |
|||
"_requested": { |
|||
"type": "range", |
|||
"registry": true, |
|||
"raw": "arraybuffer.slice@~0.0.7", |
|||
"name": "arraybuffer.slice", |
|||
"escapedName": "arraybuffer.slice", |
|||
"rawSpec": "~0.0.7", |
|||
"saveSpec": null, |
|||
"fetchSpec": "~0.0.7" |
|||
}, |
|||
"_requiredBy": [ |
|||
"/engine.io-parser" |
|||
], |
|||
"_resolved": "https://registry.npmjs.org/arraybuffer.slice/-/arraybuffer.slice-0.0.7.tgz", |
|||
"_shasum": "3bbc4275dd584cc1b10809b89d4e8b63a69e7675", |
|||
"_spec": "arraybuffer.slice@~0.0.7", |
|||
"_where": "/var/www/htdocs/coze/socket/node_modules/engine.io-parser", |
|||
"bugs": { |
|||
"url": "https://github.com/rase-/arraybuffer.slice/issues" |
|||
}, |
|||
"bundleDependencies": false, |
|||
"dependencies": {}, |
|||
"deprecated": false, |
|||
"description": "Exports a function for slicing ArrayBuffers (no polyfilling)", |
|||
"devDependencies": { |
|||
"expect.js": "0.2.0", |
|||
"mocha": "1.17.1" |
|||
}, |
|||
"homepage": "https://github.com/rase-/arraybuffer.slice", |
|||
"license": "MIT", |
|||
"name": "arraybuffer.slice", |
|||
"repository": { |
|||
"type": "git", |
|||
"url": "git+ssh://git@github.com/rase-/arraybuffer.slice.git" |
|||
}, |
|||
"version": "0.0.7" |
|||
} |
@ -0,0 +1,227 @@ |
|||
/* |
|||
* Test dependencies |
|||
*/ |
|||
|
|||
var sliceBuffer = require('../index.js'); |
|||
var expect = require('expect.js'); |
|||
|
|||
/** |
|||
* Tests |
|||
*/ |
|||
|
|||
describe('sliceBuffer', function() { |
|||
describe('using standard slice', function() { |
|||
it('should slice correctly with only start provided', function() { |
|||
var abv = new Uint8Array(10); |
|||
for (var i = 0; i < abv.length; i++) { |
|||
abv[i] = i; |
|||
} |
|||
|
|||
var sliced = sliceBuffer(abv.buffer, 3); |
|||
var sabv = new Uint8Array(sliced); |
|||
for (var i = 3, ii = 0; i < abv.length; i++, ii++) { |
|||
expect(abv[i]).to.equal(sabv[ii]); |
|||
} |
|||
}); |
|||
|
|||
it('should slice correctly with start and end provided', function() { |
|||
var abv = new Uint8Array(10); |
|||
for (var i = 0; i < abv.length; i++) { |
|||
abv[i] = i; |
|||
} |
|||
|
|||
var sliced = sliceBuffer(abv.buffer, 3, 8); |
|||
var sabv = new Uint8Array(sliced); |
|||
for (var i = 3, ii = 0; i < 8; i++, ii++) { |
|||
expect(abv[i]).to.equal(sabv[ii]); |
|||
} |
|||
}); |
|||
|
|||
it('should slice correctly with negative start', function() { |
|||
var abv = new Uint8Array(10); |
|||
for (var i = 0; i < abv.length; i++) { |
|||
abv[i] = i; |
|||
} |
|||
|
|||
var sliced = sliceBuffer(abv.buffer, -3); |
|||
var sabv = new Uint8Array(sliced); |
|||
for (var i = abv.length - 3, ii = 0; i < abv.length; i++, ii++) { |
|||
expect(abv[i]).to.equal(sabv[ii]); |
|||
} |
|||
}); |
|||
|
|||
it('should slice correctly with negative end', function() { |
|||
var abv = new Uint8Array(10); |
|||
for (var i = 0; i < abv.length; i++) { |
|||
abv[i] = i; |
|||
} |
|||
|
|||
var sliced = sliceBuffer(abv.buffer, 0, -3); |
|||
var sabv = new Uint8Array(sliced); |
|||
for (var i = 0, ii = 0; i < abv.length - 3; i++, ii++) { |
|||
expect(abv[i]).to.equal(sabv[ii]); |
|||
} |
|||
}); |
|||
|
|||
it('should slice correctly with negative start and end', function() { |
|||
var abv = new Uint8Array(10); |
|||
for (var i = 0; i < abv.length; i++) { |
|||
abv[i] = i; |
|||
} |
|||
|
|||
var sliced = sliceBuffer(abv.buffer, -6, -3); |
|||
var sabv = new Uint8Array(sliced); |
|||
for (var i = abv.length - 6, ii = 0; i < abv.length - 3; i++, ii++) { |
|||
expect(abv[i]).to.equal(sabv[ii]); |
|||
} |
|||
}); |
|||
|
|||
it('should slice correctly with equal start and end', function() { |
|||
var abv = new Uint8Array(10); |
|||
for (var i = 0; i < abv.length; i++) { |
|||
abv[i] = i; |
|||
} |
|||
|
|||
var sliced = sliceBuffer(abv.buffer, 1, 1); |
|||
expect(sliced.byteLength).to.equal(0); |
|||
}); |
|||
|
|||
it('should slice correctly when end larger than buffer', function() { |
|||
var abv = new Uint8Array(10); |
|||
for (var i = 0; i < abv.length; i++) { |
|||
abv[i] = i; |
|||
} |
|||
|
|||
var sliced = sliceBuffer(abv.buffer, 0, 100); |
|||
expect(new Uint8Array(sliced)).to.eql(abv); |
|||
}); |
|||
|
|||
it('shoud slice correctly when start larger than end', function() { |
|||
var abv = new Uint8Array(10); |
|||
for (var i = 0; i < abv.length; i++) { |
|||
abv[i] = i; |
|||
} |
|||
|
|||
var sliced = sliceBuffer(abv.buffer, 6, 5); |
|||
expect(sliced.byteLength).to.equal(0); |
|||
}); |
|||
}); |
|||
|
|||
describe('using fallback', function() { |
|||
it('should slice correctly with only start provided', function() { |
|||
var abv = new Uint8Array(10); |
|||
for (var i = 0; i < abv.length; i++) { |
|||
abv[i] = i; |
|||
} |
|||
var ab = abv.buffer; |
|||
ab.slice = undefined; |
|||
|
|||
var sliced = sliceBuffer(ab, 3); |
|||
var sabv = new Uint8Array(sliced); |
|||
for (var i = 3, ii = 0; i < abv.length; i++, ii++) { |
|||
expect(abv[i]).to.equal(sabv[ii]); |
|||
} |
|||
}); |
|||
|
|||
it('should slice correctly with start and end provided', function() { |
|||
var abv = new Uint8Array(10); |
|||
for (var i = 0; i < abv.length; i++) { |
|||
abv[i] = i; |
|||
} |
|||
var ab = abv.buffer; |
|||
ab.slice = undefined; |
|||
|
|||
|
|||
var sliced = sliceBuffer(ab, 3, 8); |
|||
var sabv = new Uint8Array(sliced); |
|||
for (var i = 3, ii = 0; i < 8; i++, ii++) { |
|||
expect(abv[i]).to.equal(sabv[ii]); |
|||
} |
|||
}); |
|||
|
|||
it('should slice correctly with negative start', function() { |
|||
var abv = new Uint8Array(10); |
|||
for (var i = 0; i < abv.length; i++) { |
|||
abv[i] = i; |
|||
} |
|||
var ab = abv.buffer; |
|||
ab.slice = undefined; |
|||
|
|||
|
|||
var sliced = sliceBuffer(ab, -3); |
|||
var sabv = new Uint8Array(sliced); |
|||
for (var i = abv.length - 3, ii = 0; i < abv.length; i++, ii++) { |
|||
expect(abv[i]).to.equal(sabv[ii]); |
|||
} |
|||
}); |
|||
|
|||
it('should slice correctly with negative end', function() { |
|||
var abv = new Uint8Array(10); |
|||
for (var i = 0; i < abv.length; i++) { |
|||
abv[i] = i; |
|||
} |
|||
var ab = abv.buffer; |
|||
ab.slice = undefined; |
|||
|
|||
var sliced = sliceBuffer(ab, 0, -3); |
|||
var sabv = new Uint8Array(sliced); |
|||
for (var i = 0, ii = 0; i < abv.length - 3; i++, ii++) { |
|||
expect(abv[i]).to.equal(sabv[ii]); |
|||
} |
|||
}); |
|||
|
|||
it('should slice correctly with negative start and end', function() { |
|||
var abv = new Uint8Array(10); |
|||
for (var i = 0; i < abv.length; i++) { |
|||
abv[i] = i; |
|||
} |
|||
var ab = abv.buffer; |
|||
ab.slice = undefined; |
|||
|
|||
var sliced = sliceBuffer(ab, -6, -3); |
|||
var sabv = new Uint8Array(sliced); |
|||
for (var i = abv.length - 6, ii = 0; i < abv.length - 3; i++, ii++) { |
|||
expect(abv[i]).to.equal(sabv[ii]); |
|||
} |
|||
}); |
|||
|
|||
it('should slice correctly with equal start and end', function() { |
|||
var abv = new Uint8Array(10); |
|||
for (var i = 0; i < abv.length; i++) { |
|||
abv[i] = i; |
|||
} |
|||
var ab = abv.buffer; |
|||
ab.slice = undefined; |
|||
|
|||
var sliced = sliceBuffer(ab, 1, 1); |
|||
expect(sliced.byteLength).to.equal(0); |
|||
}); |
|||
|
|||
it('should slice correctly when end larger than buffer', function() { |
|||
var abv = new Uint8Array(10); |
|||
for (var i = 0; i < abv.length; i++) { |
|||
abv[i] = i; |
|||
} |
|||
var ab = abv.buffer; |
|||
ab.slice = undefined; |
|||
|
|||
var sliced = sliceBuffer(ab, 0, 100); |
|||
var sabv = new Uint8Array(sliced); |
|||
for (var i = 0; i < abv.length; i++) { |
|||
expect(abv[i]).to.equal(sabv[i]); |
|||
} |
|||
}); |
|||
|
|||
it('shoud slice correctly when start larger than end', function() { |
|||
var abv = new Uint8Array(10); |
|||
for (var i = 0; i < abv.length; i++) { |
|||
abv[i] = i; |
|||
} |
|||
var ab = abv.buffer; |
|||
ab.slice = undefined; |
|||
|
|||
var sliced = sliceBuffer(ab, 6, 5); |
|||
expect(sliced.byteLength).to.equal(0); |
|||
}); |
|||
}); |
|||
}); |
@ -0,0 +1,70 @@ |
|||
|
|||
## 2.0.6 |
|||
|
|||
Version 2.0.4 adds support for React Native by clarifying in package.json that |
|||
the browser environment does not support Node.js domains. |
|||
Why this is necessary, we leave as an exercise for the user. |
|||
|
|||
## 2.0.3 |
|||
|
|||
Version 2.0.3 fixes a bug when adjusting the capacity of the task queue. |
|||
|
|||
## 2.0.1-2.02 |
|||
|
|||
Version 2.0.1 fixes a bug in the way redirects were expressed that affected the |
|||
function of Browserify, but which Mr would tolerate. |
|||
|
|||
## 2.0.0 |
|||
|
|||
Version 2 of ASAP is a full rewrite with a few salient changes. |
|||
First, the ASAP source is CommonJS only and designed with [Browserify][] and |
|||
[Browserify-compatible][Mr] module loaders in mind. |
|||
|
|||
[Browserify]: https://github.com/substack/node-browserify |
|||
[Mr]: https://github.com/montagejs/mr |
|||
|
|||
The new version has been refactored in two dimensions. |
|||
Support for Node.js and browsers have been separated, using Browserify |
|||
redirects and ASAP has been divided into two modules. |
|||
The "raw" layer depends on the tasks to catch thrown exceptions and unravel |
|||
Node.js domains. |
|||
|
|||
The full implementation of ASAP is loadable as `require("asap")` in both Node.js |
|||
and browsers. |
|||
|
|||
The raw layer that lacks exception handling overhead is loadable as |
|||
`require("asap/raw")`. |
|||
The interface is the same for both layers. |
|||
|
|||
Tasks are no longer required to be functions, but can rather be any object that |
|||
implements `task.call()`. |
|||
With this feature you can recycle task objects to avoid garbage collector churn |
|||
and avoid closures in general. |
|||
|
|||
The implementation has been rigorously documented so that our successors can |
|||
understand the scope of the problem that this module solves and all of its |
|||
nuances, ensuring that the next generation of implementations know what details |
|||
are essential. |
|||
|
|||
- [asap.js](https://github.com/kriskowal/asap/blob/master/asap.js) |
|||
- [raw.js](https://github.com/kriskowal/asap/blob/master/raw.js) |
|||
- [browser-asap.js](https://github.com/kriskowal/asap/blob/master/browser-asap.js) |
|||
- [browser-raw.js](https://github.com/kriskowal/asap/blob/master/browser-raw.js) |
|||
|
|||
The new version has also been rigorously tested across a broad spectrum of |
|||
browsers, in both the window and worker context. |
|||
The following charts capture the browser test results for the most recent |
|||
release. |
|||
The first chart shows test results for ASAP running in the main window context. |
|||
The second chart shows test results for ASAP running in a web worker context. |
|||
Test results are inconclusive (grey) on browsers that do not support web |
|||
workers. |
|||
These data are captured automatically by [Continuous |
|||
Integration][]. |
|||
|
|||
 |
|||
|
|||
 |
|||
|
|||
[Continuous Integration]: https://github.com/kriskowal/asap/blob/master/CONTRIBUTING.md |
|||
|
@ -0,0 +1,21 @@ |
|||
|
|||
Copyright 2009–2014 Contributors. All rights reserved. |
|||
|
|||
Permission is hereby granted, free of charge, to any person obtaining a copy |
|||
of this software and associated documentation files (the "Software"), to |
|||
deal in the Software without restriction, including without limitation the |
|||
rights to use, copy, modify, merge, publish, distribute, sublicense, and/or |
|||
sell copies of the Software, and to permit persons to whom the Software is |
|||
furnished to do so, subject to the following conditions: |
|||
|
|||
The above copyright notice and this permission notice shall be included in |
|||
all copies or substantial portions of the Software. |
|||
|
|||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR |
|||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, |
|||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE |
|||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER |
|||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING |
|||
FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS |
|||
IN THE SOFTWARE. |
|||
|
@ -0,0 +1,237 @@ |
|||
# ASAP |
|||
|
|||
[](https://travis-ci.org/kriskowal/asap) |
|||
|
|||
Promise and asynchronous observer libraries, as well as hand-rolled callback |
|||
programs and libraries, often need a mechanism to postpone the execution of a |
|||
callback until the next available event. |
|||
(See [Designing API’s for Asynchrony][Zalgo].) |
|||
The `asap` function executes a task **as soon as possible** but not before it |
|||
returns, waiting only for the completion of the current event and previously |
|||
scheduled tasks. |
|||
|
|||
```javascript |
|||
asap(function () { |
|||
// ... |
|||
}); |
|||
``` |
|||
|
|||
[Zalgo]: http://blog.izs.me/post/59142742143/designing-apis-for-asynchrony |
|||
|
|||
This CommonJS package provides an `asap` module that exports a function that |
|||
executes a task function *as soon as possible*. |
|||
|
|||
ASAP strives to schedule events to occur before yielding for IO, reflow, |
|||
or redrawing. |
|||
Each event receives an independent stack, with only platform code in parent |
|||
frames and the events run in the order they are scheduled. |
|||
|
|||
ASAP provides a fast event queue that will execute tasks until it is |
|||
empty before yielding to the JavaScript engine's underlying event-loop. |
|||
When a task gets added to a previously empty event queue, ASAP schedules a flush |
|||
event, preferring for that event to occur before the JavaScript engine has an |
|||
opportunity to perform IO tasks or rendering, thus making the first task and |
|||
subsequent tasks semantically indistinguishable. |
|||
ASAP uses a variety of techniques to preserve this invariant on different |
|||
versions of browsers and Node.js. |
|||
|
|||
By design, ASAP prevents input events from being handled until the task |
|||
queue is empty. |
|||
If the process is busy enough, this may cause incoming connection requests to be |
|||
dropped, and may cause existing connections to inform the sender to reduce the |
|||
transmission rate or stall. |
|||
ASAP allows this on the theory that, if there is enough work to do, there is no |
|||
sense in looking for trouble. |
|||
As a consequence, ASAP can interfere with smooth animation. |
|||
If your task should be tied to the rendering loop, consider using |
|||
`requestAnimationFrame` instead. |
|||
A long sequence of tasks can also effect the long running script dialog. |
|||
If this is a problem, you may be able to use ASAP’s cousin `setImmediate` to |
|||
break long processes into shorter intervals and periodically allow the browser |
|||
to breathe. |
|||
`setImmediate` will yield for IO, reflow, and repaint events. |
|||
It also returns a handler and can be canceled. |
|||
For a `setImmediate` shim, consider [YuzuJS setImmediate][setImmediate]. |
|||
|
|||
[setImmediate]: https://github.com/YuzuJS/setImmediate |
|||
|
|||
Take care. |
|||
ASAP can sustain infinite recursive calls without warning. |
|||
It will not halt from a stack overflow, and it will not consume unbounded |
|||
memory. |
|||
This is behaviorally equivalent to an infinite loop. |
|||
Just as with infinite loops, you can monitor a Node.js process for this behavior |
|||
with a heart-beat signal. |
|||
As with infinite loops, a very small amount of caution goes a long way to |
|||
avoiding problems. |
|||
|
|||
```javascript |
|||
function loop() { |
|||
asap(loop); |
|||
} |
|||
loop(); |
|||
``` |
|||
|
|||
In browsers, if a task throws an exception, it will not interrupt the flushing |
|||
of high-priority tasks. |
|||
The exception will be postponed to a later, low-priority event to avoid |
|||
slow-downs. |
|||
In Node.js, if a task throws an exception, ASAP will resume flushing only if—and |
|||
only after—the error is handled by `domain.on("error")` or |
|||
`process.on("uncaughtException")`. |
|||
|
|||
## Raw ASAP |
|||
|
|||
Checking for exceptions comes at a cost. |
|||
The package also provides an `asap/raw` module that exports the underlying |
|||
implementation which is faster but stalls if a task throws an exception. |
|||
This internal version of the ASAP function does not check for errors. |
|||
If a task does throw an error, it will stall the event queue unless you manually |
|||
call `rawAsap.requestFlush()` before throwing the error, or any time after. |
|||
|
|||
In Node.js, `asap/raw` also runs all tasks outside any domain. |
|||
If you need a task to be bound to your domain, you will have to do it manually. |
|||
|
|||
```js |
|||
if (process.domain) { |
|||
task = process.domain.bind(task); |
|||
} |
|||
rawAsap(task); |
|||
``` |
|||
|
|||
## Tasks |
|||
|
|||
A task may be any object that implements `call()`. |
|||
A function will suffice, but closures tend not to be reusable and can cause |
|||
garbage collector churn. |
|||
Both `asap` and `rawAsap` accept task objects to give you the option of |
|||
recycling task objects or using higher callable object abstractions. |
|||
See the `asap` source for an illustration. |
|||
|
|||
|
|||
## Compatibility |
|||
|
|||
ASAP is tested on Node.js v0.10 and in a broad spectrum of web browsers. |
|||
The following charts capture the browser test results for the most recent |
|||
release. |
|||
The first chart shows test results for ASAP running in the main window context. |
|||
The second chart shows test results for ASAP running in a web worker context. |
|||
Test results are inconclusive (grey) on browsers that do not support web |
|||
workers. |
|||
These data are captured automatically by [Continuous |
|||
Integration][]. |
|||
|
|||
[Continuous Integration]: https://github.com/kriskowal/asap/blob/master/CONTRIBUTING.md |
|||
|
|||
 |
|||
|
|||
 |
|||
|
|||
## Caveats |
|||
|
|||
When a task is added to an empty event queue, it is not always possible to |
|||
guarantee that the task queue will begin flushing immediately after the current |
|||
event. |
|||
However, once the task queue begins flushing, it will not yield until the queue |
|||
is empty, even if the queue grows while executing tasks. |
|||
|
|||
The following browsers allow the use of [DOM mutation observers][] to access |
|||
the HTML [microtask queue][], and thus begin flushing ASAP's task queue |
|||
immediately at the end of the current event loop turn, before any rendering or |
|||
IO: |
|||
|
|||
[microtask queue]: http://www.whatwg.org/specs/web-apps/current-work/multipage/webappapis.html#microtask-queue |
|||
[DOM mutation observers]: http://dom.spec.whatwg.org/#mutation-observers |
|||
|
|||
- Android 4–4.3 |
|||
- Chrome 26–34 |
|||
- Firefox 14–29 |
|||
- Internet Explorer 11 |
|||
- iPad Safari 6–7.1 |
|||
- iPhone Safari 7–7.1 |
|||
- Safari 6–7 |
|||
|
|||
In the absense of mutation observers, there are a few browsers, and situations |
|||
like web workers in some of the above browsers, where [message channels][] |
|||
would be a useful way to avoid falling back to timers. |
|||
Message channels give direct access to the HTML [task queue][], so the ASAP |
|||
task queue would flush after any already queued rendering and IO tasks, but |
|||
without having the minimum delay imposed by timers. |
|||
However, among these browsers, Internet Explorer 10 and Safari do not reliably |
|||
dispatch messages, so they are not worth the trouble to implement. |
|||
|
|||
[message channels]: http://www.whatwg.org/specs/web-apps/current-work/multipage/web-messaging.html#message-channels |
|||
[task queue]: http://www.whatwg.org/specs/web-apps/current-work/multipage/webappapis.html#concept-task |
|||
|
|||
- Internet Explorer 10 |
|||
- Safair 5.0-1 |
|||
- Opera 11-12 |
|||
|
|||
In the absense of mutation observers, these browsers and the following browsers |
|||
all fall back to using `setTimeout` and `setInterval` to ensure that a `flush` |
|||
occurs. |
|||
The implementation uses both and cancels whatever handler loses the race, since |
|||
`setTimeout` tends to occasionally skip tasks in unisolated circumstances. |
|||
Timers generally delay the flushing of ASAP's task queue for four milliseconds. |
|||
|
|||
- Firefox 3–13 |
|||
- Internet Explorer 6–10 |
|||
- iPad Safari 4.3 |
|||
- Lynx 2.8.7 |
|||
|
|||
|
|||
## Heritage |
|||
|
|||
ASAP has been factored out of the [Q][] asynchronous promise library. |
|||
It originally had a naïve implementation in terms of `setTimeout`, but |
|||
[Malte Ubl][NonBlocking] provided an insight that `postMessage` might be |
|||
useful for creating a high-priority, no-delay event dispatch hack. |
|||
Since then, Internet Explorer proposed and implemented `setImmediate`. |
|||
Robert Katić began contributing to Q by measuring the performance of |
|||
the internal implementation of `asap`, paying particular attention to |
|||
error recovery. |
|||
Domenic, Robert, and Kris Kowal collectively settled on the current strategy of |
|||
unrolling the high-priority event queue internally regardless of what strategy |
|||
we used to dispatch the potentially lower-priority flush event. |
|||
Domenic went on to make ASAP cooperate with Node.js domains. |
|||
|
|||
[Q]: https://github.com/kriskowal/q |
|||
[NonBlocking]: http://www.nonblocking.io/2011/06/windownexttick.html |
|||
|
|||
For further reading, Nicholas Zakas provided a thorough article on [The |
|||
Case for setImmediate][NCZ]. |
|||
|
|||
[NCZ]: http://www.nczonline.net/blog/2013/07/09/the-case-for-setimmediate/ |
|||
|
|||
Ember’s RSVP promise implementation later [adopted][RSVP ASAP] the name ASAP but |
|||
further developed the implentation. |
|||
Particularly, The `MessagePort` implementation was abandoned due to interaction |
|||
[problems with Mobile Internet Explorer][IE Problems] in favor of an |
|||
implementation backed on the newer and more reliable DOM `MutationObserver` |
|||
interface. |
|||
These changes were back-ported into this library. |
|||
|
|||
[IE Problems]: https://github.com/cujojs/when/issues/197 |
|||
[RSVP ASAP]: https://github.com/tildeio/rsvp.js/blob/cddf7232546a9cf858524b75cde6f9edf72620a7/lib/rsvp/asap.js |
|||
|
|||
In addition, ASAP factored into `asap` and `asap/raw`, such that `asap` remained |
|||
exception-safe, but `asap/raw` provided a tight kernel that could be used for |
|||
tasks that guaranteed that they would not throw exceptions. |
|||
This core is useful for promise implementations that capture thrown errors in |
|||
rejected promises and do not need a second safety net. |
|||
At the same time, the exception handling in `asap` was factored into separate |
|||
implementations for Node.js and browsers, using the the [Browserify][Browser |
|||
Config] `browser` property in `package.json` to instruct browser module loaders |
|||
and bundlers, including [Browserify][], [Mr][], and [Mop][], to use the |
|||
browser-only implementation. |
|||
|
|||
[Browser Config]: https://gist.github.com/defunctzombie/4339901 |
|||
[Browserify]: https://github.com/substack/node-browserify |
|||
[Mr]: https://github.com/montagejs/mr |
|||
[Mop]: https://github.com/montagejs/mop |
|||
|
|||
## License |
|||
|
|||
Copyright 2009-2014 by Contributors |
|||
MIT License (enclosed) |
|||
|
@ -0,0 +1,65 @@ |
|||
"use strict"; |
|||
|
|||
var rawAsap = require("./raw"); |
|||
var freeTasks = []; |
|||
|
|||
/** |
|||
* Calls a task as soon as possible after returning, in its own event, with |
|||
* priority over IO events. An exception thrown in a task can be handled by |
|||
* `process.on("uncaughtException") or `domain.on("error")`, but will otherwise
|
|||
* crash the process. If the error is handled, all subsequent tasks will |
|||
* resume. |
|||
* |
|||
* @param {{call}} task A callable object, typically a function that takes no |
|||
* arguments. |
|||
*/ |
|||
module.exports = asap; |
|||
function asap(task) { |
|||
var rawTask; |
|||
if (freeTasks.length) { |
|||
rawTask = freeTasks.pop(); |
|||
} else { |
|||
rawTask = new RawTask(); |
|||
} |
|||
rawTask.task = task; |
|||
rawTask.domain = process.domain; |
|||
rawAsap(rawTask); |
|||
} |
|||
|
|||
function RawTask() { |
|||
this.task = null; |
|||
this.domain = null; |
|||
} |
|||
|
|||
RawTask.prototype.call = function () { |
|||
if (this.domain) { |
|||
this.domain.enter(); |
|||
} |
|||
var threw = true; |
|||
try { |
|||
this.task.call(); |
|||
threw = false; |
|||
// If the task throws an exception (presumably) Node.js restores the
|
|||
// domain stack for the next event.
|
|||
if (this.domain) { |
|||
this.domain.exit(); |
|||
} |
|||
} finally { |
|||
// We use try/finally and a threw flag to avoid messing up stack traces
|
|||
// when we catch and release errors.
|
|||
if (threw) { |
|||
// In Node.js, uncaught exceptions are considered fatal errors.
|
|||
// Re-throw them to interrupt flushing!
|
|||
// Ensure that flushing continues if an uncaught exception is
|
|||
// suppressed listening process.on("uncaughtException") or
|
|||
// domain.on("error").
|
|||
rawAsap.requestFlush(); |
|||
} |
|||
// If the task threw an error, we do not want to exit the domain here.
|
|||
// Exiting the domain would prevent the domain from catching the error.
|
|||
this.task = null; |
|||
this.domain = null; |
|||
freeTasks.push(this); |
|||
} |
|||
}; |
|||
|
@ -0,0 +1,66 @@ |
|||
"use strict"; |
|||
|
|||
// rawAsap provides everything we need except exception management.
|
|||
var rawAsap = require("./raw"); |
|||
// RawTasks are recycled to reduce GC churn.
|
|||
var freeTasks = []; |
|||
// We queue errors to ensure they are thrown in right order (FIFO).
|
|||
// Array-as-queue is good enough here, since we are just dealing with exceptions.
|
|||
var pendingErrors = []; |
|||
var requestErrorThrow = rawAsap.makeRequestCallFromTimer(throwFirstError); |
|||
|
|||
function throwFirstError() { |
|||
if (pendingErrors.length) { |
|||
throw pendingErrors.shift(); |
|||
} |
|||
} |
|||
|
|||
/** |
|||
* Calls a task as soon as possible after returning, in its own event, with priority |
|||
* over other events like animation, reflow, and repaint. An error thrown from an |
|||
* event will not interrupt, nor even substantially slow down the processing of |
|||
* other events, but will be rather postponed to a lower priority event. |
|||
* @param {{call}} task A callable object, typically a function that takes no |
|||
* arguments. |
|||
*/ |
|||
module.exports = asap; |
|||
function asap(task) { |
|||
var rawTask; |
|||
if (freeTasks.length) { |
|||
rawTask = freeTasks.pop(); |
|||
} else { |
|||
rawTask = new RawTask(); |
|||
} |
|||
rawTask.task = task; |
|||
rawAsap(rawTask); |
|||
} |
|||
|
|||
// We wrap tasks with recyclable task objects. A task object implements
|
|||
// `call`, just like a function.
|
|||
function RawTask() { |
|||
this.task = null; |
|||
} |
|||
|
|||
// The sole purpose of wrapping the task is to catch the exception and recycle
|
|||
// the task object after its single use.
|
|||
RawTask.prototype.call = function () { |
|||
try { |
|||
this.task.call(); |
|||
} catch (error) { |
|||
if (asap.onerror) { |
|||
// This hook exists purely for testing purposes.
|
|||
// Its name will be periodically randomized to break any code that
|
|||
// depends on its existence.
|
|||
asap.onerror(error); |
|||
} else { |
|||
// In a web browser, exceptions are not fatal. However, to avoid
|
|||
// slowing down the queue of pending tasks, we rethrow the error in a
|
|||
// lower priority turn.
|
|||
pendingErrors.push(error); |
|||
requestErrorThrow(); |
|||
} |
|||
} finally { |
|||
this.task = null; |
|||
freeTasks[freeTasks.length] = this; |
|||
} |
|||
}; |
@ -0,0 +1,223 @@ |
|||
"use strict"; |
|||
|
|||
// Use the fastest means possible to execute a task in its own turn, with
|
|||
// priority over other events including IO, animation, reflow, and redraw
|
|||
// events in browsers.
|
|||
//
|
|||
// An exception thrown by a task will permanently interrupt the processing of
|
|||
// subsequent tasks. The higher level `asap` function ensures that if an
|
|||
// exception is thrown by a task, that the task queue will continue flushing as
|
|||
// soon as possible, but if you use `rawAsap` directly, you are responsible to
|
|||
// either ensure that no exceptions are thrown from your task, or to manually
|
|||
// call `rawAsap.requestFlush` if an exception is thrown.
|
|||
module.exports = rawAsap; |
|||
function rawAsap(task) { |
|||
if (!queue.length) { |
|||
requestFlush(); |
|||
flushing = true; |
|||
} |
|||
// Equivalent to push, but avoids a function call.
|
|||
queue[queue.length] = task; |
|||
} |
|||
|
|||
var queue = []; |
|||
// Once a flush has been requested, no further calls to `requestFlush` are
|
|||
// necessary until the next `flush` completes.
|
|||
var flushing = false; |
|||
// `requestFlush` is an implementation-specific method that attempts to kick
|
|||
// off a `flush` event as quickly as possible. `flush` will attempt to exhaust
|
|||
// the event queue before yielding to the browser's own event loop.
|
|||
var requestFlush; |
|||
// The position of the next task to execute in the task queue. This is
|
|||
// preserved between calls to `flush` so that it can be resumed if
|
|||
// a task throws an exception.
|
|||
var index = 0; |
|||
// If a task schedules additional tasks recursively, the task queue can grow
|
|||
// unbounded. To prevent memory exhaustion, the task queue will periodically
|
|||
// truncate already-completed tasks.
|
|||
var capacity = 1024; |
|||
|
|||
// The flush function processes all tasks that have been scheduled with
|
|||
// `rawAsap` unless and until one of those tasks throws an exception.
|
|||
// If a task throws an exception, `flush` ensures that its state will remain
|
|||
// consistent and will resume where it left off when called again.
|
|||
// However, `flush` does not make any arrangements to be called again if an
|
|||
// exception is thrown.
|
|||
function flush() { |
|||
while (index < queue.length) { |
|||
var currentIndex = index; |
|||
// Advance the index before calling the task. This ensures that we will
|
|||
// begin flushing on the next task the task throws an error.
|
|||
index = index + 1; |
|||
queue[currentIndex].call(); |
|||
// Prevent leaking memory for long chains of recursive calls to `asap`.
|
|||
// If we call `asap` within tasks scheduled by `asap`, the queue will
|
|||
// grow, but to avoid an O(n) walk for every task we execute, we don't
|
|||
// shift tasks off the queue after they have been executed.
|
|||
// Instead, we periodically shift 1024 tasks off the queue.
|
|||
if (index > capacity) { |
|||
// Manually shift all values starting at the index back to the
|
|||
// beginning of the queue.
|
|||
for (var scan = 0, newLength = queue.length - index; scan < newLength; scan++) { |
|||
queue[scan] = queue[scan + index]; |
|||
} |
|||
queue.length -= index; |
|||
index = 0; |
|||
} |
|||
} |
|||
queue.length = 0; |
|||
index = 0; |
|||
flushing = false; |
|||
} |
|||
|
|||
// `requestFlush` is implemented using a strategy based on data collected from
|
|||
// every available SauceLabs Selenium web driver worker at time of writing.
|
|||
// https://docs.google.com/spreadsheets/d/1mG-5UYGup5qxGdEMWkhP6BWCz053NUb2E1QoUTU16uA/edit#gid=783724593
|
|||
|
|||
// Safari 6 and 6.1 for desktop, iPad, and iPhone are the only browsers that
|
|||
// have WebKitMutationObserver but not un-prefixed MutationObserver.
|
|||
// Must use `global` or `self` instead of `window` to work in both frames and web
|
|||
// workers. `global` is a provision of Browserify, Mr, Mrs, or Mop.
|
|||
|
|||
/* globals self */ |
|||
var scope = typeof global !== "undefined" ? global : self; |
|||
var BrowserMutationObserver = scope.MutationObserver || scope.WebKitMutationObserver; |
|||
|
|||
// MutationObservers are desirable because they have high priority and work
|
|||
// reliably everywhere they are implemented.
|
|||
// They are implemented in all modern browsers.
|
|||
//
|
|||
// - Android 4-4.3
|
|||
// - Chrome 26-34
|
|||
// - Firefox 14-29
|
|||
// - Internet Explorer 11
|
|||
// - iPad Safari 6-7.1
|
|||
// - iPhone Safari 7-7.1
|
|||
// - Safari 6-7
|
|||
if (typeof BrowserMutationObserver === "function") { |
|||
requestFlush = makeRequestCallFromMutationObserver(flush); |
|||
|
|||
// MessageChannels are desirable because they give direct access to the HTML
|
|||
// task queue, are implemented in Internet Explorer 10, Safari 5.0-1, and Opera
|
|||
// 11-12, and in web workers in many engines.
|
|||
// Although message channels yield to any queued rendering and IO tasks, they
|
|||
// would be better than imposing the 4ms delay of timers.
|
|||
// However, they do not work reliably in Internet Explorer or Safari.
|
|||
|
|||
// Internet Explorer 10 is the only browser that has setImmediate but does
|
|||
// not have MutationObservers.
|
|||
// Although setImmediate yields to the browser's renderer, it would be
|
|||
// preferrable to falling back to setTimeout since it does not have
|
|||
// the minimum 4ms penalty.
|
|||
// Unfortunately there appears to be a bug in Internet Explorer 10 Mobile (and
|
|||
// Desktop to a lesser extent) that renders both setImmediate and
|
|||
// MessageChannel useless for the purposes of ASAP.
|
|||
// https://github.com/kriskowal/q/issues/396
|
|||
|
|||
// Timers are implemented universally.
|
|||
// We fall back to timers in workers in most engines, and in foreground
|
|||
// contexts in the following browsers.
|
|||
// However, note that even this simple case requires nuances to operate in a
|
|||
// broad spectrum of browsers.
|
|||
//
|
|||
// - Firefox 3-13
|
|||
// - Internet Explorer 6-9
|
|||
// - iPad Safari 4.3
|
|||
// - Lynx 2.8.7
|
|||
} else { |
|||
requestFlush = makeRequestCallFromTimer(flush); |
|||
} |
|||
|
|||
// `requestFlush` requests that the high priority event queue be flushed as
|
|||
// soon as possible.
|
|||
// This is useful to prevent an error thrown in a task from stalling the event
|
|||
// queue if the exception handled by Node.js’s
|
|||
// `process.on("uncaughtException")` or by a domain.
|
|||
rawAsap.requestFlush = requestFlush; |
|||
|
|||
// To request a high priority event, we induce a mutation observer by toggling
|
|||
// the text of a text node between "1" and "-1".
|
|||
function makeRequestCallFromMutationObserver(callback) { |
|||
var toggle = 1; |
|||
var observer = new BrowserMutationObserver(callback); |
|||
var node = document.createTextNode(""); |
|||
observer.observe(node, {characterData: true}); |
|||
return function requestCall() { |
|||
toggle = -toggle; |
|||
node.data = toggle; |
|||
}; |
|||
} |
|||
|
|||
// The message channel technique was discovered by Malte Ubl and was the
|
|||
// original foundation for this library.
|
|||
// http://www.nonblocking.io/2011/06/windownexttick.html
|
|||
|
|||
// Safari 6.0.5 (at least) intermittently fails to create message ports on a
|
|||
// page's first load. Thankfully, this version of Safari supports
|
|||
// MutationObservers, so we don't need to fall back in that case.
|
|||
|
|||
// function makeRequestCallFromMessageChannel(callback) {
|
|||
// var channel = new MessageChannel();
|
|||
// channel.port1.onmessage = callback;
|
|||
// return function requestCall() {
|
|||
// channel.port2.postMessage(0);
|
|||
// };
|
|||
// }
|
|||
|
|||
// For reasons explained above, we are also unable to use `setImmediate`
|
|||
// under any circumstances.
|
|||
// Even if we were, there is another bug in Internet Explorer 10.
|
|||
// It is not sufficient to assign `setImmediate` to `requestFlush` because
|
|||
// `setImmediate` must be called *by name* and therefore must be wrapped in a
|
|||
// closure.
|
|||
// Never forget.
|
|||
|
|||
// function makeRequestCallFromSetImmediate(callback) {
|
|||
// return function requestCall() {
|
|||
// setImmediate(callback);
|
|||
// };
|
|||
// }
|
|||
|
|||
// Safari 6.0 has a problem where timers will get lost while the user is
|
|||
// scrolling. This problem does not impact ASAP because Safari 6.0 supports
|
|||
// mutation observers, so that implementation is used instead.
|
|||
// However, if we ever elect to use timers in Safari, the prevalent work-around
|
|||
// is to add a scroll event listener that calls for a flush.
|
|||
|
|||
// `setTimeout` does not call the passed callback if the delay is less than
|
|||
// approximately 7 in web workers in Firefox 8 through 18, and sometimes not
|
|||
// even then.
|
|||
|
|||
function makeRequestCallFromTimer(callback) { |
|||
return function requestCall() { |
|||
// We dispatch a timeout with a specified delay of 0 for engines that
|
|||
// can reliably accommodate that request. This will usually be snapped
|
|||
// to a 4 milisecond delay, but once we're flushing, there's no delay
|
|||
// between events.
|
|||
var timeoutHandle = setTimeout(handleTimer, 0); |
|||
// However, since this timer gets frequently dropped in Firefox
|
|||
// workers, we enlist an interval handle that will try to fire
|
|||
// an event 20 times per second until it succeeds.
|
|||
var intervalHandle = setInterval(handleTimer, 50); |
|||
|
|||
function handleTimer() { |
|||
// Whichever timer succeeds will cancel both timers and
|
|||
// execute the callback.
|
|||
clearTimeout(timeoutHandle); |
|||
clearInterval(intervalHandle); |
|||
callback(); |
|||
} |
|||
}; |
|||
} |
|||
|
|||
// This is for `asap.js` only.
|
|||
// Its name will be periodically randomized to break any code that depends on
|
|||
// its existence.
|
|||
rawAsap.makeRequestCallFromTimer = makeRequestCallFromTimer; |
|||
|
|||
// ASAP was originally a nextTick shim included in Q. This was factored out
|
|||
// into this ASAP package. It was later adapted to RSVP which made further
|
|||
// amendments. These decisions, particularly to marginalize MessageChannel and
|
|||
// to capture the MutationObserver implementation in a closure, were integrated
|
|||
// back into ASAP proper.
|
|||
// https://github.com/tildeio/rsvp.js/blob/cddf7232546a9cf858524b75cde6f9edf72620a7/lib/rsvp/asap.js
|
@ -0,0 +1,87 @@ |
|||
{ |
|||
"_from": "asap@~2.0.3", |
|||
"_id": "asap@2.0.6", |
|||
"_inBundle": false, |
|||
"_integrity": "sha1-5QNHYR1+aQlDIIu9r+vLwvuGbUY=", |
|||
"_location": "/asap", |
|||
"_phantomChildren": {}, |
|||
"_requested": { |
|||
"type": "range", |
|||
"registry": true, |
|||
"raw": "asap@~2.0.3", |
|||
"name": "asap", |
|||
"escapedName": "asap", |
|||
"rawSpec": "~2.0.3", |
|||
"saveSpec": null, |
|||
"fetchSpec": "~2.0.3" |
|||
}, |
|||
"_requiredBy": [ |
|||
"/promise" |
|||
], |
|||
"_resolved": "https://registry.npmjs.org/asap/-/asap-2.0.6.tgz", |
|||
"_shasum": "e50347611d7e690943208bbdafebcbc2fb866d46", |
|||
"_spec": "asap@~2.0.3", |
|||
"_where": "/var/www/htdocs/coze/socket/node_modules/promise", |
|||
"browser": { |
|||
"./asap": "./browser-asap.js", |
|||
"./asap.js": "./browser-asap.js", |
|||
"./raw": "./browser-raw.js", |
|||
"./raw.js": "./browser-raw.js", |
|||
"./test/domain.js": "./test/browser-domain.js" |
|||
}, |
|||
"bugs": { |
|||
"url": "https://github.com/kriskowal/asap/issues" |
|||
}, |
|||
"bundleDependencies": false, |
|||
"deprecated": false, |
|||
"description": "High-priority task queue for Node.js and browsers", |
|||
"devDependencies": { |
|||
"benchmark": "^1.0.0", |
|||
"events": "^1.0.1", |
|||
"jshint": "^2.5.1", |
|||
"knox": "^0.8.10", |
|||
"mr": "^2.0.5", |
|||
"opener": "^1.3.0", |
|||
"q": "^2.0.3", |
|||
"q-io": "^2.0.3", |
|||
"saucelabs": "^0.1.1", |
|||
"wd": "^0.2.21", |
|||
"weak-map": "^1.0.5" |
|||
}, |
|||
"files": [ |
|||
"raw.js", |
|||
"asap.js", |
|||
"browser-raw.js", |
|||
"browser-asap.js" |
|||
], |
|||
"homepage": "https://github.com/kriskowal/asap#readme", |
|||
"keywords": [ |
|||
"event", |
|||
"task", |
|||
"queue" |
|||
], |
|||
"license": "MIT", |
|||
"main": "./asap.js", |
|||
"name": "asap", |
|||
"react-native": { |
|||
"domain": false |
|||
}, |
|||
"repository": { |
|||
"type": "git", |
|||
"url": "git+https://github.com/kriskowal/asap.git" |
|||
}, |
|||
"scripts": { |
|||
"benchmarks": "node benchmarks", |
|||
"lint": "jshint raw.js asap.js browser-raw.js browser-asap.js $(find scripts -name '*.js' | grep -v gauntlet)", |
|||
"test": "npm run lint && npm run test-node", |
|||
"test-browser": "node scripts/publish-bundle.js test/asap-test.js | xargs opener", |
|||
"test-node": "node test/asap-test.js", |
|||
"test-publish": "node scripts/publish-bundle.js test/asap-test.js | pbcopy", |
|||
"test-saucelabs": "node scripts/saucelabs.js test/asap-test.js scripts/saucelabs-spot-configurations.json", |
|||
"test-saucelabs-all": "node scripts/saucelabs.js test/asap-test.js scripts/saucelabs-all-configurations.json", |
|||
"test-saucelabs-worker": "node scripts/saucelabs-worker-test.js scripts/saucelabs-spot-configurations.json", |
|||
"test-saucelabs-worker-all": "node scripts/saucelabs-worker-test.js scripts/saucelabs-all-configurations.json", |
|||
"test-travis": "npm run lint && npm run test-node && npm run test-saucelabs && npm run test-saucelabs-worker" |
|||
}, |
|||
"version": "2.0.6" |
|||
} |
@ -0,0 +1,101 @@ |
|||
"use strict"; |
|||
|
|||
var domain; // The domain module is executed on demand
|
|||
var hasSetImmediate = typeof setImmediate === "function"; |
|||
|
|||
// Use the fastest means possible to execute a task in its own turn, with
|
|||
// priority over other events including network IO events in Node.js.
|
|||
//
|
|||
// An exception thrown by a task will permanently interrupt the processing of
|
|||
// subsequent tasks. The higher level `asap` function ensures that if an
|
|||
// exception is thrown by a task, that the task queue will continue flushing as
|
|||
// soon as possible, but if you use `rawAsap` directly, you are responsible to
|
|||
// either ensure that no exceptions are thrown from your task, or to manually
|
|||
// call `rawAsap.requestFlush` if an exception is thrown.
|
|||
module.exports = rawAsap; |
|||
function rawAsap(task) { |
|||
if (!queue.length) { |
|||
requestFlush(); |
|||
flushing = true; |
|||
} |
|||
// Avoids a function call
|
|||
queue[queue.length] = task; |
|||
} |
|||
|
|||
var queue = []; |
|||
// Once a flush has been requested, no further calls to `requestFlush` are
|
|||
// necessary until the next `flush` completes.
|
|||
var flushing = false; |
|||
// The position of the next task to execute in the task queue. This is
|
|||
// preserved between calls to `flush` so that it can be resumed if
|
|||
// a task throws an exception.
|
|||
var index = 0; |
|||
// If a task schedules additional tasks recursively, the task queue can grow
|
|||
// unbounded. To prevent memory excaustion, the task queue will periodically
|
|||
// truncate already-completed tasks.
|
|||
var capacity = 1024; |
|||
|
|||
// The flush function processes all tasks that have been scheduled with
|
|||
// `rawAsap` unless and until one of those tasks throws an exception.
|
|||
// If a task throws an exception, `flush` ensures that its state will remain
|
|||
// consistent and will resume where it left off when called again.
|
|||
// However, `flush` does not make any arrangements to be called again if an
|
|||
// exception is thrown.
|
|||
function flush() { |
|||
while (index < queue.length) { |
|||
var currentIndex = index; |
|||
// Advance the index before calling the task. This ensures that we will
|
|||
// begin flushing on the next task the task throws an error.
|
|||
index = index + 1; |
|||
queue[currentIndex].call(); |
|||
// Prevent leaking memory for long chains of recursive calls to `asap`.
|
|||
// If we call `asap` within tasks scheduled by `asap`, the queue will
|
|||
// grow, but to avoid an O(n) walk for every task we execute, we don't
|
|||
// shift tasks off the queue after they have been executed.
|
|||
// Instead, we periodically shift 1024 tasks off the queue.
|
|||
if (index > capacity) { |
|||
// Manually shift all values starting at the index back to the
|
|||
// beginning of the queue.
|
|||
for (var scan = 0, newLength = queue.length - index; scan < newLength; scan++) { |
|||
queue[scan] = queue[scan + index]; |
|||
} |
|||
queue.length -= index; |
|||
index = 0; |
|||
} |
|||
} |
|||
queue.length = 0; |
|||
index = 0; |
|||
flushing = false; |
|||
} |
|||
|
|||
rawAsap.requestFlush = requestFlush; |
|||
function requestFlush() { |
|||
// Ensure flushing is not bound to any domain.
|
|||
// It is not sufficient to exit the domain, because domains exist on a stack.
|
|||
// To execute code outside of any domain, the following dance is necessary.
|
|||
var parentDomain = process.domain; |
|||
if (parentDomain) { |
|||
if (!domain) { |
|||
// Lazy execute the domain module.
|
|||
// Only employed if the user elects to use domains.
|
|||
domain = require("domain"); |
|||
} |
|||
domain.active = process.domain = null; |
|||
} |
|||
|
|||
// `setImmediate` is slower that `process.nextTick`, but `process.nextTick`
|
|||
// cannot handle recursion.
|
|||
// `requestFlush` will only be called recursively from `asap.js`, to resume
|
|||
// flushing after an error is thrown into a domain.
|
|||
// Conveniently, `setImmediate` was introduced in the same version
|
|||
// `process.nextTick` started throwing recursion errors.
|
|||
if (flushing && hasSetImmediate) { |
|||
setImmediate(flush); |
|||
} else { |
|||
process.nextTick(flush); |
|||
} |
|||
|
|||
if (parentDomain) { |
|||
domain.active = process.domain = parentDomain; |
|||
} |
|||
} |
@ -0,0 +1,7 @@ |
|||
language: node_js |
|||
node_js: |
|||
- "6" |
|||
- "node" |
|||
script: npm run travis |
|||
cache: |
|||
yarn: true |
@ -0,0 +1,8 @@ |
|||
The MIT License (MIT) |
|||
Copyright (c) 2017 Samuel Reed <samuel.trace.reed@gmail.com> |
|||
|
|||
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: |
|||
|
|||
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. |
|||
|
|||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. |
@ -0,0 +1 @@ |
|||
{"/Users/samuelreed/git/forks/async-throttle/index.js":{"path":"/Users/samuelreed/git/forks/async-throttle/index.js","s":{"1":1,"2":7,"3":1,"4":6,"5":6,"6":6,"7":6,"8":6,"9":6,"10":1,"11":1,"12":3,"13":13,"14":13,"15":13,"16":1,"17":19,"18":1,"19":45,"20":6,"21":39,"22":13,"23":13,"24":13,"25":13,"26":39,"27":18,"28":6,"29":6,"30":1,"31":6,"32":6,"33":6,"34":1,"35":13,"36":13,"37":1},"b":{"1":[1,6],"2":[6,5],"3":[6,5],"4":[6,39],"5":[13,26],"6":[18,21],"7":[6,0]},"f":{"1":7,"2":3,"3":13,"4":19,"5":45,"6":6,"7":13},"fnMap":{"1":{"name":"Queue","line":3,"loc":{"start":{"line":3,"column":0},"end":{"line":3,"column":24}}},"2":{"name":"(anonymous_2)","line":22,"loc":{"start":{"line":22,"column":24},"end":{"line":22,"column":41}}},"3":{"name":"(anonymous_3)","line":23,"loc":{"start":{"line":23,"column":28},"end":{"line":23,"column":39}}},"4":{"name":"(anonymous_4)","line":31,"loc":{"start":{"line":31,"column":7},"end":{"line":31,"column":18}}},"5":{"name":"(anonymous_5)","line":36,"loc":{"start":{"line":36,"column":23},"end":{"line":36,"column":34}}},"6":{"name":"(anonymous_6)","line":55,"loc":{"start":{"line":55,"column":25},"end":{"line":55,"column":38}}},"7":{"name":"done","line":62,"loc":{"start":{"line":62,"column":0},"end":{"line":62,"column":16}}}},"statementMap":{"1":{"start":{"line":3,"column":0},"end":{"line":14,"column":1}},"2":{"start":{"line":4,"column":2},"end":{"line":6,"column":3}},"3":{"start":{"line":5,"column":4},"end":{"line":5,"column":30}},"4":{"start":{"line":8,"column":2},"end":{"line":8,"column":26}},"5":{"start":{"line":9,"column":2},"end":{"line":9,"column":53}},"6":{"start":{"line":10,"column":2},"end":{"line":10,"column":19}},"7":{"start":{"line":11,"column":2},"end":{"line":11,"column":17}},"8":{"start":{"line":12,"column":2},"end":{"line":12,"column":16}},"9":{"start":{"line":13,"column":2},"end":{"line":13,"column":31}},"10":{"start":{"line":16,"column":0},"end":{"line":20,"column":2}},"11":{"start":{"line":22,"column":0},"end":{"line":28,"column":3}},"12":{"start":{"line":23,"column":2},"end":{"line":27,"column":4}},"13":{"start":{"line":24,"column":4},"end":{"line":24,"column":75}},"14":{"start":{"line":25,"column":4},"end":{"line":25,"column":16}},"15":{"start":{"line":26,"column":4},"end":{"line":26,"column":24}},"16":{"start":{"line":30,"column":0},"end":{"line":34,"column":3}},"17":{"start":{"line":32,"column":4},"end":{"line":32,"column":43}},"18":{"start":{"line":36,"column":0},"end":{"line":53,"column":2}},"19":{"start":{"line":37,"column":2},"end":{"line":39,"column":3}},"20":{"start":{"line":38,"column":4},"end":{"line":38,"column":11}},"21":{"start":{"line":40,"column":2},"end":{"line":45,"column":3}},"22":{"start":{"line":41,"column":4},"end":{"line":41,"column":32}},"23":{"start":{"line":42,"column":4},"end":{"line":42,"column":19}},"24":{"start":{"line":43,"column":4},"end":{"line":43,"column":20}},"25":{"start":{"line":44,"column":4},"end":{"line":44,"column":16}},"26":{"start":{"line":47,"column":2},"end":{"line":52,"column":3}},"27":{"start":{"line":48,"column":4},"end":{"line":51,"column":5}},"28":{"start":{"line":49,"column":6},"end":{"line":49,"column":30}},"29":{"start":{"line":50,"column":6},"end":{"line":50,"column":27}},"30":{"start":{"line":55,"column":0},"end":{"line":60,"column":2}},"31":{"start":{"line":56,"column":2},"end":{"line":59,"column":3}},"32":{"start":{"line":57,"column":4},"end":{"line":57,"column":22}},"33":{"start":{"line":58,"column":4},"end":{"line":58,"column":16}},"34":{"start":{"line":62,"column":0},"end":{"line":65,"column":1}},"35":{"start":{"line":63,"column":2},"end":{"line":63,"column":17}},"36":{"start":{"line":64,"column":2},"end":{"line":64,"column":14}},"37":{"start":{"line":67,"column":0},"end":{"line":67,"column":23}}},"branchMap":{"1":{"line":4,"type":"if","locations":[{"start":{"line":4,"column":2},"end":{"line":4,"column":2}},{"start":{"line":4,"column":2},"end":{"line":4,"column":2}}]},"2":{"line":8,"type":"binary-expr","locations":[{"start":{"line":8,"column":12},"end":{"line":8,"column":19}},{"start":{"line":8,"column":23},"end":{"line":8,"column":25}}]},"3":{"line":9,"type":"binary-expr","locations":[{"start":{"line":9,"column":21},"end":{"line":9,"column":40}},{"start":{"line":9,"column":44},"end":{"line":9,"column":52}}]},"4":{"line":37,"type":"if","locations":[{"start":{"line":37,"column":2},"end":{"line":37,"column":2}},{"start":{"line":37,"column":2},"end":{"line":37,"column":2}}]},"5":{"line":40,"type":"if","locations":[{"start":{"line":40,"column":2},"end":{"line":40,"column":2}},{"start":{"line":40,"column":2},"end":{"line":40,"column":2}}]},"6":{"line":47,"type":"if","locations":[{"start":{"line":47,"column":2},"end":{"line":47,"column":2}},{"start":{"line":47,"column":2},"end":{"line":47,"column":2}}]},"7":{"line":56,"type":"if","locations":[{"start":{"line":56,"column":2},"end":{"line":56,"column":2}},{"start":{"line":56,"column":2},"end":{"line":56,"column":2}}]}}}} |
@ -0,0 +1,73 @@ |
|||
<!doctype html> |
|||
<html lang="en"> |
|||
<head> |
|||
<title>Code coverage report for async-throttle/</title> |
|||
<meta charset="utf-8"> |
|||
<link rel="stylesheet" href="../prettify.css"> |
|||
<link rel="stylesheet" href="../base.css"> |
|||
<style type='text/css'> |
|||
div.coverage-summary .sorter { |
|||
background-image: url(../sort-arrow-sprite.png); |
|||
} |
|||
</style> |
|||
</head> |
|||
<body> |
|||
<div class="header high"> |
|||
<h1>Code coverage report for <span class="entity">async-throttle/</span></h1> |
|||
<h2> |
|||
Statements: <span class="metric">100% <small>(37 / 37)</small></span> |
|||
Branches: <span class="metric">92.86% <small>(13 / 14)</small></span> |
|||
Functions: <span class="metric">100% <small>(7 / 7)</small></span> |
|||
Lines: <span class="metric">100% <small>(37 / 37)</small></span> |
|||
Ignored: <span class="metric"><span class="ignore-none">none</span></span> |
|||
</h2> |
|||
<div class="path"><a href="../index.html">All files</a> » async-throttle/</div> |
|||
</div> |
|||
<div class="body"> |
|||
<div class="coverage-summary"> |
|||
<table> |
|||
<thead> |
|||
<tr> |
|||
<th data-col="file" data-fmt="html" data-html="true" class="file">File</th> |
|||
<th data-col="pic" data-type="number" data-fmt="html" data-html="true" class="pic"></th> |
|||
<th data-col="statements" data-type="number" data-fmt="pct" class="pct">Statements</th> |
|||
<th data-col="statements_raw" data-type="number" data-fmt="html" class="abs"></th> |
|||
<th data-col="branches" data-type="number" data-fmt="pct" class="pct">Branches</th> |
|||
<th data-col="branches_raw" data-type="number" data-fmt="html" class="abs"></th> |
|||
<th data-col="functions" data-type="number" data-fmt="pct" class="pct">Functions</th> |
|||
<th data-col="functions_raw" data-type="number" data-fmt="html" class="abs"></th> |
|||
<th data-col="lines" data-type="number" data-fmt="pct" class="pct">Lines</th> |
|||
<th data-col="lines_raw" data-type="number" data-fmt="html" class="abs"></th> |
|||
</tr> |
|||
</thead> |
|||
<tbody><tr> |
|||
<td class="file high" data-value="index.js"><a href="index.js.html">index.js</a></td> |
|||
<td data-value="100" class="pic high"><span class="cover-fill cover-full" style="width: 100px;"></span><span class="cover-empty" style="width:0px;"></span></td> |
|||
<td data-value="100" class="pct high">100%</td> |
|||
<td data-value="37" class="abs high">(37 / 37)</td> |
|||
<td data-value="92.86" class="pct high">92.86%</td> |
|||
<td data-value="14" class="abs high">(13 / 14)</td> |
|||
<td data-value="100" class="pct high">100%</td> |
|||
<td data-value="7" class="abs high">(7 / 7)</td> |
|||
<td data-value="100" class="pct high">100%</td> |
|||
<td data-value="37" class="abs high">(37 / 37)</td> |
|||
</tr> |
|||
|
|||
</tbody> |
|||
</table> |
|||
</div> |
|||
</div> |
|||
<div class="footer"> |
|||
<div class="meta">Generated by <a href="http://istanbul-js.org/" target="_blank">istanbul</a> at Mon Sep 11 2017 11:14:14 GMT-0500 (CDT)</div> |
|||
</div> |
|||
<script src="../prettify.js"></script> |
|||
<script> |
|||
window.onload = function () { |
|||
if (typeof prettyPrint === 'function') { |
|||
prettyPrint(); |
|||
} |
|||
}; |
|||
</script> |
|||
<script src="../sorter.js"></script> |
|||
</body> |
|||
</html> |
@ -0,0 +1,246 @@ |
|||
<!doctype html> |
|||
<html lang="en"> |
|||
<head> |
|||
<title>Code coverage report for async-throttle/index.js</title> |
|||
<meta charset="utf-8"> |
|||
<link rel="stylesheet" href="../prettify.css"> |
|||
<link rel="stylesheet" href="../base.css"> |
|||
<style type='text/css'> |
|||
div.coverage-summary .sorter { |
|||
background-image: url(../sort-arrow-sprite.png); |
|||
} |
|||
</style> |
|||
</head> |
|||
<body> |
|||
<div class="header high"> |
|||
<h1>Code coverage report for <span class="entity">async-throttle/index.js</span></h1> |
|||
<h2> |
|||
Statements: <span class="metric">100% <small>(37 / 37)</small></span> |
|||
Branches: <span class="metric">92.86% <small>(13 / 14)</small></span> |
|||
Functions: <span class="metric">100% <small>(7 / 7)</small></span> |
|||
Lines: <span class="metric">100% <small>(37 / 37)</small></span> |
|||
Ignored: <span class="metric"><span class="ignore-none">none</span></span> |
|||
</h2> |
|||
<div class="path"><a href="../index.html">All files</a> » <a href="index.html">async-throttle/</a> » index.js</div> |
|||
</div> |
|||
<div class="body"> |
|||
<pre><table class="coverage"> |
|||
<tr><td class="line-count">1 |
|||
2 |
|||
3 |
|||
4 |
|||
5 |
|||
6 |
|||
7 |
|||
8 |
|||
9 |
|||
10 |
|||
11 |
|||
12 |
|||
13 |
|||
14 |
|||
15 |
|||
16 |
|||
17 |
|||
18 |
|||
19 |
|||
20 |
|||
21 |
|||
22 |
|||
23 |
|||
24 |
|||
25 |
|||
26 |
|||
27 |
|||
28 |
|||
29 |
|||
30 |
|||
31 |
|||
32 |
|||
33 |
|||
34 |
|||
35 |
|||
36 |
|||
37 |
|||
38 |
|||
39 |
|||
40 |
|||
41 |
|||
42 |
|||
43 |
|||
44 |
|||
45 |
|||
46 |
|||
47 |
|||
48 |
|||
49 |
|||
50 |
|||
51 |
|||
52 |
|||
53 |
|||
54 |
|||
55 |
|||
56 |
|||
57 |
|||
58 |
|||
59 |
|||
60 |
|||
61 |
|||
62 |
|||
63 |
|||
64 |
|||
65 |
|||
66 |
|||
67 |
|||
68</td><td class="line-coverage"><span class="cline-any cline-neutral"> </span> |
|||
<span class="cline-any cline-neutral"> </span> |
|||
<span class="cline-any cline-yes">1</span> |
|||
<span class="cline-any cline-yes">7</span> |
|||
<span class="cline-any cline-yes">1</span> |
|||
<span class="cline-any cline-neutral"> </span> |
|||
<span class="cline-any cline-neutral"> </span> |
|||
<span class="cline-any cline-yes">6</span> |
|||
<span class="cline-any cline-yes">6</span> |
|||
<span class="cline-any cline-yes">6</span> |
|||
<span class="cline-any cline-yes">6</span> |
|||
<span class="cline-any cline-yes">6</span> |
|||
<span class="cline-any cline-yes">6</span> |
|||
<span class="cline-any cline-neutral"> </span> |
|||
<span class="cline-any cline-neutral"> </span> |
|||
<span class="cline-any cline-yes">1</span> |
|||
<span class="cline-any cline-neutral"> </span> |
|||
<span class="cline-any cline-neutral"> </span> |
|||
<span class="cline-any cline-neutral"> </span> |
|||
<span class="cline-any cline-neutral"> </span> |
|||
<span class="cline-any cline-neutral"> </span> |
|||
<span class="cline-any cline-yes">1</span> |
|||
<span class="cline-any cline-yes">3</span> |
|||
<span class="cline-any cline-yes">13</span> |
|||
<span class="cline-any cline-yes">13</span> |
|||
<span class="cline-any cline-yes">13</span> |
|||
<span class="cline-any cline-neutral"> </span> |
|||
<span class="cline-any cline-neutral"> </span> |
|||
<span class="cline-any cline-neutral"> </span> |
|||
<span class="cline-any cline-yes">1</span> |
|||
<span class="cline-any cline-neutral"> </span> |
|||
<span class="cline-any cline-yes">19</span> |
|||
<span class="cline-any cline-neutral"> </span> |
|||
<span class="cline-any cline-neutral"> </span> |
|||
<span class="cline-any cline-neutral"> </span> |
|||
<span class="cline-any cline-yes">1</span> |
|||
<span class="cline-any cline-yes">45</span> |
|||
<span class="cline-any cline-yes">6</span> |
|||
<span class="cline-any cline-neutral"> </span> |
|||
<span class="cline-any cline-yes">39</span> |
|||
<span class="cline-any cline-yes">13</span> |
|||
<span class="cline-any cline-yes">13</span> |
|||
<span class="cline-any cline-yes">13</span> |
|||
<span class="cline-any cline-yes">13</span> |
|||
<span class="cline-any cline-neutral"> </span> |
|||
<span class="cline-any cline-neutral"> </span> |
|||
<span class="cline-any cline-yes">39</span> |
|||
<span class="cline-any cline-yes">18</span> |
|||
<span class="cline-any cline-yes">6</span> |
|||
<span class="cline-any cline-yes">6</span> |
|||
<span class="cline-any cline-neutral"> </span> |
|||
<span class="cline-any cline-neutral"> </span> |
|||
<span class="cline-any cline-neutral"> </span> |
|||
<span class="cline-any cline-neutral"> </span> |
|||
<span class="cline-any cline-yes">1</span> |
|||
<span class="cline-any cline-yes">6</span> |
|||
<span class="cline-any cline-yes">6</span> |
|||
<span class="cline-any cline-yes">6</span> |
|||
<span class="cline-any cline-neutral"> </span> |
|||
<span class="cline-any cline-neutral"> </span> |
|||
<span class="cline-any cline-neutral"> </span> |
|||
<span class="cline-any cline-yes">1</span> |
|||
<span class="cline-any cline-yes">13</span> |
|||
<span class="cline-any cline-yes">13</span> |
|||
<span class="cline-any cline-neutral"> </span> |
|||
<span class="cline-any cline-neutral"> </span> |
|||
<span class="cline-any cline-yes">1</span> |
|||
<span class="cline-any cline-neutral"> </span></td><td class="text"><pre class="prettyprint lang-js">'use strict'; |
|||
|
|||
function Queue(options) { |
|||
if (!(this instanceof Queue)) { |
|||
return new Queue(options); |
|||
} |
|||
|
|||
options = options || {}; |
|||
this.concurrency = options.concurrency || Infinity; |
|||
this.pending = 0; |
|||
this.jobs = []; |
|||
this.cbs = []; |
|||
this._done = done.bind(this); |
|||
} |
|||
|
|||
var arrayAddMethods = [ |
|||
'push', |
|||
'unshift', |
|||
'splice' |
|||
]; |
|||
|
|||
arrayAddMethods.forEach(function(method) { |
|||
Queue.prototype[method] = function() { |
|||
var methodResult = Array.prototype[method].apply(this.jobs, arguments); |
|||
this._run(); |
|||
return methodResult; |
|||
}; |
|||
}); |
|||
|
|||
Object.defineProperty(Queue.prototype, 'length', { |
|||
get: function() { |
|||
return this.pending + this.jobs.length; |
|||
} |
|||
}); |
|||
|
|||
Queue.prototype._run = function() { |
|||
if (this.pending === this.concurrency) { |
|||
return; |
|||
} |
|||
if (this.jobs.length) { |
|||
var job = this.jobs.shift(); |
|||
this.pending++; |
|||
job(this._done); |
|||
this._run(); |
|||
} |
|||
|
|||
if (this.pending === 0) { |
|||
while (this.cbs.length !== 0) { |
|||
var cb = this.cbs.pop(); |
|||
process.nextTick(cb); |
|||
} |
|||
} |
|||
}; |
|||
|
|||
Queue.prototype.onDone = function(cb) { |
|||
<span class="missing-if-branch" title="else path not taken" >E</span>if (typeof cb === 'function') { |
|||
this.cbs.push(cb); |
|||
this._run(); |
|||
} |
|||
}; |
|||
|
|||
function done() { |
|||
this.pending--; |
|||
this._run(); |
|||
} |
|||
|
|||
module.exports = Queue; |
|||
</pre></td></tr> |
|||
</table></pre> |
|||
|
|||
</div> |
|||
<div class="footer"> |
|||
<div class="meta">Generated by <a href="http://istanbul-js.org/" target="_blank">istanbul</a> at Mon Sep 11 2017 11:14:14 GMT-0500 (CDT)</div> |
|||
</div> |
|||
<script src="../prettify.js"></script> |
|||
<script> |
|||
window.onload = function () { |
|||
if (typeof prettyPrint === 'function') { |
|||
prettyPrint(); |
|||
} |
|||
}; |
|||
</script> |
|||
<script src="../sorter.js"></script> |
|||
</body> |
|||
</html> |
@ -0,0 +1,182 @@ |
|||
body, html { |
|||
margin:0; padding: 0; |
|||
} |
|||
body { |
|||
font-family: Helvetica Neue, Helvetica,Arial; |
|||
font-size: 10pt; |
|||
} |
|||
div.header, div.footer { |
|||
background: #eee; |
|||
padding: 1em; |
|||
} |
|||
div.header { |
|||
z-index: 100; |
|||
position: fixed; |
|||
top: 0; |
|||
border-bottom: 1px solid #666; |
|||
width: 100%; |
|||
} |
|||
div.footer { |
|||
border-top: 1px solid #666; |
|||
} |
|||
div.body { |
|||
margin-top: 10em; |
|||
} |
|||
div.meta { |
|||
font-size: 90%; |
|||
text-align: center; |
|||
} |
|||
h1, h2, h3 { |
|||
font-weight: normal; |
|||
} |
|||
h1 { |
|||
font-size: 12pt; |
|||
} |
|||
h2 { |
|||
font-size: 10pt; |
|||
} |
|||
pre { |
|||
font-family: Consolas, Menlo, Monaco, monospace; |
|||
margin: 0; |
|||
padding: 0; |
|||
line-height: 1.3; |
|||
font-size: 14px; |
|||
-moz-tab-size: 2; |
|||
-o-tab-size: 2; |
|||
tab-size: 2; |
|||
} |
|||
|
|||
div.path { font-size: 110%; } |
|||
div.path a:link, div.path a:visited { color: #000; } |
|||
table.coverage { border-collapse: collapse; margin:0; padding: 0 } |
|||
|
|||
table.coverage td { |
|||
margin: 0; |
|||
padding: 0; |
|||
color: #111; |
|||
vertical-align: top; |
|||
} |
|||
table.coverage td.line-count { |
|||
width: 50px; |
|||
text-align: right; |
|||
padding-right: 5px; |
|||
} |
|||
table.coverage td.line-coverage { |
|||
color: #777 !important; |
|||
text-align: right; |
|||
border-left: 1px solid #666; |
|||
border-right: 1px solid #666; |
|||
} |
|||
|
|||
table.coverage td.text { |
|||
} |
|||
|
|||
table.coverage td span.cline-any { |
|||
display: inline-block; |
|||
padding: 0 5px; |
|||
width: 40px; |
|||
} |
|||
table.coverage td span.cline-neutral { |
|||
background: #eee; |
|||
} |
|||
table.coverage td span.cline-yes { |
|||
background: #b5d592; |
|||
color: #999; |
|||
} |
|||
table.coverage td span.cline-no { |
|||
background: #fc8c84; |
|||
} |
|||
|
|||
.cstat-yes { color: #111; } |
|||
.cstat-no { background: #fc8c84; color: #111; } |
|||
.fstat-no { background: #ffc520; color: #111 !important; } |
|||
.cbranch-no { background: yellow !important; color: #111; } |
|||
|
|||
.cstat-skip { background: #ddd; color: #111; } |
|||
.fstat-skip { background: #ddd; color: #111 !important; } |
|||
.cbranch-skip { background: #ddd !important; color: #111; } |
|||
|
|||
.missing-if-branch { |
|||
display: inline-block; |
|||
margin-right: 10px; |
|||
position: relative; |
|||
padding: 0 4px; |
|||
background: black; |
|||
color: yellow; |
|||
} |
|||
|
|||
.skip-if-branch { |
|||
display: none; |
|||
margin-right: 10px; |
|||
position: relative; |
|||
padding: 0 4px; |
|||
background: #ccc; |
|||
color: white; |
|||
} |
|||
|
|||
.missing-if-branch .typ, .skip-if-branch .typ { |
|||
color: inherit !important; |
|||
} |
|||
|
|||
.entity, .metric { font-weight: bold; } |
|||
.metric { display: inline-block; border: 1px solid #333; padding: 0.3em; background: white; } |
|||
.metric small { font-size: 80%; font-weight: normal; color: #666; } |
|||
|
|||
div.coverage-summary table { border-collapse: collapse; margin: 3em; font-size: 110%; } |
|||
div.coverage-summary td, div.coverage-summary table th { margin: 0; padding: 0.25em 1em; border-top: 1px solid #666; border-bottom: 1px solid #666; } |
|||
div.coverage-summary th { text-align: left; border: 1px solid #666; background: #eee; font-weight: normal; } |
|||
div.coverage-summary th.file { border-right: none !important; } |
|||
div.coverage-summary th.pic { border-left: none !important; text-align: right; } |
|||
div.coverage-summary th.pct { border-right: none !important; } |
|||
div.coverage-summary th.abs { border-left: none !important; text-align: right; } |
|||
div.coverage-summary td.pct { text-align: right; border-left: 1px solid #666; } |
|||
div.coverage-summary td.abs { text-align: right; font-size: 90%; color: #444; border-right: 1px solid #666; } |
|||
div.coverage-summary td.file { border-left: 1px solid #666; white-space: nowrap; } |
|||
div.coverage-summary td.pic { min-width: 120px !important; } |
|||
div.coverage-summary a:link { text-decoration: none; color: #000; } |
|||
div.coverage-summary a:visited { text-decoration: none; color: #777; } |
|||
div.coverage-summary a:hover { text-decoration: underline; } |
|||
div.coverage-summary tfoot td { border-top: 1px solid #666; } |
|||
|
|||
div.coverage-summary .sorter { |
|||
height: 10px; |
|||
width: 7px; |
|||
display: inline-block; |
|||
margin-left: 0.5em; |
|||
background: url(sort-arrow-sprite.png) no-repeat scroll 0 0 transparent; |
|||
} |
|||
div.coverage-summary .sorted .sorter { |
|||
background-position: 0 -20px; |
|||
} |
|||
div.coverage-summary .sorted-desc .sorter { |
|||
background-position: 0 -10px; |
|||
} |
|||
|
|||
.high { background: #b5d592 !important; } |
|||
.medium { background: #ffe87c !important; } |
|||
.low { background: #fc8c84 !important; } |
|||
|
|||
span.cover-fill, span.cover-empty { |
|||
display:inline-block; |
|||
border:1px solid #444; |
|||
background: white; |
|||
height: 12px; |
|||
} |
|||
span.cover-fill { |
|||
background: #ccc; |
|||
border-right: 1px solid #444; |
|||
} |
|||
span.cover-empty { |
|||
background: white; |
|||
border-left: none; |
|||
} |
|||
span.cover-full { |
|||
border-right: none !important; |
|||
} |
|||
pre.prettyprint { |
|||
border: none !important; |
|||
padding: 0 !important; |
|||
margin: 0 !important; |
|||
} |
|||
.com { color: #999 !important; } |
|||
.ignore-none { color: #999; font-weight: normal; } |
@ -0,0 +1,73 @@ |
|||
<!doctype html> |
|||
<html lang="en"> |
|||
<head> |
|||
<title>Code coverage report for All files</title> |
|||
<meta charset="utf-8"> |
|||
<link rel="stylesheet" href="prettify.css"> |
|||
<link rel="stylesheet" href="base.css"> |
|||
<style type='text/css'> |
|||
div.coverage-summary .sorter { |
|||
background-image: url(sort-arrow-sprite.png); |
|||
} |
|||
</style> |
|||
</head> |
|||
<body> |
|||
<div class="header high"> |
|||
<h1>Code coverage report for <span class="entity">All files</span></h1> |
|||
<h2> |
|||
Statements: <span class="metric">100% <small>(37 / 37)</small></span> |
|||
Branches: <span class="metric">92.86% <small>(13 / 14)</small></span> |
|||
Functions: <span class="metric">100% <small>(7 / 7)</small></span> |
|||
Lines: <span class="metric">100% <small>(37 / 37)</small></span> |
|||
Ignored: <span class="metric"><span class="ignore-none">none</span></span> |
|||
</h2> |
|||
<div class="path"></div> |
|||
</div> |
|||
<div class="body"> |
|||
<div class="coverage-summary"> |
|||
<table> |
|||
<thead> |
|||
<tr> |
|||
<th data-col="file" data-fmt="html" data-html="true" class="file">File</th> |
|||
<th data-col="pic" data-type="number" data-fmt="html" data-html="true" class="pic"></th> |
|||
<th data-col="statements" data-type="number" data-fmt="pct" class="pct">Statements</th> |
|||
<th data-col="statements_raw" data-type="number" data-fmt="html" class="abs"></th> |
|||
<th data-col="branches" data-type="number" data-fmt="pct" class="pct">Branches</th> |
|||
<th data-col="branches_raw" data-type="number" data-fmt="html" class="abs"></th> |
|||
<th data-col="functions" data-type="number" data-fmt="pct" class="pct">Functions</th> |
|||
<th data-col="functions_raw" data-type="number" data-fmt="html" class="abs"></th> |
|||
<th data-col="lines" data-type="number" data-fmt="pct" class="pct">Lines</th> |
|||
<th data-col="lines_raw" data-type="number" data-fmt="html" class="abs"></th> |
|||
</tr> |
|||
</thead> |
|||
<tbody><tr> |
|||
<td class="file high" data-value="async-throttle/"><a href="async-throttle/index.html">async-throttle/</a></td> |
|||
<td data-value="100" class="pic high"><span class="cover-fill cover-full" style="width: 100px;"></span><span class="cover-empty" style="width:0px;"></span></td> |
|||
<td data-value="100" class="pct high">100%</td> |
|||
<td data-value="37" class="abs high">(37 / 37)</td> |
|||
<td data-value="92.86" class="pct high">92.86%</td> |
|||
<td data-value="14" class="abs high">(13 / 14)</td> |
|||
<td data-value="100" class="pct high">100%</td> |
|||
<td data-value="7" class="abs high">(7 / 7)</td> |
|||
<td data-value="100" class="pct high">100%</td> |
|||
<td data-value="37" class="abs high">(37 / 37)</td> |
|||
</tr> |
|||
|
|||
</tbody> |
|||
</table> |
|||
</div> |
|||
</div> |
|||
<div class="footer"> |
|||
<div class="meta">Generated by <a href="http://istanbul-js.org/" target="_blank">istanbul</a> at Mon Sep 11 2017 11:14:14 GMT-0500 (CDT)</div> |
|||
</div> |
|||
<script src="prettify.js"></script> |
|||
<script> |
|||
window.onload = function () { |
|||
if (typeof prettyPrint === 'function') { |
|||
prettyPrint(); |
|||
} |
|||
}; |
|||
</script> |
|||
<script src="sorter.js"></script> |
|||
</body> |
|||
</html> |
@ -0,0 +1 @@ |
|||
.pln{color:#000}@media screen{.str{color:#080}.kwd{color:#008}.com{color:#800}.typ{color:#606}.lit{color:#066}.pun,.opn,.clo{color:#660}.tag{color:#008}.atn{color:#606}.atv{color:#080}.dec,.var{color:#606}.fun{color:red}}@media print,projection{.str{color:#060}.kwd{color:#006;font-weight:bold}.com{color:#600;font-style:italic}.typ{color:#404;font-weight:bold}.lit{color:#044}.pun,.opn,.clo{color:#440}.tag{color:#006;font-weight:bold}.atn{color:#404}.atv{color:#060}}pre.prettyprint{padding:2px;border:1px solid #888}ol.linenums{margin-top:0;margin-bottom:0}li.L0,li.L1,li.L2,li.L3,li.L5,li.L6,li.L7,li.L8{list-style-type:none}li.L1,li.L3,li.L5,li.L7,li.L9{background:#eee} |
File diff suppressed because one or more lines are too long
After Width: | Height: | Size: 209 B |
@ -0,0 +1,156 @@ |
|||
var addSorting = (function () { |
|||
"use strict"; |
|||
var cols, |
|||
currentSort = { |
|||
index: 0, |
|||
desc: false |
|||
}; |
|||
|
|||
// returns the summary table element
|
|||
function getTable() { return document.querySelector('.coverage-summary table'); } |
|||
// returns the thead element of the summary table
|
|||
function getTableHeader() { return getTable().querySelector('thead tr'); } |
|||
// returns the tbody element of the summary table
|
|||
function getTableBody() { return getTable().querySelector('tbody'); } |
|||
// returns the th element for nth column
|
|||
function getNthColumn(n) { return getTableHeader().querySelectorAll('th')[n]; } |
|||
|
|||
// loads all columns
|
|||
function loadColumns() { |
|||
var colNodes = getTableHeader().querySelectorAll('th'), |
|||
colNode, |
|||
cols = [], |
|||
col, |
|||
i; |
|||
|
|||
for (i = 0; i < colNodes.length; i += 1) { |
|||
colNode = colNodes[i]; |
|||
col = { |
|||
key: colNode.getAttribute('data-col'), |
|||
sortable: !colNode.getAttribute('data-nosort'), |
|||
type: colNode.getAttribute('data-type') || 'string' |
|||
}; |
|||
cols.push(col); |
|||
if (col.sortable) { |
|||
col.defaultDescSort = col.type === 'number'; |
|||
colNode.innerHTML = colNode.innerHTML + '<span class="sorter"></span>'; |
|||
} |
|||
} |
|||
return cols; |
|||
} |
|||
// attaches a data attribute to every tr element with an object
|
|||
// of data values keyed by column name
|
|||
function loadRowData(tableRow) { |
|||
var tableCols = tableRow.querySelectorAll('td'), |
|||
colNode, |
|||
col, |
|||
data = {}, |
|||
i, |
|||
val; |
|||
for (i = 0; i < tableCols.length; i += 1) { |
|||
colNode = tableCols[i]; |
|||
col = cols[i]; |
|||
val = colNode.getAttribute('data-value'); |
|||
if (col.type === 'number') { |
|||
val = Number(val); |
|||
} |
|||
data[col.key] = val; |
|||
} |
|||
return data; |
|||
} |
|||
// loads all row data
|
|||
function loadData() { |
|||
var rows = getTableBody().querySelectorAll('tr'), |
|||
i; |
|||
|
|||
for (i = 0; i < rows.length; i += 1) { |
|||
rows[i].data = loadRowData(rows[i]); |
|||
} |
|||
} |
|||
// sorts the table using the data for the ith column
|
|||
function sortByIndex(index, desc) { |
|||
var key = cols[index].key, |
|||
sorter = function (a, b) { |
|||
a = a.data[key]; |
|||
b = b.data[key]; |
|||
return a < b ? -1 : a > b ? 1 : 0; |
|||
}, |
|||
finalSorter = sorter, |
|||
tableBody = document.querySelector('.coverage-summary tbody'), |
|||
rowNodes = tableBody.querySelectorAll('tr'), |
|||
rows = [], |
|||
i; |
|||
|
|||
if (desc) { |
|||
finalSorter = function (a, b) { |
|||
return -1 * sorter(a, b); |
|||
}; |
|||
} |
|||
|
|||
for (i = 0; i < rowNodes.length; i += 1) { |
|||
rows.push(rowNodes[i]); |
|||
tableBody.removeChild(rowNodes[i]); |
|||
} |
|||
|
|||
rows.sort(finalSorter); |
|||
|
|||
for (i = 0; i < rows.length; i += 1) { |
|||
tableBody.appendChild(rows[i]); |
|||
} |
|||
} |
|||
// removes sort indicators for current column being sorted
|
|||
function removeSortIndicators() { |
|||
var col = getNthColumn(currentSort.index), |
|||
cls = col.className; |
|||
|
|||
cls = cls.replace(/ sorted$/, '').replace(/ sorted-desc$/, ''); |
|||
col.className = cls; |
|||
} |
|||
// adds sort indicators for current column being sorted
|
|||
function addSortIndicators() { |
|||
getNthColumn(currentSort.index).className += currentSort.desc ? ' sorted-desc' : ' sorted'; |
|||
} |
|||
// adds event listeners for all sorter widgets
|
|||
function enableUI() { |
|||
var i, |
|||
el, |
|||
ithSorter = function ithSorter(i) { |
|||
var col = cols[i]; |
|||
|
|||
return function () { |
|||
var desc = col.defaultDescSort; |
|||
|
|||
if (currentSort.index === i) { |
|||
desc = !currentSort.desc; |
|||
} |
|||
sortByIndex(i, desc); |
|||
removeSortIndicators(); |
|||
currentSort.index = i; |
|||
currentSort.desc = desc; |
|||
addSortIndicators(); |
|||
}; |
|||
}; |
|||
for (i =0 ; i < cols.length; i += 1) { |
|||
if (cols[i].sortable) { |
|||
el = getNthColumn(i).querySelector('.sorter'); |
|||
if (el.addEventListener) { |
|||
el.addEventListener('click', ithSorter(i)); |
|||
} else { |
|||
el.attachEvent('onclick', ithSorter(i)); |
|||
} |
|||
} |
|||
} |
|||
} |
|||
// adds sorting functionality to the UI
|
|||
return function () { |
|||
if (!getTable()) { |
|||
return; |
|||
} |
|||
cols = loadColumns(); |
|||
loadData(cols); |
|||
addSortIndicators(); |
|||
enableUI(); |
|||
}; |
|||
})(); |
|||
|
|||
window.addEventListener('load', addSorting); |
@ -0,0 +1,74 @@ |
|||
TN: |
|||
SF:/Users/samuelreed/git/forks/async-throttle/index.js |
|||
FN:3,Queue |
|||
FN:22,(anonymous_2) |
|||
FN:23,(anonymous_3) |
|||
FN:31,(anonymous_4) |
|||
FN:36,(anonymous_5) |
|||
FN:55,(anonymous_6) |
|||
FN:62,done |
|||
FNF:7 |
|||
FNH:7 |
|||
FNDA:7,Queue |
|||
FNDA:3,(anonymous_2) |
|||
FNDA:13,(anonymous_3) |
|||
FNDA:19,(anonymous_4) |
|||
FNDA:45,(anonymous_5) |
|||
FNDA:6,(anonymous_6) |
|||
FNDA:13,done |
|||
DA:3,1 |
|||
DA:4,7 |
|||
DA:5,1 |
|||
DA:8,6 |
|||
DA:9,6 |
|||
DA:10,6 |
|||
DA:11,6 |
|||
DA:12,6 |
|||
DA:13,6 |
|||
DA:16,1 |
|||
DA:22,1 |
|||
DA:23,3 |
|||
DA:24,13 |
|||
DA:25,13 |
|||
DA:26,13 |
|||
DA:30,1 |
|||
DA:32,19 |
|||
DA:36,1 |
|||
DA:37,45 |
|||
DA:38,6 |
|||
DA:40,39 |
|||
DA:41,13 |
|||
DA:42,13 |
|||
DA:43,13 |
|||
DA:44,13 |
|||
DA:47,39 |
|||
DA:48,18 |
|||
DA:49,6 |
|||
DA:50,6 |
|||
DA:55,1 |
|||
DA:56,6 |
|||
DA:57,6 |
|||
DA:58,6 |
|||
DA:62,1 |
|||
DA:63,13 |
|||
DA:64,13 |
|||
DA:67,1 |
|||
LF:37 |
|||
LH:37 |
|||
BRDA:4,1,0,1 |
|||
BRDA:4,1,1,6 |
|||
BRDA:8,2,0,6 |
|||
BRDA:8,2,1,5 |
|||
BRDA:9,3,0,6 |
|||
BRDA:9,3,1,5 |
|||
BRDA:37,4,0,6 |
|||
BRDA:37,4,1,39 |
|||
BRDA:40,5,0,13 |
|||
BRDA:40,5,1,26 |
|||
BRDA:47,6,0,18 |
|||
BRDA:47,6,1,21 |
|||
BRDA:56,7,0,6 |
|||
BRDA:56,7,1,0 |
|||
BRF:14 |
|||
BRH:13 |
|||
end_of_record |
@ -0,0 +1,67 @@ |
|||
'use strict'; |
|||
|
|||
function Queue(options) { |
|||
if (!(this instanceof Queue)) { |
|||
return new Queue(options); |
|||
} |
|||
|
|||
options = options || {}; |
|||
this.concurrency = options.concurrency || Infinity; |
|||
this.pending = 0; |
|||
this.jobs = []; |
|||
this.cbs = []; |
|||
this._done = done.bind(this); |
|||
} |
|||
|
|||
var arrayAddMethods = [ |
|||
'push', |
|||
'unshift', |
|||
'splice' |
|||
]; |
|||
|
|||
arrayAddMethods.forEach(function(method) { |
|||
Queue.prototype[method] = function() { |
|||
var methodResult = Array.prototype[method].apply(this.jobs, arguments); |
|||
this._run(); |
|||
return methodResult; |
|||
}; |
|||
}); |
|||
|
|||
Object.defineProperty(Queue.prototype, 'length', { |
|||
get: function() { |
|||
return this.pending + this.jobs.length; |
|||
} |
|||
}); |
|||
|
|||
Queue.prototype._run = function() { |
|||
if (this.pending === this.concurrency) { |
|||
return; |
|||
} |
|||
if (this.jobs.length) { |
|||
var job = this.jobs.shift(); |
|||
this.pending++; |
|||
job(this._done); |
|||
this._run(); |
|||
} |
|||
|
|||
if (this.pending === 0) { |
|||
while (this.cbs.length !== 0) { |
|||
var cb = this.cbs.pop(); |
|||
process.nextTick(cb); |
|||
} |
|||
} |
|||
}; |
|||
|
|||
Queue.prototype.onDone = function(cb) { |
|||
if (typeof cb === 'function') { |
|||
this.cbs.push(cb); |
|||
this._run(); |
|||
} |
|||
}; |
|||
|
|||
function done() { |
|||
this.pending--; |
|||
this._run(); |
|||
} |
|||
|
|||
module.exports = Queue; |
@ -0,0 +1,69 @@ |
|||
{ |
|||
"_from": "async-limiter@~1.0.0", |
|||
"_id": "async-limiter@1.0.0", |
|||
"_inBundle": false, |
|||
"_integrity": "sha512-jp/uFnooOiO+L211eZOoSyzpOITMXx1rBITauYykG3BRYPu8h0UcxsPNB04RR5vo4Tyz3+ay17tR6JVf9qzYWg==", |
|||
"_location": "/async-limiter", |
|||
"_phantomChildren": {}, |
|||
"_requested": { |
|||
"type": "range", |
|||
"registry": true, |
|||
"raw": "async-limiter@~1.0.0", |
|||
"name": "async-limiter", |
|||
"escapedName": "async-limiter", |
|||
"rawSpec": "~1.0.0", |
|||
"saveSpec": null, |
|||
"fetchSpec": "~1.0.0" |
|||
}, |
|||
"_requiredBy": [ |
|||
"/ws" |
|||
], |
|||
"_resolved": "https://registry.npmjs.org/async-limiter/-/async-limiter-1.0.0.tgz", |
|||
"_shasum": "78faed8c3d074ab81f22b4e985d79e8738f720f8", |
|||
"_spec": "async-limiter@~1.0.0", |
|||
"_where": "/var/www/htdocs/coze/socket/node_modules/ws", |
|||
"author": { |
|||
"name": "Samuel Reed" |
|||
}, |
|||
"bugs": { |
|||
"url": "https://github.com/strml/async-limiter/issues" |
|||
}, |
|||
"bundleDependencies": false, |
|||
"dependencies": {}, |
|||
"deprecated": false, |
|||
"description": "asynchronous function queue with adjustable concurrency", |
|||
"devDependencies": { |
|||
"coveralls": "^2.11.2", |
|||
"eslint": "^4.6.1", |
|||
"eslint-plugin-mocha": "^4.11.0", |
|||
"intelli-espower-loader": "^1.0.1", |
|||
"istanbul": "^0.3.2", |
|||
"mocha": "^3.5.2", |
|||
"power-assert": "^1.4.4" |
|||
}, |
|||
"homepage": "https://github.com/strml/async-limiter#readme", |
|||
"keywords": [ |
|||
"throttle", |
|||
"async", |
|||
"limiter", |
|||
"asynchronous", |
|||
"job", |
|||
"task", |
|||
"concurrency", |
|||
"concurrent" |
|||
], |
|||
"license": "MIT", |
|||
"name": "async-limiter", |
|||
"repository": { |
|||
"type": "git", |
|||
"url": "git+https://github.com/strml/async-limiter.git" |
|||
}, |
|||
"scripts": { |
|||
"coverage": "istanbul cover ./node_modules/mocha/bin/_mocha --report lcovonly -- -R spec && cat ./coverage/lcov.info | coveralls", |
|||
"example": "node example", |
|||
"lint": "eslint .", |
|||
"test": "mocha --R intelli-espower-loader test/", |
|||
"travis": "npm run lint && npm run coverage" |
|||
}, |
|||
"version": "1.0.0" |
|||
} |
@ -0,0 +1,132 @@ |
|||
# Async-Limiter |
|||
|
|||
A module for limiting concurrent asynchronous actions in flight. Forked from [queue](https://github.com/jessetane/queue). |
|||
|
|||
[](http://www.npmjs.org/async-limiter) |
|||
[](https://travis-ci.org/STRML/async-limiter) |
|||
[](https://coveralls.io/r/STRML/async-limiter) |
|||
|
|||
This module exports a class `Limiter` that implements some of the `Array` API. |
|||
Pass async functions (ones that accept a callback or return a promise) to an instance's additive array methods. |
|||
|
|||
## Motivation |
|||
|
|||
Certain functions, like `zlib`, have [undesirable behavior](https://github.com/nodejs/node/issues/8871#issuecomment-250915913) when |
|||
run at infinite concurrency. |
|||
|
|||
In this case, it is actually faster, and takes far less memory, to limit concurrency. |
|||
|
|||
This module should do the absolute minimum work necessary to queue up functions. PRs are welcome that would |
|||
make this module faster or lighter, but new functionality is not desired. |
|||
|
|||
Style should confirm to nodejs/node style. |
|||
|
|||
## Example |
|||
|
|||
``` javascript |
|||
var Limiter = require('async-limiter') |
|||
|
|||
var t = new Limiter({concurrency: 2}); |
|||
var results = [] |
|||
|
|||
// add jobs using the familiar Array API |
|||
t.push(function (cb) { |
|||
results.push('two') |
|||
cb() |
|||
}) |
|||
|
|||
t.push( |
|||
function (cb) { |
|||
results.push('four') |
|||
cb() |
|||
}, |
|||
function (cb) { |
|||
results.push('five') |
|||
cb() |
|||
} |
|||
) |
|||
|
|||
t.unshift(function (cb) { |
|||
results.push('one') |
|||
cb() |
|||
}) |
|||
|
|||
t.splice(2, 0, function (cb) { |
|||
results.push('three') |
|||
cb() |
|||
}) |
|||
|
|||
// Jobs run automatically. If you want a callback when all are done, |
|||
// call 'onDone()'. |
|||
t.onDone(function () { |
|||
console.log('all done:', results) |
|||
}) |
|||
``` |
|||
|
|||
## Zlib Example |
|||
|
|||
```js |
|||
const zlib = require('zlib'); |
|||
const Limiter = require('async-limiter'); |
|||
|
|||
const message = {some: "data"}; |
|||
const payload = new Buffer(JSON.stringify(message)); |
|||
|
|||
// Try with different concurrency values to see how this actually |
|||
// slows significantly with higher concurrency! |
|||
// |
|||
// 5: 1398.607ms |
|||
// 10: 1375.668ms |
|||
// Infinity: 4423.300ms |
|||
// |
|||
const t = new Limiter({concurrency: 5}); |
|||
function deflate(payload, cb) { |
|||
t.push(function(done) { |
|||
zlib.deflate(payload, function(err, buffer) { |
|||
done(); |
|||
cb(err, buffer); |
|||
}); |
|||
}); |
|||
} |
|||
|
|||
console.time('deflate'); |
|||
for(let i = 0; i < 30000; ++i) { |
|||
deflate(payload, function (err, buffer) {}); |
|||
} |
|||
q.onDone(function() { |
|||
console.timeEnd('deflate'); |
|||
}); |
|||
``` |
|||
|
|||
## Install |
|||
|
|||
`npm install async-limiter` |
|||
|
|||
## Test |
|||
|
|||
`npm test` |
|||
|
|||
## API |
|||
|
|||
### `var t = new Limiter([opts])` |
|||
Constructor. `opts` may contain inital values for: |
|||
* `q.concurrency` |
|||
|
|||
## Instance methods |
|||
|
|||
### `q.onDone(fn)` |
|||
`fn` will be called once and only once, when the queue is empty. |
|||
|
|||
## Instance methods mixed in from `Array` |
|||
Mozilla has docs on how these methods work [here](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array). |
|||
### `q.push(element1, ..., elementN)` |
|||
### `q.unshift(element1, ..., elementN)` |
|||
### `q.splice(index , howMany[, element1[, ...[, elementN]]])` |
|||
|
|||
## Properties |
|||
### `q.concurrency` |
|||
Max number of jobs the queue should process concurrently, defaults to `Infinity`. |
|||
|
|||
### `q.length` |
|||
Jobs pending + jobs to process (readonly). |
|||
|
@ -0,0 +1,3 @@ |
|||
src |
|||
test |
|||
node_modules |
@ -0,0 +1,60 @@ |
|||
# babel-code-frame |
|||
|
|||
> Generate errors that contain a code frame that point to source locations. |
|||
|
|||
## Install |
|||
|
|||
```sh |
|||
npm install --save-dev babel-code-frame |
|||
``` |
|||
|
|||
## Usage |
|||
|
|||
```js |
|||
import codeFrame from 'babel-code-frame'; |
|||
|
|||
const rawLines = `class Foo { |
|||
constructor() |
|||
}`; |
|||
const lineNumber = 2; |
|||
const colNumber = 16; |
|||
|
|||
const result = codeFrame(rawLines, lineNumber, colNumber, { /* options */ }); |
|||
|
|||
console.log(result); |
|||
``` |
|||
|
|||
```sh |
|||
1 | class Foo { |
|||
> 2 | constructor() |
|||
| ^ |
|||
3 | } |
|||
``` |
|||
|
|||
If the column number is not known, you may pass `null` instead. |
|||
|
|||
## Options |
|||
|
|||
### `highlightCode` |
|||
|
|||
`boolean`, defaults to `false`. |
|||
|
|||
Toggles syntax highlighting the code as JavaScript for terminals. |
|||
|
|||
### `linesAbove` |
|||
|
|||
`number`, defaults to `2`. |
|||
|
|||
Adjust the number of lines to show above the error. |
|||
|
|||
### `linesBelow` |
|||
|
|||
`number`, defaults to `3`. |
|||
|
|||
Adjust the number of lines to show below the error. |
|||
|
|||
### `forceColor` |
|||
|
|||
`boolean`, defaults to `false`. |
|||
|
|||
Enable this to forcibly syntax highlight the code as JavaScript (for non-terminals); overrides `highlightCode`. |
@ -0,0 +1,141 @@ |
|||
"use strict"; |
|||
|
|||
exports.__esModule = true; |
|||
|
|||
exports.default = function (rawLines, lineNumber, colNumber) { |
|||
var opts = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : {}; |
|||
|
|||
colNumber = Math.max(colNumber, 0); |
|||
|
|||
var highlighted = opts.highlightCode && _chalk2.default.supportsColor || opts.forceColor; |
|||
var chalk = _chalk2.default; |
|||
if (opts.forceColor) { |
|||
chalk = new _chalk2.default.constructor({ enabled: true }); |
|||
} |
|||
var maybeHighlight = function maybeHighlight(chalkFn, string) { |
|||
return highlighted ? chalkFn(string) : string; |
|||
}; |
|||
var defs = getDefs(chalk); |
|||
if (highlighted) rawLines = highlight(defs, rawLines); |
|||
|
|||
var linesAbove = opts.linesAbove || 2; |
|||
var linesBelow = opts.linesBelow || 3; |
|||
|
|||
var lines = rawLines.split(NEWLINE); |
|||
var start = Math.max(lineNumber - (linesAbove + 1), 0); |
|||
var end = Math.min(lines.length, lineNumber + linesBelow); |
|||
|
|||
if (!lineNumber && !colNumber) { |
|||
start = 0; |
|||
end = lines.length; |
|||
} |
|||
|
|||
var numberMaxWidth = String(end).length; |
|||
|
|||
var frame = lines.slice(start, end).map(function (line, index) { |
|||
var number = start + 1 + index; |
|||
var paddedNumber = (" " + number).slice(-numberMaxWidth); |
|||
var gutter = " " + paddedNumber + " | "; |
|||
if (number === lineNumber) { |
|||
var markerLine = ""; |
|||
if (colNumber) { |
|||
var markerSpacing = line.slice(0, colNumber - 1).replace(/[^\t]/g, " "); |
|||
markerLine = ["\n ", maybeHighlight(defs.gutter, gutter.replace(/\d/g, " ")), markerSpacing, maybeHighlight(defs.marker, "^")].join(""); |
|||
} |
|||
return [maybeHighlight(defs.marker, ">"), maybeHighlight(defs.gutter, gutter), line, markerLine].join(""); |
|||
} else { |
|||
return " " + maybeHighlight(defs.gutter, gutter) + line; |
|||
} |
|||
}).join("\n"); |
|||
|
|||
if (highlighted) { |
|||
return chalk.reset(frame); |
|||
} else { |
|||
return frame; |
|||
} |
|||
}; |
|||
|
|||
var _jsTokens = require("js-tokens"); |
|||
|
|||
var _jsTokens2 = _interopRequireDefault(_jsTokens); |
|||
|
|||
var _esutils = require("esutils"); |
|||
|
|||
var _esutils2 = _interopRequireDefault(_esutils); |
|||
|
|||
var _chalk = require("chalk"); |
|||
|
|||
var _chalk2 = _interopRequireDefault(_chalk); |
|||
|
|||
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } |
|||
|
|||
function getDefs(chalk) { |
|||
return { |
|||
keyword: chalk.cyan, |
|||
capitalized: chalk.yellow, |
|||
jsx_tag: chalk.yellow, |
|||
punctuator: chalk.yellow, |
|||
|
|||
number: chalk.magenta, |
|||
string: chalk.green, |
|||
regex: chalk.magenta, |
|||
comment: chalk.grey, |
|||
invalid: chalk.white.bgRed.bold, |
|||
gutter: chalk.grey, |
|||
marker: chalk.red.bold |
|||
}; |
|||
} |
|||
|
|||
var NEWLINE = /\r\n|[\n\r\u2028\u2029]/; |
|||
|
|||
var JSX_TAG = /^[a-z][\w-]*$/i; |
|||
|
|||
var BRACKET = /^[()\[\]{}]$/; |
|||
|
|||
function getTokenType(match) { |
|||
var _match$slice = match.slice(-2), |
|||
offset = _match$slice[0], |
|||
text = _match$slice[1]; |
|||
|
|||
var token = (0, _jsTokens.matchToToken)(match); |
|||
|
|||
if (token.type === "name") { |
|||
if (_esutils2.default.keyword.isReservedWordES6(token.value)) { |
|||
return "keyword"; |
|||
} |
|||
|
|||
if (JSX_TAG.test(token.value) && (text[offset - 1] === "<" || text.substr(offset - 2, 2) == "</")) { |
|||
return "jsx_tag"; |
|||
} |
|||
|
|||
if (token.value[0] !== token.value[0].toLowerCase()) { |
|||
return "capitalized"; |
|||
} |
|||
} |
|||
|
|||
if (token.type === "punctuator" && BRACKET.test(token.value)) { |
|||
return "bracket"; |
|||
} |
|||
|
|||
return token.type; |
|||
} |
|||
|
|||
function highlight(defs, text) { |
|||
return text.replace(_jsTokens2.default, function () { |
|||
for (var _len = arguments.length, args = Array(_len), _key = 0; _key < _len; _key++) { |
|||
args[_key] = arguments[_key]; |
|||
} |
|||
|
|||
var type = getTokenType(args); |
|||
var colorize = defs[type]; |
|||
if (colorize) { |
|||
return args[0].split(NEWLINE).map(function (str) { |
|||
return colorize(str); |
|||
}).join("\n"); |
|||
} else { |
|||
return args[0]; |
|||
} |
|||
}); |
|||
} |
|||
|
|||
module.exports = exports["default"]; |
@ -0,0 +1,66 @@ |
|||
{ |
|||
"name": "babel-code-frame", |
|||
"version": "6.22.0", |
|||
"lockfileVersion": 1, |
|||
"requires": true, |
|||
"dependencies": { |
|||
"ansi-regex": { |
|||
"version": "2.1.1", |
|||
"resolved": "https://registry.npmjs.org/ansi-regex/-/ansi-regex-2.1.1.tgz", |
|||
"integrity": "sha1-w7M6te42DYbg5ijwRorn7yfWVN8=" |
|||
}, |
|||
"ansi-styles": { |
|||
"version": "2.2.1", |
|||
"resolved": "https://registry.npmjs.org/ansi-styles/-/ansi-styles-2.2.1.tgz", |
|||
"integrity": "sha1-tDLdM1i2NM914eRmQ2gkBTPB3b4=" |
|||
}, |
|||
"chalk": { |
|||
"version": "1.1.3", |
|||
"resolved": "https://registry.npmjs.org/chalk/-/chalk-1.1.3.tgz", |
|||
"integrity": "sha1-qBFcVeSnAv5NFQq9OHKCKn4J/Jg=", |
|||
"requires": { |
|||
"ansi-styles": "2.2.1", |
|||
"escape-string-regexp": "1.0.5", |
|||
"has-ansi": "2.0.0", |
|||
"strip-ansi": "3.0.1", |
|||
"supports-color": "2.0.0" |
|||
} |
|||
}, |
|||
"escape-string-regexp": { |
|||
"version": "1.0.5", |
|||
"resolved": "https://registry.npmjs.org/escape-string-regexp/-/escape-string-regexp-1.0.5.tgz", |
|||
"integrity": "sha1-G2HAViGQqN/2rjuyzwIAyhMLhtQ=" |
|||
}, |
|||
"esutils": { |
|||
"version": "2.0.2", |
|||
"resolved": "https://registry.npmjs.org/esutils/-/esutils-2.0.2.tgz", |
|||
"integrity": "sha1-Cr9PHKpbyx96nYrMbepPqqBLrJs=" |
|||
}, |
|||
"has-ansi": { |
|||
"version": "2.0.0", |
|||
"resolved": "https://registry.npmjs.org/has-ansi/-/has-ansi-2.0.0.tgz", |
|||
"integrity": "sha1-NPUEnOHs3ysGSa8+8k5F7TVBbZE=", |
|||
"requires": { |
|||
"ansi-regex": "2.1.1" |
|||
} |
|||
}, |
|||
"js-tokens": { |
|||
"version": "3.0.2", |
|||
"resolved": "https://registry.npmjs.org/js-tokens/-/js-tokens-3.0.2.tgz", |
|||
"integrity": "sha1-mGbfOVECEw449/mWvOtlRDIJwls=" |
|||
}, |
|||
"strip-ansi": { |
|||
"version": "3.0.1", |
|||
"resolved": "https://registry.npmjs.org/strip-ansi/-/strip-ansi-3.0.1.tgz", |
|||
"integrity": "sha1-ajhfuIU9lS1f8F0Oiq+UJ43GPc8=", |
|||
"requires": { |
|||
"ansi-regex": "2.1.1" |
|||
} |
|||
}, |
|||
"supports-color": { |
|||
"version": "2.0.0", |
|||
"resolved": "https://registry.npmjs.org/supports-color/-/supports-color-2.0.0.tgz", |
|||
"integrity": "sha1-U10EXOa2Nj+kARcIRimZXp3zJMc=" |
|||
} |
|||
} |
|||
} |
@ -0,0 +1,46 @@ |
|||
{ |
|||
"_from": "babel-code-frame@^6.26.0", |
|||
"_id": "babel-code-frame@6.26.0", |
|||
"_inBundle": false, |
|||
"_integrity": "sha1-Y/1D99weO7fONZR9uP42mj9Yx0s=", |
|||
"_location": "/babel-code-frame", |
|||
"_phantomChildren": {}, |
|||
"_requested": { |
|||
"type": "range", |
|||
"registry": true, |
|||
"raw": "babel-code-frame@^6.26.0", |
|||
"name": "babel-code-frame", |
|||
"escapedName": "babel-code-frame", |
|||
"rawSpec": "^6.26.0", |
|||
"saveSpec": null, |
|||
"fetchSpec": "^6.26.0" |
|||
}, |
|||
"_requiredBy": [ |
|||
"/babel-traverse" |
|||
], |
|||
"_resolved": "https://registry.npmjs.org/babel-code-frame/-/babel-code-frame-6.26.0.tgz", |
|||
"_shasum": "63fd43f7dc1e3bb7ce35947db8fe369a3f58c74b", |
|||
"_spec": "babel-code-frame@^6.26.0", |
|||
"_where": "/var/www/htdocs/coze/socket/node_modules/babel-traverse", |
|||
"author": { |
|||
"name": "Sebastian McKenzie", |
|||
"email": "sebmck@gmail.com" |
|||
}, |
|||
"bundleDependencies": false, |
|||
"dependencies": { |
|||
"chalk": "^1.1.3", |
|||
"esutils": "^2.0.2", |
|||
"js-tokens": "^3.0.2" |
|||
}, |
|||
"deprecated": false, |
|||
"description": "Generate errors that contain a code frame that point to source locations.", |
|||
"homepage": "https://babeljs.io/", |
|||
"license": "MIT", |
|||
"main": "lib/index.js", |
|||
"name": "babel-code-frame", |
|||
"repository": { |
|||
"type": "git", |
|||
"url": "https://github.com/babel/babel/tree/master/packages/babel-code-frame" |
|||
}, |
|||
"version": "6.26.0" |
|||
} |
@ -0,0 +1,3 @@ |
|||
src |
|||
test |
|||
node_modules |
@ -0,0 +1,5 @@ |
|||
# babel-helper-function-name |
|||
|
|||
## Usage |
|||
|
|||
TODO |
@ -0,0 +1,133 @@ |
|||
"use strict"; |
|||
|
|||
exports.__esModule = true; |
|||
|
|||
exports.default = function (_ref) { |
|||
var node = _ref.node, |
|||
parent = _ref.parent, |
|||
scope = _ref.scope, |
|||
id = _ref.id; |
|||
|
|||
if (node.id) return; |
|||
|
|||
if ((t.isObjectProperty(parent) || t.isObjectMethod(parent, { kind: "method" })) && (!parent.computed || t.isLiteral(parent.key))) { |
|||
id = parent.key; |
|||
} else if (t.isVariableDeclarator(parent)) { |
|||
id = parent.id; |
|||
|
|||
if (t.isIdentifier(id)) { |
|||
var binding = scope.parent.getBinding(id.name); |
|||
if (binding && binding.constant && scope.getBinding(id.name) === binding) { |
|||
node.id = id; |
|||
node.id[t.NOT_LOCAL_BINDING] = true; |
|||
return; |
|||
} |
|||
} |
|||
} else if (t.isAssignmentExpression(parent)) { |
|||
id = parent.left; |
|||
} else if (!id) { |
|||
return; |
|||
} |
|||
|
|||
var name = void 0; |
|||
if (id && t.isLiteral(id)) { |
|||
name = id.value; |
|||
} else if (id && t.isIdentifier(id)) { |
|||
name = id.name; |
|||
} else { |
|||
return; |
|||
} |
|||
|
|||
name = t.toBindingIdentifierName(name); |
|||
id = t.identifier(name); |
|||
|
|||
id[t.NOT_LOCAL_BINDING] = true; |
|||
|
|||
var state = visit(node, name, scope); |
|||
return wrap(state, node, id, scope) || node; |
|||
}; |
|||
|
|||
var _babelHelperGetFunctionArity = require("babel-helper-get-function-arity"); |
|||
|
|||
var _babelHelperGetFunctionArity2 = _interopRequireDefault(_babelHelperGetFunctionArity); |
|||
|
|||
var _babelTemplate = require("babel-template"); |
|||
|
|||
var _babelTemplate2 = _interopRequireDefault(_babelTemplate); |
|||
|
|||
var _babelTypes = require("babel-types"); |
|||
|
|||
var t = _interopRequireWildcard(_babelTypes); |
|||
|
|||
function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } else { var newObj = {}; if (obj != null) { for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) newObj[key] = obj[key]; } } newObj.default = obj; return newObj; } } |
|||
|
|||
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } |
|||
|
|||
var buildPropertyMethodAssignmentWrapper = (0, _babelTemplate2.default)("\n (function (FUNCTION_KEY) {\n function FUNCTION_ID() {\n return FUNCTION_KEY.apply(this, arguments);\n }\n\n FUNCTION_ID.toString = function () {\n return FUNCTION_KEY.toString();\n }\n\n return FUNCTION_ID;\n })(FUNCTION)\n"); |
|||
|
|||
var buildGeneratorPropertyMethodAssignmentWrapper = (0, _babelTemplate2.default)("\n (function (FUNCTION_KEY) {\n function* FUNCTION_ID() {\n return yield* FUNCTION_KEY.apply(this, arguments);\n }\n\n FUNCTION_ID.toString = function () {\n return FUNCTION_KEY.toString();\n };\n\n return FUNCTION_ID;\n })(FUNCTION)\n"); |
|||
|
|||
var visitor = { |
|||
"ReferencedIdentifier|BindingIdentifier": function ReferencedIdentifierBindingIdentifier(path, state) { |
|||
if (path.node.name !== state.name) return; |
|||
|
|||
var localDeclar = path.scope.getBindingIdentifier(state.name); |
|||
if (localDeclar !== state.outerDeclar) return; |
|||
|
|||
state.selfReference = true; |
|||
path.stop(); |
|||
} |
|||
}; |
|||
|
|||
function wrap(state, method, id, scope) { |
|||
if (state.selfReference) { |
|||
if (scope.hasBinding(id.name) && !scope.hasGlobal(id.name)) { |
|||
scope.rename(id.name); |
|||
} else { |
|||
if (!t.isFunction(method)) return; |
|||
|
|||
var build = buildPropertyMethodAssignmentWrapper; |
|||
if (method.generator) build = buildGeneratorPropertyMethodAssignmentWrapper; |
|||
var _template = build({ |
|||
FUNCTION: method, |
|||
FUNCTION_ID: id, |
|||
FUNCTION_KEY: scope.generateUidIdentifier(id.name) |
|||
}).expression; |
|||
_template.callee._skipModulesRemap = true; |
|||
|
|||
var params = _template.callee.body.body[0].params; |
|||
for (var i = 0, len = (0, _babelHelperGetFunctionArity2.default)(method); i < len; i++) { |
|||
params.push(scope.generateUidIdentifier("x")); |
|||
} |
|||
|
|||
return _template; |
|||
} |
|||
} |
|||
|
|||
method.id = id; |
|||
scope.getProgramParent().references[id.name] = true; |
|||
} |
|||
|
|||
function visit(node, name, scope) { |
|||
var state = { |
|||
selfAssignment: false, |
|||
selfReference: false, |
|||
outerDeclar: scope.getBindingIdentifier(name), |
|||
references: [], |
|||
name: name |
|||
}; |
|||
|
|||
var binding = scope.getOwnBinding(name); |
|||
|
|||
if (binding) { |
|||
if (binding.kind === "param") { |
|||
state.selfReference = true; |
|||
} else {} |
|||
} else if (state.outerDeclar || scope.hasGlobal(name)) { |
|||
scope.traverse(node, visitor, state); |
|||
} |
|||
|
|||
return state; |
|||
} |
|||
|
|||
module.exports = exports["default"]; |
@ -0,0 +1,43 @@ |
|||
{ |
|||
"_from": "babel-helper-function-name@^6.24.1", |
|||
"_id": "babel-helper-function-name@6.24.1", |
|||
"_inBundle": false, |
|||
"_integrity": "sha1-00dbjAPtmCQqJbSDUasYOZ01gKk=", |
|||
"_location": "/babel-helper-function-name", |
|||
"_phantomChildren": {}, |
|||
"_requested": { |
|||
"type": "range", |
|||
"registry": true, |
|||
"raw": "babel-helper-function-name@^6.24.1", |
|||
"name": "babel-helper-function-name", |
|||
"escapedName": "babel-helper-function-name", |
|||
"rawSpec": "^6.24.1", |
|||
"saveSpec": null, |
|||
"fetchSpec": "^6.24.1" |
|||
}, |
|||
"_requiredBy": [ |
|||
"/babel-plugin-transform-class-properties" |
|||
], |
|||
"_resolved": "https://registry.npmjs.org/babel-helper-function-name/-/babel-helper-function-name-6.24.1.tgz", |
|||
"_shasum": "d3475b8c03ed98242a25b48351ab18399d3580a9", |
|||
"_spec": "babel-helper-function-name@^6.24.1", |
|||
"_where": "/var/www/htdocs/coze/socket/node_modules/babel-plugin-transform-class-properties", |
|||
"bundleDependencies": false, |
|||
"dependencies": { |
|||
"babel-helper-get-function-arity": "^6.24.1", |
|||
"babel-runtime": "^6.22.0", |
|||
"babel-template": "^6.24.1", |
|||
"babel-traverse": "^6.24.1", |
|||
"babel-types": "^6.24.1" |
|||
}, |
|||
"deprecated": false, |
|||
"description": "Helper function to change the property 'name' of every function", |
|||
"license": "MIT", |
|||
"main": "lib/index.js", |
|||
"name": "babel-helper-function-name", |
|||
"repository": { |
|||
"type": "git", |
|||
"url": "https://github.com/babel/babel/tree/master/packages/babel-helper-function-name" |
|||
}, |
|||
"version": "6.24.1" |
|||
} |
@ -0,0 +1,3 @@ |
|||
src |
|||
test |
|||
node_modules |
@ -0,0 +1,5 @@ |
|||
# babel-helper-get-function-arity |
|||
|
|||
## Usage |
|||
|
|||
TODO |
@ -0,0 +1,22 @@ |
|||
"use strict"; |
|||
|
|||
exports.__esModule = true; |
|||
|
|||
exports.default = function (node) { |
|||
var params = node.params; |
|||
for (var i = 0; i < params.length; i++) { |
|||
var param = params[i]; |
|||
if (t.isAssignmentPattern(param) || t.isRestElement(param)) { |
|||
return i; |
|||
} |
|||
} |
|||
return params.length; |
|||
}; |
|||
|
|||
var _babelTypes = require("babel-types"); |
|||
|
|||
var t = _interopRequireWildcard(_babelTypes); |
|||
|
|||
function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } else { var newObj = {}; if (obj != null) { for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) newObj[key] = obj[key]; } } newObj.default = obj; return newObj; } } |
|||
|
|||
module.exports = exports["default"]; |
@ -0,0 +1,40 @@ |
|||
{ |
|||
"_from": "babel-helper-get-function-arity@^6.24.1", |
|||
"_id": "babel-helper-get-function-arity@6.24.1", |
|||
"_inBundle": false, |
|||
"_integrity": "sha1-j3eCqpNAfEHTqlCQj4mwMbG2hT0=", |
|||
"_location": "/babel-helper-get-function-arity", |
|||
"_phantomChildren": {}, |
|||
"_requested": { |
|||
"type": "range", |
|||
"registry": true, |
|||
"raw": "babel-helper-get-function-arity@^6.24.1", |
|||
"name": "babel-helper-get-function-arity", |
|||
"escapedName": "babel-helper-get-function-arity", |
|||
"rawSpec": "^6.24.1", |
|||
"saveSpec": null, |
|||
"fetchSpec": "^6.24.1" |
|||
}, |
|||
"_requiredBy": [ |
|||
"/babel-helper-function-name" |
|||
], |
|||
"_resolved": "https://registry.npmjs.org/babel-helper-get-function-arity/-/babel-helper-get-function-arity-6.24.1.tgz", |
|||
"_shasum": "8f7782aa93407c41d3aa50908f89b031b1b6853d", |
|||
"_spec": "babel-helper-get-function-arity@^6.24.1", |
|||
"_where": "/var/www/htdocs/coze/socket/node_modules/babel-helper-function-name", |
|||
"bundleDependencies": false, |
|||
"dependencies": { |
|||
"babel-runtime": "^6.22.0", |
|||
"babel-types": "^6.24.1" |
|||
}, |
|||
"deprecated": false, |
|||
"description": "Helper function to get function arity", |
|||
"license": "MIT", |
|||
"main": "lib/index.js", |
|||
"name": "babel-helper-get-function-arity", |
|||
"repository": { |
|||
"type": "git", |
|||
"url": "https://github.com/babel/babel/tree/master/packages/babel-helper-get-function-arity" |
|||
}, |
|||
"version": "6.24.1" |
|||
} |
@ -0,0 +1,3 @@ |
|||
src |
|||
test |
|||
node_modules |
@ -0,0 +1,18 @@ |
|||
# babel-messages |
|||
|
|||
> Collection of debug messages used by Babel. |
|||
|
|||
## Install |
|||
|
|||
```sh |
|||
npm install --save-dev babel-messages |
|||
``` |
|||
|
|||
## Usage |
|||
|
|||
```js |
|||
import * as messages from 'babel-messages'; |
|||
|
|||
messages.get('tailCallReassignmentDeopt'); |
|||
// > "Function reference has been..." |
|||
``` |
@ -0,0 +1,84 @@ |
|||
"use strict"; |
|||
|
|||
exports.__esModule = true; |
|||
exports.MESSAGES = undefined; |
|||
|
|||
var _stringify = require("babel-runtime/core-js/json/stringify"); |
|||
|
|||
var _stringify2 = _interopRequireDefault(_stringify); |
|||
|
|||
exports.get = get; |
|||
exports.parseArgs = parseArgs; |
|||
|
|||
var _util = require("util"); |
|||
|
|||
var util = _interopRequireWildcard(_util); |
|||
|
|||
function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } else { var newObj = {}; if (obj != null) { for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) newObj[key] = obj[key]; } } newObj.default = obj; return newObj; } } |
|||
|
|||
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } |
|||
|
|||
var MESSAGES = exports.MESSAGES = { |
|||
tailCallReassignmentDeopt: "Function reference has been reassigned, so it will probably be dereferenced, therefore we can't optimise this with confidence", |
|||
classesIllegalBareSuper: "Illegal use of bare super", |
|||
classesIllegalSuperCall: "Direct super call is illegal in non-constructor, use super.$1() instead", |
|||
scopeDuplicateDeclaration: "Duplicate declaration $1", |
|||
settersNoRest: "Setters aren't allowed to have a rest", |
|||
noAssignmentsInForHead: "No assignments allowed in for-in/of head", |
|||
expectedMemberExpressionOrIdentifier: "Expected type MemberExpression or Identifier", |
|||
invalidParentForThisNode: "We don't know how to handle this node within the current parent - please open an issue", |
|||
readOnly: "$1 is read-only", |
|||
unknownForHead: "Unknown node type $1 in ForStatement", |
|||
didYouMean: "Did you mean $1?", |
|||
codeGeneratorDeopt: "Note: The code generator has deoptimised the styling of $1 as it exceeds the max of $2.", |
|||
missingTemplatesDirectory: "no templates directory - this is most likely the result of a broken `npm publish`. Please report to https://github.com/babel/babel/issues", |
|||
unsupportedOutputType: "Unsupported output type $1", |
|||
illegalMethodName: "Illegal method name $1", |
|||
lostTrackNodePath: "We lost track of this node's position, likely because the AST was directly manipulated", |
|||
|
|||
modulesIllegalExportName: "Illegal export $1", |
|||
modulesDuplicateDeclarations: "Duplicate module declarations with the same source but in different scopes", |
|||
|
|||
undeclaredVariable: "Reference to undeclared variable $1", |
|||
undeclaredVariableType: "Referencing a type alias outside of a type annotation", |
|||
undeclaredVariableSuggestion: "Reference to undeclared variable $1 - did you mean $2?", |
|||
|
|||
traverseNeedsParent: "You must pass a scope and parentPath unless traversing a Program/File. Instead of that you tried to traverse a $1 node without passing scope and parentPath.", |
|||
traverseVerifyRootFunction: "You passed `traverse()` a function when it expected a visitor object, are you sure you didn't mean `{ enter: Function }`?", |
|||
traverseVerifyVisitorProperty: "You passed `traverse()` a visitor object with the property $1 that has the invalid property $2", |
|||
traverseVerifyNodeType: "You gave us a visitor for the node type $1 but it's not a valid type", |
|||
|
|||
pluginNotObject: "Plugin $2 specified in $1 was expected to return an object when invoked but returned $3", |
|||
pluginNotFunction: "Plugin $2 specified in $1 was expected to return a function but returned $3", |
|||
pluginUnknown: "Unknown plugin $1 specified in $2 at $3, attempted to resolve relative to $4", |
|||
pluginInvalidProperty: "Plugin $2 specified in $1 provided an invalid property of $3" |
|||
}; |
|||
|
|||
function get(key) { |
|||
for (var _len = arguments.length, args = Array(_len > 1 ? _len - 1 : 0), _key = 1; _key < _len; _key++) { |
|||
args[_key - 1] = arguments[_key]; |
|||
} |
|||
|
|||
var msg = MESSAGES[key]; |
|||
if (!msg) throw new ReferenceError("Unknown message " + (0, _stringify2.default)(key)); |
|||
|
|||
args = parseArgs(args); |
|||
|
|||
return msg.replace(/\$(\d+)/g, function (str, i) { |
|||
return args[i - 1]; |
|||
}); |
|||
} |
|||
|
|||
function parseArgs(args) { |
|||
return args.map(function (val) { |
|||
if (val != null && val.inspect) { |
|||
return val.inspect(); |
|||
} else { |
|||
try { |
|||
return (0, _stringify2.default)(val) || val + ""; |
|||
} catch (e) { |
|||
return util.inspect(val); |
|||
} |
|||
} |
|||
}); |
|||
} |
@ -0,0 +1,44 @@ |
|||
{ |
|||
"_from": "babel-messages@^6.23.0", |
|||
"_id": "babel-messages@6.23.0", |
|||
"_inBundle": false, |
|||
"_integrity": "sha1-8830cDhYA1sqKVHG7F7fbGLyYw4=", |
|||
"_location": "/babel-messages", |
|||
"_phantomChildren": {}, |
|||
"_requested": { |
|||
"type": "range", |
|||
"registry": true, |
|||
"raw": "babel-messages@^6.23.0", |
|||
"name": "babel-messages", |
|||
"escapedName": "babel-messages", |
|||
"rawSpec": "^6.23.0", |
|||
"saveSpec": null, |
|||
"fetchSpec": "^6.23.0" |
|||
}, |
|||
"_requiredBy": [ |
|||
"/babel-traverse" |
|||
], |
|||
"_resolved": "https://registry.npmjs.org/babel-messages/-/babel-messages-6.23.0.tgz", |
|||
"_shasum": "f3cdf4703858035b2a2951c6ec5edf6c62f2630e", |
|||
"_spec": "babel-messages@^6.23.0", |
|||
"_where": "/var/www/htdocs/coze/socket/node_modules/babel-traverse", |
|||
"author": { |
|||
"name": "Sebastian McKenzie", |
|||
"email": "sebmck@gmail.com" |
|||
}, |
|||
"bundleDependencies": false, |
|||
"dependencies": { |
|||
"babel-runtime": "^6.22.0" |
|||
}, |
|||
"deprecated": false, |
|||
"description": "Collection of debug messages used by Babel.", |
|||
"homepage": "https://babeljs.io/", |
|||
"license": "MIT", |
|||
"main": "lib/index.js", |
|||
"name": "babel-messages", |
|||
"repository": { |
|||
"type": "git", |
|||
"url": "https://github.com/babel/babel/tree/master/packages/babel-messages" |
|||
}, |
|||
"version": "6.23.0" |
|||
} |
@ -0,0 +1,3 @@ |
|||
node_modules |
|||
*.log |
|||
src |
@ -0,0 +1,35 @@ |
|||
# babel-plugin-syntax-class-properties |
|||
|
|||
Allow parsing of class properties. |
|||
|
|||
## Installation |
|||
|
|||
```sh |
|||
$ npm install babel-plugin-syntax-class-properties |
|||
``` |
|||
|
|||
## Usage |
|||
|
|||
### Via `.babelrc` (Recommended) |
|||
|
|||
**.babelrc** |
|||
|
|||
```json |
|||
{ |
|||
"plugins": ["syntax-class-properties"] |
|||
} |
|||
``` |
|||
|
|||
### Via CLI |
|||
|
|||
```sh |
|||
$ babel --plugins syntax-class-properties script.js |
|||
``` |
|||
|
|||
### Via Node API |
|||
|
|||
```javascript |
|||
require("babel-core").transform("code", { |
|||
plugins: ["syntax-class-properties"] |
|||
}); |
|||
``` |
@ -0,0 +1,13 @@ |
|||
"use strict"; |
|||
|
|||
exports.__esModule = true; |
|||
|
|||
exports.default = function () { |
|||
return { |
|||
manipulateOptions: function manipulateOptions(opts, parserOpts) { |
|||
parserOpts.plugins.push("classProperties"); |
|||
} |
|||
}; |
|||
}; |
|||
|
|||
module.exports = exports["default"]; |
@ -0,0 +1,41 @@ |
|||
{ |
|||
"_from": "babel-plugin-syntax-class-properties@^6.8.0", |
|||
"_id": "babel-plugin-syntax-class-properties@6.13.0", |
|||
"_inBundle": false, |
|||
"_integrity": "sha1-1+sjt5oxf4VDlixQW4J8fWysJ94=", |
|||
"_location": "/babel-plugin-syntax-class-properties", |
|||
"_phantomChildren": {}, |
|||
"_requested": { |
|||
"type": "range", |
|||
"registry": true, |
|||
"raw": "babel-plugin-syntax-class-properties@^6.8.0", |
|||
"name": "babel-plugin-syntax-class-properties", |
|||
"escapedName": "babel-plugin-syntax-class-properties", |
|||
"rawSpec": "^6.8.0", |
|||
"saveSpec": null, |
|||
"fetchSpec": "^6.8.0" |
|||
}, |
|||
"_requiredBy": [ |
|||
"/babel-plugin-transform-class-properties" |
|||
], |
|||
"_resolved": "https://registry.npmjs.org/babel-plugin-syntax-class-properties/-/babel-plugin-syntax-class-properties-6.13.0.tgz", |
|||
"_shasum": "d7eb23b79a317f8543962c505b827c7d6cac27de", |
|||
"_spec": "babel-plugin-syntax-class-properties@^6.8.0", |
|||
"_where": "/var/www/htdocs/coze/socket/node_modules/babel-plugin-transform-class-properties", |
|||
"bundleDependencies": false, |
|||
"dependencies": {}, |
|||
"deprecated": false, |
|||
"description": "Allow parsing of class properties", |
|||
"devDependencies": {}, |
|||
"keywords": [ |
|||
"babel-plugin" |
|||
], |
|||
"license": "MIT", |
|||
"main": "lib/index.js", |
|||
"name": "babel-plugin-syntax-class-properties", |
|||
"repository": { |
|||
"type": "git", |
|||
"url": "https://github.com/babel/babel/tree/master/packages/babel-plugin-syntax-class-properties" |
|||
}, |
|||
"version": "6.13.0" |
|||
} |
@ -0,0 +1,4 @@ |
|||
node_modules |
|||
*.log |
|||
src |
|||
test |
@ -0,0 +1,87 @@ |
|||
# babel-plugin-transform-class-properties |
|||
|
|||
> This plugin transforms es2015 static class properties as well as properties declared with the es2016 property initializer syntax. |
|||
|
|||
## Example |
|||
|
|||
Below is a class with four class properties which will be transformed. |
|||
|
|||
```js |
|||
class Bork { |
|||
//Property initializer syntax |
|||
instanceProperty = "bork"; |
|||
boundFunction = () => { |
|||
return this.instanceProperty; |
|||
} |
|||
|
|||
//Static class properties |
|||
static staticProperty = "babelIsCool"; |
|||
static staticFunction = function() { |
|||
return Bork.staticProperty; |
|||
} |
|||
} |
|||
|
|||
let myBork = new Bork; |
|||
|
|||
//Property initializers are not on the prototype. |
|||
console.log(myBork.prototype.boundFunction); // > undefined |
|||
|
|||
//Bound functions are bound to the class instance. |
|||
console.log(myBork.boundFunction.call(undefined)); // > "bork" |
|||
|
|||
//Static function exists on the class. |
|||
console.log(Bork.staticFunction()); // > "babelIsCool" |
|||
``` |
|||
|
|||
|
|||
## Installation |
|||
|
|||
```sh |
|||
npm install --save-dev babel-plugin-transform-class-properties |
|||
``` |
|||
|
|||
## Usage |
|||
|
|||
### Via `.babelrc` (Recommended) |
|||
|
|||
**.babelrc** |
|||
|
|||
```json |
|||
// without options |
|||
{ |
|||
"plugins": ["transform-class-properties"] |
|||
} |
|||
|
|||
// with options |
|||
{ |
|||
"plugins": [ |
|||
["transform-class-properties", { "spec": true }] |
|||
] |
|||
} |
|||
``` |
|||
|
|||
### Via CLI |
|||
|
|||
```sh |
|||
babel --plugins transform-class-properties script.js |
|||
``` |
|||
|
|||
### Via Node API |
|||
|
|||
```javascript |
|||
require("babel-core").transform("code", { |
|||
plugins: ["transform-class-properties"] |
|||
}); |
|||
``` |
|||
|
|||
## Options |
|||
|
|||
### `spec` |
|||
|
|||
`boolean`, defaults to `false`. |
|||
|
|||
Class properties are compiled to use `Object.defineProperty`. Static fields are now defined even if they are not initialized. |
|||
|
|||
## References |
|||
|
|||
* [Proposal: ES Class Fields & Static Properties](https://github.com/jeffmo/es-class-static-properties-and-fields) |
@ -0,0 +1,252 @@ |
|||
"use strict"; |
|||
|
|||
exports.__esModule = true; |
|||
|
|||
var _getIterator2 = require("babel-runtime/core-js/get-iterator"); |
|||
|
|||
var _getIterator3 = _interopRequireDefault(_getIterator2); |
|||
|
|||
exports.default = function (_ref) { |
|||
var t = _ref.types; |
|||
|
|||
var findBareSupers = { |
|||
Super: function Super(path) { |
|||
if (path.parentPath.isCallExpression({ callee: path.node })) { |
|||
this.push(path.parentPath); |
|||
} |
|||
} |
|||
}; |
|||
|
|||
var referenceVisitor = { |
|||
ReferencedIdentifier: function ReferencedIdentifier(path) { |
|||
if (this.scope.hasOwnBinding(path.node.name)) { |
|||
this.collision = true; |
|||
path.skip(); |
|||
} |
|||
} |
|||
}; |
|||
|
|||
var buildObjectDefineProperty = (0, _babelTemplate2.default)("\n Object.defineProperty(REF, KEY, {\n // configurable is false by default\n enumerable: true,\n writable: true,\n value: VALUE\n });\n "); |
|||
|
|||
var buildClassPropertySpec = function buildClassPropertySpec(ref, _ref2) { |
|||
var key = _ref2.key, |
|||
value = _ref2.value, |
|||
computed = _ref2.computed; |
|||
return buildObjectDefineProperty({ |
|||
REF: ref, |
|||
KEY: t.isIdentifier(key) && !computed ? t.stringLiteral(key.name) : key, |
|||
VALUE: value ? value : t.identifier("undefined") |
|||
}); |
|||
}; |
|||
|
|||
var buildClassPropertyNonSpec = function buildClassPropertyNonSpec(ref, _ref3) { |
|||
var key = _ref3.key, |
|||
value = _ref3.value, |
|||
computed = _ref3.computed; |
|||
return t.expressionStatement(t.assignmentExpression("=", t.memberExpression(ref, key, computed || t.isLiteral(key)), value)); |
|||
}; |
|||
|
|||
return { |
|||
inherits: require("babel-plugin-syntax-class-properties"), |
|||
|
|||
visitor: { |
|||
Class: function Class(path, state) { |
|||
var buildClassProperty = state.opts.spec ? buildClassPropertySpec : buildClassPropertyNonSpec; |
|||
var isDerived = !!path.node.superClass; |
|||
var constructor = void 0; |
|||
var props = []; |
|||
var body = path.get("body"); |
|||
|
|||
for (var _iterator = body.get("body"), _isArray = Array.isArray(_iterator), _i = 0, _iterator = _isArray ? _iterator : (0, _getIterator3.default)(_iterator);;) { |
|||
var _ref4; |
|||
|
|||
if (_isArray) { |
|||
if (_i >= _iterator.length) break; |
|||
_ref4 = _iterator[_i++]; |
|||
} else { |
|||
_i = _iterator.next(); |
|||
if (_i.done) break; |
|||
_ref4 = _i.value; |
|||
} |
|||
|
|||
var _path = _ref4; |
|||
|
|||
if (_path.isClassProperty()) { |
|||
props.push(_path); |
|||
} else if (_path.isClassMethod({ kind: "constructor" })) { |
|||
constructor = _path; |
|||
} |
|||
} |
|||
|
|||
if (!props.length) return; |
|||
|
|||
var nodes = []; |
|||
var ref = void 0; |
|||
|
|||
if (path.isClassExpression() || !path.node.id) { |
|||
(0, _babelHelperFunctionName2.default)(path); |
|||
ref = path.scope.generateUidIdentifier("class"); |
|||
} else { |
|||
ref = path.node.id; |
|||
} |
|||
|
|||
var instanceBody = []; |
|||
|
|||
for (var _iterator2 = props, _isArray2 = Array.isArray(_iterator2), _i2 = 0, _iterator2 = _isArray2 ? _iterator2 : (0, _getIterator3.default)(_iterator2);;) { |
|||
var _ref5; |
|||
|
|||
if (_isArray2) { |
|||
if (_i2 >= _iterator2.length) break; |
|||
_ref5 = _iterator2[_i2++]; |
|||
} else { |
|||
_i2 = _iterator2.next(); |
|||
if (_i2.done) break; |
|||
_ref5 = _i2.value; |
|||
} |
|||
|
|||
var _prop = _ref5; |
|||
|
|||
var propNode = _prop.node; |
|||
if (propNode.decorators && propNode.decorators.length > 0) continue; |
|||
|
|||
if (!state.opts.spec && !propNode.value) continue; |
|||
|
|||
var isStatic = propNode.static; |
|||
|
|||
if (isStatic) { |
|||
nodes.push(buildClassProperty(ref, propNode)); |
|||
} else { |
|||
if (!propNode.value) continue; |
|||
instanceBody.push(buildClassProperty(t.thisExpression(), propNode)); |
|||
} |
|||
} |
|||
|
|||
if (instanceBody.length) { |
|||
if (!constructor) { |
|||
var newConstructor = t.classMethod("constructor", t.identifier("constructor"), [], t.blockStatement([])); |
|||
if (isDerived) { |
|||
newConstructor.params = [t.restElement(t.identifier("args"))]; |
|||
newConstructor.body.body.push(t.returnStatement(t.callExpression(t.super(), [t.spreadElement(t.identifier("args"))]))); |
|||
} |
|||
|
|||
var _body$unshiftContaine = body.unshiftContainer("body", newConstructor); |
|||
|
|||
constructor = _body$unshiftContaine[0]; |
|||
} |
|||
|
|||
var collisionState = { |
|||
collision: false, |
|||
scope: constructor.scope |
|||
}; |
|||
|
|||
for (var _iterator3 = props, _isArray3 = Array.isArray(_iterator3), _i3 = 0, _iterator3 = _isArray3 ? _iterator3 : (0, _getIterator3.default)(_iterator3);;) { |
|||
var _ref6; |
|||
|
|||
if (_isArray3) { |
|||
if (_i3 >= _iterator3.length) break; |
|||
_ref6 = _iterator3[_i3++]; |
|||
} else { |
|||
_i3 = _iterator3.next(); |
|||
if (_i3.done) break; |
|||
_ref6 = _i3.value; |
|||
} |
|||
|
|||
var prop = _ref6; |
|||
|
|||
prop.traverse(referenceVisitor, collisionState); |
|||
if (collisionState.collision) break; |
|||
} |
|||
|
|||
if (collisionState.collision) { |
|||
var initialisePropsRef = path.scope.generateUidIdentifier("initialiseProps"); |
|||
|
|||
nodes.push(t.variableDeclaration("var", [t.variableDeclarator(initialisePropsRef, t.functionExpression(null, [], t.blockStatement(instanceBody)))])); |
|||
|
|||
instanceBody = [t.expressionStatement(t.callExpression(t.memberExpression(initialisePropsRef, t.identifier("call")), [t.thisExpression()]))]; |
|||
} |
|||
|
|||
if (isDerived) { |
|||
var bareSupers = []; |
|||
constructor.traverse(findBareSupers, bareSupers); |
|||
for (var _iterator4 = bareSupers, _isArray4 = Array.isArray(_iterator4), _i4 = 0, _iterator4 = _isArray4 ? _iterator4 : (0, _getIterator3.default)(_iterator4);;) { |
|||
var _ref7; |
|||
|
|||
if (_isArray4) { |
|||
if (_i4 >= _iterator4.length) break; |
|||
_ref7 = _iterator4[_i4++]; |
|||
} else { |
|||
_i4 = _iterator4.next(); |
|||
if (_i4.done) break; |
|||
_ref7 = _i4.value; |
|||
} |
|||
|
|||
var bareSuper = _ref7; |
|||
|
|||
bareSuper.insertAfter(instanceBody); |
|||
} |
|||
} else { |
|||
constructor.get("body").unshiftContainer("body", instanceBody); |
|||
} |
|||
} |
|||
|
|||
for (var _iterator5 = props, _isArray5 = Array.isArray(_iterator5), _i5 = 0, _iterator5 = _isArray5 ? _iterator5 : (0, _getIterator3.default)(_iterator5);;) { |
|||
var _ref8; |
|||
|
|||
if (_isArray5) { |
|||
if (_i5 >= _iterator5.length) break; |
|||
_ref8 = _iterator5[_i5++]; |
|||
} else { |
|||
_i5 = _iterator5.next(); |
|||
if (_i5.done) break; |
|||
_ref8 = _i5.value; |
|||
} |
|||
|
|||
var _prop2 = _ref8; |
|||
|
|||
_prop2.remove(); |
|||
} |
|||
|
|||
if (!nodes.length) return; |
|||
|
|||
if (path.isClassExpression()) { |
|||
path.scope.push({ id: ref }); |
|||
path.replaceWith(t.assignmentExpression("=", ref, path.node)); |
|||
} else { |
|||
if (!path.node.id) { |
|||
path.node.id = ref; |
|||
} |
|||
|
|||
if (path.parentPath.isExportDeclaration()) { |
|||
path = path.parentPath; |
|||
} |
|||
} |
|||
|
|||
path.insertAfter(nodes); |
|||
}, |
|||
ArrowFunctionExpression: function ArrowFunctionExpression(path) { |
|||
var classExp = path.get("body"); |
|||
if (!classExp.isClassExpression()) return; |
|||
|
|||
var body = classExp.get("body"); |
|||
var members = body.get("body"); |
|||
if (members.some(function (member) { |
|||
return member.isClassProperty(); |
|||
})) { |
|||
path.ensureBlock(); |
|||
} |
|||
} |
|||
} |
|||
}; |
|||
}; |
|||
|
|||
var _babelHelperFunctionName = require("babel-helper-function-name"); |
|||
|
|||
var _babelHelperFunctionName2 = _interopRequireDefault(_babelHelperFunctionName); |
|||
|
|||
var _babelTemplate = require("babel-template"); |
|||
|
|||
var _babelTemplate2 = _interopRequireDefault(_babelTemplate); |
|||
|
|||
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } |
|||
|
|||
module.exports = exports["default"]; |
@ -0,0 +1,48 @@ |
|||
{ |
|||
"_from": "babel-plugin-transform-class-properties@^6.24.1", |
|||
"_id": "babel-plugin-transform-class-properties@6.24.1", |
|||
"_inBundle": false, |
|||
"_integrity": "sha1-anl2PqYdM9NvN7YRqp3vgagbRqw=", |
|||
"_location": "/babel-plugin-transform-class-properties", |
|||
"_phantomChildren": {}, |
|||
"_requested": { |
|||
"type": "range", |
|||
"registry": true, |
|||
"raw": "babel-plugin-transform-class-properties@^6.24.1", |
|||
"name": "babel-plugin-transform-class-properties", |
|||
"escapedName": "babel-plugin-transform-class-properties", |
|||
"rawSpec": "^6.24.1", |
|||
"saveSpec": null, |
|||
"fetchSpec": "^6.24.1" |
|||
}, |
|||
"_requiredBy": [ |
|||
"/pillarjs" |
|||
], |
|||
"_resolved": "https://registry.npmjs.org/babel-plugin-transform-class-properties/-/babel-plugin-transform-class-properties-6.24.1.tgz", |
|||
"_shasum": "6a79763ea61d33d36f37b611aa9def81a81b46ac", |
|||
"_spec": "babel-plugin-transform-class-properties@^6.24.1", |
|||
"_where": "/var/www/htdocs/coze/socket/node_modules/pillarjs", |
|||
"bundleDependencies": false, |
|||
"dependencies": { |
|||
"babel-helper-function-name": "^6.24.1", |
|||
"babel-plugin-syntax-class-properties": "^6.8.0", |
|||
"babel-runtime": "^6.22.0", |
|||
"babel-template": "^6.24.1" |
|||
}, |
|||
"deprecated": false, |
|||
"description": "This plugin transforms static class properties as well as properties declared with the property initializer syntax", |
|||
"devDependencies": { |
|||
"babel-helper-plugin-test-runner": "^6.24.1" |
|||
}, |
|||
"keywords": [ |
|||
"babel-plugin" |
|||
], |
|||
"license": "MIT", |
|||
"main": "lib/index.js", |
|||
"name": "babel-plugin-transform-class-properties", |
|||
"repository": { |
|||
"type": "git", |
|||
"url": "https://github.com/babel/babel/tree/master/packages/babel-plugin-transform-class-properties" |
|||
}, |
|||
"version": "6.24.1" |
|||
} |
@ -0,0 +1,2 @@ |
|||
scripts |
|||
node_modules |
@ -0,0 +1,2 @@ |
|||
# babel-runtime |
|||
|
@ -0,0 +1,4 @@ |
|||
module.exports = { |
|||
"default": require("core-js/library"), |
|||
__esModule: true |
|||
}; |
@ -0,0 +1 @@ |
|||
module.exports = { "default": require("core-js/library/fn/array/concat"), __esModule: true }; |
@ -0,0 +1 @@ |
|||
module.exports = { "default": require("core-js/library/fn/array/copy-within"), __esModule: true }; |
@ -0,0 +1 @@ |
|||
module.exports = { "default": require("core-js/library/fn/array/entries"), __esModule: true }; |
@ -0,0 +1 @@ |
|||
module.exports = { "default": require("core-js/library/fn/array/every"), __esModule: true }; |
@ -0,0 +1 @@ |
|||
module.exports = { "default": require("core-js/library/fn/array/fill"), __esModule: true }; |
@ -0,0 +1 @@ |
|||
module.exports = { "default": require("core-js/library/fn/array/filter"), __esModule: true }; |
@ -0,0 +1 @@ |
|||
module.exports = { "default": require("core-js/library/fn/array/find-index"), __esModule: true }; |
@ -0,0 +1 @@ |
|||
module.exports = { "default": require("core-js/library/fn/array/find"), __esModule: true }; |
@ -0,0 +1 @@ |
|||
module.exports = { "default": require("core-js/library/fn/array/for-each"), __esModule: true }; |
@ -0,0 +1 @@ |
|||
module.exports = { "default": require("core-js/library/fn/array/from"), __esModule: true }; |
@ -0,0 +1 @@ |
|||
module.exports = { "default": require("core-js/library/fn/array/includes"), __esModule: true }; |
@ -0,0 +1 @@ |
|||
module.exports = { "default": require("core-js/library/fn/array/index-of"), __esModule: true }; |
@ -0,0 +1 @@ |
|||
module.exports = { "default": require("core-js/library/fn/array/join"), __esModule: true }; |
@ -0,0 +1 @@ |
|||
module.exports = { "default": require("core-js/library/fn/array/keys"), __esModule: true }; |
@ -0,0 +1 @@ |
|||
module.exports = { "default": require("core-js/library/fn/array/last-index-of"), __esModule: true }; |
@ -0,0 +1 @@ |
|||
module.exports = { "default": require("core-js/library/fn/array/map"), __esModule: true }; |
@ -0,0 +1 @@ |
|||
module.exports = { "default": require("core-js/library/fn/array/of"), __esModule: true }; |
@ -0,0 +1 @@ |
|||
module.exports = { "default": require("core-js/library/fn/array/pop"), __esModule: true }; |
Some files were not shown because too many files changed in this diff
Loading…
Reference in new issue