Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@infinite-list/data-model

Package Overview
Dependencies
Maintainers
1
Versions
155
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@infinite-list/data-model - npm Package Compare versions

Comparing version 0.3.0 to 0.4.0

1

dist/common.d.ts

@@ -29,1 +29,2 @@ export declare const DEFAULT_LAYOUT: {

export declare const buildStateTokenIndexKey: (startIndex: number, endIndex: number) => string;
export declare function findLastIndex(arr: Array<any>, fn: Function): number;

8

dist/ListDimensions.d.ts
import ListBaseDimensions from './ListBaseDimensions';
import { IndexInfo } from './types';
import { IndexInfo, ScrollMetrics } from './types';
declare class ListDimensions<ItemT extends {} = {}> extends ListBaseDimensions<ItemT> {

@@ -17,3 +17,3 @@ private _dataModel;

getFinalIndexKeyOffset(index: number, exclusive?: boolean): number;
getFinalIndexKeyBottomOffset(): number;
getFinalIndexKeyBottomOffset(index: number, exclusive?: boolean): number;
getFinalIndexRangeOffsetMap(startIndex: number, endIndex: number, exclusive?: boolean): {};

@@ -29,3 +29,7 @@ computeIndexRange(minOffset: number, maxOffset: number): {

getFinalKeyIndexInfo(key: string): IndexInfo;
updateScrollMetrics(_scrollMetrics?: ScrollMetrics, _options?: {
useCache?: boolean;
flush?: boolean;
}): void;
}
export default ListDimensions;
{
"name": "@infinite-list/data-model",
"version": "0.3.0",
"version": "0.4.0",
"files": [

@@ -5,0 +5,0 @@ "dist",

@@ -63,1 +63,26 @@ 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
// }

@@ -9,2 +9,3 @@ import shallowArrayEqual from '@x-oasis/shallow-array-equal';

} from './types';
import { findLastIndex } from './common'
import ListGroupDimensions from './ListGroupDimensions';

@@ -61,3 +62,3 @@

// @ts-ignore
const index = this._anchorKeys.findLastIndex((v) => v === anchorKey);
const index = findLastIndex(this._anchorKeys, (v) => v === anchorKey);
if (index !== -1) {

@@ -64,0 +65,0 @@ this._indexKeys.splice(index + 1, 0, key);

import ListBaseDimensions from './ListBaseDimensions';
import ListDimensionsModel from './ListDimensionsModel';
import { IndexInfo } from './types';
import { IndexInfo, ScrollMetrics } from './types';
import createStore from './state/createStore';

@@ -28,3 +28,3 @@ import { ReducerResult } from './state/types'

setData(data: Array<ItemT>) {
const changedType = this._dataModel.setData(data);
this._dataModel.setData(data);
}

@@ -65,4 +65,6 @@

getFinalIndexKeyBottomOffset() {
return 0;
getFinalIndexKeyBottomOffset(index: number, exclusive?: boolean) {
const containerOffset = exclusive ? 0 : this.getContainerOffset()
const height = this.getTotalLength()
return containerOffset + (typeof height === 'number' ? height : 0)
}

@@ -97,5 +99,9 @@

onItemLayoutChanged() {}
onItemLayoutChanged() {
this.updateScrollMetrics(this._scrollMetrics);
}
onDataSourceChanged() {}
onDataSourceChanged() {
this.updateScrollMetrics(this._scrollMetrics);
}

@@ -107,4 +113,15 @@ getFinalKeyIndexInfo(key: string): IndexInfo {

}
updateScrollMetrics(
_scrollMetrics?: ScrollMetrics,
_options?: {
useCache?: boolean;
flush?: boolean;
}
) {
this._scrollMetrics = _scrollMetrics || this._scrollMetrics;
this._updateScrollMetrics(this._scrollMetrics, _options);
}
}
export default ListDimensions;

@@ -300,9 +300,2 @@ import PrefixIntervalTree from '@x-oasis/prefix-interval-tree';

// if (!this._listGroupDimension && changedType === KeysChangedType.Initial) {
// const state = this.resolveInitialState();
// this.setState(state);
// this._state = state;
// return changedType;
// }
if (changedType === KeysChangedType.Equal) return KeysChangedType.Equal;

@@ -317,8 +310,2 @@

// if (!this._listGroupDimension) {
// setTimeout(() => {
// if (this._scrollMetrics) this.dispatchStoreMetrics(this._scrollMetrics);
// });
// }
return changedType;

@@ -325,0 +312,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

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc