UNPKG

async-states

Version:

Core of async-states

31 lines (29 loc) 954 B
let __DEV__ = process.env.NODE_ENV !== "production"; let maybeWindow = typeof window !== "undefined" ? window : undefined; let isServer = typeof maybeWindow === "undefined" || "Deno" in maybeWindow; let emptyArray = []; function defaultHash(args, payload) { return JSON.stringify({ args, payload }); } function isPromise(candidate) { return !!candidate && isFunction(candidate.then); } function isFunction(fn) { return typeof fn === "function"; } function cloneProducerProps(props) { return { args: props.args, payload: props.payload, }; } const defaultAnonymousPrefix = "async-state-"; const nextKey = (function autoKey() { let key = 0; return function incrementAndGet() { key += 1; return `${defaultAnonymousPrefix}${key}`; }; })(); export { __DEV__, cloneProducerProps, defaultHash, emptyArray, isFunction, isPromise, isServer, maybeWindow, nextKey }; //# sourceMappingURL=utils.js.map