UNPKG

reflected-ffi

Version:

A remotely reflected Foreign Function Interface

18 lines (16 loc) 444 B
// (c) https://github.com/WebReflection/to-json-callback // brought in here to avoid a dependency for quick testing /** * @param {Function} [callback=this] * @returns {string} */ export default function (callback = this) { return String(callback).replace( /^(async\s*)?(\bfunction\b)?(.*?)\(/, (_, isAsync, fn, name) => ( name && !fn ? `${isAsync || ""}function ${name}(` : _ ), ); };