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

ticatec-dictionary

v0.0.5

Published

拥有管理数据字典的工具类库

Downloads

1

Readme

公共数据字典管理

在前台的开发中,我们经常需要中使用数据字典用于选择,key-value转换工作。通过这个管理类库可以简单的实现。里面总共包括了三个组件

数据字典管理类单一实例 dicManager

这是一个数据字典管理类的实例。项目中需要的所有数据字典都可以让这个来管理。使用方法如下:

  import dicManager from 'ticatec-dictonary';

dicManager包括以下方法:

  • 注册一个普通数据字典,registerDic
  • 注册一个树状数据字典, registerTreeDic
  • 获取一个数据字典,get
  • 初始化加载指定的数据字典

registerDic

    /**
     * 注册一个普通的数据字典
     * @param key 数据字典的名称
     * @param dataLoader 加载数据的方法
     * @param keyName 数据字典中key的字段名
     * @param getText 可以是数据项中文字值对应的字段名,也可以是一个函数,根据key返回对应的文字值
     */
    dicManager.registerDic(key, dataLoader, keyName, getText)

registerTreeDic

    /**
     * 注册一个普通的数据字典
     * @param key 数据字典的名称
     * @param dataLoader 加载数据的方法
     * @param keyName 数据字典中key的字段名
     * @param getText 可以是数据项中文字值对应的字段名,也可以是一个函数,根据key返回对应的文字值
     */
    dicManager.registerTreeDic(key, dataLoader, keyName, getText)

get

返回对应的数据字典

    let dic = await dicManager.get('country');

Dictionary

数据字典类,可以获取list,根据key查找对应的数据项,根据key查找对应的文本值

  • async reload() 重新加载数据
  • toList() 转换成数组
  • get(key) 返回对应的数据对象
  • getText(key) 返回对应的文本值

TreeDictionary

  • async reload() 重新加载数据
  • toList() 转换成数组
  • get(key) 返回对应的数据对象
  • getText(key) 返回对应的文本值
  • getChildren(key) 返回指定数据项的子项目列表