extra-function
Version:
A function is a set of statements that performs a task or calculates a value.
244 lines (241 loc) • 8.97 kB
JavaScript
var _build = {};
Object.defineProperty(_build, "__esModule", { value: true });
var throttleEarly_1 = _build.throttleEarly = throttle_1 = _build.throttle = debounceEarly_1 = _build.debounceEarly = debounce_1 = _build.debounce = after = _build.after = restrictAfter_1 = _build.restrictAfter = before = _build.before = restrictBefore_1 = _build.restrictBefore = once = _build.once = restrictOnce_1 = _build.restrictOnce = restrict_1 = _build.restrict = delay_1 = _build.delay = defer_1 = _build.defer = curryRight_1 = _build.curryRight = curry_1 = _build.curry = composeRight_1 = _build.composeRight = compose_1 = _build.compose = partialRight = _build.partialRight = attachRight_1 = _build.attachRight = partial = _build.partial = attach_1 = _build.attach = unspread_1 = _build.unspread = spread_1 = _build.spread = flip = _build.flip = reverse_1 = _build.reverse = memoize_1 = _build.memoize = negate_1 = _build.negate = decontextify_1 = _build.decontextify = contextify_1 = _build.contextify = isGenerator_1 = _build.isGenerator = isAsync_1 = _build.isAsync = is_1 = _build.is = apply_1 = _build.apply = call_1 = _build.call = bind_1 = _build.bind = arity = _build.arity = length_1 = _build.length = name_1 = _build.name = ARGUMENTS_1 = _build.ARGUMENTS = COMPARE_1 = _build.COMPARE = IDENTITY_1 = _build.IDENTITY = TRUE_1 = _build.TRUE = FALSE_1 = _build.FALSE = NOOP_1 = _build.NOOP = void 0;
function NOOP(...args) { }
var NOOP_1 = _build.NOOP = NOOP;
function FALSE(...args) {
return false;
}
var FALSE_1 = _build.FALSE = FALSE;
function TRUE(...args) {
return true;
}
var TRUE_1 = _build.TRUE = TRUE;
function IDENTITY(v) {
return v;
}
var IDENTITY_1 = _build.IDENTITY = IDENTITY;
function COMPARE(a, b) {
return a < b ? -1 : (a > b ? 1 : 0);
}
var COMPARE_1 = _build.COMPARE = COMPARE;
function ARGUMENTS(...args) {
return args;
}
var ARGUMENTS_1 = _build.ARGUMENTS = ARGUMENTS;
function name(x) {
return x.name;
}
var name_1 = _build.name = name;
function length(x) {
return x.length;
}
var length_1 = _build.length = length;
var arity = _build.arity = length;
function bind(x, ths, ...prefix) {
return x.bind(ths, ...prefix);
}
var bind_1 = _build.bind = bind;
function call(x, ths = null, ...args) {
return x.call(ths, ...args);
}
var call_1 = _build.call = call;
function apply(x, ths = null, args) {
return x.apply(ths, args);
}
var apply_1 = _build.apply = apply;
function is(v) {
return typeof v === "function";
}
var is_1 = _build.is = is;
function isAsync(v) {
const AsyncFunction = (async function () { }).constructor;
return v instanceof AsyncFunction;
}
var isAsync_1 = _build.isAsync = isAsync;
function isGenerator(v) {
const GeneratorFunction = (function* () { }).constructor;
return v instanceof GeneratorFunction;
}
var isGenerator_1 = _build.isGenerator = isGenerator;
function contextify(x) {
return function (...args) { return x(this, ...args); };
}
var contextify_1 = _build.contextify = contextify;
function decontextify(x) {
return (ths = null, ...args) => x.call(ths, ...args);
}
var decontextify_1 = _build.decontextify = decontextify;
function negate(x) {
return (...args) => !x(...args);
}
var negate_1 = _build.negate = negate;
function memoize(x, fr = null, cache = null) {
var fr = fr || IDENTITY;
var cache = cache || new Map();
return (...args) => {
var k = fr(...args);
if (cache.has(k))
return cache.get(k);
var v = x(...args);
cache.set(k, v);
return v;
};
}
var memoize_1 = _build.memoize = memoize;
function reverse(x) {
return (...args) => x(...args.reverse());
}
var reverse_1 = _build.reverse = reverse;
var flip = _build.flip = reverse;
function spread(x) {
return (...args) => x(args);
}
var spread_1 = _build.spread = spread;
function unspread(x) {
return (args) => x(...args);
}
var unspread_1 = _build.unspread = unspread;
function attach(x, ...prefix) {
return (...args) => x(...prefix, ...args);
}
var attach_1 = _build.attach = attach;
var partial = _build.partial = attach;
function attachRight(x, ...suffix) {
return (...args) => x(...args, ...suffix);
}
var attachRight_1 = _build.attachRight = attachRight;
var partialRight = _build.partialRight = attachRight;
function compose(...xs) {
return composeRight(...xs.reverse());
}
var compose_1 = _build.compose = compose;
function composeRight(...xs) {
return (...args) => {
if (xs.length === 0)
return;
var a = xs[0](...args);
for (var i = 1, I = xs.length; i < I; i++)
a = xs[i](a);
return a;
};
}
var composeRight_1 = _build.composeRight = composeRight;
function curry(x, n = x.length) {
return (...args) => {
if (args.length >= n)
return x(...args);
else
return curry((...rest) => x(...args, ...rest), n - args.length);
};
}
var curry_1 = _build.curry = curry;
function curryRight(x, n = x.length) {
return curry(reverse(x), n);
}
var curryRight_1 = _build.curryRight = curryRight;
function defer(x) {
return (...args) => {
var h = setImmediate(flush);
function clear() { clearImmediate(h); h = null; }
function flush() { x(...args); clear(); }
return { clear, flush };
};
}
var defer_1 = _build.defer = defer;
function delay(x, t) {
return (...args) => {
var h = setTimeout(flush, t);
function clear() { clearTimeout(h); h = null; }
function flush() { x(...args); clear(); }
return { clear, flush };
};
}
var delay_1 = _build.delay = delay;
function restrict(x, start, end = -1) {
var i = -1;
return (...args) => {
if ((++i < start) === (i < end || end < 0))
return;
return x(...args);
};
}
var restrict_1 = _build.restrict = restrict;
function restrictOnce(x) {
return restrict(x, 0, 1);
}
var restrictOnce_1 = _build.restrictOnce = restrictOnce;
var once = _build.once = restrictOnce;
function restrictBefore(x, n) {
return restrict(x, 0, n);
}
var restrictBefore_1 = _build.restrictBefore = restrictBefore;
var before = _build.before = restrictBefore;
function restrictAfter(x, n) {
return restrict(x, n);
}
var restrictAfter_1 = _build.restrictAfter = restrictAfter;
var after = _build.after = restrictAfter;
function debounce(x, t, T = -1) {
var savedArgs;
var h = null, H = null;
function clear() {
clearTimeout(h);
clearTimeout(H);
h = H = null;
}
function flush() { x(...savedArgs); clear(); }
return (...args) => {
savedArgs = args;
if (T >= 0)
H = H || setTimeout(flush, T);
if (T < 0 || t < T) {
clearTimeout(h);
h = setTimeout(flush, t);
}
return { clear, flush };
};
}
var debounce_1 = _build.debounce = debounce;
function debounceEarly(x, t, T = -1) {
var h = null, H = null;
function clear() { h = H = null; }
function flush() { clear(); }
return (...args) => {
if (!h && !H)
x(...args);
if (T >= 0)
H = H || setTimeout(flush, T);
if (T < 0 || t < T) {
clearTimeout(h);
h = setTimeout(flush, t);
}
return { clear, flush };
};
}
var debounceEarly_1 = _build.debounceEarly = debounceEarly;
function throttle(x, t) {
var savedArgs;
var h = null;
function clear() { h = null; }
function flush() { x(...savedArgs); clear(); }
return (...args) => {
savedArgs = args;
h = h || setTimeout(flush, t);
return { clear, flush };
};
}
var throttle_1 = _build.throttle = throttle;
function throttleEarly(x, t) {
var h = null;
function clear() { h = null; }
function flush() { clear(); }
return (...args) => {
if (!h)
x(...args);
h = h || setTimeout(flush, t);
return { clear, flush };
};
}
throttleEarly_1 = _build.throttleEarly = throttleEarly;
export { ARGUMENTS_1 as ARGUMENTS, COMPARE_1 as COMPARE, FALSE_1 as FALSE, IDENTITY_1 as IDENTITY, NOOP_1 as NOOP, TRUE_1 as TRUE, after, apply_1 as apply, arity, attach_1 as attach, attachRight_1 as attachRight, before, bind_1 as bind, call_1 as call, compose_1 as compose, composeRight_1 as composeRight, contextify_1 as contextify, curry_1 as curry, curryRight_1 as curryRight, debounce_1 as debounce, debounceEarly_1 as debounceEarly, decontextify_1 as decontextify, _build as default, defer_1 as defer, delay_1 as delay, flip, is_1 as is, isAsync_1 as isAsync, isGenerator_1 as isGenerator, length_1 as length, memoize_1 as memoize, name_1 as name, negate_1 as negate, once, partial, partialRight, restrict_1 as restrict, restrictAfter_1 as restrictAfter, restrictBefore_1 as restrictBefore, restrictOnce_1 as restrictOnce, reverse_1 as reverse, spread_1 as spread, throttle_1 as throttle, throttleEarly_1 as throttleEarly, unspread_1 as unspread };