@x-oasis/recycler
Advanced tools
Comparing version 0.1.35 to 0.1.36
import IntegerBufferSet from '@x-oasis/integer-buffer-set'; | ||
import { OnRecyclerProcess, RecyclerProps, SafeRange } from './types'; | ||
export { OnRecyclerProcess, RecyclerProps }; | ||
declare class Recycler { | ||
declare class Recycler<ItemMeta = any> { | ||
private _queue; | ||
@@ -14,8 +14,8 @@ private _thresholdIndexValue; | ||
constructor(props?: RecyclerProps); | ||
get queue(): IntegerBufferSet<any>[]; | ||
get queue(): IntegerBufferSet<ItemMeta>[]; | ||
get thresholdIndexValue(): number; | ||
get recyclerReservedBufferPerBatch(): number; | ||
getIndices(): any[]; | ||
addBuffer(type: string): IntegerBufferSet<any>; | ||
ensureBuffer(type: string): IntegerBufferSet<any>; | ||
getIndices(): import("@x-oasis/integer-buffer-set/dist/types").BufferIndicesItem<ItemMeta>[]; | ||
addBuffer(type: string): IntegerBufferSet<ItemMeta>; | ||
ensureBuffer(type: string): IntegerBufferSet<ItemMeta>; | ||
reset(): void; | ||
@@ -22,0 +22,0 @@ updateIndices(props: { |
{ | ||
"name": "@x-oasis/recycler", | ||
"version": "0.1.35", | ||
"version": "0.1.36", | ||
"description": "IntegerBufferSet function", | ||
@@ -18,4 +18,7 @@ "main": "dist/index.js", | ||
}, | ||
"publishConfig": { | ||
"access": "public" | ||
}, | ||
"dependencies": { | ||
"@x-oasis/integer-buffer-set": "0.1.35" | ||
"@x-oasis/integer-buffer-set": "0.1.36" | ||
}, | ||
@@ -22,0 +25,0 @@ "scripts": { |
@@ -1,3 +0,3 @@ | ||
import IntegerBufferSet from '@x-oasis/integer-buffer-set'; | ||
import { OnRecyclerProcess, RecyclerProps, SafeRange, ItemMeta } from './types'; | ||
import IntegerBufferSet, { IndicesItem } from '@x-oasis/integer-buffer-set'; | ||
import { OnRecyclerProcess, RecyclerProps, SafeRange } from './types'; | ||
import { | ||
@@ -11,4 +11,4 @@ DEFAULT_RECYCLER_TYPE, | ||
class Recycler { | ||
private _queue: Array<IntegerBufferSet> = []; | ||
class Recycler<ItemMeta = any> { | ||
private _queue: IntegerBufferSet<ItemMeta>[] = []; | ||
@@ -24,4 +24,4 @@ /** | ||
private _recyclerBufferSize: number; | ||
private _metaExtractor: (index: number) => any; | ||
private _indexExtractor: (meta: any) => number; | ||
private _metaExtractor: (index: number) => ItemMeta; | ||
private _indexExtractor: (meta: ItemMeta) => number; | ||
private _getType: (index: number) => string; | ||
@@ -65,3 +65,6 @@ private _getMetaType: (meta: ItemMeta) => string; | ||
getIndices() { | ||
return this._queue.reduce((acc, cur) => acc.concat(cur.getIndices()), []); | ||
return this._queue.reduce<IndicesItem<ItemMeta>[]>( | ||
(acc, cur) => acc.concat(cur.getIndices()), | ||
[] | ||
); | ||
} | ||
@@ -73,3 +76,3 @@ | ||
if (index !== -1) return this._queue[index]; | ||
const buffer = new IntegerBufferSet({ | ||
const buffer = new IntegerBufferSet<ItemMeta>({ | ||
type, | ||
@@ -89,2 +92,5 @@ getMetaType: this._getMetaType, | ||
/** | ||
* should be invoked after getIndices... | ||
*/ | ||
reset() { | ||
@@ -91,0 +97,0 @@ this.queue.forEach((buffer) => buffer.reset()); |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
48529
527
+ Added@x-oasis/integer-buffer-set@0.1.36(transitive)
- Removed@x-oasis/integer-buffer-set@0.1.35(transitive)