utils-try-function:将函数包装在trycatch块中

时间:2021-05-05 19:09:22
【文件属性】:
文件名称:utils-try-function:将函数包装在trycatch块中
文件大小:10KB
文件格式:ZIP
更新时间:2021-05-05 19:09:22
JavaScript 尝试功能 将函数包装在try / catch块中。 安装 $ npm install utils-try-function 用法 var wrap = require ( 'utils-try-function' ) ; 包装(fcn) 将function包装在try/catch块中。 function fcn ( ) { throw new Error ( 'beep boop' ) ; } var f = wrap ( fcn ) ; var out = f ( ) ; if ( out instanceof Error ) { console . error ( out . message ) ; // returns 'beep boop' } 返回的function具有与包装function相同的签名。 function fcn ( a , b , c , d )
【文件预览】:
utils-try-function-master
----.jshintrc(1KB)
----.gitattributes(12B)
----.jshintignore(118B)
----lib()
--------index.js(1KB)
----.npmignore(519B)
----examples()
--------index.js(1KB)
----TODO.md(11B)
----.travis.yml(141B)
----LICENSE(1KB)
----test()
--------test.js(2KB)
----README.md(5KB)
----Makefile(2KB)
----.editorconfig(169B)
----.gitignore(1KB)
----package.json(1KB)

网友评论