【文件属性】:
文件名称:p-if:有条件的承诺链
文件大小:5KB
文件格式:ZIP
更新时间:2021-05-16 01:34:35
TypeScript
若
有条件的承诺链
安装
$ npm install p-if
用法
import pIf from 'p-if' ;
getData ( )
. then ( pIf ( process . env . NODE_ENV !== 'production' , addDebugInfo ) )
. then ( data => {
console . log ( data ) ;
} ) ;
也可以嵌套:
import pIf from 'p-if' ;
getList ( )
. then ( pIf ( shouldSort , pIf ( sortDirection === 'ascending' , sort . asc , sort . desc ) ) )
. then ( list => {
console . log ( list ) ;
}
【文件预览】:
p-if-main
----index.test-d.ts(2KB)
----.gitattributes(19B)
----.github()
--------workflows()
----test.js(1KB)
----license(1KB)
----index.d.ts(1KB)
----.npmrc(19B)
----.editorconfig(175B)
----.gitignore(23B)
----index.js(366B)
----readme.md(1KB)
----package.json(758B)