當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。