Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@wjsc/hold-on

Package Overview
Dependencies
Maintainers
1
Versions
6
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@wjsc/hold-on - npm Package Compare versions

Comparing version 1.0.4 to 1.0.5

2

package.json
{
"name": "@wjsc/hold-on",
"version": "1.0.4",
"version": "1.0.5",
"description": "Returns a function execution result or a cached version of it",

@@ -5,0 +5,0 @@ "main": "index.js",

@@ -75,11 +75,42 @@ ![Current Version](https://img.shields.io/npm/v/@wjsc/hold-on.svg)

#### 3. Third example: It's also great to retrieve a file from a remote Storage such as S3
#### 3. Third example: Cache file from local storage
```
const hold = require('@wjsc/hold-on');
const fs = require('fs');
const myFunction = () => new Promise((resolve, reject) => {
fs.readFile('./my-file', 'utf8', (err, data) =>
err ? reject(err) : resolve(data)
)
})
const myOptimizedFunction = hold(myFunction, 5000);
myOptimizedFunction().then(console.log);
```
#### 4. Fourth example: It's also great to cache a file from a remote Storage such as S3
```
const hold = require('@wjsc/hold-on');
const aws = require('aws-sdk');
aws.config.update({
secretAccessKey: 'ABCDE',
accessKeyId: '12345'
})
const s3 = new aws.S3();
const myFunction = () => s3.getObject({ Bucket: 'abc', Key: 'abc.txt' });
const myOptimizedFunction = hold(myFunction, 20000);
const myFunction = () => {
return new Promise((resolve, reject) => {
s3.getObject({
Bucket: 'my-bucket',
Key: 'my-file'
}, (err, data) => {
if ( err ) reject(err)
else resolve(data.Body.toString())
})
})
}
const myOptimizedFunction = hold(myFunction, 5000);
myOptimizedFunction().then(console.log);

@@ -86,0 +117,0 @@ ```

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc