How to use fromentries - 9 common examples

To help you get started, we’ve selected a few fromentries 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 developmentseed / observe / app / reducers / map.js View on Github external
fetchedTiles = {}
        lru = []
      } else {
        // clear tagged data
        const offlinePredicate = x =>
          // drop offline tiles tagged with only the specified tag
          !(
            x.offline &&
            x.offline.length === 1 &&
            x.offline.includes(offline)
          )

        const offlineFilter = tile =>
          tile.offline ? tile.offline.filter(t => t !== offline) : false

        fetchedTiles = fromEntries(
          Object.entries(state.fetchedTiles)
            .filter(([k, v]) => offlinePredicate(v))
            .map(([k, v]) => [
              k,
              {
                ...v,
                offline: offlineFilter(v)
              }
            ])
        )
        lru = state.lru.filter(offlinePredicate).map(tile => ({
          ...tile,
          offline: offlineFilter(tile)
        }))

        // TODO this really ought to update pendingEviction with the list of
github developmentseed / observe / app / reducers / map.js View on Github external
// TODO re-tag fetchedTiles (remove id)

        return {
          ...state,
          offlineResources
        }
      }

      return state
    }

    case types.DELETED_OFFLINE_RESOURCE: {
      const { id } = action

      const offlineResources = fromEntries(
        Object.entries(state.offlineResources).filter(([k, v]) => k !== id)
      )

      return {
        ...state,
        offlineResources
      }
    }

    case types.RENAME_OFFLINE_RESOURCE: {
      const { id, name } = action

      return {
        ...state,
        offlineResources: {
          ...state.offlineResources,
github magento / baler / src / magentoFS.ts View on Github external
const pendingThemes: Promise<[string, Theme]>[] = Object.entries(
        themePaths,
    ).map(async ([fullID, path]) => {
        const [area, vendor, name] = fullID.split('/');
        const themeID = `${vendor}/${name}`;
        const theme: Theme = {
            name,
            vendor,
            area: area as Theme['area'],
            themeID,
            path,
            parentID: await getThemeParentName(path),
        };
        return [themeID, theme] as [string, Theme];
    });
    return fromEntries(await Promise.all(pendingThemes));
}
github magento / baler / src / magentoFS.ts View on Github external
function getModulesFromPaths(
    modulePaths: ComponentPaths['modules'],
): Record {
    return fromEntries(
        Object.entries(modulePaths).map(([moduleID, path]) => {
            const mod: Module = {
                moduleID,
                path: path,
            };
            return [moduleID, mod] as [string, Module];
        }),
    );
}
github DrewML / scd / src / magentoFS.ts View on Github external
export async function getComponents(root: string): Promise {
    assertAbsolute(root);
    const [composer, nonComposer] = await Promise.all([
        getComposerComponents(root),
        getNonComposerComponents(root),
    ]);

    const allModules = [...composer.modules, ...nonComposer.modules];
    const allThemes = [...composer.themes, ...nonComposer.themes];

    const modulesByName = fromEntries(allModules.map(m => [m.moduleID, m]));
    const themesByID = fromEntries(
        allThemes.map(theme => {
            return [theme.themeID, theme];
        }),
    );

    return {
        modules: modulesByName,
        themes: themesByID,
    };
}
github developmentseed / observe / app / selectors / index.js View on Github external
offlineResources =>
    fromEntries(
      Object.entries(offlineResources).map(([name, resource]) => {
        const { data, mapTiles, satelliteTiles, satellite } = resource

        let percentage = (data.percentage + mapTiles.percentage) / 2
        let tilePercentage = mapTiles.percentage
        let size = data.size + mapTiles.size
        let total = mapTiles.total
        let completed = mapTiles.completed

        if (satellite) {
          percentage =
            (data.percentage +
              mapTiles.percentage +
              satelliteTiles.percentage) /
            3
          tilePercentage = (mapTiles.percentage + satelliteTiles.percentage) / 2
github DrewML / scd / src / magentoFS.ts View on Github external
export async function getComponents(root: string): Promise {
    assertAbsolute(root);
    const [composer, nonComposer] = await Promise.all([
        getComposerComponents(root),
        getNonComposerComponents(root),
    ]);

    const allModules = [...composer.modules, ...nonComposer.modules];
    const allThemes = [...composer.themes, ...nonComposer.themes];

    const modulesByName = fromEntries(allModules.map(m => [m.moduleID, m]));
    const themesByID = fromEntries(
        allThemes.map(theme => {
            return [theme.themeID, theme];
        }),
    );

    return {
        modules: modulesByName,
        themes: themesByID,
    };
}
github Yoctol / bottender / packages / bottender / src / server / Server.ts View on Github external
protected async run(
    req: IncomingMessage,
    res: ServerResponse
  ): Promise {
    if (this.useConsole) {
      return;
    }

    const { pathname, searchParams } = new url.URL(
      `http://${req.headers.host}${req.url}`
    );

    const query = fromEntries(searchParams.entries());

    for (let i = 0; i < this._channelBots.length; i++) {
      const { webhookPath, bot } = this._channelBots[i];

      if (pathname === webhookPath) {
        const result = (bot.connector as any).preprocess({
          method: req.method,
          headers: req.headers,
          query,
          rawBody: (req as any).rawBody,
          body: (req as any).body,
        });

        const { shouldNext } = result;
        let { response } = result;

fromentries

Object.fromEntries() ponyfill (in 6 lines)

MIT
Latest version published 3 years ago

Package Health Score

67 / 100
Full package analysis

Popular fromentries functions