How to use remeda - 9 common examples

To help you get started, we’ve selected a few remeda 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 vladimiry / ElectronMail / src / electron-preload / webview / protonmail / api / build-db-patch.ts View on Github external
Code?: number, // 15052
                        Error?: string, // Message does not exist
                        ErrorDescription?: string,
                        Details?: object;
                    }>(error)
                    &&
                    error.status === 422
                    &&
                    error.data.Code === 15052
                ) { // ignoring the error as expected to happen
                    logger.warn(
                        // WARN don't log message-specific data as it might include sensitive fields
                        `Skip message fetching as it has been already removed from the trash before fetch action started`,
                        // WARN don't log full error as it might include sensitive data
                        JSON.stringify(
                            pick(error, ["data", "status", "statusText"]),
                        ),
                    );
                } else {
                    throw error;
                }
            }
        }
        await (async () => {
            const labels = await api.label.query();
            const upsertIds = mapping.folders.upsertIds.map(({id}) => id);
            const folders = labels
                .filter(({ID}) => upsertIds.includes(ID))
                .map(Database.buildFolder);
            patch.folders.upsert.push(...folders);
        })();
        for (const {id} of mapping.contacts.upsertIds) {
github typeless-js / create-react-app-starter / src / components / RouteResolver.tsx View on Github external
import React, { useEffect, useState } from 'react';
import * as R from 'remeda';
import { usePrevious } from 'src/hooks/usePrevious';
import { RouteConfig } from 'src/types';
import { useActions, useMappedState } from 'typeless';
import { getRouterState, RouterActions, RouterLocation } from 'typeless-router';
import { getGlobalState } from 'src/features/global/interface';

// load dynamically all routes from all interfaces
const req = require.context('../features', true, /interface.tsx?$/);

const routes = R.flatMap(req.keys(), key => {
  const module = req(key);
  const items = Object.values(module);
  return items.filter((item: any) => item.type === 'route') as RouteConfig[];
});

function getMatch(loc: RouterLocation | null, isLogged: boolean) {
  if (!loc) {
    return null;
  }
  return routes.find(route => {
    if ((route.auth && !isLogged) || (!route.auth && isLogged)) {
      return false;
    }
    return route.path === loc.pathname;
  });
}
github typeless-js / create-react-app-starter / src / components / RouteResolver.tsx View on Github external
(global, router) => ({
      ...R.pick(global, ['isLoaded', 'user']),
      ...R.pick(router, ['location']),
    })
  );
github typeless-js / create-react-app-starter / src / components / RouteResolver.tsx View on Github external
(global, router) => ({
      ...R.pick(global, ['isLoaded', 'user']),
      ...R.pick(router, ['location']),
    })
  );
github alternate-file / vscode-alternate-file / src / engine / Projections.ts View on Github external
) => (
  patterns: AlternatePattern.t[]
): ResultP => {
  return pipeAsync(
    patterns,
    R.map(AlternatePattern.alternatePath(userFilePath, projectionsPath)),
    paths => R.compact(paths) as string[],
    File.findExisting,
    mapError((alternatesAttempted: string[]) => ({
      alternatesAttempted,
      message: `No alternate found for ${userFilePath}. Tried: ${alternatesAttempted}`,
      startingFile: userFilePath
    }))
  );
};
github alternate-file / vscode-alternate-file / src / engine / File.ts View on Github external
export const findExisting = async (filePaths: t[]): ResultP => {
  return pipeAsync(
    filePaths,
    R.map(fileExists),
    files => Promise.all(files),
    file => firstOk(file),
    mapError(always(filePaths))
  );
};
github alternate-file / vscode-alternate-file / src / engine / Projections.ts View on Github external
    paths => R.compact(paths) as string[],
    File.findExisting,
github alternate-file / vscode-alternate-file / src / engine / Projections.ts View on Github external
export const projectionsToAlternatePatterns = (
  projections: t
): AlternatePattern.t[] => {
  const pairs = R.toPairs(projections) as ProjectionPair[];
  const allPairs = R.flatten(pairs.map(splitOutAlternates));

  return allPairs.map(projectionPairToAlternatePattern);
};
github alternate-file / vscode-alternate-file / src / engine / Projections.ts View on Github external
export const projectionsToAlternatePatterns = (
  projections: t
): AlternatePattern.t[] => {
  const pairs = R.toPairs(projections) as ProjectionPair[];
  const allPairs = R.flatten(pairs.map(splitOutAlternates));

  return allPairs.map(projectionPairToAlternatePattern);
};

remeda

A utility library for JavaScript and Typescript.

MIT
Latest version published 6 days ago

Package Health Score

89 / 100
Full package analysis