@fireflysemantics/slice 14.0.7

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.
@@ -0,0 +1,144 @@
1
+ import { Observable } from 'rxjs';
2
+ import { scrollPosition } from "./models/scrollPosition";
3
+ /**
4
+ * Returns all the entities are distinct by the
5
+ * `property` value argument.
6
+ *
7
+ * Note that the implementation uses a `Map<string, E>` to
8
+ * index the entities by key. Therefore the more recent occurences
9
+ * matching a key instance will overwrite the previous ones.
10
+ *
11
+ * @param property The name of the property to check for distinct values by.
12
+ * @param entities The entities in the array.
13
+ *
14
+ * @example
15
+ ```
16
+ let todos: Todo[] = [
17
+ { id: 1, title: "Lets do it!" },
18
+ { id: 1, title: "Lets do it again!" },
19
+ { id: 2, title: "All done!" }
20
+ ];
21
+
22
+ let todos2: Todo[] = [
23
+ { id: 1, title: "Lets do it!" },
24
+ { id: 2, title: "All done!" }
25
+ ];
26
+
27
+ expect(distinct(todos, "id").length).toEqual(2);
28
+ expect(distinct(todos2, "id").length).toEqual(2);
29
+
30
+ ```
31
+ */
32
+ export declare function distinct<E, K extends keyof E>(entities: E[], property: K): E[];
33
+ /**
34
+ * Returns true if all the entities are distinct by the
35
+ * `property` value argument.
36
+ *
37
+ * @param property The name of the property to check for distinct values by.
38
+ * @param entities The entities in the array.
39
+ *
40
+ * @example
41
+ *
42
+ ```
43
+ let todos: Todo[] = [
44
+ { id: 1, title: "Lets do it!" },
45
+ { id: 1, title: "Lets do it again!" },
46
+ { id: 2, title: "All done!" }
47
+ ];
48
+
49
+ let todos2: Todo[] = [
50
+ { id: 1, title: "Lets do it!" },
51
+ { id: 2, title: "All done!" }
52
+ ];
53
+
54
+ expect(unique(todos, "id")).toBeFalsy();
55
+ expect(unique(todos2, "id")).toBeTruthy();
56
+ ```
57
+ */
58
+ export declare function unique<E>(entities: E[], property: keyof E): boolean;
59
+ /**
60
+ * Create a global ID
61
+ * @return The global id.
62
+ *
63
+ * @example
64
+ * let e.guid = GUID();
65
+ */
66
+ export declare function GUID(): string;
67
+ /**
68
+ * Set the global identfication property on the instance.
69
+ *
70
+ * @param e Entity we want to set the global identifier on.
71
+ * @param gid The name of the `gid` property. If not specified it defaults to `ESTORE_CONFIG_DEFAULT.guidKey`.
72
+ */
73
+ export declare function attachGUID<E>(e: E, gid?: string): string;
74
+ /**
75
+ * Set the global identfication property on the instance.
76
+ *
77
+ * @param e[] Entity array we want to set the global identifiers on.
78
+ * @param gid The name of the `gid` property. If not specified it defaults to `gid`.
79
+ */
80
+ export declare function attachGUIDs<E>(e: E[], gid?: string): void;
81
+ /**
82
+ * Create a shallow copy of the argument.
83
+ * @param o The object to copy
84
+ */
85
+ export declare function shallowCopy<E>(o: E): E;
86
+ /**
87
+ * Create a deep copy of the argument.
88
+ * @param o The object to copy
89
+ */
90
+ export declare function deepCopy<E>(o: E): any;
91
+ /**
92
+ * Gets the current active value from the `active`
93
+ * Map.
94
+ *
95
+ * This is used for the scenario where we are managing
96
+ * a single active instance. For example
97
+ * when selecting a book from a collection of books.
98
+ *
99
+ * The selected `Book` instance becomes the active value.
100
+ *
101
+ * @example
102
+ * const book:Book = getActiveValue(bookStore.active);
103
+ * @param m
104
+ */
105
+ export declare function getActiveValue<E>(m: Map<any, E>): any;
106
+ /**
107
+ * The method can be used to exclude keys from an instance
108
+ * of type `E`.
109
+ *
110
+ * We can use this to exclude values when searching an object.
111
+ *
112
+ * @param entity An instance of type E
113
+ * @param exclude The keys to exclude
114
+ *
115
+ * @example
116
+ * todo = { id: '1', description: 'Do it!' }
117
+ * let keys = excludeKeys<Todo>(todo, ['id]);
118
+ * // keys = ['description']
119
+ */
120
+ export declare function excludeKeys<E>(entity: E, exclude: string[]): string[];
121
+ /**
122
+ *
123
+ * @param entities The entity to search
124
+ * @param exclude Keys to exclude from each entity
125
+ *
126
+ * @return E[] Array of entities with properties containing the search term.
127
+ */
128
+ export declare function search<E>(query: string | undefined, entities: E[], exclude?: string[]): E[];
129
+ /**
130
+ * @param scrollable The element being scrolled
131
+ * @param debounceMS The number of milliseconds to debounce scroll events
132
+ * @param sp The function returning the scroll position coordinates.
133
+ * @return A boolean valued observable indicating whether the element is scrolling up or down
134
+ */
135
+ export declare function scrollingUp(scrollable: any, debounceMS: number, sp: scrollPosition): Observable<boolean>;
136
+ /**
137
+ * Filters the entities properties to the set contained in the
138
+ * `keys` array.
139
+ *
140
+ * @param keys The array of keys that the entity be limited to
141
+ * @param entity The entity to map
142
+ * @return An entity instance that has only the keys provided in the keys array
143
+ */
144
+ export declare function mapEntity(keys: string[], entity: any): any;
package/package.json ADDED
@@ -0,0 +1,42 @@
1
+ {
2
+ "name": "@fireflysemantics/slice",
3
+ "version": "14.0.7",
4
+ "author": "Ole Ersoy",
5
+ "license": "MIT",
6
+ "bugs": {
7
+ "url": "https://github.com/fireflysemantics/slice/issues"
8
+ },
9
+ "repository": {
10
+ "type": "git",
11
+ "url": "git+https://github.com/fireflysemantics/slice.git"
12
+ },
13
+ "keywords": [
14
+ "Light Weight",
15
+ "Javascript",
16
+ "Typescript",
17
+ "Angular",
18
+ "React",
19
+ "Vue",
20
+ "State",
21
+ "Query",
22
+ "Reactive",
23
+ "RxJS",
24
+ "Observables",
25
+ "Multicasting"
26
+ ],
27
+ "peerDependencies": {
28
+ "@types/nanoid": "*",
29
+ "nanoid": "*",
30
+ "rxjs": "*"
31
+ },
32
+ "main": "bundles/fireflysemantics-slice.umd.js",
33
+ "module": "fesm2015/fireflysemantics-slice.js",
34
+ "es2015": "fesm2015/fireflysemantics-slice.js",
35
+ "esm2015": "esm2015/fireflysemantics-slice.js",
36
+ "fesm2015": "fesm2015/fireflysemantics-slice.js",
37
+ "typings": "fireflysemantics-slice.d.ts",
38
+ "sideEffects": false,
39
+ "dependencies": {
40
+ "tslib": "*"
41
+ }
42
+ }
@@ -0,0 +1,6 @@
1
+ export * from './lib/models/';
2
+ export * from './lib/AbstractStore';
3
+ export * from './lib/EStore';
4
+ export * from './lib/OStore';
5
+ export * from './lib/Slice';
6
+ export * from './lib/utilities';