marcuswestin / store.js

Cross-browser storage for all use cases, used across the web.
MIT License
14.02k stars 1.33k forks source link

Store functions break when called as functions (not methods) #229

Closed nicolasartman closed 7 years ago

nicolasartman commented 7 years ago
const store = require("store");

store.set('foo', 'bar');
store.get('foo'); // 'bar'
store.get.call('foo'); // this._storage is not defined

There are number of ways to fix this and I'd be happy to try a PR if you're interested. Let me know if you have a preferred method (that = this, closure binding the internal vars, something else...) and I'll try to stick to that.

marcuswestin commented 7 years ago

You need store.get.call(store, 'foo') - look up javascript call function.