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

redux-session

Package Overview
Dependencies
Maintainers
2
Versions
6
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

redux-session - npm Package Compare versions

Comparing version 1.0.3 to 1.0.4

12

dist/index.js

@@ -40,3 +40,3 @@ 'use strict';

function shallowOmit (keys, obj) {
var j = {}, k;
var j = {};
for (var k$1 in obj) {

@@ -239,3 +239,3 @@ if (keys.indexOf(k$1) === -1) {

// dispatch the action
next(action);
var result = next(action);

@@ -246,6 +246,8 @@ // flag for whether storage should be cleared.

// clear storage if needed
if (shouldClearStorage) storage.clear(ns, _opts);
if (shouldClearStorage) { storage.clear(ns, _opts); }
// otherwise, update storage with the latest
else updateStorage();
else { updateStorage(); }
return result;
}; }

@@ -256,2 +258,2 @@ }

exports.adapters = adapters;
exports.createSession = createSession;
exports.createSession = createSession;
{
"name": "redux-session",
"version": "1.0.3",
"version": "1.0.4",
"description": "Automatically cache parts (or all) of your state in localStorage, sessionStorage or cookies.",

@@ -20,3 +20,3 @@ "main": "dist/index.js",

"type": "git",
"url": "git+https://github.com/helpfulhuman/redux-session.git"
"url": "git+https://github.com/samuelsantia/redux-session.git"
},

@@ -39,12 +39,12 @@ "keywords": [

"devDependencies": {
"buble": "^0.12.5",
"chai": "^3.5.0",
"mocha": "^2.5.3",
"mock-local-storage": "^1.0.2",
"rollup": "^0.34.1",
"rollup-plugin-buble": "^0.12.1",
"rollup-watch": "^2.5.0",
"rollup": "^0.50.0",
"rollup-plugin-buble": "^0.16.0",
"rollup-watch": "^4.3.1",
"sinon": "^1.17.5",
"sinon-chai": "^2.8.0"
}
},
"dependencies": {}
}

@@ -118,5 +118,39 @@ # Redux Session Middleware

## Debouncing
A custom debouncing method can be passed in via the opts if you want to override the default method. This function wraps around the call to update the session storage and prevents it from being updated too many times in the same interval. The default function will simply return if the update was called within the designated interval, however a custom function can be used if any other actions need to take place during the debounce method.
```js
function myDebouncer(fn, wait) {
console.log("this is my custom debouncer");
// do some custom stuff!
let timeout, dirty;
return function () {
if (timeout) {
dirty = true;
return;
}
timeout = setTimeout(function () {
clearTimeout(timeout);
timeout = null;
if (dirty) {
fn.apply(this, arguments);
dirty = false;
}
}, wait);
fn.apply(this, arguments);
}
}
const session = createSession({
ns: 'myproject',
debounce: myDebouncer
});
```
## Clearing Stored State
Finally, if you want to clear your stored session data completely, you can dispatch an action your store with the type of `CLEARED_STORED_STATE`. The session middleware will watch for this action to invoke the adapter's `clear()` method. You can optionally specify a custom `clearStorage` function to spy on actions and determine if the stored state should be dropped.
Finally, if you want to clear your stored session data completely, you can dispatch an action your store with the type of `CLEAR_STORED_STATE`. The session middleware will watch for this action to invoke the adapter's `clear()` method. You can optionally specify a custom `clearStorage` function to spy on actions and determine if the stored state should be dropped.

@@ -123,0 +157,0 @@ ```js

import buble from 'rollup-plugin-buble';
export default {
entry: 'src/index.js',
format: 'cjs',
input: 'src/index.js',
output: {
file: 'dist/index.js',
format: 'cjs',
},
exports: 'named',
plugins: [ buble() ],
dest: 'dist/index.js'
};

@@ -0,0 +0,0 @@ function notImplementedWarning () {

@@ -0,0 +0,0 @@ export default {

@@ -93,3 +93,3 @@ import { getAdapter, debounce, shallowOmit } from './utils';

// dispatch the action
next(action);
const result = next(action);

@@ -104,4 +104,6 @@ // flag for whether storage should be cleared.

else updateStorage();
return result;
}
}
}

@@ -0,0 +0,0 @@ /**

@@ -203,2 +203,12 @@ const chai = require('chai');

it('the created middleware chains the passed action', function () {
const action = { type: 'TEST' };
const session = createSession({ ns, adapter: testAdapter });
testStore.dispatch.withArgs(action).returns(action);
const result = session(testStore)(testStore.dispatch)(action);
expect(testStore.dispatch).to.have.been.calledWith(action);
expect(result).to.be.equal(action);
});
});

@@ -0,0 +0,0 @@ global.window = {};

@@ -0,0 +0,0 @@ const { stub } = require('sinon');

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

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