当前位置: 首页>>代码示例>>TypeScript>>正文


TypeScript underscore.isEmpty函数代码示例

本文整理汇总了TypeScript中underscore.isEmpty函数的典型用法代码示例。如果您正苦于以下问题:TypeScript isEmpty函数的具体用法?TypeScript isEmpty怎么用?TypeScript isEmpty使用的例子?那么, 这里精选的函数代码示例或许可以为您提供帮助。


在下文中一共展示了isEmpty函数的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的TypeScript代码示例。

示例1: async

  watcher.on(actions.checkForGameUpdates, async (store, action) => {
    reschedule(store);

    if (!store.getState().setup.done) {
      return;
    }

    store.dispatch(
      actions.gameUpdateCheckStatus({
        checking: true,
        progress: 0,
      })
    );

    try {
      store.dispatch(
        actions.gameUpdateCheckStatus({
          checking: true,
          progress: 0,
        })
      );

      const res = await mcall(messages.CheckUpdate, {}, convo => {
        hookLogging(convo, logger);

        convo.on(messages.GameUpdateAvailable, async ({ update }) => {
          store.dispatch(actions.gameUpdateAvailable({ update }));
        });

        convo.on(messages.Progress, async ({ progress }) => {
          store.dispatch(
            actions.gameUpdateCheckStatus({
              checking: true,
              progress,
            })
          );
        });
      });

      if (!isEmpty(res.updates)) {
        for (const update of res.updates) {
          store.dispatch(actions.gameUpdateAvailable({ update }));
        }
      }

      if (!isEmpty(res.warnings)) {
        logger.warn(`Got warnings when checking for updates: `);
        for (const w of res.warnings) {
          logger.warn(w);
        }
      }
    } finally {
      store.dispatch(
        actions.gameUpdateCheckStatus({
          checking: false,
          progress: -1,
        })
      );
    }
  });
开发者ID:itchio,项目名称:itch,代码行数:60,代码来源:updater.ts

示例2: dispatchUpdateNotification

function dispatchUpdateNotification(
  store: Store,
  cave: Cave,
  result: CheckUpdateResult
) {
  if (!result) {
    return;
  }

  if (!isEmpty(result.warnings)) {
    store.dispatch(
      actions.statusMessage({
        message: [
          "status.game_update.check_failed",
          { err: result.warnings[0] },
        ],
      })
    );
    return;
  }

  if (isEmpty(result.updates)) {
    store.dispatch(
      actions.statusMessage({
        message: ["status.game_update.not_found", { title: cave.game.title }],
      })
    );
  } else {
    store.dispatch(
      actions.statusMessage({
        message: ["status.game_update.found", { title: cave.game.title }],
      })
    );
  }
}
开发者ID:itchio,项目名称:itch,代码行数:35,代码来源:updater.ts

示例3: hasSearchResults

export function hasSearchResults(sr: ISearchResults): boolean {
  if (sr && sr.games && !isEmpty(sr.games.ids)) {
    return true;
  }
  if (sr && sr.users && !isEmpty(sr.users.ids)) {
    return true;
  }
  return false;
}
开发者ID:HorrerGames,项目名称:itch,代码行数:9,代码来源:search-helpers.ts

示例4: concatTemplates

export function concatTemplates(
  a: IMenuTemplate,
  b: IMenuTemplate
): IMenuTemplate {
  if (isEmpty(a)) {
    return b;
  }

  if (isEmpty(b)) {
    return a;
  }

  return [...a, { type: "separator" }, ...b];
}
开发者ID:HorrerGames,项目名称:itch,代码行数:14,代码来源:build-template.ts

示例5: getFromAdapters

async function getFromAdapters(): Promise<DimData | undefined> {
  for (const adapter of adapters.slice().reverse()) {
    if (adapter.enabled) {
        if ($featureFlags.debugSync) {
          console.log('getting from ', adapter.name);
        }
        try {
          const value = await adapter.get();

          if (value && !_.isEmpty(value)) {
            if ($featureFlags.debugSync) {
              console.log('got', value, 'from adapter ', adapter.name);
            }
            return value;
          }
        } catch (e) {
          console.error('Sync: Error loading from', adapter.name, e);
          reportException('Sync Load', e);
        }
    } else if ($featureFlags.debugSync) {
      console.log(adapter.name, 'is disabled');
    }
  }
  return undefined;
}
开发者ID:delphiactual,项目名称:DIM,代码行数:25,代码来源:sync.service.ts

