• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

TypeScript ramda.forEach函数代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

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



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

示例1: getMigrationStates

export function getMigrationStates(
  migrations: Migration[], journalEntries: JournalEntry[]
): MigrationState[] {
  let migrationIDSet: { [id: string]: boolean } = {};
  let states: { [id: string]: MigrationState } = {};

  R.forEach(function(migration) {
    migrationIDSet[migration.id] = true;
    states[migration.id] = {
      migrationID: migration.id,
      migrationName: migration.name,
      state: State.pending
    };
  }, migrations);

  R.forEach(function(entry) {
    if (!migrationIDSet[entry.migrationID]) {
      states[entry.migrationID] = {
        migrationID: entry.migrationID,
        migrationName: entry.migrationName,
        state: State.missing
      };
    } else if (entry.operation === Operation.apply) {
      states[entry.migrationID].state = State.applied;
    } else if (entry.operation === Operation.revert) {
      states[entry.migrationID].state = State.reverted;
    } else {
      throw new InvalidJournalOperationError(entry.operation);
    }
  }, journalEntries);

  return R.sortBy(s => s.migrationID, R.values(states));
}
开发者ID:programble,项目名称:careen,代码行数:33,代码来源:status.ts


示例2: getAuditLog

  /**
   * Return a audit log object for assigning to the model
   *
   * Example:
   *
   * ```
   * const auditLog = RecordHelper.getAuditLog(this.$isNewRecord, username);
   * const writeAuditLog = R.pipe(R.keys,
   *    R.forEach(n => this[n] = auditLog[n]))(auditLog);
   * ```
   */
  static getAuditLog(isNewRecord, username) {
    let model = { }
    if (isNewRecord) {
      const createLog = this.getCreateLog(username);
      const writeCreateLog = R.pipe(R.keys,
        R.forEach(n => model[n] = createLog[n]))(createLog);
    }

    const updateLog = this.getUpdateLog(username);
    const writeUpdateLog = R.pipe(R.keys,
      R.forEach(n => model[n] = updateLog[n]))(updateLog);
    return model;
  }
开发者ID:simbiosis-group,项目名称:ion2-helper,代码行数:24,代码来源:record-helper.ts


示例3: curry

  const convertResponse = curry((startedAt: number, axiosResult: AxiosResponse | AxiosError) => {
    const end: number = toNumber(new Date())
    const duration: number = end - startedAt

    // new in Axios 0.13 -- some data could be buried 1 level now
    const isError = axiosResult instanceof Error || axios.isCancel(axiosResult)
    const axiosResponse = axiosResult as AxiosResponse
    const axiosError = axiosResult as AxiosError
    const response = isError ? axiosError.response : axiosResponse
    const status = (response && response.status) || null
    const problem = isError ? getProblemFromError(axiosResult) : getProblemFromStatus(status)
    const originalError = isError ? axiosError : null
    const ok = in200s(status)
    const config = axiosResult.config || null
    const headers = (response && response.headers) || null
    let data = (response && response.data) || null

    // give an opportunity for anything to the response transforms to change stuff along the way
    let transformedResponse = {
      duration,
      problem,
      originalError,
      ok,
      status,
      headers,
      config,
      data,
    }
    if (responseTransforms.length > 0) {
      forEach(transform => transform(transformedResponse), responseTransforms)
    }

    return transformedResponse
  })
开发者ID:skellock,项目名称:apisauce,代码行数:34,代码来源:apisauce.ts


示例4: createCourse

R.map(rawCourse => {
  const course = createCourse(rawCourse);
  const words = getVocabularyRecursive(course);

  R.forEach(word => {
    const id = word
      .toLowerCase()
      .replace(/\s/g, '_')
      .replace(/ß/g, 'sz')
      .replace(/ä/g, 'ae')
      .replace(/ü/g, 'ue')
      .replace(/ö/g, 'oe')
      .replace(/é/g, 'e');

    if (typeof wordsDb[id] === 'undefined') {
      console.log(`[ERR] Word does not exist:`, id);
      return;
    }

    if (typeof loadWordImage[id] === 'undefined') {
      console.log(`[ERR] Image does not exist:`, id);
      return;
    }

    if (typeof loadWordSound[`${id}_short`] === 'undefined') {
      console.log(`[ERR] Sound does not exist:`, id);
      return;
    }

    // if (typeof loadWordSound[`${id}_long`] === 'undefined') {
    //   console.log(`[WARN] Long sound does not exist:`, id)
    //   return;
    // }
  }, words);
}, courses);
开发者ID:serlo-org,项目名称:serlo-abc,代码行数:35,代码来源:check-assets.ts


示例5: getImmutableModel

 /**
  * Return a immutable model
  * @param model An object with key value pair
  */
 static getImmutableModel(model) {
   let newModel: any = { };
   const getFields = R.keys();
   const assignFields = field => newModel[field] = model[field];
   const prepareModel = R.pipe(getFields, R.forEach(assignFields));
   prepareModel(model);
   return newModel;
 }
开发者ID:simbiosis-group,项目名称:ion2-helper,代码行数:12,代码来源:record-helper.ts


