@infinite-list/data-model
Advanced tools
Comparing version 0.4.9 to 0.4.10
@@ -29,3 +29,1 @@ export declare const DEFAULT_LAYOUT: { | ||
export declare const buildStateTokenIndexKey: (startIndex: number, endIndex: number) => string; | ||
export declare function findLastIndex(arr: Array<any>, fn: Function): number; | ||
export declare function getByValue(map: any, searchValue: any): any; |
{ | ||
"name": "@infinite-list/data-model", | ||
"version": "0.4.9", | ||
"version": "0.4.10", | ||
"files": [ | ||
@@ -23,2 +23,4 @@ "dist", | ||
"@x-oasis/default-boolean-value": "^0.1.14", | ||
"@x-oasis/find-last-index": "^0.1.34", | ||
"@x-oasis/get-map-key-by-value": "^0.1.34", | ||
"@x-oasis/is-clamped": "^0.1.14", | ||
@@ -25,0 +27,0 @@ "@x-oasis/layout-equal": "^0.1.16", |
@@ -63,34 +63,1 @@ export const DEFAULT_LAYOUT = { | ||
`space_${startIndex}_${endIndex}`; | ||
export function findLastIndex(arr: Array<any>, fn: Function) { | ||
// @ts-ignore | ||
if (Array.prototype.findLastIndex) return arr.findIndex(fn); | ||
const len = arr.length; | ||
for (let index = len - 1; index > 0; index--) { | ||
if (fn.apply(arr, [arr[index], index, arr])) { | ||
return index; | ||
} | ||
} | ||
return -1; | ||
} | ||
// Array.prototype.myfindLastIndex = function(fn) { | ||
// const context = this | ||
// const len = this.length | ||
// for (let index = len -1; index > 0; index--) { | ||
// if (fn.apply(context, [context[index], index, context])) { | ||
// return index | ||
// } | ||
// } | ||
// return -1 | ||
// } | ||
// https://stackoverflow.com/questions/47135661/how-can-i-get-a-key-in-a-javascript-map-by-its-value | ||
export function getByValue(map, searchValue) { | ||
for (const [key, value] of map.entries()) { | ||
if (value === searchValue) return key; | ||
} | ||
} |
@@ -9,3 +9,3 @@ import shallowArrayEqual from '@x-oasis/shallow-array-equal'; | ||
} from './types'; | ||
import { findLastIndex } from './common' | ||
import findLastIndex from '@x-oasis/find-last-index'; | ||
import ListGroupDimensions from './ListGroupDimensions'; | ||
@@ -12,0 +12,0 @@ |
import Batchinator from '@x-oasis/batchinator'; | ||
import defaultBooleanValue from '@x-oasis/default-boolean-value'; | ||
import noop from '@x-oasis/noop'; | ||
import { getByValue } from './common'; | ||
import getMapKeyByValue from '@x-oasis/get-map-key-by-value'; | ||
import { StateEventListener, ItemMetaStateEventHelperProps } from './types'; | ||
@@ -212,3 +212,3 @@ | ||
this._handleCountMap.set(handler, value + 1); | ||
const key = getByValue(this._reusableStrictEventListenerMap, handler); | ||
const key = getMapKeyByValue(this._reusableStrictEventListenerMap, handler); | ||
if (key) { | ||
@@ -215,0 +215,0 @@ const _value = this._strictListenerKeyToHandleCountMap[key] || 0; |
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is not supported yet
3265497
18
35890
+ Added@x-oasis/find-last-index@0.1.35(transitive)
+ Added@x-oasis/get-map-key-by-value@0.1.35(transitive)