
Product
Introducing Supply Chain Attack Campaigns Tracking in the Socket Dashboard
Campaign-level threat intelligence in Socket now shows when active supply chain attacks affect your repositories and packages.
util-interface
Advanced tools
import interfaceRepair from 'util-interface'
或者
var interfaceRepair = require('util-interface')
或者
<script src="node_modules/util-interface/dist/index.min.js"></script>
<script>
//直接使用 interfaceRepair 函数
</script>
/*
所有需要用到的参数,都要设置默认值
逻辑 :
如果默认值为数字,就将对应参数转化为数字,接口参数不存在,或转化失败(NaN),采取默认值
如果默认值为字符串,就将对应参数转化为字符串,接口参数不存在,采取默认值
如果默认值为json,就将对应参数转化为json,接口参数不存在或为其他数据类型, 就采取默认值
如果默认值为数组, 就将对应参数转化为数组, 接口参数不存在或为其他数据类型, 就转化为空数组
*/
//默认值
var def = {
status : 1,
msg : '调用成功',
data : {
data : [{
name : '新浪用户'
}]
}
}
//接口
result = {
status : 0,
data : {
data : [{
name : '义薄云天黑心小王子'
},{
name : ''
}]
}
}
result = interfaceRepair(def, 接口result, options)
/*
{
"status": 1,
"msg": "调用成功",
"data": {
"data": [{
"name": "义薄云天黑心小王子"
}, {
"name": "新浪用户"
}]
}
}
*/
| Name | Default | Description |
|---|---|---|
| stringEmptyToDef | true | 参数为空字符串, 是否采取默认值 |
FAQs
The npm package util-interface receives a total of 2 weekly downloads. As such, util-interface popularity was classified as not popular.
We found that util-interface 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.

Product
Campaign-level threat intelligence in Socket now shows when active supply chain attacks affect your repositories and packages.

Research
Malicious PyPI package sympy-dev targets SymPy users, a Python symbolic math library with 85 million monthly downloads.

Security News
Node.js 25.4.0 makes require(esm) stable, formalizing CommonJS and ESM compatibility across supported Node versions.