當前位置: 首頁>>代碼示例>>TypeScript>>正文


TypeScript ramda.mapObjIndexed函數代碼示例

本文整理匯總了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;未經允許,請勿轉載。