npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

localstorage-browser-polyfill

v0.1.0

Published

[![NPM version](https://img.shields.io/npm/v/localstorage-browser-polyfill.svg?style=flat)](https://npmjs.org/package/localstorage-browser-polyfill)

Downloads

112

Readme

localstorage-browser-polyfill

NPM version

IE6/7 localStorage test

IE 8 and 9 store data based only on hostname, ignoring the scheme (http vs https) and port number as required by the specification.

Do not use localStorage.some = 'abc' and localStorage.some change storage, You must use localStorage.setItem('some') and localStorage.getItem('some').

Usage

commonjs

require('localstorage-browser-polyfill')

Script tag

<script src="http://unpkg.com/localstorage-browser-polyfill/localstorage-browser-polyfill.js"></script>

window.localStorageBrowserPolyfill

Current browser support for localStorage?

if (typeof window.localStorageBrowserPolyfill === 'undefined') {
    console.log('Support!')
}
else {
    console.log('Not support!')
}

storage event

Because can't perfect simulation storage event, so use regularly polling.

if (typeof window.localStorageBrowserPolyfill === 'undefined') {
    // IE onstorage
    if (document.attachEvent) {
        document.attachEvent("onstorage", function () {

        })
    }
    else{
        window.addEventListener("storage", function () {

        })
    }
}
else {
    setTimeout(function () {
        var some = localStorage.getItem('some')
        // Do something
        setTimeout(arguments.callee, 500)
    }, 500)
}

Known issues

  1. IE10 in Windows 8 has an issue where localStorage can fail with the error message "SCRIPT5: Access is denied" if "integrity" settings are not set correctly. see details
  2. In IE attempting to access localStorage on HTML files served from the file system results in the localStorage object being undefined
  3. Internet Explorer does not support storing most of the ASCII characters with codes under x20.
  4. The "storage" event is completely wrong in IE: IE10 : The storage event is fired even on the originating document where it occurred. Causes problems with multiple windows websites, and huge problems with iframes. IE11 : The storage event's oldValue and newValue are identical (newValue is supposed to contain the storage's updated value).

Partial workaround: regularly probe the storage's value and compare with the last known value on all pages where you want to listen to this event, and track the last submitted value to determine if the modification was triggered locally. 5. In iOS 5 & 6 localStorage data is stored in a location that may occasionally be cleared out by the OS. 6. In private browsing mode, Safari, iOS Safari and the Android browser (not include Chrome for Android) do not support setting sessionStorage or localStorage. 7. IE 8 and 9 store data based only on hostname, ignoring the scheme (http vs https) and port number as required by the specification. 8. Storing large amounts of data in Safari (on OSX & iOS) can result in freezing the browser see bug