@wjsc/hold-on
Advanced tools
Comparing version 1.0.3 to 1.0.4
{ | ||
"name": "@wjsc/hold-on", | ||
"version": "1.0.3", | ||
"version": "1.0.4", | ||
"description": "Returns a function execution result or a cached version of it", | ||
@@ -5,0 +5,0 @@ "main": "index.js", |
@@ -58,5 +58,7 @@ ![Current Version](https://img.shields.io/npm/v/@wjsc/hold-on.svg) | ||
const hold = require('@wjsc/hold-on'); | ||
const fetch = require('node-fetch); // Or any HTTP client | ||
// Any HTTP client | ||
const fetch = require('node-fetch'); | ||
const myFunction = () => fetch('https://httpstat.us/200'); | ||
const myFunction = () => fetch('https://httpstat.us/200') | ||
.then(res => res.text()); | ||
const myOptimizedFunction = hold(myFunction, 5000); | ||
@@ -66,5 +68,7 @@ | ||
for(let i = 0; i<50; i++){ | ||
console.log(myOptimizedFunction()); | ||
myOptimizedFunction() | ||
.then(console.log); | ||
} | ||
// If you call the function after 5000 ms, the request will be executed again | ||
// If you call the function after 5000 ms | ||
// the request will be executed again | ||
@@ -71,0 +75,0 @@ ``` |
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
14298
115