@microphi/store 2.2.3 → 2.3.0
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/lib/index.d.ts +0 -1
- package/lib/index.d.ts.map +1 -1
- package/lib/index.js +0 -1
- package/lib/index.js.map +1 -1
- package/package.json +4 -3
- package/lib/lib/list/list.d.ts +0 -21
- package/lib/lib/list/list.d.ts.map +0 -1
- package/lib/lib/list/list.js +0 -82
- package/lib/lib/list/list.js.map +0 -1
package/lib/index.d.ts
CHANGED
package/lib/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAIA,cAAc,mBAAmB,CAAC;AAClC,cAAc,qBAAqB,CAAC;AACpC,cAAc,qBAAqB,CAAC
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAIA,cAAc,mBAAmB,CAAC;AAClC,cAAc,qBAAqB,CAAC;AACpC,cAAc,qBAAqB,CAAC"}
|
package/lib/index.js
CHANGED
package/lib/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,cAAc,mBAAmB,CAAC;AAClC,cAAc,qBAAqB,CAAC;AACpC,cAAc,qBAAqB,CAAC
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,cAAc,mBAAmB,CAAC;AAClC,cAAc,qBAAqB,CAAC;AACpC,cAAc,qBAAqB,CAAC","sourcesContent":["/*\n * Public API Surface of store\n */\n\nexport * from './lib/store/store';\nexport * from './lib/effect/effect';\nexport * from './lib/reduce/reduce';\n"]}
|
package/package.json
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@microphi/store",
|
|
3
|
+
"licence": "MIT",
|
|
3
4
|
"keywords": [
|
|
4
5
|
"redux",
|
|
5
6
|
"reducer",
|
|
@@ -22,9 +23,9 @@
|
|
|
22
23
|
"files": [
|
|
23
24
|
"lib"
|
|
24
25
|
],
|
|
25
|
-
"version": "2.
|
|
26
|
+
"version": "2.3.0",
|
|
26
27
|
"dependencies": {
|
|
27
|
-
"@microphi/debug": "^2.
|
|
28
|
+
"@microphi/debug": "^2.3.0",
|
|
28
29
|
"reflect-metadata": "^0.1.13",
|
|
29
30
|
"tslib": "^2.5.0"
|
|
30
31
|
},
|
|
@@ -41,5 +42,5 @@
|
|
|
41
42
|
"prepack": "yarn build",
|
|
42
43
|
"lint:ci": "eslint ./src"
|
|
43
44
|
},
|
|
44
|
-
"gitHead": "
|
|
45
|
+
"gitHead": "6b2df1f7209ccda9b934bbdbcf71f59acc383380"
|
|
45
46
|
}
|
package/lib/lib/list/list.d.ts
DELETED
|
@@ -1,21 +0,0 @@
|
|
|
1
|
-
import { $Keys } from 'utility-types';
|
|
2
|
-
export declare class List<EntityType extends object> implements Iterable<EntityType> {
|
|
3
|
-
private IDField;
|
|
4
|
-
readonly entities: Map<any, EntityType>;
|
|
5
|
-
/**
|
|
6
|
-
* maps entities position from the original array to their ids
|
|
7
|
-
*/
|
|
8
|
-
private readonly ids;
|
|
9
|
-
get size(): number;
|
|
10
|
-
has(id: any): boolean;
|
|
11
|
-
get(id: any): EntityType | undefined;
|
|
12
|
-
private getId;
|
|
13
|
-
constructor(IDField: $Keys<EntityType>, entities?: EntityType[]);
|
|
14
|
-
[Symbol.iterator](): IterableIterator<EntityType>;
|
|
15
|
-
upsert(...entities: EntityType[]): void;
|
|
16
|
-
prepend(...entities: EntityType[]): void;
|
|
17
|
-
clear(): void;
|
|
18
|
-
delete(...entities: EntityType[]): void;
|
|
19
|
-
append(...entities: EntityType[]): void;
|
|
20
|
-
}
|
|
21
|
-
//# sourceMappingURL=list.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"list.d.ts","sourceRoot":"","sources":["../../../src/lib/list/list.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,EAAE,MAAM,eAAe,CAAC;AAEtC,qBAAa,IAAI,CAAC,UAAU,SAAS,MAAM,CAAE,YAAW,QAAQ,CAAC,UAAU,CAAC;IA8B9D,OAAO,CAAC,OAAO;IA3B3B,SAAgB,QAAQ,uBAA8B;IAEtD;;OAEG;IACH,OAAO,CAAC,QAAQ,CAAC,GAAG,CAAa;IAEjC,IAAW,IAAI,WAOd;IAEM,GAAG,CAAC,EAAE,EAAE,GAAG;IAIX,GAAG,CAAC,EAAE,EAAE,GAAG;IAGlB,OAAO,CAAC,KAAK;gBAIO,OAAO,EAAE,KAAK,CAAC,UAAU,CAAC,EAAE,QAAQ,GAAE,UAAU,EAAO;IAW1E,CAAC,MAAM,CAAC,QAAQ,CAAC,IAAI,gBAAgB,CAAC,UAAU,CAAC;IAQ3C,MAAM,CAAC,GAAG,QAAQ,EAAE,UAAU,EAAE;IAYhC,OAAO,CAAC,GAAG,QAAQ,EAAE,UAAU,EAAE;IAejC,KAAK;IAOL,MAAM,CAAC,GAAG,QAAQ,EAAE,UAAU,EAAE;IAchC,MAAM,CAAC,GAAG,QAAQ,EAAE,UAAU,EAAE;CAYxC"}
|
package/lib/lib/list/list.js
DELETED
|
@@ -1,82 +0,0 @@
|
|
|
1
|
-
export class List {
|
|
2
|
-
get size() {
|
|
3
|
-
if (this.ids.length !== this.entities.size) {
|
|
4
|
-
throw new Error(`Size Mismatch ${this.ids.length} !== ${this.entities.size}`);
|
|
5
|
-
}
|
|
6
|
-
return this.entities.size;
|
|
7
|
-
}
|
|
8
|
-
has(id) {
|
|
9
|
-
return this.entities.has(id);
|
|
10
|
-
}
|
|
11
|
-
get(id) {
|
|
12
|
-
return this.entities.get(id);
|
|
13
|
-
}
|
|
14
|
-
getId(entity) {
|
|
15
|
-
return entity[this.IDField];
|
|
16
|
-
}
|
|
17
|
-
constructor(IDField, entities = []) {
|
|
18
|
-
this.IDField = IDField;
|
|
19
|
-
this.entities = new Map();
|
|
20
|
-
/**
|
|
21
|
-
* maps entities position from the original array to their ids
|
|
22
|
-
*/
|
|
23
|
-
this.ids = [];
|
|
24
|
-
this.ids = entities.map((e) => this.getId(e));
|
|
25
|
-
entities
|
|
26
|
-
.forEach((item) => {
|
|
27
|
-
const id = item[IDField];
|
|
28
|
-
this.entities.set(id, item);
|
|
29
|
-
});
|
|
30
|
-
}
|
|
31
|
-
*[Symbol.iterator]() {
|
|
32
|
-
for (const idx in this.ids) {
|
|
33
|
-
const id = this.ids[idx];
|
|
34
|
-
// @ts-ignore
|
|
35
|
-
yield this.entities.get(id);
|
|
36
|
-
}
|
|
37
|
-
}
|
|
38
|
-
upsert(...entities) {
|
|
39
|
-
entities.forEach((e) => {
|
|
40
|
-
const id = this.getId(e);
|
|
41
|
-
if (!this.entities.has(id)) {
|
|
42
|
-
this.ids.push(id);
|
|
43
|
-
}
|
|
44
|
-
this.entities.set(id, e);
|
|
45
|
-
});
|
|
46
|
-
}
|
|
47
|
-
prepend(...entities) {
|
|
48
|
-
entities.reverse().forEach((e) => {
|
|
49
|
-
const id = this.getId(e);
|
|
50
|
-
if (this.entities.has(id)) {
|
|
51
|
-
this.delete(e);
|
|
52
|
-
}
|
|
53
|
-
this.ids.unshift(id);
|
|
54
|
-
this.entities.set(id, e);
|
|
55
|
-
});
|
|
56
|
-
}
|
|
57
|
-
clear() {
|
|
58
|
-
this.ids.length = 0;
|
|
59
|
-
this.entities.clear();
|
|
60
|
-
}
|
|
61
|
-
delete(...entities) {
|
|
62
|
-
entities.forEach((e) => {
|
|
63
|
-
const id = this.getId(e);
|
|
64
|
-
const indexOfId = this.ids.findIndex((_id) => _id === id);
|
|
65
|
-
if (indexOfId >= 0) {
|
|
66
|
-
this.ids.splice(indexOfId, 1);
|
|
67
|
-
this.entities.delete(id);
|
|
68
|
-
}
|
|
69
|
-
});
|
|
70
|
-
}
|
|
71
|
-
append(...entities) {
|
|
72
|
-
entities.forEach((e) => {
|
|
73
|
-
const id = this.getId(e);
|
|
74
|
-
if (this.entities.has(id)) {
|
|
75
|
-
this.delete(e);
|
|
76
|
-
}
|
|
77
|
-
this.ids.push(id);
|
|
78
|
-
this.entities.set(id, e);
|
|
79
|
-
});
|
|
80
|
-
}
|
|
81
|
-
}
|
|
82
|
-
//# sourceMappingURL=list.js.map
|
package/lib/lib/list/list.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"list.js","sourceRoot":"","sources":["../../../src/lib/list/list.ts"],"names":[],"mappings":"AAEA,MAAM,OAAO,IAAI;IAUf,IAAW,IAAI;QACb,IAAI,IAAI,CAAC,GAAG,CAAC,MAAM,KAAK,IAAI,CAAC,QAAQ,CAAC,IAAI,EAAE,CAAC;YAE3C,MAAM,IAAI,KAAK,CAAC,iBAAiB,IAAI,CAAC,GAAG,CAAC,MAAM,QAAQ,IAAI,CAAC,QAAQ,CAAC,IAAI,EAAE,CAAC,CAAC;QAChF,CAAC;QAED,OAAO,IAAI,CAAC,QAAQ,CAAC,IAAI,CAAC;IAC5B,CAAC;IAEM,GAAG,CAAC,EAAO;QAChB,OAAO,IAAI,CAAC,QAAQ,CAAC,GAAG,CAAC,EAAE,CAAC,CAAC;IAC/B,CAAC;IAEM,GAAG,CAAC,EAAO;QAChB,OAAO,IAAI,CAAC,QAAQ,CAAC,GAAG,CAAC,EAAE,CAAC,CAAC;IAC/B,CAAC;IACO,KAAK,CAAC,MAAkB;QAC9B,OAAO,MAAM,CAAC,IAAI,CAAC,OAAO,CAAC,CAAC;IAC9B,CAAC;IAED,YAAoB,OAA0B,EAAE,WAAyB,EAAE;QAAvD,YAAO,GAAP,OAAO,CAAmB;QA3B9B,aAAQ,GAAG,IAAI,GAAG,EAAmB,CAAC;QAEtD;;WAEG;QACc,QAAG,GAAU,EAAE,CAAC;QAwB/B,IAAI,CAAC,GAAG,GAAG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AC;YAClB,IAAI,CAAC,QAAQ,CAAC,GAAG,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC;QAC3B,CAAC,CAAC,CAAC;IACL,CAAC;CACF","sourcesContent":["import { $Keys } from 'utility-types';\n\nexport class List<EntityType extends object> implements Iterable<EntityType> {\n\n\n public readonly entities = new Map<any, EntityType>();\n\n /**\n * maps entities position from the original array to their ids\n */\n private readonly ids: any[] = [];\n\n public get size() {\n if (this.ids.length !== this.entities.size) {\n\n throw new Error(`Size Mismatch ${this.ids.length} !== ${this.entities.size}`);\n }\n\n return this.entities.size;\n }\n\n public has(id: any) {\n return this.entities.has(id);\n }\n\n public get(id: any) {\n return this.entities.get(id);\n }\n private getId(entity: EntityType) {\n return entity[this.IDField];\n }\n\n constructor(private IDField: $Keys<EntityType>, entities: EntityType[] = []) {\n\n this.ids = entities.map((e) => this.getId(e));\n\n entities\n .forEach((item) => {\n const id = item[IDField];\n this.entities.set(id, item);\n });\n }\n\n *[Symbol.iterator](): IterableIterator<EntityType> {\n for (const idx in this.ids) {\n const id = this.ids[idx];\n // @ts-ignore\n yield this.entities.get(id);\n }\n }\n\n public upsert(...entities: EntityType[]) {\n entities.forEach((e) => {\n const id = this.getId(e);\n\n if (!this.entities.has(id)) {\n this.ids.push(id);\n }\n\n this.entities.set(id, e);\n });\n }\n\n public prepend(...entities: EntityType[]) {\n entities.reverse().forEach((e) => {\n const id = this.getId(e);\n\n if (this.entities.has(id)) {\n this.delete(e);\n }\n\n this.ids.unshift(id);\n\n this.entities.set(id, e);\n\n });\n }\n\n public clear() {\n\n this.ids.length = 0;\n this.entities.clear();\n\n }\n\n public delete(...entities: EntityType[]) {\n\n entities.forEach((e) => {\n const id = this.getId(e);\n const indexOfId = this.ids.findIndex((_id) => _id === id);\n\n if (indexOfId >= 0) {\n this.ids.splice(indexOfId, 1);\n this.entities.delete(id);\n }\n });\n\n }\n\n public append(...entities: EntityType[]) {\n entities.forEach((e) => {\n const id = this.getId(e);\n\n if (this.entities.has(id)) {\n this.delete(e);\n }\n\n this.ids.push(id);\n this.entities.set(id, e);\n });\n }\n}\n"]}
|