UNPKG

badman-core

Version:

badman-core is the layer what all the badman packages depended,or can be used as a tool kit.

38 lines 1.22 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); class Base { static sleep(seconds = 0, cb) { return new Promise((resolve, reject) => { setTimeout(() => { resolve(true); }, seconds); }).then(val => { if (cb) cb(val); }); } static clone(source, target) { let keys = Object.keys(source); let i = keys.length; while (i--) { let k = keys[i]; target[k] = source[k]; } return target; } static getMethodArgs(func) { // 先用正则匹配,取得符合参数模式的字符串. // 第一个分组是这个: ([^)]*) 非右括号的任意字符 let args = func.toString().match(/function\s.*?\(([^)]*)\)/)[1]; // 用逗号来分隔参数(arguments string). return args.split(",").map(function (arg) { // 去除注释(inline comments)以及空格 return arg.replace(/\/\*.*\*\//, "").trim(); }).filter(function (arg) { // 确保没有 undefined. return arg; }); } } exports.default = Base; //# sourceMappingURL=Base.js.map