pax_global_header 0000666 0000000 0000000 00000000064 14627411764 0014526 g ustar 00root root 0000000 0000000 52 comment=5feea55d9820970daf5cd9c4a874053047940ac3
medikoo-timers-ext-5feea55/ 0000775 0000000 0000000 00000000000 14627411764 0015755 5 ustar 00root root 0000000 0000000 medikoo-timers-ext-5feea55/.editorconfig 0000664 0000000 0000000 00000000456 14627411764 0020437 0 ustar 00root root 0000000 0000000 # EditorConfig is awesome: http://EditorConfig.org
# top-most EditorConfig file
root = true
[*]
charset = utf-8
end_of_line = lf
insert_final_newline = true
indent_style = tab
trim_trailing_whitespace = true
[*.{md,yml}]
indent_size = 2
indent_style = space
[*.md]
trim_trailing_whitespace = false
medikoo-timers-ext-5feea55/.github/ 0000775 0000000 0000000 00000000000 14627411764 0017315 5 ustar 00root root 0000000 0000000 medikoo-timers-ext-5feea55/.github/FUNDING.yml 0000664 0000000 0000000 00000000020 14627411764 0021122 0 ustar 00root root 0000000 0000000 github: medikoo
medikoo-timers-ext-5feea55/.github/workflows/ 0000775 0000000 0000000 00000000000 14627411764 0021352 5 ustar 00root root 0000000 0000000 medikoo-timers-ext-5feea55/.github/workflows/integrate.yml 0000664 0000000 0000000 00000000376 14627411764 0024065 0 ustar 00root root 0000000 0000000 # main only
name: Integrate
on:
push:
branches: [main]
env:
FORCE_COLOR: 1
jobs:
_:
uses: medikoo/github-actions-workflows/.github/workflows/0.12-integrate.yml@main
secrets:
USER_GITHUB_TOKEN: ${{ secrets.USER_GITHUB_TOKEN }}
medikoo-timers-ext-5feea55/.github/workflows/publish.yml 0000664 0000000 0000000 00000000472 14627411764 0023546 0 ustar 00root root 0000000 0000000 # Version tags only
name: Publish
on:
push:
tags:
- v[0-9]+.[0-9]+.[0-9]+
env:
FORCE_COLOR: 1
jobs:
_:
uses: medikoo/github-actions-workflows/.github/workflows/publish.yml@main
secrets:
USER_GITHUB_TOKEN: ${{ secrets.USER_GITHUB_TOKEN }}
NPM_TOKEN: ${{ secrets.NPM_TOKEN }}
medikoo-timers-ext-5feea55/.github/workflows/validate.yml 0000664 0000000 0000000 00000000275 14627411764 0023672 0 ustar 00root root 0000000 0000000 # PR's only
name: Validate
on:
pull_request:
branches: [main]
env:
FORCE_COLOR: 1
jobs:
_:
uses: medikoo/github-actions-workflows/.github/workflows/0.12-validate.yml@main
medikoo-timers-ext-5feea55/.gitignore 0000664 0000000 0000000 00000000106 14627411764 0017742 0 ustar 00root root 0000000 0000000 /.nyc_output
/coverage
/node_modules
npm-debug.log
/package-lock.json
medikoo-timers-ext-5feea55/.npmignore 0000664 0000000 0000000 00000000064 14627411764 0017754 0 ustar 00root root 0000000 0000000 /.editorconfig
/.github
/commitlint.config.js
/test
medikoo-timers-ext-5feea55/CHANGELOG.md 0000664 0000000 0000000 00000003320 14627411764 0017564 0 ustar 00root root 0000000 0000000 # Changelog
All notable changes to this project will be documented in this file. See [standard-version](https://github.com/conventional-changelog/standard-version) for commit guidelines.
### [0.1.8](https://github.com/medikoo/timers-ext/compare/v0.1.7...v0.1.8) (2024-06-03)
### Maintenance Improvements
- Bump dependencies ([1644a83](https://github.com/medikoo/timers-ext/commit/1644a83a63dbcb239140d0574014438cf58dddca))
- Declare minimum Node.js version ([2cb991d](https://github.com/medikoo/timers-ext/commit/2cb991d1b7a835a4a332d1d77932ad39dc54e487))
## [0.1.7](https://github.com/medikoo/timers-ext/compare/v0.1.6...v0.1.7) (2018-10-04)
### Bug Fixes
- typo in error message ([36720cf](https://github.com/medikoo/timers-ext/commit/36720cf))
## [0.1.6](https://github.com/medikoo/timers-ext/compare/v0.1.5...v0.1.6) (2018-10-04)
### Features
- report timeout value on error ([abb4afa](https://github.com/medikoo/timers-ext/commit/abb4afa))
## [0.1.5](https://github.com/medikoo/timers-ext/compare/v0.1.4...v0.1.5) (2018-03-13)
### Features
- **promise:** sleep util ([c50d575](https://github.com/medikoo/timers-ext/commit/c50d575))
## [0.1.4](https://github.com/medikoo/timers-ext/compare/v0.1.3...v0.1.4) (2018-03-08)
### Bug Fixes
- **promise:** clear timeout on promise resolution ([6301a6b](https://github.com/medikoo/timers-ext/commit/6301a6b))
## [0.1.3](https://github.com/medikoo/timers-ext/compare/v0.1.2...v0.1.3) (2018-03-07)
### Features
- **promise:** promise.timeout method ([3f52d27](https://github.com/medikoo/timers-ext/commit/3f52d27))
## Changelog for previous versions
See `CHANGES` file
medikoo-timers-ext-5feea55/CHANGES 0000664 0000000 0000000 00000001101 14627411764 0016741 0 ustar 00root root 0000000 0000000 For recent changelog see CHANGELOG.md
-----
v0.1.2 -- 2017.04.03
* `throttle` util
v0.1.1 -- 2017.03.15
* Workaround IE8 resolution issue
* Support any callable objects as callbacks
* Improve documentation
* Fix spelling of LICENSE
* Configure lint scripts
* Update dependencies
v0.1.0 -- 2014.04.27
First production ready version
- Depend strictly on npm hosted package versions
- Full documentation
- Add `once` (moved from next-tick project)
- Make timeout value optional in delay
- Rename MAX_VALUE into MAX_TIMEOUT
v0.0.0 -- 2013.08.27
Initial (dev) version
medikoo-timers-ext-5feea55/LICENSE 0000664 0000000 0000000 00000001405 14627411764 0016762 0 ustar 00root root 0000000 0000000 ISC License
Copyright (c) 2013-2024, Mariusz Nowak, @medikoo, medikoo.com
Permission to use, copy, modify, and/or distribute this software for any
purpose with or without fee is hereby granted, provided that the above
copyright notice and this permission notice appear in all copies.
THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH
REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT,
INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE
OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
PERFORMANCE OF THIS SOFTWARE.
medikoo-timers-ext-5feea55/README.md 0000664 0000000 0000000 00000005025 14627411764 0017236 0 ustar 00root root 0000000 0000000 [![Build status][build-image]][build-url]
[![Tests coverage][cov-image]][cov-url]
[![npm version][npm-image]][npm-url]
# timers-ext
## Timers extensions
### Installation
$ npm install timers-ext
To port it to Browser or any other (non CJS) environment, use your favorite CJS bundler. No favorite yet? Try: [Browserify](http://browserify.org/), [Webmake](https://github.com/medikoo/modules-webmake) or [Webpack](http://webpack.github.io/)
### API
#### MAX*TIMEOUT *(timers-ext/max-timeout)\_
Maximum possible timeout value in milliseconds. It equals to maximum positive value for 32bit signed integer, so _2³¹ (2147483647)_, which makes it around 24.9 days
#### delay(fn[, timeout]) _(timers-ext/delay)_
Returns function which when invoked will call _fn_ function after specified
_timeout_. If _timeout_ is not provided [nextTick](https://github.com/medikoo/next-tick/#next-tick) propagation is used.
#### once(fn[, timeout]) _(timers-ext/once)_
Makes sure to execute _fn_ function only once after a defined interval of time (debounce). If _timeout_ is not provided [nextTick](https://github.com/medikoo/next-tick/#next-tick) propagation is used.
```javascript
var nextTick = require("next-tick");
var logFoo = function () { console.log("foo"); };
var logFooOnce = require("timers-ext/once")(logFoo);
logFooOnce();
logFooOnce(); // ignored, logFoo will be logged only once
logFooOnce(); // ignored
nextTick(function () {
logFooOnce(); // Invokes another log (as tick passed)
logFooOnce(); // ignored
logFooOnce(); // ignored
});
```
#### validTimeout(timeout) _(timers-ext/valid-timeout)_
Validates timeout value.
For `NaN` resolved _timeout_ `0` is returned.
If _timeout_ resolves to a number:
- for _timeout < 0_ `0` is returned
- for _0 >= timeout <= [MAX_TIMEOUT](#max_timeout-timers-extmax-timeout)_, `timeout` value is returned
- for _timeout > [MAX_TIMEOUT](#max_timeout-timers-extmax-timeout)_ exception is thrown
### Tests
$ npm test
## Security contact information
To report a security vulnerability, please use the [Tidelift security contact](https://tidelift.com/security). Tidelift will coordinate the fix and disclosure.
[build-image]: https://github.com/medikoo/timers-ext/workflows/Integrate/badge.svg
[build-url]: https://github.com/medikoo/timers-ext/actions?query=workflow%3AIntegrate
[cov-image]: https://img.shields.io/codecov/c/github/medikoo/timers-ext.svg
[cov-url]: https://codecov.io/gh/medikoo/timers-ext
[npm-image]: https://img.shields.io/npm/v/timers-ext.svg
[npm-url]: https://www.npmjs.com/package/timers-ext
medikoo-timers-ext-5feea55/commitlint.config.js 0000664 0000000 0000000 00000001236 14627411764 0021740 0 ustar 00root root 0000000 0000000 "use strict";
module.exports = {
rules: {
"body-leading-blank": [2, "always"],
"body-max-line-length": [2, "always", 72],
"footer-leading-blank": [2, "always"],
"footer-max-line-length": [2, "always", 72],
"header-max-length": [2, "always", 72],
"scope-case": [2, "always", "start-case"],
"scope-enum": [2, "always", [""]],
"subject-case": [2, "always", "sentence-case"],
"subject-empty": [2, "never"],
"subject-full-stop": [2, "never", "."],
"type-case": [2, "always", "lower-case"],
"type-empty": [2, "never"],
"type-enum": [
2, "always",
["build", "chore", "ci", "docs", "feat", "fix", "perf", "refactor", "style", "test"]
]
}
};
medikoo-timers-ext-5feea55/delay.js 0000664 0000000 0000000 00000000767 14627411764 0017423 0 ustar 00root root 0000000 0000000 "use strict";
var callable = require("es5-ext/object/valid-callable")
, nextTick = require("next-tick")
, validTimeout = require("./valid-timeout");
var apply = Function.prototype.apply;
module.exports = function (fn/*, timeout*/) {
var delay, timeout = arguments[1];
callable(fn);
if (timeout === undefined) {
delay = nextTick;
} else {
timeout = validTimeout(timeout);
delay = setTimeout;
}
return function () { return delay(apply.bind(fn, this, arguments), timeout); };
};
medikoo-timers-ext-5feea55/max-timeout.js 0000664 0000000 0000000 00000000054 14627411764 0020563 0 ustar 00root root 0000000 0000000 "use strict";
module.exports = 2147483647;
medikoo-timers-ext-5feea55/once.js 0000664 0000000 0000000 00000001752 14627411764 0017244 0 ustar 00root root 0000000 0000000 // It's actually "debounce"
"use strict";
var isValue = require("es5-ext/object/is-value")
, callable = require("es5-ext/object/valid-callable")
, nextTick = require("next-tick")
, validTimeout = require("./valid-timeout");
var apply = Function.prototype.apply;
module.exports = function (fn/*, timeout*/) {
var scheduled, run, context, args, delay, timeout = arguments[1], handle;
callable(fn);
if (isValue(timeout)) {
timeout = validTimeout(timeout);
delay = setTimeout;
} else {
delay = nextTick;
}
run = function () {
if (!scheduled) return; // IE8 tends to not clear immediate timeouts properly
scheduled = false;
handle = null;
apply.call(fn, context, args);
context = null;
args = null;
};
return function () {
if (scheduled) {
if (!isValue(handle)) {
// 'nextTick' based, no room for debounce
return;
}
clearTimeout(handle);
}
scheduled = true;
context = this;
args = arguments;
handle = delay(run, timeout);
};
};
medikoo-timers-ext-5feea55/package.json 0000664 0000000 0000000 00000004115 14627411764 0020244 0 ustar 00root root 0000000 0000000 {
"name": "timers-ext",
"version": "0.1.8",
"description": "Timers extensions",
"author": "Mariusz Nowak (http://www.medikoo.com/)",
"repository": "medikoo/timers-ext",
"keywords": [
"timeout",
"delay",
"interval",
"time",
"timer",
"timers"
],
"dependencies": {
"es5-ext": "^0.10.64",
"next-tick": "^1.1.0"
},
"devDependencies": {
"eslint": "^8.57.0",
"eslint-config-medikoo": "^4.2.0",
"git-list-updated": "^1.2.1",
"github-release-from-cc-changelog": "^2.3.0",
"husky": "^4.3.8",
"lint-staged": "^15.2.5",
"nyc": "^15.1.0",
"prettier-elastic": "^3.2.5",
"tad": "^3.1.1"
},
"husky": {
"hooks": {
"pre-commit": "lint-staged"
}
},
"lint-staged": {
"*.js": [
"eslint"
],
"*.{css,html,js,json,md,yaml,yml}": [
"prettier -c"
]
},
"eslintConfig": {
"extends": "medikoo/es5",
"root": true,
"globals": {
"clearInterval": true,
"clearTimeout": true,
"setInterval": true,
"setTimeout": true
}
},
"prettier": {
"printWidth": 100,
"tabWidth": 4,
"trailingComma": "none",
"overrides": [
{
"files": [
"*.md",
"*.yml"
],
"options": {
"tabWidth": 2
}
}
]
},
"nyc": {
"all": true,
"exclude": [
".github",
"coverage/**",
"test/**",
"*.config.js"
],
"reporter": [
"lcov",
"html",
"text-summary"
]
},
"scripts": {
"coverage": "nyc npm test",
"lint": "eslint --ignore-path=.gitignore .",
"lint:updated": "pipe-git-updated --base=main --ext=js -- eslint --ignore-pattern '!*'",
"prettier-check": "prettier -c --ignore-path .gitignore \"**/*.{css,html,js,json,md,yaml,yml}\"",
"prettier-check:updated": "pipe-git-updated --base=main --ext=css --ext=html --ext=js --ext=json --ext=md --ext=yaml --ext=yml -- prettier -c",
"prettify": "prettier --write --ignore-path .gitignore \"**/*.{css,html,js,json,md,yaml,yml}\"",
"prettify:updated": "pipe-git-updated ---base=main -ext=css --ext=html --ext=js --ext=json --ext=md --ext=yaml --ext=yml -- prettier --write",
"test": "tad"
},
"engines": {
"node": ">=0.12"
},
"license": "ISC"
}
medikoo-timers-ext-5feea55/promise/ 0000775 0000000 0000000 00000000000 14627411764 0017433 5 ustar 00root root 0000000 0000000 medikoo-timers-ext-5feea55/promise/.eslintrc.json 0000664 0000000 0000000 00000000043 14627411764 0022224 0 ustar 00root root 0000000 0000000 { "globals": { "Promise": true } }
medikoo-timers-ext-5feea55/promise/sleep.js 0000664 0000000 0000000 00000001105 14627411764 0021076 0 ustar 00root root 0000000 0000000 "use strict";
var isValue = require("es5-ext/object/is-value")
, isPromise = require("es5-ext/object/is-promise")
, nextTick = require("next-tick")
, ensureTimeout = require("../valid-timeout");
module.exports = function (/* timeout */) {
var Constructor = isPromise(this) ? this.constructor : Promise;
var timeout = arguments[0];
if (isValue(timeout)) timeout = ensureTimeout(timeout);
return new Constructor(function (resolve) {
if (isValue(timeout)) {
setTimeout(function () { resolve(); }, timeout);
} else {
nextTick(resolve);
}
});
};
medikoo-timers-ext-5feea55/promise_/ 0000775 0000000 0000000 00000000000 14627411764 0017572 5 ustar 00root root 0000000 0000000 medikoo-timers-ext-5feea55/promise_/timeout.js 0000664 0000000 0000000 00000002145 14627411764 0021620 0 ustar 00root root 0000000 0000000 "use strict";
var customError = require("es5-ext/error/custom")
, isValue = require("es5-ext/object/is-value")
, ensurePromise = require("es5-ext/object/ensure-promise")
, nextTick = require("next-tick")
, ensureTimeout = require("../valid-timeout");
module.exports = function (/* timeout */) {
ensurePromise(this);
var timeout = arguments[0];
if (isValue(timeout)) timeout = ensureTimeout(timeout);
return new this.constructor(
function (resolve, reject) {
var isSettled = false, timeoutId;
var timeoutCallback = function () {
if (isSettled) return;
reject(
customError(
"Operation timeout (exceeded " +
(isValue(timeout) ? timeout + "ms" : "tick") +
")",
"PROMISE_TIMEOUT"
)
);
};
if (isValue(timeout)) timeoutId = setTimeout(timeoutCallback, timeout);
else nextTick(timeoutCallback);
this.then(
function (value) {
isSettled = true;
clearTimeout(timeoutId);
resolve(value);
}, function (reason) {
isSettled = true;
clearTimeout(timeoutId);
reject(reason);
}
);
}.bind(this)
);
};
medikoo-timers-ext-5feea55/test/ 0000775 0000000 0000000 00000000000 14627411764 0016734 5 ustar 00root root 0000000 0000000 medikoo-timers-ext-5feea55/test/.eslintrc.json 0000664 0000000 0000000 00000000070 14627411764 0021525 0 ustar 00root root 0000000 0000000 { "rules": { "id-length": "off", "no-shadow": "off" } }
medikoo-timers-ext-5feea55/test/delay.js 0000664 0000000 0000000 00000001045 14627411764 0020370 0 ustar 00root root 0000000 0000000 "use strict";
module.exports = function (t, a, d) {
var data
, count = 0
, x = function (a, b, c) { data = [this, a, b, c, ++count]; }
, y = t(x, 200)
, z = {};
a(data, undefined, "Setup");
y.call(z, 111, "foo", false);
a(data, undefined, "Immediately");
setTimeout(function () {
a(data, undefined, "100ms");
setTimeout(function () {
a.deep(data, [z, 111, "foo", false, 1], "250ms");
data = null;
clearTimeout(y());
setTimeout(function () {
a(data, null, "Clear");
d();
}, 300);
}, 150);
}, 100);
};
medikoo-timers-ext-5feea55/test/max-timeout.js 0000664 0000000 0000000 00000000330 14627411764 0021537 0 ustar 00root root 0000000 0000000 "use strict";
module.exports = function (t, a, d) {
var invoked, id;
id = setTimeout(function () { invoked = true; }, t);
setTimeout(function () {
a(invoked, undefined);
clearTimeout(id);
d();
}, 100);
};
medikoo-timers-ext-5feea55/test/once.js 0000664 0000000 0000000 00000001004 14627411764 0020211 0 ustar 00root root 0000000 0000000 "use strict";
module.exports = function (t, a, d) {
var called = 0, fn = t(function () { ++called; });
fn();
fn();
fn();
setTimeout(function () {
a(called, 1);
called = 0;
fn = t(function () { ++called; }, 50);
fn();
fn();
fn();
setTimeout(function () {
fn();
fn();
setTimeout(function () {
fn();
fn();
setTimeout(function () {
fn();
fn();
setTimeout(function () {
a(called, 1);
d();
}, 70);
}, 30);
}, 30);
}, 30);
}, 10);
};
medikoo-timers-ext-5feea55/test/promise/ 0000775 0000000 0000000 00000000000 14627411764 0020412 5 ustar 00root root 0000000 0000000 medikoo-timers-ext-5feea55/test/promise/sleep.js 0000664 0000000 0000000 00000001153 14627411764 0022060 0 ustar 00root root 0000000 0000000 "use strict";
var delay = require("../../delay");
module.exports = function (t, a) {
if (typeof Promise !== "function") return null;
return {
Tick: function (d) {
var isInvoked = false;
t().then(function (result) {
isInvoked = true;
delay(function () {
a(result, undefined);
d();
})();
}, delay(d));
a(isInvoked, false);
},
Timeout: function (d) {
var isInvoked = false;
t(100).then(
delay(function (result) {
isInvoked = true;
a(result, undefined);
d();
}),
delay(d)
);
setTimeout(function () { a(isInvoked, false); }, 50);
}
};
};
medikoo-timers-ext-5feea55/test/promise_/ 0000775 0000000 0000000 00000000000 14627411764 0020551 5 ustar 00root root 0000000 0000000 medikoo-timers-ext-5feea55/test/promise_/.eslintrc.json 0000664 0000000 0000000 00000000043 14627411764 0023342 0 ustar 00root root 0000000 0000000 { "globals": { "Promise": true } }
medikoo-timers-ext-5feea55/test/promise_/timeout.js 0000664 0000000 0000000 00000001507 14627411764 0022600 0 ustar 00root root 0000000 0000000 "use strict";
var delay = require("../../delay");
module.exports = function (t, a) {
if (typeof Promise !== "function") return null;
return {
Success: function (d) {
var promise = t.call(
new Promise(function (resolve) {
setTimeout(function () { resolve("foo"); }, 20);
}),
40
);
promise.then(
// Delay to escape error swallowing
delay(function (result) {
a(result, "foo");
d();
}),
delay(d)
);
},
Timeout: function (d) {
var promise = t.call(
new Promise(function (resolve) {
setTimeout(function () { resolve("foo"); }, 40);
}),
20
);
promise.then(
// Delay to escape error swallowing
delay(function () {
a.never();
d();
}),
delay(function (err) {
a(err.code, "PROMISE_TIMEOUT");
d();
})
);
}
};
};
medikoo-timers-ext-5feea55/test/throttle.js 0000664 0000000 0000000 00000001107 14627411764 0021136 0 ustar 00root root 0000000 0000000 "use strict";
module.exports = function (t, a, d) {
var called = 0;
var fn = t(function () { ++called; }, 200);
fn();
a(called, 1);
fn();
fn();
a(called, 1);
// Wait 120ms
setTimeout(function () {
a(called, 1);
fn();
// Wait 120ms
setTimeout(function () {
a(called, 2);
fn();
fn();
// Wait 80ms
setTimeout(function () {
a(called, 2);
// Wait 120ms
setTimeout(function () {
a(called, 3);
// Wait 400ms
setTimeout(function () {
a(called, 3);
d();
}, 400);
}, 120);
}, 80);
}, 120);
}, 120);
};
medikoo-timers-ext-5feea55/test/valid-timeout.js 0000664 0000000 0000000 00000000307 14627411764 0022055 0 ustar 00root root 0000000 0000000 "use strict";
module.exports = function (t, a) {
a(t(NaN), 0, "NaN");
a(t(-343), 0, "Negative");
a(t(232342), 232342, "Positive");
a.throws(function () { t(1e23); }, TypeError, "Too large");
};
medikoo-timers-ext-5feea55/throttle.js 0000664 0000000 0000000 00000001335 14627411764 0020162 0 ustar 00root root 0000000 0000000 "use strict";
var callable = require("es5-ext/object/valid-callable")
, validTimeout = require("./valid-timeout")
, apply = Function.prototype.apply;
module.exports = function (fn, timeout) {
var isScheduled = false, context, args, run;
callable(fn);
timeout = validTimeout(timeout);
run = function () {
var currentContext = context, currentArgs = args;
if (!args) {
isScheduled = false;
return;
}
context = null;
args = null;
setTimeout(run, timeout);
apply.call(fn, currentContext, currentArgs);
};
return function () {
if (isScheduled) {
context = this;
args = arguments;
return;
}
isScheduled = true;
setTimeout(run, timeout);
apply.call(fn, this, arguments);
};
};
medikoo-timers-ext-5feea55/valid-timeout.js 0000664 0000000 0000000 00000000440 14627411764 0021074 0 ustar 00root root 0000000 0000000 "use strict";
var toPosInt = require("es5-ext/number/to-pos-integer")
, maxTimeout = require("./max-timeout");
module.exports = function (value) {
value = toPosInt(value);
if (value > maxTimeout) throw new TypeError(value + " exceeds maximum possible timeout");
return value;
};