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

localstoragerepo

v1.0.1

Published

Generic CRUD repo generator that uses only one unique key of the sessionStorage

Downloads

2

Readme

alt text ( LocalStorageRepo )

A repo generator that uses only on key of the sessionStorage to store all data in a unique Array. is write in pure ES5 and implements a comple generic CRUD.

Goals

To have a generic repo (CRUD) generator linked to one key of the LocalStorage for use it as a lightweitgt persistence system directly in the browser.

you can use for ...

some examples Store all data you need indexed and easly accesible as you can do with a "repo" as in a imaginary animal clinic.

petsRepo = new LocalStorageRepo("pets" , "name");
productRepo = new LocalStorageRepo("products", "idProduct");

petsRepo.create({name:"kytybity", specie: "cat", clinicalData:"have a large tail"});
petsRepo.create({name:"rufo", specie: "dog", clinicalData:"Wooof"});
console.log ( petsRepo.findOneById("kytybity") )
petsRepo.update({name:"kytybity", specie: "cat", clinicalData:"have no tail, we cut it"});
petsRepo.findBy("specie" , "cat");//find all cats only , no dogs.

but you can do some other stuff , like ... store functions as text indexed by name and rerun later ;) dont know why someone want to do this :P

functions = new LocalStorageRepo("functions", "name")
functions.update({name:"somefunc", text: sumefunc.toString()})
eval((functions.findOneById("somefunc").text)

or if you want avoid "eval" you can do like this too ( is a bit more  hkr ... XD)
var getFooFromStorageLoL = new Function( "return " + (new LocalStorageRepo("functions", "name")).findOneById("foo").text )
var foo = getFooFromStorageLoL();
//now you can use your foo as allways... 

save an Oajax response.... and all that you wants , if it can be stored in a nutshell of course ^^

rxjs.ajax("/my/great/stuff").subscribe(repo.create)

Instalation

include as script for prod

<script>
  https://cdn.rawgit.com/pascualmg/LocalStorageRepo/master/LocalStorageRepo.js
</script>

include as script for devel

<script>
https://rawgit.com/pascualmg/LocalStorageRepo/master/LocalStorageRepo.js
</script>

or copypaste in console https://github.com/pascualmg/LocalStorageRepo/blob/master/LocalStorageRepo.js

(https://stackoverflow.com/questions/6551446/can-i-run-html-files-directly-from-github-instead-of-just-viewing-their-source)

functional load test create 1001 elements , delete 500 update 500

 function testInBrowser() {
        var repo = (new LocalStorageRepo("logs", "id"));
        repo.reset();
        for (var i = 1000; i >= 0; i--) {//CREATE 1001 elements
                   repo.create({id:i,data1:i, data2:i});//only requires the id
        }

        for (var i = 499; i >= 0; i--) {//DELETE 500
          repo.del(i) //uses the "id" as id
        }
        for (var metaId = 500; metaId <= 1000; metaId++) {//UPDATE 500
          repo.update({id:1, data1: i + "updated", newfields:"more data"});
        }
		
	console.log(repo.findAll())

      }

Unitary test with jest

npm install
npm test

Limitations

The max quote , is the max quote of a key -> value in the DataStorage in your navigator .