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

akasha

Package Overview
Dependencies
Maintainers
2
Versions
26
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

akasha - npm Package Compare versions

Comparing version 0.1.9 to 0.1.10

src/pretend-storage.coffee

63

lib/akasha.js

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

},
set: function(k, v) {
set: function(k, v, opts) {
var ks, ref;

@@ -25,3 +25,3 @@ ks = (ref = cookies.getJSON(key('_keys'))) != null ? ref : [];

cookies.set(key('_keys'), ks);
return cookies.set(key(k), v);
return cookies.set(key(k, opts), v);
},

@@ -45,12 +45,27 @@ remove: function(k) {

var storage = function(backend) {
var root, store;
var err, root, store;
root = typeof window === 'undefined' ? global : window;
store = root[backend + 'Storage'];
try {
store = root[backend + 'Storage'];
} catch (error) {
return {
get: function() {
return void 0;
},
set: function() {
return void 0;
},
remove: function() {
return void 0;
},
clear: function() {
return void 0;
}
};
}
return {
get: function(k) {
var err;
try {
return JSON.parse(store.getItem(k));
} catch (error) {
err = error;
console.error('Unable to parse', k);

@@ -60,3 +75,3 @@ return void 0;

},
set: function(k, v) {
set: function(k, v, opts) {
return store.setItem(k, JSON.stringify(v));

@@ -76,2 +91,31 @@ },

// src/pretend-storage.coffee
var pretendStorage = (function() {
var key, postFix, pretendStorage;
pretendStorage = {};
postFix = md5(window.location.host);
key = function(k) {
return k + "_" + postFix;
};
return {
get: function(k) {
return pretendStorage[key(k)];
},
set: function(k, v, opts) {
return pretendStorage[key(k)] = v;
},
remove: function(k) {
return delete pretendStorage[key(k)];
},
clear: function() {
var results;
results = [];
for (key in pretendStorage) {
results.push(delete pretendStorage[key(k)]);
}
return results;
}
};
})();
// src/index.coffee

@@ -89,3 +133,2 @@ var supported;

} catch (error) {
err = error;
return false;

@@ -98,4 +141,6 @@ }

return localStorage;
} else if (supported(cookieStorage)) {
return cookieStorage;
} else {
return cookieStorage;
return pretendStorage;
}

@@ -102,0 +147,0 @@ })();

10

package.json
{
"name": "akasha",
"version": "0.1.9",
"version": "0.1.10",
"description": "Cross-browser storage with cookie-based fallback. Inspired by [store.js](https://github.com/marcuswestin/store.js/).",

@@ -44,6 +44,6 @@ "main": "lib/akasha.js",

"devDependencies": {
"coffee-script": "1.12.5",
"sake-bundle": "^0.5.1",
"sake-cli": "^0.5.6",
"sake-outdated": "^0.1.27",
"coffee-script": "1.12.7",
"sake-bundle": "^0.6.0",
"sake-cli": "^0.5.21",
"sake-outdated": "^0.1.28",
"sake-publish": "^0.1.16",

@@ -50,0 +50,0 @@ "sake-version": "^0.1.19"

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

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