@leafer/list 1.0.0-beta.8 → 1.0.0-rc.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json CHANGED
@@ -1,12 +1,15 @@
1
1
  {
2
2
  "name": "@leafer/list",
3
- "version": "1.0.0-beta.8",
3
+ "version": "1.0.0-rc.1",
4
4
  "description": "@leafer/list",
5
5
  "author": "Chao (Leafer) Wan",
6
6
  "license": "MIT",
7
7
  "main": "src/index.ts",
8
+ "types": "types/index.d.ts",
8
9
  "files": [
9
- "src"
10
+ "src",
11
+ "types",
12
+ "dist"
10
13
  ],
11
14
  "repository": {
12
15
  "type": "git",
@@ -19,6 +22,6 @@
19
22
  "leaferjs"
20
23
  ],
21
24
  "devDependencies": {
22
- "@leafer/interface": "1.0.0-beta.8"
25
+ "@leafer/interface": "1.0.0-rc.1"
23
26
  }
24
27
  }
package/src/LeafList.ts CHANGED
@@ -13,7 +13,7 @@ export class LeafList implements ILeafList {
13
13
  }
14
14
 
15
15
  public has(leaf: ILeaf): boolean {
16
- return this.keys[leaf.innerId] !== undefined
16
+ return leaf && this.keys[leaf.innerId] !== undefined
17
17
  }
18
18
 
19
19
  public indexAt(index: number): ILeaf {
@@ -0,0 +1,39 @@
1
+ import { ILeafList, ILeaf, INumberMap, ILeafListItemCallback, ILeafLevelList, ILeafArrayMap } from '@leafer/interface';
2
+
3
+ declare class LeafList implements ILeafList {
4
+ list: ILeaf[];
5
+ keys: INumberMap;
6
+ get length(): number;
7
+ constructor(item?: ILeaf | ILeaf[]);
8
+ has(leaf: ILeaf): boolean;
9
+ indexAt(index: number): ILeaf;
10
+ indexOf(leaf: ILeaf): number;
11
+ pushList(list: ILeaf[]): void;
12
+ unshift(leaf: ILeaf): void;
13
+ push(leaf: ILeaf): void;
14
+ sort(reverse?: boolean): void;
15
+ remove(leaf: ILeaf): void;
16
+ forEach(itemCallback: ILeafListItemCallback): void;
17
+ clone(): ILeafList;
18
+ reset(): void;
19
+ destroy(): void;
20
+ }
21
+
22
+ declare class LeafLevelList implements ILeafLevelList {
23
+ levelMap: ILeafArrayMap;
24
+ keys: INumberMap;
25
+ levels: number[];
26
+ get length(): number;
27
+ private _length;
28
+ constructor(item?: ILeaf | ILeaf[]);
29
+ has(leaf: ILeaf): boolean;
30
+ without(leaf: ILeaf): boolean;
31
+ sort(reverse?: boolean): void;
32
+ pushList(list: ILeaf[]): void;
33
+ push(leaf: ILeaf): void;
34
+ forEach(itemCallback: ILeafListItemCallback): void;
35
+ reset(): void;
36
+ destroy(): void;
37
+ }
38
+
39
+ export { LeafLevelList, LeafList };