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

@alanchenchen/svelte-store-persisted

v0.1.1

Published

persisted plugin for svelte store manager

Downloads

16

Readme

svelte-store-persisted

LICENSE

A persisted plugin for svelte store manager

基于svelte store manager开发的将state状态持久化的插件

Author:Alan Chen

Version: 0.1.1

Date: 2020/1/19

features

  1. 自动同步state到浏览器本地存储,初始化同步一次,在每次commit都会更新。
  2. 本地存储默认是window.localStorage,可选window.sessionStorage。
  3. 由于和mutaion绑定,所以只支持同步操作的本地存储,而不支持web IndexDB。
  4. 本插件支持store单独调用,也支持全局调用,当全局调用时,store必须提供模块的name。
  5. 支持存储指定store的指定数据。

installation

npm install --save-dev @alanchenchen/svelte-store-persisted or yarn add @alanchenchen/svelte-store-persisted --dev

usage

// 全局使用
import { useGlobalPlugins } from "@alanchenchen/svelte-store";
import persisted from "@alanchenchen/svelte-store-persisted";

useGlobalPlugins([
    persisted()
]);
// 分模块使用
// a.js
import { createStore } from "@alanchenchen/svelte-store";
import persisted from "@alanchenchen/svelte-store-persisted";

const a = createStore({name: "A"});
a.use(persisted());
// b.js
import { createStore } from "@alanchenchen/svelte-store";
import persisted from "@alanchenchen/svelte-store-persisted";

const b = createStore({name: "B"});
b.use(persisted());

options

persisted的参数是个对象,格式如下:

  • key - storage存储的key值,默认svelte-store,当全局使用时,会取store实例的name属性,全局使用必须要补全store实例的name。
  • paths - store实例存储在storage里的数据路径,由store实例初始值的key的数组,默认空数组,全部的属性都会存储。
  • filter - 过滤某些不需要存储的情况,回调函数,返回值为true的数据才会被存储,参数如下:
    • storeName - 应用此插件的store实例名称,当全局使用时,可以过滤某些store不被存储
    • type - mutation的类型
  • storage - storage的类型,默认window.localStorage,可选window.sessionStorage。

build

  1. git clone https://github.com/alanchenchen/svelte-store-persisted.git
  2. 然后yarn安装好依赖
  3. 接着使用下面的脚本命令即可,目前入口文件是src/index.ts

scripts

  1. npm run build编译ts文件到dist目录.

license

  • Anti 996(996.ICU)