mirror of
https://github.com/S2-/minifyfromhtml.git
synced 2025-08-03 04:10:04 +02:00
use minify
This commit is contained in:
21
node_modules/try-to-catch/lib/try-to-catch.js
generated
vendored
Normal file
21
node_modules/try-to-catch/lib/try-to-catch.js
generated
vendored
Normal file
@@ -0,0 +1,21 @@
|
||||
'use strict';
|
||||
|
||||
const success = (a) => [null, a];
|
||||
const fail = (a) => [a];
|
||||
|
||||
const noArg = (f, a) => () => f(...a);
|
||||
|
||||
module.exports = (fn, ...args) => {
|
||||
check(fn);
|
||||
|
||||
return Promise.resolve()
|
||||
.then(noArg(fn, args))
|
||||
.then(success)
|
||||
.catch(fail);
|
||||
};
|
||||
|
||||
function check(fn) {
|
||||
if (typeof fn !== 'function')
|
||||
throw Error('fn should be a function!');
|
||||
}
|
||||
|
Reference in New Issue
Block a user