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 🙏

© 2026 – Pkg Stats / Ryan Hefner

ember-local-storage-proxy

v0.2.1

Published

Library for wrapping HTML5 local storage values as Ember properties.

Readme

ember-local-storage-proxy

ember-local-storage-proxy is a library for wrapping HTML5 local storage or session storage values as Ember properties. It is available as an Ember CLI addon.

Installation

ember install ember-local-storage-proxy

Usage

The ember-local-storage-proxy module exports the following:

  • isLocalStorageSupported, isSessionStorageSupported: Boolean consts that represent whether the current browser supports each type of storage.

  • localStorageProxy(key, defaultValue), sessionStorageProxy(key, defaultValue): Returns an Ember computed property that is synced with window.localStorage[key] or window.sessionStorage[key].

    • If not specified, key defaults to the name of the property it is assigned to.
    • If not specified, the default value will be undefined.

In any Ember object (e.g., service, component, controller, or route), use localStorageProxy or sessionStorageProxy to define a proxy property like this:

// services/settings.js

import Ember from 'ember';
import { localStorageProxy, sessionStorageProxy }
  from 'ember-local-storage-proxy';

export default Ember.Service.extend({
  // Define a property synced with window.localStorage['settings/enableFoo'],
  // with a default value of false.
  enableFoo: Ember.computed(localStorageProxy('settings/enableFoo', false)),

  // Define a property synced with window.sessionStorage['userId'], with a
  // default value of undefined.
  userId: Ember.computed(sessionStorageProxy()),
  
  toggleFoo() {
    // This will read and write window.localStorage['settings/enableFoo']
    // transparently.
    this.set('enableFoo', !this.get('enableFoo'));
  },

  // This will fire when enableFoo is updated, as expected.
  onFooChanged: Ember.observer('enableFoo', function() {
    console.log('Foo is %s', this.get('enableFoo') ? 'on' : 'off');
  })
});

To use a proxy property elsewhere, e.g., in a component:

// components/my-component/component.js
import Ember from 'ember';
export default Ember.Component.extend({
  settings: Ember.inject.service(),
  // Optionally define an alias for ease of use.
  enableFoo: Ember.computed.alias('settings.enableFoo')
});

In its template:

<!-- components/my-component/template.hbs -->
{{#if enableFoo}}...{{/if}}

Note, however, that Ember cannot detect direct changes to the underlying local / session storage value. In other words, if your code directly sets window.localStorage['prefs/enableFoo'] = true instead of using set('enableFoo', true), a subsequent get('enableFoo') will still return the previous value false, and any observers will fail to fire. As a result, you should always access or update the value through the proxy property defined via localStorageProxy and sessionStorageProxy.

Encoding / Decoding

Properties defined using localStorageProxy / sessionStorageProxy serialize all values to strings via JSON.Stringify for storage. When read back, they are deserialized via JSON.parse.

For builtin data types, including arrays and plain objects, the encoding and decoding should work transparently.

For custom data types, you would need to first serialize the values to strings or JSON objects before storing them in a proxy property.

Compatibility

Although browser support for HTML5 local storage is pretty much universal at this point, ember-local-storage-proxy will stub out window.localStorage and window.sessionStorage with an empty object in the rare case that they're not supported. In such cases, all the computed properties defined with localStorageProxy / sessionStorageProxy can be read from and written to as normal, except that the values will not be persisted.