native-document 1.0.258 → 1.0.261
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/index.js +2 -2
- package/package.json +1 -1
- package/src/core/data/ObservableArray.js +9 -1
- package/src/core/data/ObservableQuery.js +4 -0
- package/src/core/utils/helpers.js +17 -0
- package/types/helpers.d.ts +7 -0
- package/types/observable.d.ts +5 -0
- package/utils.d.ts +2 -1
- package/utils.js +2 -0
package/index.js
CHANGED
|
@@ -8,8 +8,8 @@ export { SingletonView, useSingleton } from './src/core/wrappers/SingletonView';
|
|
|
8
8
|
export { default as PluginsManager } from './src/core/utils/plugins-manager';
|
|
9
9
|
export { default as Validator } from './src/core/utils/validator';
|
|
10
10
|
|
|
11
|
-
export { Formatters } from
|
|
12
|
-
export {default as ShortcutManager} from
|
|
11
|
+
export { Formatters } from './src/core/utils/formatters';
|
|
12
|
+
export {default as ShortcutManager} from './src/core/utils/shortcut-manager';
|
|
13
13
|
|
|
14
14
|
export * from './src/core/utils/property-accumulator';
|
|
15
15
|
export * from './src/core/utils/args-types';
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "native-document",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.261",
|
|
4
4
|
"description": "A reactive JavaScript framework that preserves native DOM simplicity without sacrificing modern features",
|
|
5
5
|
"author": "AfroCodeur <https://github.com/afrocodeur>",
|
|
6
6
|
"license": "MIT",
|
|
@@ -6,7 +6,7 @@ import NativeDocumentError from '../errors/NativeDocumentError.js';
|
|
|
6
6
|
import {nextTick} from '../utils/helpers';
|
|
7
7
|
|
|
8
8
|
export const mutationMethods = ['push', 'pop', 'shift', 'unshift', 'reverse', 'sort', 'splice'];
|
|
9
|
-
export const noMutationMethods = ['map', 'forEach', 'filter', 'reduce', 'some', 'every', 'find', 'findIndex', 'concat', 'includes', 'indexOf'];
|
|
9
|
+
export const noMutationMethods = ['map', 'forEach', 'filter', 'reduce', 'some', 'every', 'find', 'findIndex', 'concat', 'includes', 'indexOf', 'at', 'lastIndexOf', 'findLastIndex'];
|
|
10
10
|
|
|
11
11
|
const toObservable = (item) => item?.__$Observable ? item : ObservableArray.auto(item);
|
|
12
12
|
|
|
@@ -578,4 +578,12 @@ ObservableArray.prototype.fnClear = function () {
|
|
|
578
578
|
// return result;
|
|
579
579
|
// };
|
|
580
580
|
|
|
581
|
+
ObservableArray.prototype.first = function () {
|
|
582
|
+
return this.$currentValue[0];
|
|
583
|
+
};
|
|
584
|
+
|
|
585
|
+
ObservableArray.prototype.last = function () {
|
|
586
|
+
return this.$currentValue.at(-1);
|
|
587
|
+
};
|
|
588
|
+
|
|
581
589
|
export default ObservableArray;
|
|
@@ -123,6 +123,10 @@ ObservableQuery.prototype.map = function(fn) {
|
|
|
123
123
|
|
|
124
124
|
ObservableQuery.prototype.set = function(dataset) {
|
|
125
125
|
this.$currentResultData.forEach((element) => {
|
|
126
|
+
if(typeof element.set === 'function') {
|
|
127
|
+
element.set(dataset);
|
|
128
|
+
return;
|
|
129
|
+
}
|
|
126
130
|
for(const key in dataset) {
|
|
127
131
|
const prop = element[key];
|
|
128
132
|
const value = dataset[key];
|
|
@@ -141,4 +141,21 @@ export const deepClone = (value, onObservableFound) => {
|
|
|
141
141
|
}
|
|
142
142
|
}
|
|
143
143
|
return cloned;
|
|
144
|
+
};
|
|
145
|
+
|
|
146
|
+
|
|
147
|
+
export const lock = (fn, defaultReturn) => {
|
|
148
|
+
let isLocked = false;
|
|
149
|
+
|
|
150
|
+
return async (...args) => {
|
|
151
|
+
if(isLocked) {
|
|
152
|
+
return typeof defaultReturn === 'function' ? defaultReturn() : defaultReturn;
|
|
153
|
+
}
|
|
154
|
+
isLocked = true;
|
|
155
|
+
try {
|
|
156
|
+
return await fn(...args);
|
|
157
|
+
} finally {
|
|
158
|
+
isLocked = false;
|
|
159
|
+
}
|
|
160
|
+
};
|
|
144
161
|
};
|
package/types/observable.d.ts
CHANGED
|
@@ -217,9 +217,14 @@ export interface ObservableArray<T> extends ObservableItem<T[]> {
|
|
|
217
217
|
find(callback: (value: T, index: number, array: T[]) => boolean): T | undefined;
|
|
218
218
|
at(index: number): T | undefined;
|
|
219
219
|
findIndex(callback: (value: T, index: number, array: T[]) => boolean): number;
|
|
220
|
+
findLastIndex(callback: (value: T, index: number, array: T[]) => boolean): number;
|
|
220
221
|
concat(...items: (T | T[])[]): T[];
|
|
221
222
|
indexOf(item: T): number;
|
|
223
|
+
lastIndexOf(item: T): number;
|
|
222
224
|
includes(item: T): boolean;
|
|
225
|
+
at(index: number): T | undefined;
|
|
226
|
+
first(): T | undefined;
|
|
227
|
+
last(): T | undefined;
|
|
223
228
|
|
|
224
229
|
where(predicates: PredicateMap<T> | ((item: T) => boolean)): ObservableArray<T>;
|
|
225
230
|
whereSome<K extends keyof T>(fields: K[], filter: FilterResult<T[K]>): ObservableArray<T>;
|
package/utils.d.ts
CHANGED
package/utils.js
CHANGED
|
@@ -4,6 +4,8 @@ import * as filters from './src/core/utils/filters/index';
|
|
|
4
4
|
import {classPropertyAccumulator, cssPropertyAccumulator} from './src/core/utils/property-accumulator';
|
|
5
5
|
import {LocalStorage} from './src/core/utils/localstorage';
|
|
6
6
|
|
|
7
|
+
export * from './src/core/utils/helpers';
|
|
8
|
+
|
|
7
9
|
const Service = Cache;
|
|
8
10
|
|
|
9
11
|
export {
|