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

ng-local-storage-service

v1.1.0

Published

[![Bower Version](https://img.shields.io/bower/v/ng-local-storage-service.svg)](https://github.com/justinsa/angular-local-storage-service) [![NPM Version](https://img.shields.io/npm/v/ng-local-storage-service.svg)](https://www.npmjs.com/package/ng-local-

Downloads

8

Readme

Bower Version NPM Version Master Build Status license

An Angular service for client-side set, get, remove, bind, and clean of local storage mechanisms. It provides fallbacks to cookies or in-memory storage based on client capabilities and service configuration.

##Dependencies

  • AngularJS - http://angularjs.org
    • Angular Cookies - ngCookies - Only required if cookieFallback is enabled.

##Features

  • Directly store Objects, Arrays, Floats, Booleans, and Strings. No need to convert objects to strings and then reverse them.
  • Two way bind a $scope variable to localStorage or sessionStorage which will be updated whenever the model is updated, and vice versa.
  • Cookie fallback if Storage is not supported.
  • In-memory fallback if Storage is not supported and storing to cookies is disabled.

##Basic Setup

  1. Add this module to your app as a dependency:
var app = angular.module('yourApp', ['local-storage.service']);
  1. Inject $store as a parameter in declarations that require it:
app.controller('yourController', function($scope, $store){ ... });

##Configuration Options

The default configuration is:

  1. cookieFallback: true - if true, then session cookies are used for storage when the browser does not support the Storage interface. If false, then cookies are never used.
  2. useSessionStorage: false - if true, then sessionStorage is used instead of localStorage. If false, localStorage is used as the default. This is, of course, dependent on the browser supporting the Storage interface.

To override the default configuration options, configure the module with an options argument during application configuration:

app.config(['$storeProvider', function ($storeProvider) {
  $storeProvider.configure({
    cookieFallback: false,
    useSessionStorage: true
  });
}]);

##Basic Usage ###Binding

// Binding it to a $scope.variable - the params ($scope, varName, defaultValue(optional))
$store.bind($scope, 'viewType', 'cardView');

// To change the variable both locally in your controller and in storage
$scope.viewType = "ANYTHING";

###Unbinding

// Unbinding and remove a $scope.variable
$store.unbind($scope, 'viewType');

###Set

// Set a key-value pair in storage
$store.set("key", "value");

###Get

// Get a value from storage
$store.get("key");

###Has

// Determine if a key is present in storage
$store.has("key");

###Remove

// Remove a key-value pair from storage
$store.remove("key");

###Clear

// Clear all key-value pairs from storage
// Note: this is not supported for cookie storage as there is no $cookie service support for such an action.
$store.clear();

##Additional Methods These methods were primarily implemented for testing purposes, but they may be useful in special scenarios and are part of the exposed API.

// Get the configuration hash
$store.getConfiguration();
// Get the value of the supported boolean. This value is used by the service for picking
// the appropriate storage mechanism to use.
$store.getSupported();
// Set the supported boolean. This value is used by the service for picking
// the appropriate storage mechanism to use.
$store.setSupported(false);
// Get the supported storage interface (localStorage or sessionStorage). This variable will be undefined if the Storage interface is not supported.
$store.getStorage();
// Get the in-memory storage object.
$store.getMemStore();

##Development After forking you should only have to run npm install from a command line to get your environment setup.

After install you have two gulp commands available to you:

  1. gulp js:lint
  2. gulp js:test