Git Product home page Git Product logo

local-storage's Introduction

local-storage's People

Contributors

bevacqua avatar bnorton avatar ionoclastbrigham avatar kromdaniel avatar mike-zorn avatar vojtechbartos avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

local-storage's Issues

Can you add namespace supported?

The local storage is for the domain of the site. However, we have many sites under the domain separated by different sub-folders.

I am wondering if the library can support namespace in the API.

Thanks so much!

set() should not silently ignore exceptions

Hi,

the set function, as it is currently implemented, simply gulps down all exceptions:

function set (key, value) {
  try {
    ls.setItem(key, JSON.stringify(value));
    return true;
  } catch (e) {
    return false;
  }
}
  • the function should either not catch exceptions (breaking change)
  • or at least log exceptions to the console.

Actively suppressing exceptions decreases visibility into the fact that errors are happening at all and makes debugging harder.

Cheer,

Checking for IE11 Support

I am a maintainer of a project which must have support for IE11 browser.
I'm wondering what is your browser support list since this project has been flagged as not ES5 safe.

Checking ES5 support for node_modules on my project with are-you-es5 shows:

> npx are-you-es5 check . -rv

...
✅ js-cookie is ES5
❌ local-storage is not ES5
✅ lz-string is ES5
...

I'm using version 2.0.0.

Upgrading from 1.4 to 2.0 gives my localstorage.get syntax error with TypeScript

Sorry for not understanding better how to post, but had a working project that just did these two lines:

import ls from 'local-storage';
const user = ls.get('userInfo');

When I upgraded to 2.0, I started getting TypeScrpt error complaining about get.

The error is as follows:

Property 'get' does not exist on type '<T>(key: string, value?: T | undefined) => void'.

If this issue makes no sense, feel free to close. I really don't understand why I'd get an error like that.

I can't use any functionalities into my javascript

Hello, so i included the module and use it like:

<script src="node_modules/local-storage/dist/local-storage.js"></script>
<script>ls.set('foo','bar'); console.log(ls.get('foo'));</script>

But nothing happens instead of an error which is: Uncaught ReferenceError: ls is not defined;
I installed it like that npm install local-storage --save
So how can i use it into my own javascript?

Does this work with subdomains?

We have a public site which saves a returned authorization token to localStorage using a javascript plugin. Then we redirect the user to an "app" subdomain (a nodejs site using your local-storage node module). Is there a syntax for this module that, on app.mysite.com, we can access the local storage for mysite.com to retrieve the authorization token? In basic javascript, I think it is something like

localStorage['mysite.com']

(otherwise, not specifying the index would default to localStorage for app.mysite.com).

Cannot parse a non JSON Value from local storage

Hi,

I recently had an issue where the localstorage system was corrupted, and so the ls.get() function returned an error:

Reproduce with this local storage content::

|-----|-----------|
| foo | undefined |
|-----|-----------|
ls.get('foo') // -> Throws an error because undefined is not a valid JSON.

Did this ever happened to one of you? How did you manage the thing?

For the time being, I use a try/catch and delete the key of the localstorage if such a thing happens.

listener for same tab

I guess the library was build for a specific purpose to sync states between tabs.

If its meant for more common use,
it would be nice to support localstorage listener for same tab as well
( not considering which tab localStorage value was thrown).

What happens when .set fails?

In the README, it's specified that, upon .set, the function will return whether the operation fails. However, it does not state what kind of object will be returned, i.e. a string, booleon or actual Error object.

I guess this is an issue with the documentation and if this can't be updated easily, then I'll go in to the source code and find out. If I do, I'll do a pull request for the docs.

Thanks for the great library!

Feature proposal: always store data somewhere

I have a need where no matter what, I would want the value to be stored, either in localStorage or in the local module.

For cases like the quota limit exceed or any weird error triggered by local storage, I would want the local module store to be used.

Right now there's no way to do that. What do you think about the feature? I can implement it. I did it in my own small module but then thought well maybe this particular simple module I saw should just work like that.

Feature: Cookie fallback, and JSON caching

I want to implement a feature for this site - falling back on the cookie (by setting a flag by the client, to avoid compatibility) for persistent storage, and caching the localStorage objects instead of always returning JSON.parse in ls.get.

In addition, I want to add event-listener support and encryption support.

Will these features be welcomed?

Change main file to dist

Hey there, is any possibility of updating the dist/local-storage.js file to be the main file in the package.json and also transpiling it down completely to es5?

I'm working on a project that needs to support older browsers and I'm getting issues with it.

browser compatibility issue happens when doing both the following
import ls from 'local-storage';
import ls from 'local-storage/dist/local-storage';

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.