Dia antes primera install
This commit is contained in:
29
node_modules/stringify-parameters/lib/stringify-parameters.js
generated
vendored
Normal file
29
node_modules/stringify-parameters/lib/stringify-parameters.js
generated
vendored
Normal file
@@ -0,0 +1,29 @@
|
||||
'use strict';
|
||||
|
||||
const unpackString = require('unpack-string');
|
||||
|
||||
function stringifyParameters(fn) {
|
||||
if (!fn || (fn.constructor !== String && fn.constructor !== Function)) {
|
||||
return;
|
||||
}
|
||||
|
||||
let fnString = fn.toString().replace(/^\s+|\s+$/g, '');
|
||||
if (!fnString) {
|
||||
return;
|
||||
}
|
||||
|
||||
const isDeclaredWithFunctionKeyword = /^function/i;
|
||||
const isNotArrowFunction = /^[^\s=>]+\(/i;
|
||||
|
||||
// Is an Arrow function with a parameter declared without parenthesis and with no default value
|
||||
if (!isDeclaredWithFunctionKeyword.test(fnString) && !isNotArrowFunction.test(fnString)) {
|
||||
let arrowWithoutParenthesis = fnString.match(/^(.*?)=>/);
|
||||
if (arrowWithoutParenthesis) {
|
||||
return unpackString(arrowWithoutParenthesis[1]).replace(/^\s+|\s+$/g, '');
|
||||
}
|
||||
}
|
||||
|
||||
return unpackString(fnString).replace(/^\s+|\s+$/g, '');
|
||||
}
|
||||
|
||||
module.exports = stringifyParameters;
|
||||
Reference in New Issue
Block a user