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 🙏

© 2026 – Pkg Stats / Ryan Hefner

mobx-extend

v1.0.6

Published

A simple mobx extension package that provides initialization and reset functions for mobx data. And changed the way toJS is used

Readme

一个简单的mobx扩展包,提供对mobx数据进行初始化,重置功能。以及改变了toJS的使用方式(A simple mobx extension package that provides initialization and reset functions for mobx data. And changed the way toJS is used)

English translated by Google Translator

如果你的版本低于1.0.6,建议卸载重装。(If your version is lower than 1.0.6, it is recommended to uninstall and reinstall.)

  • 对package.json中的依赖了解不够造成的问题,深表歉意。(I apologize for the problems caused by insufficient understanding of the dependencies in package.json.)
  • 请先检查node_module文件下的mobx-extend目录,若包含了另一个node_module文件夹,请卸载并安装最新版本。(Please check the mobx-extend directory under the node_module file first, if it contains another node_module folder, please uninstall and install the latest version.)

安装(install)

请先安装mobx 4.x 或者 5.x(Please install mobx 4.x or 5.x first)

npm install mobx-extend

使用(how to use)

在mobx类文件中(In the mobx class file)

// store.js
import mobxExtend from 'mobx-extend'
import {observable} from 'mobx'

// no param
@mobxExtend
class Store{
    @observable test
    @observable sth
}

// with param

/** 
 * 根据typeOf关键字返回值来自定义需要重置的类型默认值,默认为
 * (Customize the default value of the type that 
 * needs to be reset according to the return value of 
 * the typeOf keyword, the default is):
 * 
 *  bool=false,
    arr=[],
    obj={},
    num=0,
    str='',
    func=function(){
        console.warn(`function ${key} is init now`
        )};
 */
@mobxExtend({
    bool:true,
    str:undefined,
    num:-1,
    arr:[],
    obj:Object.create(null),
    func:()=>{}
})
class Store{
    @observable test
    @observable sth
}

export default new Store()

初始化mobx数据(Initialize mobx data)

首先,在需要使用的文件中导入之前的mobx类文件(First, import the previous mobx class file in the file that needs to be used)

import store from './store.js'

初始化mobx数据,可用于组件挂载前/后,随你喜欢(Initialize mobx data, which can be used before/after component mounting,up to you)

store.init(initParams)

  • {Object} initParams 需要初始化数据的一些字段(Some fields that need to initialize data)
stroe.init({
    test:'initTest',
    sth: null
})

重置mobx(reset mobx)

store.reset([fields],[exclude])

  • {Array} fields 需要重置的mobx keys(Mobx keys that need to be reset)
  • {Boolean} exclude 为true时,则意味着fields为不需重置的mobx keys(When true, it means that fields are mobx keys that do not need to be reset)
// 重置mobx数据 (reset mobx data)
store.reset()
// 或者只重置部分数据,如(Or only reset part of the data, such as):test
store.reset(['test'])
// 指定不重置的数据,如(Specify data not to be reset, such as):test
store.reset(['test'],true)

将mobx对象转为普通的js对象(Convert mobx objects to ordinary js objects)

这个方法只是为了不用在使用的文件中导入toJS而已(This method is just to avoid importing toJS in the used file)

store.toJS([fields])

  • {Array} fields 需要转换成js对象的keys(The keys that need to be converted into js objects)
store.toJS(['test'])