New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

rolling-storage

Package Overview
Dependencies
Maintainers
1
Versions
2
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

rolling-storage - npm Package Compare versions

Comparing version 1.0.0 to 1.0.1

.npmignore

7

bower.json
{
"name": "rolling-storage",
"main": "rolling-storage.js",
"version": "1.0.0",
"version": "1.0.1",
"homepage": "https://github.com/compstak/rolling-storage",

@@ -19,3 +19,6 @@ "authors": [

],
"license": "MIT"
"license": "MIT",
"devDependencies": {
"expect": "~0.3.1"
}
}
{
"name": "rolling-storage",
"version": "1.0.0",
"version": "1.0.1",
"description": "An API for localStorage or sessionStorage with ttl and size limits",

@@ -5,0 +5,0 @@ "main": "rolling-storage.js",

@@ -62,4 +62,10 @@ (function (root, factory) {

var saveInventoryTimeout = null;
function saveInventory () {
storage.setItem('rollingStorage-inventory-'+namespace, JSON.stringify(inventory));
if (!saveInventoryTimeout) {
saveInventoryTimeout = setTimeout(function () {
saveInventoryTimeout = null;
storage.setItem('rollingStorage-inventory-'+namespace, JSON.stringify(inventory));
}, 4);
}
}

@@ -66,0 +72,0 @@

/* global describe, expect, it, rollingStorage */
describe('Instantiation', function () {
it('should be a function', function () {
expect(typeof rollingStorage).toBe('function');
expect(rollingStorage).to.be.a('function');
});
it('should error if no options are provided', function () {
expect(rollingStorage).toThrow();
expect(rollingStorage).to.throwError();
});

@@ -14,3 +15,3 @@

return rollingStorage({'fart': 'fart'});
}).toThrow();
}).to.throwError();
});

@@ -25,3 +26,3 @@

});
}).toThrow();
}).to.throwError();
});

@@ -36,3 +37,3 @@

});
}).toThrow();
}).to.throwError();
});

@@ -47,3 +48,3 @@

});
}).toThrow();
}).to.throwError();
});

@@ -58,3 +59,3 @@

});
}).toThrow();
}).to.throwError();
});

@@ -70,9 +71,9 @@

expect(typeof inst.get).toBe('function');
expect(typeof inst.set).toBe('function');
expect(typeof inst.has).toBe('function');
expect(typeof inst.remove).toBe('function');
expect(typeof inst.flush).toBe('function');
expect(inst.get).to.be.a('function');
expect(inst.set).to.be.a('function');
expect(inst.has).to.be.a('function');
expect(inst.remove).to.be.a('function');
expect(inst.flush).to.be.a('function');
});
});

@@ -18,7 +18,7 @@ /* global describe, expect, it, rollingStorage, beforeEach */

inst.set('test-string', '1234567890987654321');
expect(inst.get('test-string')).toBe('1234567890987654321');
expect(inst.get('test-string')).to.be('1234567890987654321');
});
it('Should clear said string in the flush process', function () {
expect(inst.get('test-string')).toBe(undefined);
expect(inst.get('test-string')).to.be(undefined);
});

@@ -28,3 +28,3 @@

inst.set('test-number', 1234);
expect(inst.get('test-number')).toBe(1234);
expect(inst.get('test-number')).to.be(1234);
});

@@ -34,3 +34,3 @@

inst.set('test-bool', true);
expect(inst.get('test-bool')).toBe(true);
expect(inst.get('test-bool')).to.be(true);
});

@@ -40,3 +40,3 @@

inst.set('test-array', ['pig', 'dog', 'donut']);
expect(inst.get('test-array')).toEqual(['pig', 'dog', 'donut']);
expect(inst.get('test-array')).to.eql(['pig', 'dog', 'donut']);
});

@@ -46,3 +46,3 @@

inst.set('test-object', {'pig': 'dog', 'donut': 'bagel'});
expect(inst.get('test-object')).toEqual({'pig': 'dog', 'donut': 'bagel'});
expect(inst.get('test-object')).to.eql({'pig': 'dog', 'donut': 'bagel'});
});

@@ -53,13 +53,13 @@

inst.remove('test-string');
expect(inst.get('test-string')).toBe(undefined);
expect(inst.get('test-string')).to.be(undefined);
});
it('Should respond to has correctly', function () {
expect(inst.has('test-string')).toBe(false);
expect(inst.has('test-string')).to.be(false);
inst.set('test-string', '1234567890987654321');
expect(inst.has('test-string')).toBe(true);
expect(inst.has('test-string')).to.be(true);
inst.remove('test-string');
expect(inst.has('test-string')).toBe(false);
expect(inst.has('test-string')).to.be(false);
});

@@ -77,7 +77,7 @@

expect(inst.has('test-string1')).toBe(false);
expect(inst.has('test-string2')).toBe(false);
expect(inst.has('test-string3')).toBe(false);
expect(inst.has('test-string4')).toBe(false);
expect(inst.has('test-string5')).toBe(false);
expect(inst.has('test-string1')).to.be(false);
expect(inst.has('test-string2')).to.be(false);
expect(inst.has('test-string3')).to.be(false);
expect(inst.has('test-string4')).to.be(false);
expect(inst.has('test-string5')).to.be(false);
});

@@ -99,4 +99,4 @@

expect(inst.has('test-string1')).toBe(false);
expect(inst2.has('test-string1')).toBe(true);
expect(inst.has('test-string1')).to.be(false);
expect(inst2.has('test-string1')).to.be(true);
});

@@ -103,0 +103,0 @@

@@ -16,20 +16,24 @@ /* global describe, expect, it, rollingStorage, beforeEach, afterEach, jasmine */

// jasmine clock causes issues with testem right now.
beforeEach(function() {
jasmine.clock().install();
//jasmine.clock().install();
});
afterEach(function() {
jasmine.clock().uninstall();
//jasmine.clock().uninstall();
});
it('Should expire after the ttl', function () {
it('Should expire after the ttl', function (done) {
var inst = createIt(10);
inst.set('timer!', 'poo');
expect(inst.has('timer!')).toBe(true);
expect(inst.has('timer!')).to.be(true);
jasmine.clock().tick(11);
expect(inst.has('timer!')).toBe(false);
//jasmine.clock().tick(11);
inst.flush();
setTimeout(function () {
expect(inst.has('timer!')).to.be(false);
inst.flush();
done();
}, 11);

@@ -42,11 +46,11 @@ });

inst.set('first', 'poo');
expect(inst.has('first')).toBe(true);
expect(inst.has('first')).to.be(true);
inst.set('bigger-poo', 'somuchbig');
expect(inst.has('first')).toBe(false);
expect(inst.has('bigger-poo')).toBe(true);
expect(inst.has('first')).to.be(false);
expect(inst.has('bigger-poo')).to.be(true);
inst.set('smaller-poo', '1');
expect(inst.has('bigger-poo')).toBe(false);
expect(inst.has('smaller-poo')).toBe(true);
expect(inst.has('bigger-poo')).to.be(false);
expect(inst.has('smaller-poo')).to.be(true);

@@ -53,0 +57,0 @@ inst.flush();

{
"framework": "jasmine2",
"framework": "mocha",
"src_files": [
"bower_components/expect/index.js",
"rolling-storage.js",
"spec/*.js"
]
],
"on_start": {
"command": "bower install"
}
}
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