示例6: work

  async work(): Promise<void> {
    const installLocationId = this.space().firstPathElement();

    let call = withLogger(this.logger);

    const { caves, installLocationPath, installLocationSize } = await call(
      messages.FetchCavesByInstallLocationID,
      { installLocationId }
    );

    let games: Game[] = [];
    if (!isEmpty(caves)) {
      for (const c of caves) {
        games.push(c.game);
      }
      games = uniq(games, g => g.id);
    }

    this.pushUnfilteredGames(games, { disableFilters: true });
    this.push({
      location: {
        path: installLocationPath,
        size: installLocationSize,
      },
    });
  }
开发者ID:HorrerGames,项目名称:itch,代码行数:26,代码来源:location-fetcher.ts

示例7: countCurrencies

  /**
   * Calculates a count of how many of each type of currency you
   * have on all characters, limited to only currencies required to
   * buy items from the provided vendors.
   */
  function countCurrencies(stores: D1Store[], vendors: { [vendorHash: number]: Vendor }) {
    if (!stores || !vendors || !stores.length || _.isEmpty(vendors)) {
      return {};
    }

    const categories = flatMap(Object.values(vendors), (v) => v.categories);
    const saleItems = flatMap(categories, (c) => c.saleItems);
    const costs = flatMap(saleItems, (i: any) => i.costs);
    const currencies = costs.map((c: any) => c.currency.itemHash);

    const totalCoins: { [currencyHash: number]: number } = {};
    currencies.forEach((currencyHash) => {
      // Legendary marks and glimmer are special cases
      switch (currencyHash) {
        case 2534352370:
          totalCoins[currencyHash] = D1StoresService.getVault()!.legendaryMarks;
          break;
        case 3159615086:
          totalCoins[currencyHash] = D1StoresService.getVault()!.glimmer;
          break;
        case 2749350776:
          totalCoins[currencyHash] = D1StoresService.getVault()!.silver;
          break;
        default:
          totalCoins[currencyHash] = sum(stores, (store) => {
            return store.amountOfItem({ hash: currencyHash } as any);
          });
          break;
      }
    });
    return totalCoins;
  }
开发者ID:bhollis,项目名称:DIM,代码行数:37,代码来源:vendor.service.ts

示例8: validateRequest

    // res: Response where to send error HTTP message if the request is invalid
    // requestBody: req.body OR req.query
    // constraints: validate.js format
    // return true if the request is valid
    static validateRequest(res: Response,
                           requestBody: any,
                           constraints: any): boolean {
        console.log(requestBody);
        if (_.isEmpty(requestBody)) {
            APIHelper.sendEmptyRequestResponse(res);
            return false;
        }
        let validation = validate(requestBody, constraints);
        console.log(requestBody);
        if (_.keys(validation).length > 0) {
            let validationErrors = {};
            for (let prop in validation) {
                if (!validation.hasOwnProperty(prop)) {
                    continue;
                }
                validationErrors[prop] = validation[prop];
            }
            APIHelper.sendInvalidInputResponse(res, validationErrors);
            return false;
        } else {

            return true;
        }
    }
开发者ID:JohanBaskovec,项目名称:libraryBackEnd,代码行数:29,代码来源:apiHelper.ts

示例9: on

  on(actions.searchHighlightOffset, (state, action) => {
    const { offset, relative } = action.payload;
    let highlight = offset;
    if (relative) {
      highlight = state.highlight + offset;
    }

    let numGames = 0;
    if (
      state.results &&
      state.results.games &&
      !isEmpty(state.results.games.ids)
    ) {
      numGames = state.results.games.ids.length;
    }

    if (highlight < 0) {
      highlight = numGames - 1;
    }
    if (highlight >= numGames) {
      highlight = 0;
    }

    return {
      ...state,
      highlight,
    };
  });
开发者ID:HorrerGames,项目名称:itch,代码行数:28,代码来源:search.ts


注:本文中的underscore.isEmpty函数示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。