@teleology/fp
Advanced tools
Comparing version 1.0.13 to 1.0.14
@@ -185,2 +185,14 @@ "use strict"; | ||
}); | ||
}); | ||
var _poll = require("./poll"); | ||
Object.keys(_poll).forEach(function (key) { | ||
if (key === "default" || key === "__esModule") return; | ||
Object.defineProperty(exports, key, { | ||
enumerable: true, | ||
get: function () { | ||
return _poll[key]; | ||
} | ||
}); | ||
}); |
@@ -6,7 +6,12 @@ "use strict"; | ||
}); | ||
exports.timeout = exports.sleep = void 0; | ||
exports.timeout = exports.race = exports.sleep = void 0; | ||
const sleep = (millis, ...params) => new Promise(resolve => setTimeout(resolve, millis, ...params)); | ||
const sleep = (millis, ...params) => new Promise(resolve => setTimeout(resolve, millis, ...params)); // Create an alias for Promise.race | ||
exports.sleep = sleep; | ||
const { | ||
race | ||
} = Promise; | ||
exports.race = race; | ||
@@ -13,0 +18,0 @@ const timeout = (fn, millis = 500) => (...args) => Promise.race([sleep(millis, 'timeout'), fn(...args)]).then(result => { |
{ | ||
"name": "@teleology/fp", | ||
"version": "1.0.13", | ||
"version": "1.0.14", | ||
"description": "A small collection of functional programming utils", | ||
@@ -5,0 +5,0 @@ "repository": "git@github.com:icarus-sullivan/teleology-fp.git", |
@@ -255,2 +255,30 @@ # @teleology/fp | ||
## poll | ||
A wrapper around a functon to long-poll at pre-defined intervals. Can be used with defaults or a custom rolloff function. | ||
```javascript | ||
const { poll } = require('@teleology/fp'); | ||
const fn = async () => console.log('hello'); | ||
const cancel = poll(fn); // calls fn every 200ms | ||
const cancel2 = poll(fn, 1000); // calls fn every 1000ms | ||
const linear = async (i) => new Promise((res) => setTimeout(res, i * 1000)); | ||
const cancel3 = poll(fn, linear); // rolls off in a lineaer fashion | ||
``` | ||
## noop | ||
A function that does nothing. | ||
```javascript | ||
const { noop } = require('@teleology/fp'); | ||
// I do nothing | ||
noop(); | ||
``` | ||
---- | ||
@@ -260,2 +288,5 @@ | ||
**1.0.14** | ||
- Added `noop` function | ||
**1.0.10** | ||
@@ -262,0 +293,0 @@ - Adding `timeout` function |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
18333
21
362
308