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

ladda-cache

Package Overview
Dependencies
Maintainers
1
Versions
30
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

ladda-cache - npm Package Compare versions

Comparing version 0.2.10 to 0.2.11

2

package.json
{
"name": "ladda-cache",
"version": "0.2.10",
"version": "0.2.11",
"description": "Data fetching layer with support for caching",

@@ -5,0 +5,0 @@ "main": "dist/bundle.js",

@@ -324,2 +324,40 @@ /* eslint-disable no-unused-expressions */

it('makes sure that updateOnCreate hook is applied only when needed', () => {
// we're testing here whether our detection on where to apply a create event
// actually works. We had a bug here, where a create event was applied twice,
// when several updateOnCreate fns where defined, on api functions, where
// the name of one was a substring of another (like getList and getList2)
const xs = [{ id: 1 }, { id: 2 }];
const createX = (newX) => Promise.resolve(newX);
createX.operation = 'CREATE';
const getList = () => Promise.resolve(xs);
getList.operation = 'READ';
getList.updateOnCreate = (args, newX, cachedXs) => [...cachedXs, newX];
// eslint-disable-next-line no-unused-vars
const getList2 = (someArg) => Promise.resolve(xs);
getList2.operation = 'READ';
getList2.updateOnCreate = (args, newX, cachedXs) => [...cachedXs, newX];
const getList3 = () => Promise.resolve(xs);
getList3.operation = 'READ';
getList3.updateOnCreate = (args, newX, cachedXs) => [...cachedXs, newX];
const api = build({ x: { api: { getList, getList2, getList3, createX } } });
return api.x.getList2('x').then(() => {
return api.x.getList3().then(() => {
return api.x.createX({ id: 3 }).then((nextX) => {
return api.x.getList2('x').then((nextXs) => {
expect(nextXs).to.deep.equal([...xs, nextX]);
return api.x.getList3().then((otherNextXs) => {
expect(otherNextXs).to.deep.equal([...xs, nextX]);
});
});
});
});
});
});
it('can decide how to update based on prior arguments', () => {

@@ -326,0 +364,0 @@ const xs = [{ id: 1 }, { id: 2 }];

@@ -31,5 +31,8 @@ /* Handles queries, in essence all GET operations.

const key = createKey(entity, [name]);
// for fns without arguments: check for direct match
// for fns with arguments: check, but ignore the arguments, which are added behind a -
const regexp = new RegExp(`^${key}(-|$)`);
return compose(
reduce((mem, [cacheKey, cacheValue]) => {
return cacheKey.indexOf(key) === 0 ? [...mem, cacheValue] : mem;
return regexp.test(cacheKey) ? [...mem, cacheValue] : mem;
}, []),

@@ -36,0 +39,0 @@ toPairs,

Sorry, the diff of this file is too big to display

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