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


TypeScript lodash.curry函数代码示例

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


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

示例1: metricFindQuery

  metricFindQuery(query) {
    var interpolated = this.templateSrv.replace(query, null, 'regex');

    return this._seriesQuery(interpolated)
      .then(_.curry(this.responseParser.parse)(query));
  }
开发者ID:bigthinka,项目名称:grafana,代码行数:6,代码来源:datasource.ts

示例2: mapInternal

) {
  const entries = await mapInternal(
    async (value: T, index: number, collection: T[]) => {
      return [await iteratee(value, index, collection), value] as [boolean, T];
    },
    concurrency,
    collection,
  );

  return entries.filter(([valid]) => valid).map(([, value]) => value);
}

export interface FilterConcurrent {
  <T>(iteratee: Iterator<T, boolean>, concurrency: number, collection: PromiseOrValue<T[]>): Promise<T[]>;
  <T>(iteratee: Iterator<T, boolean>, concurrency: number): CurriedFunction1<PromiseOrValue<T[]>, Promise<T[]>>;
  <T>(iteratee: Iterator<T, boolean>): CurriedFunction2<number, PromiseOrValue<T[]>, Promise<T[]>>;
  <T>(): CurriedFunction3<Iterator<T, boolean>, number, PromiseOrValue<T[]>, Promise<T[]>>;
}

export const filterConcurrent: FilterConcurrent = curry(filterInternal);

export interface Filter {
  <T>(iteratee: Iterator<T, boolean>, collection: PromiseOrValue<T[]>): Promise<boolean>;
  <T>(iteratee: Iterator<T, boolean>): CurriedFunction1<PromiseOrValue<T[]>, Promise<boolean>>;
  <T>(): CurriedFunction2<Iterator<T, boolean>, PromiseOrValue<T[]>, Promise<boolean>>;
}

export const filter: Filter = bind(filterInternal, null, bind.placeholder, Infinity, bind.placeholder) as any;

export const filterSeries: Filter = bind(filterInternal, null, bind.placeholder, 1, bind.placeholder) as any;
开发者ID:vietthang,项目名称:hidoki,代码行数:30,代码来源:filter.ts

示例3: removePreAndSuf

export function removePreAndSuf(value: string, prefix: string, suffix: string): string {
  return _.flow([_.curry(removeSuffix)(_, suffix), _.curry(removePrefix)(_, prefix)])(value);
}
开发者ID:danielwii,项目名称:asuna-admin,代码行数:3,代码来源:func.ts

示例4: mapInternal

import { mapInternal } from './map';

async function someInternal<T>(
  iteratee: Iterator<T, boolean>,
  concurrency: number,
  collection: PromiseOrValue<T[]>,
) {
  const entries = await mapInternal(iteratee, concurrency, collection);

  return entries.some(identity);
}

export interface SomeConcurrent {
  <T>(iteratee: Iterator<T, boolean>, concurrency: number, collection: PromiseOrValue<T[]>): Promise<boolean>;
  <T>(iteratee: Iterator<T, boolean>, concurrency: number): CurriedFunction1<PromiseOrValue<T[]>, Promise<boolean>>;
  <T>(iteratee: Iterator<T, boolean>): CurriedFunction2<number, PromiseOrValue<T[]>, Promise<boolean>>;
  <T>(): CurriedFunction3<Iterator<T, boolean>, number, PromiseOrValue<T[]>, Promise<boolean>>;
}

export const someConcurrent: SomeConcurrent = curry(someInternal);

export interface Some {
  <T>(iteratee: Iterator<T, boolean>, collection: PromiseOrValue<T[]>): Promise<boolean>;
  <T>(iteratee: Iterator<T, boolean>): CurriedFunction1<PromiseOrValue<T[]>, Promise<boolean>>;
  <T>(): CurriedFunction2<Iterator<T, boolean>, PromiseOrValue<T[]>, Promise<boolean>>;
}

export const some: Some = bind(someInternal, null, bind.placeholder, Infinity, bind.placeholder) as any;

export const someSeries: Some = bind(someInternal, null, bind.placeholder, 1, bind.placeholder) as any;
开发者ID:vietthang,项目名称:hidoki,代码行数:30,代码来源:some.ts

示例5: return

import { curry, CurriedFunction1, CurriedFunction2, CurriedFunction3 } from 'lodash';

import { Reducer, PromiseOrValue } from './utils/common';

export async function reduceRightInternal<T, U>(
  iteratee: Reducer<T, U>,
  initialValue: PromiseOrValue<U>,
  collection: PromiseOrValue<T[]>,
) {
  return (await collection).reduceRight<Promise<U>>(
    async (prevValue, value, currentIndex, array) => {
      return await iteratee(await prevValue, value, currentIndex, array);
    },
    Promise.resolve(initialValue),
  );
}

