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

cache-point

Package Overview
Dependencies
Maintainers
1
Versions
16
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

cache-point - npm Package Compare versions

Comparing version 0.3.2 to 0.3.3

28

example/simple.js

@@ -5,3 +5,16 @@ 'use strict'

// endure a 3s wait for the result
// The first invocation will take 3s, the rest instantaneous.
// outputs: 'result'
getData('some input')
.then(console.log)
// cache.read() will resolve on hit, reject on miss.
function getData (input) {
return cache
.read(input)
.catch(() => expensiveOperation(input))
}
// The expensive operation we're aiming to avoid,
// (3 second cost per invocation)
function expensiveOperation (input) {

@@ -16,14 +29,1 @@ return new Promise((resolve, reject) => {

}
// cache.read() will resolve on hit, reject on miss.
function getData (input) {
return cache
.read(input)
.catch(() => expensiveOperation(input))
}
// The first invocation will take 3s, the rest instantaneous.
getData('some input')
.then(console.log)
// outputs: 'result'

@@ -13,3 +13,17 @@ 'use strict'

*
* // endure a 3s wait for the result
* // The first invocation will take 3s, the rest instantaneous.
* // outputs: 'result'
* getData('some input')
* .then(console.log)
*
* // check the cache for output generated with this input.
* // cache.read() will resolve on hit, reject on miss.
* function getData (input) {
* return cache
* .read(input)
* .catch(() => expensiveOperation(input))
* }
*
* // The expensive operation we're aiming to avoid,
* // (3 second cost per invocation)
* function expensiveOperation (input) {

@@ -24,16 +38,2 @@ * return new Promise((resolve, reject) => {

* }
*
* // check the cache for output generated with this input.
* // cache.read() will resolve on hit, reject on miss.
* function getData (input) {
* return cache
* .read(input)
* .catch(() => expensiveOperation(input))
* }
*
* // The first invocation will take 3s, the rest instantaneous.
* getData('some input')
* .then(console.log)
*
* // outputs: 'result'
*/

@@ -130,3 +130,3 @@

/**
* Used internally to convert a key value into a hex checksum. Override if for some reason you need a different hashing strategy.
* Used internally to convert a key value into a hex checksum. Override if for some reason you need a different hashing strategy.
* @param {*} - One or more values to index the data, e.g. a request object or set of function args.

@@ -133,0 +133,0 @@ * @returns {string}

{
"name": "cache-point",
"author": "Lloyd Brookes <75pound@gmail.com>",
"version": "0.3.2",
"version": "0.3.3",
"description": "Simple, filesystem-backed memoisation cache.",

@@ -27,2 +27,3 @@ "repository": "https://github.com/75lb/cache-point.git",

"core-assert": "~0.2.0",
"jsdoc-to-markdown": "^2.0.0-alpha.0",
"test-runner": "~0.1.8"

@@ -29,0 +30,0 @@ },

@@ -17,3 +17,17 @@ [![view on npm](http://img.shields.io/npm/v/cache-point.svg)](https://www.npmjs.org/package/cache-point)

// endure a 3s wait for the result
// The first invocation will take 3s, the rest instantaneous.
// outputs: 'result'
getData('some input')
.then(console.log)
// check the cache for output generated with this input.
// cache.read() will resolve on hit, reject on miss.
function getData (input) {
return cache
.read(input)
.catch(() => expensiveOperation(input))
}
// The expensive operation we're aiming to avoid,
// (3 second cost per invocation)
function expensiveOperation (input) {

@@ -28,16 +42,2 @@ return new Promise((resolve, reject) => {

}
// check the cache for output generated with this input.
// cache.read() will resolve on hit, reject on miss.
function getData (input) {
return cache
.read(input)
.catch(() => expensiveOperation(input))
}
// The first invocation will take 3s, the rest instantaneous.
getData('some input')
.then(console.log)
// outputs: 'result'
```

@@ -149,1 +149,2 @@

&copy; 2016 Lloyd Brookes \<75pound@gmail.com\>. Documented by [jsdoc-to-markdown](https://github.com/jsdoc2md/jsdoc-to-markdown).
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