How to use the @tinkoff/utils/object/propEq function in @tinkoff/utils

To help you get started, we’ve selected a few @tinkoff/utils examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github TinkoffCreditSystems / tinkoff-request / packages / cache-utils / src / shouldCacheExecute.ts View on Github external
export default (name: string, dflt: boolean) => (context: Context) => {
    const request = context.getRequest();
    const forced = prop('cacheForce', request);
    const forcedSpecific = prop(`${name}CacheForce`, request);
    const disabled = propEq('cache', false, request);
    const enabledSpecific = propOr(`${name}Cache`, disabled ? false : dflt, request);
    const isComplete = context.getStatus() === Status.COMPLETE;

    if (context.getStatus() === Status.INIT) {
        context.updateExternalMeta(CACHE, {
            forced,
            enabled: !disabled,
            [`${name}Enabled`]: enabledSpecific,
            [`${name}Force`]: forcedSpecific,
        });
    }

    if (forcedSpecific) {
        return isComplete;
    }