示例6: Promise

  .then(files => {
    // Loaders for React Native app
    let str = `import { AssetTypes } from '../../../packages/entities';

    const images: { [id: string]: () => AssetTypes.ImageAsset } = {`;

    R.forEach(file => {
      str += `
  ${getFilename(file)}: () => require('./images/${file}'),`;
    }, files);

    str += `
};

export default images;`;

    // Process files
    return Promise.all([
      writeFile(path.join(assetsPath, 'images.ts'), str),
      Promise.all(
        R.map(file => {
          const source = path.join(imagesPath, file);

          // Create three output files
          const targets = R.map(
            suffix =>
              path.join(
                outputPath,
                `${getFilename(file)}${suffix}${getExtname(file)}`
              ),
            suffixes
          );

          return Promise.all(
            R.zipWith(
              (target, size) =>
                new Promise((resolve, reject) => {
                  gm(source)
                    .resize(size, size, '!')
                    .quality(0.8)
                    .write(target, err => {
                      if (err) {
                        reject(err);
                        return;
                      }

                      resolve();
                    });
                }),
              targets,
              sizes
            )
          );
        }, files)
      )
    ]);
  });
开发者ID:serlo-org,项目名称:serlo-abc,代码行数:57,代码来源:generate-words-images.ts


示例7: before

 before(function() {
   R.forEach(method => spies[method] = sinon.spy(dummy, method), [
     'connect', 'ensureJournal', 'readJournal', 'beginTransaction',
     'runMigrationSQL', 'appendJournal', 'rollbackTransaction',
     'commitTransaction', 'disconnect'
   ]);
   spies.readUpSQL = sinon.spy(files, 'readUpSQL');
   spies.readDownSQL = sinon.spy(files, 'readDownSQL');
 });
开发者ID:programble,项目名称:careen,代码行数:9,代码来源:runner.ts


示例8: resetChildrenProgress

  public resetChildrenProgress(id: string) {
    const entity = this.course.findEntity(id);

    if (entity && isInternalNode(entity)) {
      forEach(child => {
        this.progress[child.getId()] = { progress: Progress.Unseen };
        this.resetChildrenProgress(child.getId());
      }, entity.getChildren());
    }
  }
开发者ID:serlo-org,项目名称:serlo-abc,代码行数:10,代码来源:CourseInteractor.ts


示例9: MockAssetResolver

const runTests = <S, F>(
  assert: (
    fixture: ExerciseFixture<S, F>,
    /* tslint:disable-next-line:no-any */
    exercise: AbstractExercise<any, S, F>
  ) => void
) => {
  const resolver = new MockAssetResolver();
  const factory = new EntityFactory(resolver);

  const cases = values(
    mapObjIndexed(
      (
        E: {
          fixtures: Array<ExerciseFixture<S, F>>;
          /* tslint:disable-next-line:no-any */
          new (p: any): AbstractExercise<any, S, F>;
        },
        type
      ) => () => {
        forEach(fixture => {
          try {
            const exercise = factory.createExercise(
              type as ExerciseTypes,
              fixture.props
            );

            // Catch test failures so that we can pass a custom message
            assert(fixture, exercise);
          } catch (e) {
            throw new Error(`${type} › ${fixture.name}:\n${e.message}`);
          }
        }, E.fixtures);
      },
      Exercises
    )
  );

  // Execute the test runners
  forEach(runTestCases => runTestCases(), cases);

  // Check that each test case was run
  const numberOfAssertions = sum(
    values(
      map<
        { [type: string]: { fixtures: Array<ExerciseFixture<S, F>> } },
        { [type: string]: number }
      >(
        (E: { fixtures: Array<ExerciseFixture<S, F>> }) => E.fixtures.length,
        Exercises
      )
    )
  );
  expect.assertions(numberOfAssertions);
};
开发者ID:serlo-org,项目名称:serlo-abc,代码行数:55,代码来源:exercises.ts


示例10: it

 it('resets progress correctly', () => {
   const root = '09438926-b170-4005-a6e8-5dd8fba83cde';
   const children = [
     '01f23c2a-b681-43db-9d27-5d8d59f62aed',
     '23e20d5b-ad8e-41be-9891-5ca7b12675c4',
     'e194f80b-7312-43a2-995e-060f64631782',
     '84fdc1a1-e3bf-4a87-8360-0c3b7beec179'
   ];
   forEach(
     id => {
       interactor.markAsCorrect(id);
     },
     [root, ...children]
   );
   interactor.resetChildrenProgress(root);
   expect(interactor.getProgress(root).progress).toBe(Progress.Correct);
   forEach(id => {
     expect(interactor.getProgress(id).progress).toBe(Progress.Unseen);
   }, children);
 });
开发者ID:serlo-org,项目名称:serlo-abc,代码行数:20,代码来源:CourseInteractor.ts



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
TypeScript ramda.fromPairs函数代码示例发布时间:2022-05-25
下一篇:
TypeScript ramda.flatten函数代码示例发布时间:2022-05-25
热门推荐
热门话题
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap