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


TypeScript memoize-one.default函数代码示例

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


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

示例1: memoizeOne

import { storesSelector } from '../inventory/reducer';
import { maxLightLoadout } from '../loadout/auto-loadouts';
import { itemTags } from '../inventory/dim-item-info';
import { characterSortSelector } from '../settings/character-sort';
import store from '../store/store';
import { loadoutsSelector } from '../loadout/reducer';
import { InventoryCuratedRoll } from '../curated-rolls/curatedRollService';
import { curationsSelector } from '../curated-rolls/reducer';
import { D2SeasonInfo } from '../inventory/d2-season-info';
import memoizeOne from 'memoize-one';

/** Make a Regexp that searches starting at a word boundary */
const startWordRegexp = memoizeOne((predicate: string) =>
  // Only some languages effectively use the \b regex word boundary
  ['de', 'en', 'es', 'es-mx', 'fr', 'it', 'pl', 'pt-br'].includes(
    store.getState().settings.language
  )
    ? new RegExp(`\\b${escapeRegExp(predicate)}`, 'i')
    : new RegExp(escapeRegExp(predicate), 'i')
);

export const searchConfigSelector = createSelector(
  destinyVersionSelector,
  buildSearchConfig
);

/**
 * A selector for the search config for a particular destiny version.
 */
export const searchFiltersConfigSelector = createSelector(
  searchConfigSelector,
  storesSelector,
开发者ID:w1cked,项目名称:DIM,代码行数:32,代码来源:search-filters.ts

示例2: getActiveTimeMachine

export const getActiveTimeMachine = (state: AppState) => {
  const {activeTimeMachineID, timeMachines} = state.timeMachines
  const timeMachine = timeMachines[activeTimeMachineID]

  return timeMachine
}

export const getActiveQuery = (state: AppState): DashboardDraftQuery => {
  const {draftQueries, activeQueryIndex} = getActiveTimeMachine(state)

  return draftQueries[activeQueryIndex]
}

const getTablesMemoized = memoizeOne(
  (files: string[]): FluxTable[] => (files ? flatMap(files, parseResponse) : [])
)

export const getTables = (state: AppState): FluxTable[] =>
  getTablesMemoized(getActiveTimeMachine(state).queryResults.files)

const getVisTableMemoized = memoizeOne(toMinardTable)

export const getVisTable = (state: AppState): Table => {
  const fluxTables = getTables(state)
  const {table} = getVisTableMemoized(fluxTables)

  return table
}

const getNumericColumnsMemoized = memoizeOne(
开发者ID:sebito91,项目名称:influxdb,代码行数:30,代码来源:index.ts

示例3: add

import memoizeOne, { EqualityFn } from 'memoize-one';

declare function add(a: number, b: number): number ;
declare function lousyEqualityFn(a: any, b: any): boolean;
declare function strictEqualityFn<T>(a: T, b: T): boolean;

/**
 * Accepts a second argument.
 */
memoizeOne(add); // $ExpectType (a: number, b: number) => number
memoizeOne(add, lousyEqualityFn); // $ExpectType (a: number, b: number) => number
memoizeOne(add, strictEqualityFn); // $ExpectType (a: number, b: number) => number

/**
 * The second argument can be, but doesn't have to be strictly typed.
 */
memoizeOne(add, (a, b) => a === b); // $ExpectType (a: number, b: number) => number
memoizeOne(add, (a: string, b: string) => a === b); // $ExpectType (a: number, b: number) => number

/**
 * Function passed as the second argument accepts exactly two arguments.
 */
memoizeOne(add, (a: number, b: number, c: number) => a === b || c); // $ExpectError

/**
 * Function passed as the second argument returns a boolean.
 */
memoizeOne(add, (a: string, b: string) => 0); // $ExpectError

/**
 * The `EqualityFn` type is publicly accessible.
开发者ID:CNBoland,项目名称:DefinitelyTyped,代码行数:31,代码来源:memoize-one-tests.ts

示例4: memoizeOne

 (notesById: NotesById) =>
   memoizeOne((noteIds: string[]): Note[] => getNotes(notesById, noteIds))
开发者ID:,项目名称:,代码行数:2,代码来源:

示例5: add

import memoizeOne, { EqualityFn } from 'memoize-one';

declare function add(a: number, b: number): number ;
declare function lousyEqualityFn(a: any, b: any): boolean;
declare function strictEqualityFn<T>(a: T, b: T): boolean;
declare function equalityFnWithIndex<T>(a: T, b: T, index: number): boolean;

/**
 * Accepts a second argument.
 */
memoizeOne(add); // $ExpectType (a: number, b: number) => number
memoizeOne(add, lousyEqualityFn); // $ExpectType (a: number, b: number) => number
memoizeOne(add, strictEqualityFn); // $ExpectType (a: number, b: number) => number
memoizeOne(add, equalityFnWithIndex); // $ExpectType (a: number, b: number) => number

/**
 * The second argument can be, but doesn't have to be strictly typed.
 */
memoizeOne(add, (a, b) => a === b); // $ExpectType (a: number, b: number) => number
memoizeOne(add, (a: string, b: string) => a === b); // $ExpectType (a: number, b: number) => number

/**
 * Function passed as the second argument accepts no more than three arguments.
 */
memoizeOne(add, (a: number, b: number, c: number, d: number) => Boolean(a &&  b && c && d)); // $ExpectError

/**
 * Function passed as the second argument returns a boolean.
 */
memoizeOne(add, (a: string, b: string) => 0); // $ExpectError
开发者ID:Jeremy-F,项目名称:DefinitelyTyped,代码行数:30,代码来源:memoize-one-tests.ts

示例6: getActiveTimeMachine

export const getActiveTimeMachine = (state: AppState) => {
  const {activeTimeMachineID, timeMachines} = state.timeMachines
  const timeMachine = timeMachines[activeTimeMachineID]

  return timeMachine
}

export const getActiveQuery = (state: AppState): DashboardDraftQuery => {
  const {draftQueries, activeQueryIndex} = getActiveTimeMachine(state)

  return draftQueries[activeQueryIndex]
}

const getTablesMemoized = memoizeOne(
  (files: string[]): FluxTable[] => (files ? flatMap(files, parseResponse) : [])
)

export const getTables = (state: AppState): FluxTable[] =>
  getTablesMemoized(getActiveTimeMachine(state).queryResults.files)

const getVisTableMemoized = memoizeOne(fromFlux)

export const getVisTable = (state: AppState): Table => {
  const files = getActiveTimeMachine(state).queryResults.files || []
  const {table} = getVisTableMemoized(files.join('\n\n'))

  return table
}

const getNumericColumnsMemoized = memoizeOne(
开发者ID:influxdata,项目名称:influxdb,代码行数:30,代码来源:index.ts


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