Giter VIP home page Giter VIP logo

Comments (7)

concisetony avatar concisetony commented on May 22, 2024

yes

from store.js.

marcuswestin avatar marcuswestin commented on May 22, 2024

Hi guys!

I think I would be a bit surprised if JSON parsing was a bottle neck in any real world usage of store.js. Do you do have such a problem? If you do I can definitely see the value of a store.exists(key). However, if you don't I believe it may be in the interest of the project to avoid adding features without real world needs. Basically in the interest of keeping it lean, avoiding feature creep, and so on.

What do you guys think?

Cheers,
Marcus

from store.js.

joshefin avatar joshefin commented on May 22, 2024

It's not a bottleneck in most cases, but when the data is large (few thousand items) it would be useful to avoid unneeded parsing.

from store.js.

marcuswestin avatar marcuswestin commented on May 22, 2024

Hmm, are you sure? Like, have you tested that? I would not take it for granted that the CPU bound parsing takes significantly longer than reading the string from disk (if that's how local storage persistence works, I don't know).

You may have a point, but if you haven't collected the data then can you know that there is a need

Cheers!

from store.js.

marcuswestin avatar marcuswestin commented on May 22, 2024

Here's an attempt at explaining why I'm hesitant adding things without understanding why it's necessary:

First the downsides: every new feature adds complexity, bytes to download (if store.js is used on thousands of sites and downloaded by millions of people every month, then do those bytes become meaningful? Probably. We recently removed support for Firefox 2 and 3 for this reason). It also is another thing to maintain, document, and read up on when you're considering to use the project and are trying to understand it.

However, there may be upsides! And if there are, I'm all for new beneficial features! But we should really know that they are beneficial!

Let me know if you are up to get some data supporting the need, would love to know the performance of read vs parse and if there is a significant bottleneck in either or if they're about the same. If not, I'm going to vote for closing this issue. Oui?

Cheers!
Marcus

from store.js.

A973C avatar A973C commented on May 22, 2024

👍

Hi!
I'm actually facing the same need! I use LocalStorage to store user requested information and I don't want to save a duplicated content. So if an option could exist, I also would be interested!

Based on the ReadMe example:
store.set('tags', ['javascript', 'localStorage', 'store.js'])

How can I check if user input (for example "store.js") exist in store.tags?

Cheers and thank you for your great plugin!

================================================

EDIT as closed topic:

Marcus, you've saved my day!
Thank you so much ;-)

Cheers!

from store.js.

marcuswestin avatar marcuswestin commented on May 22, 2024

Not quite the same issue, but here is what you'd do. Three options I guess:

Just store the tags:

store.set('javascript',true)
store.get('javascript)

Store all tags in an array:

var tags = store.get('tags') || []
var tagPresent = tags.indexOf('javascript') != -1
tags.push('javascript')
store.set('tags', tags)

Store tags in an object

var tags = store.get('tags') || {}
var tagPresent = tags['javascript']
tags['javascript'] = true
store.set('tags', tags)

Cheers!
Marcus

from store.js.

Related Issues (20)

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.