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

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

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

本文整理汇总了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;未经允许,请勿转载。


鲜花

握手

雷人

路过

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

请发表评论

全部评论

专题导读
上一篇:
TypeScript memory-fs.readFileSync函数代码示例发布时间:2022-05-25
下一篇:
TypeScript memfs.Volume类代码示例发布时间: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