
Security News
Axios Maintainer Confirms Social Engineering Attack Behind npm Compromise
Axios compromise traced to social engineering, showing how attacks on maintainers can bypass controls and expose the broader software supply chain.
root-data-filter
Advanced tools
一个 Javascript 封装的全局数据过滤转换器
插件的设计初衷
在项目开发中我们会有很多时候需要使用到自定义全局常量,如果在某个模块中单独去定义这样不利于项目的管理,如果能把常量定义(可以单独分包分模块)和常量自动注册并提供统一获取接口这样会有利于常量数据在项目中的管理和使用。
插件的设计思想
构建配置抽离成npm包的意义
通用性
可维护性
质量
编辑器
语言
构建工具
构建命令
更新状态
| 版本 | 时间 |
|---|---|
| 1.0.0 | 2020-01-08 |
库目录结构
未压缩版: timeout-provider.js
压缩版:timeout-provider.min.js
使用
使用npm
$ npm install root-data-filter --save
使用cdn
<script type="text/javascript" src="root-data-filter.min.js"></script>
示例:
// 导入插件
import RootDataFilterLibrary from 'root-data-filter'
// 真实项目开发时应该把 data 数据放到专门的文件中进行模块化区分管理
var data = {
SEX_TYPE: [
{ paramValue: 0, paramDesc: '女' },
{ paramValue: 1, paramDesc: '男' }
],
FLAG_TYPE: [
{ paramValue: 1, paramDesc: '新增' },
{ paramValue: 10, paramDesc: '等待' },
{ paramValue: 128, paramDesc: '归档' },
{ paramValue: 256, paramDesc: '停用' },
{ paramValue: 384, paramDesc: '丢弃' }
],
WF_TYPE: [
{ paramValue: 0, paramDesc: '退回' },
{ paramValue: 1, paramDesc: '提交' },
{ paramValue: 2, paramDesc: '转交' }
],
BOOLEAN_NUMBER_TYPE: [
{ paramValue: 0, paramDesc: '否' },
{ paramValue: 1, paramDesc: '是' }
],
BOOLEAN_BOOLEAN_TYPE: [
{ paramValue: false, paramDesc: '否' },
{ paramValue: true, paramDesc: '是' }
],
// KEY 也可以是 '命名空间/名称' 防止命名冲突
'USER/BOOLEAN_BOOLEAN_TYPE': [
{ paramValue: false, paramDesc: '否' },
{ paramValue: true, paramDesc: '是' }
]
};
var Filter = new RootDataFilterLibrary(data);
var value = Filter._rootFilter(true, 'USER/BOOLEAN_BOOLEAN_TYPE');
console.info(value); // 是
类: RootDataFilterLibrary
构造器 Constructor
new RootDataFilterLibrary()
示例
const RootDataFilterLibrary = new RootDataFilterLibrary({})
方法
函数: _rootFilter(val, id) → {string|number}
说明:插件对外接口函数,转换真实的 value
| 名称 | 类型 | 描述 |
|---|---|---|
| val | string|number | paramValue 的值 |
| id | string |number | 字典名称 key |
实例:
var data = {'USER/BOOLEAN_BOOLEAN_TYPE': [{ paramValue: false, paramDesc: '否' },{ paramValue: true, paramDesc: '是' }]}
var Filter = new RootDataFilterLibrary(data);
var value = Filter._rootFilter(true, 'USER/BOOLEAN_BOOLEAN_TYPE');
console.info(value); // 是
FAQs
一个Javascript封装的全局数据过滤转换器
We found that root-data-filter demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Security News
Axios compromise traced to social engineering, showing how attacks on maintainers can bypass controls and expose the broader software supply chain.

Security News
Node.js has paused its bug bounty program after funding ended, removing payouts for vulnerability reports but keeping its security process unchanged.

Security News
The Axios compromise shows how time-dependent dependency resolution makes exposure harder to detect and contain.