UNPKG

tsdown

Version:

The Elegant Bundler for Libraries

25 lines (24 loc) 585 B
//#region src/utils/general.ts function toArray(val, defaultValue) { if (Array.isArray(val)) return val; else if (val == null) { if (defaultValue) return [defaultValue]; return []; } else return [val]; } function resolveComma(arr) { return arr.flatMap((format) => format.split(",")); } function debounce(fn, wait) { let timeout; return function(...args) { if (timeout) clearTimeout(timeout); timeout = setTimeout(() => { timeout = void 0; fn.apply(this, args); }, wait); }; } const noop = (v) => v; //#endregion export { debounce, noop, resolveComma, toArray };