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

TypeScript ramda.mapObjIndexed函数代码示例

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

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



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

示例1:

export const clean = (obj) => {
	const nilEmpty: any = R.mapObjIndexed((x , key) => (R.isEmpty(x)) ? undefined : x);
	const nilComputed: any = R.mapObjIndexed((x , key) => (key.indexOf('$') >= 0) ? undefined : x);
	const trimProps = R.map((n: any) => R.is(String, n) ? R.trim(n) : n);
	const cleanNil = R.reject(R.isNil);
	return R.pipe(nilEmpty, nilComputed, trimProps, cleanNil)(obj);
}
开发者ID:simbiosis-group,项目名称:ion2-claim,代码行数:7,代码来源:index.ts


示例2: mapObjIndexed

export function method<
  ClientsT extends IOClients = IOClients,
  StateT = void,
  CustomT = void
>(options: MethodOptions<ClientsT, StateT, CustomT>) {
  const handlers = mapObjIndexed(
    handler => compose(Array.isArray(handler) ? handler : [handler]),
    options as Record<
      string,
      | RouteHandler<ClientsT, StateT, CustomT>
      | Array<RouteHandler<ClientsT, StateT, CustomT>>
    >
  )

  return async (
    ctx: ServiceContext<ClientsT, StateT, CustomT>,
    next: () => Promise<any>
  ) => {
    const verb = ctx.method.toUpperCase()
    const handler = handlers[verb] || handlers.DEFAULT

    if (handler) {
      await handler(ctx)
    }

    await next()
  }
}
开发者ID:vtex,项目名称:apps-client-node,代码行数:28,代码来源:method.ts


示例3: countPerOrigin

function countPerOrigin (obj: { [key: string]: any[] }) {
  try {
    return mapObjIndexed(val => val.length, obj)
  } catch (_) {
    return {}
  }
}
开发者ID:vtex,项目名称:apps-client-node,代码行数:7,代码来源:request.ts


示例4: wrapForeignOpt

export const associationDecorator = ({ modelName, fields }: { modelName: string; fields }) => {
  const TAG = '[associationDecorator]';
  logger.log(TAG, { fields });

  // prettier-ignore
  const associationFields = R.filter(R.compose(R.not, R.isNil, R.prop('associations')))(fields);
  logger.log(TAG, { associationFields }, R.not(R.isEmpty(associationFields)));
  if (R.not(R.isEmpty(associationFields))) {
    const wrapForeignOpt = R.map(opt => ({
      ...opt,
      association: AppContext.adapters.models.getAssociationConfigs(opt.modelName),
    }));
    const withAssociations = R.mapObjIndexed(field => ({
      ...field,
      foreignOpts: wrapForeignOpt(field.foreignOpts),
    }))(associationFields);
    logger.debug(TAG, { withAssociations, wrapForeignOpt });

    const wrappedFields = R.mergeDeepRight(fields, withAssociations);
    logger.debug(TAG, { wrappedFields });

    return { modelName, fields: wrappedFields };
  }

  return { modelName, fields };
};
开发者ID:danielwii,项目名称:asuna-admin,代码行数:26,代码来源:index.ts


示例5: overrideConfigKeyFromEnv

 private overrideConfigKeyFromEnv() {
   this.configMap = R.mapObjIndexed((value: string, key: string, config: any) => {
     if (process.env[key]) {
       config[key] = process.env[key];
     }
     return config[key];
   }, this.configMap);
 }
开发者ID:A-Horse,项目名称:bblist-backend,代码行数:8,代码来源:configure.ts


示例6: toArray

  /**
   * Convert a object to array
   * @param obj The object to be converted to array
   */
  static toArray(obj) {
    let array = [];
    if (obj) {
      const toArray = R.mapObjIndexed((val, key) => array.push({ $key: key, value: val }));
      const loadArray = toArray(obj)
    }

    return array;
  }
开发者ID:simbiosis-group,项目名称:ion2-helper,代码行数:13,代码来源:object-helper.ts


示例7: 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


示例8: curryN

let transformReq = curryN(2, (req: Request, multipart: boolean) => ifElse(
  () => multipart,
  pipe<any, any, any, any>(
    mapObjIndexed((v: any, k: string) => v
      ? req[propOr(false, 'path', v) ? 'attach' : 'field'](k, v)
      : req),
    values,
    last
  ),
  req.send.bind(req)
))
开发者ID:goodmind,项目名称:cycle-telegram,代码行数:11,代码来源:api-request.ts


示例9: clean

 /**
  * Return a clean part of the model for updating to database
  */
 static clean(model) {
   const removeComputedProps = R.pipe(
     R.mapObjIndexed((x , key) => {
       if (key.indexOf('$') >= 0) { return undefined }
       return x;
     }),
     R.reject(R.isNil)
   );
   const trimValues = R.map(n => { return R.is(String, n) ? R.trim(n) : n });
   const removeNullFields = R.reject(R.isNil)
   return R.pipe(removeComputedProps, trimValues, removeNullFields)(model);
 }
开发者ID:simbiosis-group,项目名称:ion2-helper,代码行数:15,代码来源:record-helper.ts


示例10: mapObjIndexed

], (active, byName) => {
    // TODO We might want to use the selected preset values (pass from host frame or content canvas) instead of individual dimension values
    if (active !== null) {
        return mapObjIndexed((dimensionValues, name) => {
            const dimensionConfiguration = byName[name];
            const presets = dimensionConfiguration.presets;
            const activePreset = Object.keys(presets).find(dimensionName => presets[dimensionName].values === dimensionValues);
            const presetName = activePreset || dimensionConfiguration.defaultPreset;
            const finalActivePreset = presets[presetName];
            return Object.assign({}, finalActivePreset, {name: presetName});
        }, active);
    }
    return {};
});
开发者ID:jonnitto,项目名称:neos-ui,代码行数:14,代码来源:index.ts


示例11: telegramDriver

  function telegramDriver (sourceRequest: Observable<Observable<DriverSink>>, runSA: StreamAdapter): DriverExecution {
    let adapt = adapter(runSA)
    let request = sourceRequest.map(x => convertStream(x, runSA, RxAdapter))

    if (isWebhookResponse(request, options)) {
      handleWebhook(token, request, proxyWebHook)
    }

    let responses = handleRequest(token, request as Observable<Observable<TcombRequest>>).share()
    responses.subscribeOnError((err: any) => console.error('request error: ', err))

    return Object.assign(
      {
        token,
        dispose: () => disposable.dispose()
      },
      mapObjIndexed(adapt, {
        events: makeEventsSelector(sources),
        updates,
        responses
      })) as DriverExecution
  }
开发者ID:goodmind,项目名称:cycle-telegram,代码行数:22,代码来源:telegram-driver.ts



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


鲜花

握手

雷人

路过

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

请发表评论

全部评论

专题导读
上一篇:
TypeScript ramda.merge函数代码示例发布时间:2022-05-25
下一篇:
TypeScript ramda.map函数代码示例发布时间: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