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

@allnulled/universal-store

v1.0.3

Published

State manager for browser and node.js.

Downloads

224

Readme

universal-store

Gestor de estado para navegador y node.js.

Instalación

Descargar la librería

npm install -s @allnulled/universal-store

Importar la librería

Modos de importar la librería

Dado que usa otras librerías, y pueden quererse usar desde otros módulos o no, puedes usar el archivo:

  • store.js: este fichero tiene todas las APIs necesarias. Incluye:
  • store.unbundled.js: este fichero solo tiene la parte que le es propia, y sobreentiende que cargarás las otras librerías necesarias por tu propia cuenta.

NOTA: Por defecto, se usa store.unbundled.js.

En node.js

Puedes usar require o import indistintamente para importar el módulo.

En browser

<script src="node_modules/@allnulled/universal-store/dist/store.js"></script>

O alternativamente:

<script src="node_modules/@allnulled/universal-store/dist/lib/ufs.js"></script>
<script src="node_modules/@allnulled/universal-store/dist/store.unbundled.js"></script>

API

Crear una store

Para crear una store, desde node.js puedes:

const store = require("@allnulled/universal-store").create();

Si estás en browser y no usas módulos, o si estás en node.js y no quieres usar require, puedes:

const store = UniversalStore.create();

Usar una store

Los métodos de la API disponibles por defecto son:

store.get("property/id");
store.set("property/id", 1);
store.watch("property/id", function(event, property_path, value) {});
store.unwatch("property/id", previous_function);
store.delete("property/id");
store.push("property/id/to/array", 1);
store.pop("property/id/to/array");
store.unshift("property/id/to/array", 1);
store.shift("property/id/to/array");
store.add("property/id/to/object", "key", 1);
store.remove("property/id/to/object", "key");
store.splice("property/id/to/array", 5, 10, ...[1, 1, 1]);
store.extend("property/id/to/object", { more: "props" });
store.modify("property/id", function(value) { return "new value"; });
store.hydrate("file_to_read_from.json");
store.dehydrate("file_to_write_to.json");

Todos son métodos síncronos y no tienen alternativa.

Los métodos hydrate y dehydrate están polyfileados con la librería ufs o universal-file-system, de allnulled también. Así que puedes persistir el estado del store tanto en node.js como en el browser.