export interface ReduceRight {
  <T, U>(iteratee: Reducer<T, U>, initialValue: PromiseOrValue<U>, collection: PromiseOrValue<T[]>): Promise<boolean>;
  <T, U>(iteratee: Reducer<T, U>, initialValue: PromiseOrValue<U>): CurriedFunction1<PromiseOrValue<T[]>, Promise<boolean>>;
  <T, U>(iteratee: Reducer<T, U>): CurriedFunction2<PromiseOrValue<U>, PromiseOrValue<T[]>, Promise<boolean>>;
  <T, U>(): CurriedFunction3<Reducer<T, U>, PromiseOrValue<U>, PromiseOrValue<T[]>, Promise<boolean>>;
}

export const reduceRight: ReduceRight = curry(reduceRightInternal);
开发者ID:vietthang,项目名称:hidoki,代码行数:25,代码来源:reduceRight.ts

示例6: curry

 const mapReducer = action => curry(getReducer(action.type))(action);
开发者ID:alessioalex,项目名称:tinydraft,代码行数:1,代码来源:oddstream.ts

示例7: return

import { curry, CurriedFunction1, CurriedFunction2, CurriedFunction3 } from 'lodash';

import { Reducer, PromiseOrValue } from './utils/common';

export async function reduceInternal<T, U>(
  iteratee: Reducer<T, U>,
  initialValue: PromiseOrValue<U>,
  collection: PromiseOrValue<T[]>,
) {
  return (await collection).reduce<Promise<U>>(
    async (prevValue, value, currentIndex, array) => {
      return await iteratee(await prevValue, value, currentIndex, array);
    },
    Promise.resolve(initialValue),
  );
}

export interface Reduce {
  <T, U>(iteratee: Reducer<T, U>, initialValue: PromiseOrValue<U>, collection: PromiseOrValue<T[]>): Promise<boolean>;
  <T, U>(iteratee: Reducer<T, U>, initialValue: PromiseOrValue<U>): CurriedFunction1<PromiseOrValue<T[]>, Promise<boolean>>;
  <T, U>(iteratee: Reducer<T, U>): CurriedFunction2<PromiseOrValue<U>, PromiseOrValue<T[]>, Promise<boolean>>;
  <T, U>(): CurriedFunction3<Reducer<T, U>, PromiseOrValue<U>, PromiseOrValue<T[]>, Promise<boolean>>;
}

export const reduce: Reduce = curry(reduceInternal);
开发者ID:vietthang,项目名称:hidoki,代码行数:25,代码来源:reduce.ts

示例8: initialAction

export async function initialAction(state: State) {
    console.log("First!");
    return state;
}

export function githubInitialized(text: string) {
    let [token, repo, branch] = text.split(' ');
    Actions.onNext(initializeGitHub(repo, token, branch));
};

const initializeGitHub = curry(
    async (repo: string, token: string, branch: string, state: State) => {
        let github = state.github || new GitHubHelper();
        await github.setup(token, repo, branch);
        let message = "Logged in";
        let files = new Map(), changes = new Map();
        return { changes, files, github, message };
    }
);

export function filesListed() { Actions.onNext(listFiles); }

async function listFiles(state: State) {
    let {github} = state;
    let entries = await github.listFiles();
    let files = new Map<string, string>();
    for (let e of entries) {
        files.set(e.path, await github.download(e.download_url));
    }
    return Object.assign({}, state, { files });
开发者ID:duncanmak,项目名称:experiments,代码行数:30,代码来源:actions.ts

示例9: curry

 const curriedReducer = actionType => curry(this[camelCase(actionType)]);
开发者ID:andreruffert,项目名称:tinydraft,代码行数:1,代码来源:drafts-editor-store.ts

示例10: functionChanged

import { Subject } from 'rx';
import { curry } from 'lodash';
import { State } from './State';

export interface Action { (state: State): State };
export const Actions = new Subject<Action | State>();

export function functionChanged(fn, value) {
    Actions.onNext(changeFunction(fn, value));
}

export const changeFunction = curry((fn: string, value: any, state: State): State => {
    return Object.assign({}, state, { [fn]: value });
});

export function dataChanged(name, value, data) {
    Actions.onNext(changeData(name, value, data));
}

export const changeData = curry((name: string, value: any, data, state: State): State => {
    return Object.assign({}, state, { [name]: value, data: data });
});
开发者ID:roguishmountain,项目名称:graphs,代码行数:22,代码来源:Actions.ts


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