native-document 1.0.258 → 1.0.259

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,6 +1,6 @@
1
1
  {
2
2
  "name": "native-document",
3
- "version": "1.0.258",
3
+ "version": "1.0.259",
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];
@@ -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>;