This commit is contained in:
Lukian LEIZOUR 2022-11-26 15:56:34 +01:00
parent 70e2f7a8aa
commit 008d2f30d7
675 changed files with 189892 additions and 0 deletions

2
node_modules/hang/.npmignore generated vendored Normal file
View file

@ -0,0 +1,2 @@
node_modules
coverage

19
node_modules/hang/.travis.yml generated vendored Normal file
View file

@ -0,0 +1,19 @@
language: node_js
node_js:
- "0.12"
- "0.10"
- "iojs"
before_install:
- "npm install -g npm@1.4.x"
script:
- "npm run test-travis"
after_script:
- "npm install coveralls@2.11.x && cat coverage/lcov.info | coveralls"
matrix:
fast_finish: true
notifications:
irc:
channels:
- "irc.freenode.org#unshift"
on_success: change
on_failure: change

22
node_modules/hang/LICENSE generated vendored Normal file
View file

@ -0,0 +1,22 @@
The MIT License (MIT)
Copyright (c) 2015 Unshift.io, Arnout Kazemier, the Contributors.
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.

52
node_modules/hang/README.md generated vendored Normal file
View file

@ -0,0 +1,52 @@
# hang
[![Made by unshift][made-by]](http://unshift.io)[![Version npm][version]](http://browsenpm.org/package/hang)[![Build Status][build]](https://travis-ci.org/unshiftio/hang)[![Dependencies][david]](https://david-dm.org/unshiftio/hang)[![Coverage Status][cover]](https://coveralls.io/r/unshiftio/hang?branch=master)[![IRC channel][irc]](http://webchat.freenode.net/?channels=unshift)
[made-by]: https://img.shields.io/badge/made%20by-unshift-00ffcc.svg?style=flat-square
[version]: https://img.shields.io/npm/v/hang.svg?style=flat-square
[build]: https://img.shields.io/travis/unshiftio/hang/master.svg?style=flat-square
[david]: https://img.shields.io/david/unshiftio/hang.svg?style=flat-square
[cover]: https://img.shields.io/coveralls/unshiftio/hang/master.svg?style=flat-square
[irc]: https://img.shields.io/badge/IRC-irc.freenode.net%23unshift-00a8ff.svg?style=flat-square
`hang` is micro helper function that will guarantee that your callbacks are
called async. The returned function can be called in sync or completely async.
When it's called in `sync` we will "hang" execution in a `setImmidiate` or
`setTimeout(0)` to ensure that it's called in async.
## Installation
The module is released in the public npm registry and can be installed by
running:
```
npm install --save hang
```
## Usage
Require the module and supply it the function that should be called in
completely async:
```js
'use strict';
var hang = require('hang');
var fn = hang(function (foo) {
console.log(this, foo); // foo, bar
});
fn.call('foo', 'bar')
//
// Or call it "async"
//
setTimeout(function () {
fn.call('foo', 'bar')
}, 10);
```
## License
MIT

48
node_modules/hang/index.js generated vendored Normal file
View file

@ -0,0 +1,48 @@
'use strict';
/**
* Delay function calls only if they are not already ran async.
*
* @param {Function} fn Function that should be forced in async execution
* @returns {Function} A wrapped function that will called the supplied callback.
* @api public
*/
module.exports = function hang(fn) {
var start = +(new Date());
/**
* The wrapped function.
*
* @api private
*/
function bro() {
var self = this;
//
// Time has passed since we've generated this function so we're going to
// assume that this function is already executed async.
//
if (+(new Date()) > start) {
return fn.apply(self, arguments);
}
for (var i = 0, l = arguments.length, args = new Array(l); i < l; i++) {
args[i] = arguments[i];
}
(global.setImmediate || global.setTimeout)(function delay() {
fn.apply(self, args);
self = args = null;
}, 0);
}
//
// To make debugging more easy we want to use the name of the supplied
// function. So when you look at the functions that are assigned to event
// listeners you don't see a load of `onetime` functions but actually the
// names of the functions that this module will call.
//
bro.displayName = fn.displayName || fn.name || bro.displayName || bro.name;
return bro;
};

49
node_modules/hang/package.json generated vendored Normal file
View file

@ -0,0 +1,49 @@
{
"name": "hang",
"version": "1.0.0",
"description": "Force the supplied callback in to async execution",
"main": "index.js",
"scripts": {
"100%": "istanbul check-coverage --statements 100 --functions 100 --lines 100 --branches 100",
"test": "mocha test.js",
"watch": "mocha --watch test.js",
"coverage": "istanbul cover ./node_modules/.bin/_mocha -- test.js",
"test-travis": "istanbul cover node_modules/.bin/_mocha --report lcovonly -- test.js"
},
"repository": {
"type": "git",
"url": "https://github.com/unshiftio/hang"
},
"keywords": [
"dont",
"keep",
"me",
"hanging",
"bro",
"hang",
"suspend",
"wait",
"defer",
"deferred",
"wating",
"delay",
"async",
"force",
"sync",
"execution",
"callback",
"pattern"
],
"author": "Arnout Kazemier",
"license": "MIT",
"bugs": {
"url": "https://github.com/unshiftio/hang/issues"
},
"homepage": "https://github.com/unshiftio/hang",
"devDependencies": {
"assume": "1.2.x",
"istanbul": "0.3.x",
"mocha": "2.2.x",
"pre-commit": "1.0.x"
}
}

40
node_modules/hang/test.js generated vendored Normal file
View file

@ -0,0 +1,40 @@
describe('hang', function () {
'use strict';
var hang = require('./')
, assume = require('assume');
it('is exported as a function', function () {
assume(hang).is.a('function');
});
it('returns a function with the same name as the provided fn', function () {
var what = hang(function what() {});
assume(what.displayName).equals('what');
});
it('calls the supplied callback', function (next) {
var h = hang(next);
assume(h).does.not.equals(next);
h();
});
it('instantly calls the supplied function if called async', function (next) {
setImmediate(hang(next));
});
it('proxies the arguments and this value', function (next) {
var fn = hang(function (a, b, c) {
assume(a).equals('a');
assume(b).equals('b');
assume(c).equals('c');
assume(this).equals('foo');
next();
});
fn.apply('foo', ['a', 'b', 'c']);
});
});