Security News
The Unpaid Backbone of Open Source: Solo Maintainers Face Increasing Security Demands
Solo open source maintainers face burnout and security challenges, with 60% unpaid and 60% considering quitting.
Renamed on npm from store.js to store. See http://search.npmjs.org/#/store
store.js exposes a simple API for cross browser local storage
// Store 'marcus' at 'username'
store.set('username', 'marcus')
// Get 'username'
store.get('username')
// Remove 'username'
store.remove('username')
// Clear all keys
store.clear()
// Store an object literal - store.js uses JSON.stringify under the hood
store.set('user', { name: 'marcus', likes: 'javascript' })
// Get the stored object - store.js uses JSON.parse under the hood
var user = store.get('user')
alert(user.name + ' likes ' + user.likes)
store.js depends on JSON for serialization.
Access to the userData behavior in IE6 and IE7 is restricted to "same directory" in the path of the URL, much like access to localStorage is restricted to "same domain" in the protocol and host name of the URL. In addition, just as localStorage cannot be accessed across sub domains, userData behavior cannot be accessed across sub-directories.
Here are some examples to demonstrate the IE6 and IE7 limitations:
// on http://example.com/path1/
store.set('foo', 1)
// on http://example.com/path1/test.html the value of "foo"
// is readable because we are in the same "directory" /path1/
store.get('foo') == 1
store.set('bar', 2)
// on http://example.com/path2/ the values of "foo" and "bar" are not readable
// because we are not in the same "directory" - the directory is not /path2/
store.get('foo') == null
store.get('bar') == null
// on http://example.com/path1/subpath/ the values of "foo" and "bar" are not
// readable here either, because we are in the directory /path1/subpath/.
store.get('foo') == null
store.get('bar') == null
store.js uses localStorage when available, and falls back on globalStorage for earlier versions of Firefox and the userData behavior in IE6 and IE7. No flash to slow down your page load. No cookies to fatten your network requests.
localStorage, when used without store.js, calls toString on all stored values. This means that you can't conveniently store and retrieve numbers, objects or arrays:
localStorage.myage = 24
localStorage.myage != 24
localStorage.myage == '24'
localStorage.user = { name: 'marcus', likes: 'javascript' }
localStorage.user == "[object Object]"
localStorage.tags = ['javascript', 'localStorage', 'store.js']
localStorage.tags.length == 32
localStorage.tags == "javascript,localStorage,store.js"
What we want (and get with store.js) is
store.set('myage', 24)
store.get('myage') == 24
store.set('user', { name: 'marcus', likes: 'javascript' })
alert("Hi my name is " + store.get('user').name + "!")
store.set('tags', ['javascript', 'localStorage', 'store.js'])
alert("We've got " + store.get('tags').length + " tags here")
The native serialization engine of javascript is JSON. Rather than leaving it up to you to serialize and deserialize your values, store.js uses JSON.stringify() and JSON.parse() on each call to store.set() and store.get(), respectively.
Some browsers do not have native support for JSON. For those browsers you should include JSON.js (non-minified copy is included in this repo).
Go to test.html in your browser
FAQs
Renamed on npm from store.js to store. See http://search.npmjs.org/#/store
The npm package store.js receives a total of 87 weekly downloads. As such, store.js popularity was classified as not popular.
We found that store.js demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 0 open source maintainers collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
Solo open source maintainers face burnout and security challenges, with 60% unpaid and 60% considering quitting.
Security News
License exceptions modify the terms of open source licenses, impacting how software can be used, modified, and distributed. Developers should be aware of the legal implications of these exceptions.
Security News
A developer is accusing Tencent of violating the GPL by modifying a Python utility and changing its license to BSD, highlighting the importance of copyleft compliance.