@superutils/rx 0.1.1 → 0.1.3
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/dist/browser/index.min.js +2 -2
- package/dist/browser/index.min.js.map +1 -1
- package/dist/index.cjs +14 -8
- package/dist/index.d.cts +21 -8
- package/dist/index.d.ts +21 -8
- package/dist/index.js +15 -8
- package/package.json +4 -3
package/dist/index.cjs
CHANGED
|
@@ -278,8 +278,6 @@ var DataStorage = class {
|
|
|
278
278
|
* ```
|
|
279
279
|
*/
|
|
280
280
|
constructor(name, options) {
|
|
281
|
-
/** Debounce and throttle related options */
|
|
282
|
-
// readonly deferOptions
|
|
283
281
|
this.initialized = false;
|
|
284
282
|
this.subscriptions = {
|
|
285
283
|
subject: void 0,
|
|
@@ -296,7 +294,10 @@ var DataStorage = class {
|
|
|
296
294
|
this.setAll(data, true);
|
|
297
295
|
return this;
|
|
298
296
|
};
|
|
299
|
-
this.find = (predicateOrOptions) => (0, import_core6.find)(
|
|
297
|
+
this.find = (predicateOrOptions) => (0, import_core6.find)(
|
|
298
|
+
this.getAll(),
|
|
299
|
+
predicateOrOptions
|
|
300
|
+
);
|
|
300
301
|
this.filter = (predicate, limit, asArray, result) => (0, import_core6.filter)(this.getAll(), predicate, limit, asArray, result);
|
|
301
302
|
this.get = (key) => this.getAll().get(key);
|
|
302
303
|
this.getAll = (forceRead = false) => {
|
|
@@ -337,9 +338,9 @@ var DataStorage = class {
|
|
|
337
338
|
if (!(0, import_core6.isMap)(data)) return this.subject.next(/* @__PURE__ */ new Map());
|
|
338
339
|
this.write(data);
|
|
339
340
|
(0, import_core6.fallbackIfFails)(
|
|
340
|
-
|
|
341
|
+
() => {
|
|
341
342
|
var _a2;
|
|
342
|
-
return
|
|
343
|
+
return (_a2 = this.onChange) == null ? void 0 : _a2.call(this, data);
|
|
343
344
|
},
|
|
344
345
|
[],
|
|
345
346
|
this.triggerOnError("onChange")
|
|
@@ -382,10 +383,10 @@ var DataStorage = class {
|
|
|
382
383
|
this.subject.next(new Map(data));
|
|
383
384
|
return this;
|
|
384
385
|
};
|
|
385
|
-
this.sort = ((
|
|
386
|
+
this.sort = ((byKeyOrNameOrComparator, options) => {
|
|
386
387
|
const result = (0, import_core6.sort)(
|
|
387
388
|
this.getAll(),
|
|
388
|
-
|
|
389
|
+
byKeyOrNameOrComparator,
|
|
389
390
|
options
|
|
390
391
|
);
|
|
391
392
|
(options == null ? void 0 : options.save) && this.setAll(result, true);
|
|
@@ -409,12 +410,17 @@ var DataStorage = class {
|
|
|
409
410
|
this.triggerOnError("stringify-json")
|
|
410
411
|
);
|
|
411
412
|
};
|
|
413
|
+
this.toObject = () => {
|
|
414
|
+
const obj = {};
|
|
415
|
+
for (const [key, value] of this.getAll()) obj[key] = value;
|
|
416
|
+
return obj;
|
|
417
|
+
};
|
|
412
418
|
this.toString = (data) => this.toJSON(void 0, void 0, data);
|
|
413
419
|
this.triggerOnError = (type) => (err) => {
|
|
414
420
|
this.onError && (0, import_core6.fallbackIfFails)(this.onError, [err, type], "");
|
|
415
421
|
};
|
|
416
422
|
this.unsubscribe = () => unsubscribeAll_default(this.subscriptions);
|
|
417
|
-
this.values = () =>
|
|
423
|
+
this.values = () => (0, import_core6.getValues)(this.getAll());
|
|
418
424
|
this.write = (data) => {
|
|
419
425
|
try {
|
|
420
426
|
!this.initialized && this.init();
|
package/dist/index.d.cts
CHANGED
|
@@ -102,7 +102,7 @@ type ValueModifier<T = unknown, TCopy = T> = (newValue: T, previousValue: TCopy
|
|
|
102
102
|
* null,
|
|
103
103
|
* // copy and transform the value from number$
|
|
104
104
|
* newValue => newValue % 2 === 0,
|
|
105
|
-
* // debounce/throttle value changes to even$
|
|
105
|
+
* // debounce/throttle value changes to even$
|
|
106
106
|
* // {
|
|
107
107
|
* // delay: 300 //
|
|
108
108
|
* // throttle: false,
|
|
@@ -160,7 +160,7 @@ type StorageMap<K, V extends StorageValue> = <T>(callback: (value: V, key: K, da
|
|
|
160
160
|
type StorageOnChangeFn<K, V extends StorageValue> = (data: Map<K, V>) => ValueOrPromise<void | Map<K, V>>;
|
|
161
161
|
type StorageOnErrorFn = (err: unknown, type: OnErrorType) => ValueOrPromise<void>;
|
|
162
162
|
/** Initial options provided through the constructor */
|
|
163
|
-
type StorageOptions<Key, Value extends StorageValue, CacheDisabled extends boolean = false> = {
|
|
163
|
+
type StorageOptions<Key extends StorageKey, Value extends StorageValue, CacheDisabled extends boolean = false> = {
|
|
164
164
|
/** value to set, only if storage is empty. Default: `new Map()` */
|
|
165
165
|
initialValue?: Map<Key, Value>;
|
|
166
166
|
} & Pick<Partial<IDataStorage<Key, Value, CacheDisabled>>, 'cacheDisabled' | 'onChange' | 'onError' | 'parse' | 'spaces' | 'storage' | 'stringify'> & (CacheDisabled extends false ? Pick<Partial<IDataStorage<Key, Value, CacheDisabled>>, 'delay' | 'delayOptions'> : {
|
|
@@ -184,8 +184,9 @@ type StorageSortOptions = SortOptions & {
|
|
|
184
184
|
};
|
|
185
185
|
type StorageStringifyFn<K, V extends StorageValue> = (data: Map<K, V>) => string;
|
|
186
186
|
type StorageToJSON<K, V> = (replacer?: null | ((key: K, value: V) => unknown), spacing?: string | number, data?: Map<K, V>) => string;
|
|
187
|
-
type
|
|
188
|
-
|
|
187
|
+
type StorageKey = string;
|
|
188
|
+
type StorageValue = object;
|
|
189
|
+
interface IDataStorage<Key extends StorageKey, Value extends StorageValue, CacheDisabled extends boolean = false> {
|
|
189
190
|
/** Disable in-memory cache and only directly read/write from storage (local storage or JSON fle) */
|
|
190
191
|
readonly cacheDisabled: CacheDisabled;
|
|
191
192
|
/**
|
|
@@ -227,6 +228,15 @@ interface IDataStorage<Key, Value extends StorageValue, CacheDisabled extends bo
|
|
|
227
228
|
* - node: `undefined` (in-memory mode)
|
|
228
229
|
*/
|
|
229
230
|
readonly storage?: StorageCompact | null;
|
|
231
|
+
/**
|
|
232
|
+
* The underlying RxJS Subject that serves as the primary reactive interface for observing data modifications.
|
|
233
|
+
*
|
|
234
|
+
* Its implementation type is determined by the caching strategy:
|
|
235
|
+
* - **BehaviorSubject**: Used when caching is enabled.
|
|
236
|
+
* It maintains the current state and emits it immediately to new subscribers.
|
|
237
|
+
* - **Subject**: Used when caching is disabled.
|
|
238
|
+
* It acts as a pure event pipe, emitting updates only at the moment they occur without retaining an in-memory copy.
|
|
239
|
+
*/
|
|
230
240
|
readonly subject: CacheDisabled extends true ? Subject<Map<Key, Value>> : BehaviorSubject<Map<Key, Value>>;
|
|
231
241
|
/** Clear all items */
|
|
232
242
|
readonly clear: () => IDataStorage<Key, Value, CacheDisabled>;
|
|
@@ -346,6 +356,8 @@ interface IDataStorage<Key, Value extends StorageValue, CacheDisabled extends bo
|
|
|
346
356
|
readonly toArray: () => [Key, Value][];
|
|
347
357
|
/** Convert list of items (Map) to JSON string of 2D Array */
|
|
348
358
|
readonly toJSON: StorageToJSON<Key, Value>;
|
|
359
|
+
/** Convert list of items into an object */
|
|
360
|
+
readonly toObject: () => Record<Key, Value>;
|
|
349
361
|
/** Convert list of items (Map) to JSON string of 2D Array */
|
|
350
362
|
readonly toString: () => string;
|
|
351
363
|
/**
|
|
@@ -357,7 +369,7 @@ interface IDataStorage<Key, Value extends StorageValue, CacheDisabled extends bo
|
|
|
357
369
|
* - The instance stopping listening to force update cache triggers.
|
|
358
370
|
*/
|
|
359
371
|
readonly unsubscribe: () => void;
|
|
360
|
-
/** Get all values */
|
|
372
|
+
/** Get all values as an array */
|
|
361
373
|
readonly values: () => Value[];
|
|
362
374
|
/**
|
|
363
375
|
* Write data to the underlying storage (localStorage or file).
|
|
@@ -391,11 +403,11 @@ interface IDataStorage<Key, Value extends StorageValue, CacheDisabled extends bo
|
|
|
391
403
|
* ```
|
|
392
404
|
*/
|
|
393
405
|
declare const forceUpdateCache$: Subject<string | boolean | string[]>;
|
|
394
|
-
declare class DataStorage<Key, Value extends StorageValue, CacheDisabled extends boolean = false> implements IDataStorage<Key, Value, CacheDisabled> {
|
|
406
|
+
declare class DataStorage<Key extends StorageKey, Value extends StorageValue, CacheDisabled extends boolean = false> implements IDataStorage<Key, Value, CacheDisabled> {
|
|
395
407
|
readonly cacheDisabled: CacheDisabled;
|
|
396
408
|
readonly delay: number;
|
|
397
|
-
readonly delayOptions?: DelayOptions;
|
|
398
409
|
/** Debounce and throttle related options */
|
|
410
|
+
readonly delayOptions?: DelayOptions;
|
|
399
411
|
readonly initialized: boolean;
|
|
400
412
|
readonly name: string;
|
|
401
413
|
get size(): number;
|
|
@@ -533,6 +545,7 @@ declare class DataStorage<Key, Value extends StorageValue, CacheDisabled extends
|
|
|
533
545
|
readonly stringify?: StorageStringifyFn<Key, Value>;
|
|
534
546
|
readonly toArray: () => [Key, Value][];
|
|
535
547
|
readonly toJSON: StorageToJSON<Key, Value>;
|
|
548
|
+
readonly toObject: () => Record<Key, Value>;
|
|
536
549
|
readonly toString: (data?: Map<Key, Value>) => string;
|
|
537
550
|
private triggerOnError;
|
|
538
551
|
readonly unsubscribe: () => void;
|
|
@@ -727,4 +740,4 @@ declare const isSubscriptionLike: (value: unknown, strict?: boolean) => value is
|
|
|
727
740
|
*/
|
|
728
741
|
declare const unsubscribeAll: (unsub?: UnsubscribeCandidates, onError?: (err: unknown) => void) => void;
|
|
729
742
|
|
|
730
|
-
export { type CopyRxSubjectOptions, DataStorage, type DelayOptions, type IDataStorage, IGNORE_UPDATE_SYMBOL, IntervalRunner, IntervalSubject, type OnErrorType, type OnResultType, type StorageCompact, type StorageFilter, type StorageFind, type StorageMap, type StorageOnChangeFn, type StorageOnErrorFn, type StorageOptions, type StorageParseFn, type StorageSearch, type StorageSort, type StorageSortByComparator, type StorageSortByKey, type StorageSortByPropertyName, type StorageSortOptions, type StorageStringifyFn, type StorageToJSON, type StorageValue, type SubjectLike, type SubscriptionLike, type Unsubscribe, type UnsubscribeCandidates, type UnwrapSubjectValue, type ValueModifier, asPromise, copyRxSubject, forceUpdateCache$, isSubjectLike, isSubscriptionLike, type onBeforeExecType, unsubscribeAll };
|
|
743
|
+
export { type CopyRxSubjectOptions, DataStorage, type DelayOptions, type IDataStorage, IGNORE_UPDATE_SYMBOL, IntervalRunner, IntervalSubject, type OnErrorType, type OnResultType, type StorageCompact, type StorageFilter, type StorageFind, type StorageKey, type StorageMap, type StorageOnChangeFn, type StorageOnErrorFn, type StorageOptions, type StorageParseFn, type StorageSearch, type StorageSort, type StorageSortByComparator, type StorageSortByKey, type StorageSortByPropertyName, type StorageSortOptions, type StorageStringifyFn, type StorageToJSON, type StorageValue, type SubjectLike, type SubscriptionLike, type Unsubscribe, type UnsubscribeCandidates, type UnwrapSubjectValue, type ValueModifier, asPromise, copyRxSubject, forceUpdateCache$, isSubjectLike, isSubscriptionLike, type onBeforeExecType, unsubscribeAll };
|
package/dist/index.d.ts
CHANGED
|
@@ -102,7 +102,7 @@ type ValueModifier<T = unknown, TCopy = T> = (newValue: T, previousValue: TCopy
|
|
|
102
102
|
* null,
|
|
103
103
|
* // copy and transform the value from number$
|
|
104
104
|
* newValue => newValue % 2 === 0,
|
|
105
|
-
* // debounce/throttle value changes to even$
|
|
105
|
+
* // debounce/throttle value changes to even$
|
|
106
106
|
* // {
|
|
107
107
|
* // delay: 300 //
|
|
108
108
|
* // throttle: false,
|
|
@@ -160,7 +160,7 @@ type StorageMap<K, V extends StorageValue> = <T>(callback: (value: V, key: K, da
|
|
|
160
160
|
type StorageOnChangeFn<K, V extends StorageValue> = (data: Map<K, V>) => ValueOrPromise<void | Map<K, V>>;
|
|
161
161
|
type StorageOnErrorFn = (err: unknown, type: OnErrorType) => ValueOrPromise<void>;
|
|
162
162
|
/** Initial options provided through the constructor */
|
|
163
|
-
type StorageOptions<Key, Value extends StorageValue, CacheDisabled extends boolean = false> = {
|
|
163
|
+
type StorageOptions<Key extends StorageKey, Value extends StorageValue, CacheDisabled extends boolean = false> = {
|
|
164
164
|
/** value to set, only if storage is empty. Default: `new Map()` */
|
|
165
165
|
initialValue?: Map<Key, Value>;
|
|
166
166
|
} & Pick<Partial<IDataStorage<Key, Value, CacheDisabled>>, 'cacheDisabled' | 'onChange' | 'onError' | 'parse' | 'spaces' | 'storage' | 'stringify'> & (CacheDisabled extends false ? Pick<Partial<IDataStorage<Key, Value, CacheDisabled>>, 'delay' | 'delayOptions'> : {
|
|
@@ -184,8 +184,9 @@ type StorageSortOptions = SortOptions & {
|
|
|
184
184
|
};
|
|
185
185
|
type StorageStringifyFn<K, V extends StorageValue> = (data: Map<K, V>) => string;
|
|
186
186
|
type StorageToJSON<K, V> = (replacer?: null | ((key: K, value: V) => unknown), spacing?: string | number, data?: Map<K, V>) => string;
|
|
187
|
-
type
|
|
188
|
-
|
|
187
|
+
type StorageKey = string;
|
|
188
|
+
type StorageValue = object;
|
|
189
|
+
interface IDataStorage<Key extends StorageKey, Value extends StorageValue, CacheDisabled extends boolean = false> {
|
|
189
190
|
/** Disable in-memory cache and only directly read/write from storage (local storage or JSON fle) */
|
|
190
191
|
readonly cacheDisabled: CacheDisabled;
|
|
191
192
|
/**
|
|
@@ -227,6 +228,15 @@ interface IDataStorage<Key, Value extends StorageValue, CacheDisabled extends bo
|
|
|
227
228
|
* - node: `undefined` (in-memory mode)
|
|
228
229
|
*/
|
|
229
230
|
readonly storage?: StorageCompact | null;
|
|
231
|
+
/**
|
|
232
|
+
* The underlying RxJS Subject that serves as the primary reactive interface for observing data modifications.
|
|
233
|
+
*
|
|
234
|
+
* Its implementation type is determined by the caching strategy:
|
|
235
|
+
* - **BehaviorSubject**: Used when caching is enabled.
|
|
236
|
+
* It maintains the current state and emits it immediately to new subscribers.
|
|
237
|
+
* - **Subject**: Used when caching is disabled.
|
|
238
|
+
* It acts as a pure event pipe, emitting updates only at the moment they occur without retaining an in-memory copy.
|
|
239
|
+
*/
|
|
230
240
|
readonly subject: CacheDisabled extends true ? Subject<Map<Key, Value>> : BehaviorSubject<Map<Key, Value>>;
|
|
231
241
|
/** Clear all items */
|
|
232
242
|
readonly clear: () => IDataStorage<Key, Value, CacheDisabled>;
|
|
@@ -346,6 +356,8 @@ interface IDataStorage<Key, Value extends StorageValue, CacheDisabled extends bo
|
|
|
346
356
|
readonly toArray: () => [Key, Value][];
|
|
347
357
|
/** Convert list of items (Map) to JSON string of 2D Array */
|
|
348
358
|
readonly toJSON: StorageToJSON<Key, Value>;
|
|
359
|
+
/** Convert list of items into an object */
|
|
360
|
+
readonly toObject: () => Record<Key, Value>;
|
|
349
361
|
/** Convert list of items (Map) to JSON string of 2D Array */
|
|
350
362
|
readonly toString: () => string;
|
|
351
363
|
/**
|
|
@@ -357,7 +369,7 @@ interface IDataStorage<Key, Value extends StorageValue, CacheDisabled extends bo
|
|
|
357
369
|
* - The instance stopping listening to force update cache triggers.
|
|
358
370
|
*/
|
|
359
371
|
readonly unsubscribe: () => void;
|
|
360
|
-
/** Get all values */
|
|
372
|
+
/** Get all values as an array */
|
|
361
373
|
readonly values: () => Value[];
|
|
362
374
|
/**
|
|
363
375
|
* Write data to the underlying storage (localStorage or file).
|
|
@@ -391,11 +403,11 @@ interface IDataStorage<Key, Value extends StorageValue, CacheDisabled extends bo
|
|
|
391
403
|
* ```
|
|
392
404
|
*/
|
|
393
405
|
declare const forceUpdateCache$: Subject<string | boolean | string[]>;
|
|
394
|
-
declare class DataStorage<Key, Value extends StorageValue, CacheDisabled extends boolean = false> implements IDataStorage<Key, Value, CacheDisabled> {
|
|
406
|
+
declare class DataStorage<Key extends StorageKey, Value extends StorageValue, CacheDisabled extends boolean = false> implements IDataStorage<Key, Value, CacheDisabled> {
|
|
395
407
|
readonly cacheDisabled: CacheDisabled;
|
|
396
408
|
readonly delay: number;
|
|
397
|
-
readonly delayOptions?: DelayOptions;
|
|
398
409
|
/** Debounce and throttle related options */
|
|
410
|
+
readonly delayOptions?: DelayOptions;
|
|
399
411
|
readonly initialized: boolean;
|
|
400
412
|
readonly name: string;
|
|
401
413
|
get size(): number;
|
|
@@ -533,6 +545,7 @@ declare class DataStorage<Key, Value extends StorageValue, CacheDisabled extends
|
|
|
533
545
|
readonly stringify?: StorageStringifyFn<Key, Value>;
|
|
534
546
|
readonly toArray: () => [Key, Value][];
|
|
535
547
|
readonly toJSON: StorageToJSON<Key, Value>;
|
|
548
|
+
readonly toObject: () => Record<Key, Value>;
|
|
536
549
|
readonly toString: (data?: Map<Key, Value>) => string;
|
|
537
550
|
private triggerOnError;
|
|
538
551
|
readonly unsubscribe: () => void;
|
|
@@ -727,4 +740,4 @@ declare const isSubscriptionLike: (value: unknown, strict?: boolean) => value is
|
|
|
727
740
|
*/
|
|
728
741
|
declare const unsubscribeAll: (unsub?: UnsubscribeCandidates, onError?: (err: unknown) => void) => void;
|
|
729
742
|
|
|
730
|
-
export { type CopyRxSubjectOptions, DataStorage, type DelayOptions, type IDataStorage, IGNORE_UPDATE_SYMBOL, IntervalRunner, IntervalSubject, type OnErrorType, type OnResultType, type StorageCompact, type StorageFilter, type StorageFind, type StorageMap, type StorageOnChangeFn, type StorageOnErrorFn, type StorageOptions, type StorageParseFn, type StorageSearch, type StorageSort, type StorageSortByComparator, type StorageSortByKey, type StorageSortByPropertyName, type StorageSortOptions, type StorageStringifyFn, type StorageToJSON, type StorageValue, type SubjectLike, type SubscriptionLike, type Unsubscribe, type UnsubscribeCandidates, type UnwrapSubjectValue, type ValueModifier, asPromise, copyRxSubject, forceUpdateCache$, isSubjectLike, isSubscriptionLike, type onBeforeExecType, unsubscribeAll };
|
|
743
|
+
export { type CopyRxSubjectOptions, DataStorage, type DelayOptions, type IDataStorage, IGNORE_UPDATE_SYMBOL, IntervalRunner, IntervalSubject, type OnErrorType, type OnResultType, type StorageCompact, type StorageFilter, type StorageFind, type StorageKey, type StorageMap, type StorageOnChangeFn, type StorageOnErrorFn, type StorageOptions, type StorageParseFn, type StorageSearch, type StorageSort, type StorageSortByComparator, type StorageSortByKey, type StorageSortByPropertyName, type StorageSortOptions, type StorageStringifyFn, type StorageToJSON, type StorageValue, type SubjectLike, type SubscriptionLike, type Unsubscribe, type UnsubscribeCandidates, type UnwrapSubjectValue, type ValueModifier, asPromise, copyRxSubject, forceUpdateCache$, isSubjectLike, isSubscriptionLike, type onBeforeExecType, unsubscribeAll };
|
package/dist/index.js
CHANGED
|
@@ -164,6 +164,7 @@ import {
|
|
|
164
164
|
find,
|
|
165
165
|
getEntries,
|
|
166
166
|
getKeys,
|
|
167
|
+
getValues,
|
|
167
168
|
isArr as isArr2,
|
|
168
169
|
isFn as isFn5,
|
|
169
170
|
isMap,
|
|
@@ -264,8 +265,6 @@ var DataStorage = class {
|
|
|
264
265
|
* ```
|
|
265
266
|
*/
|
|
266
267
|
constructor(name, options) {
|
|
267
|
-
/** Debounce and throttle related options */
|
|
268
|
-
// readonly deferOptions
|
|
269
268
|
this.initialized = false;
|
|
270
269
|
this.subscriptions = {
|
|
271
270
|
subject: void 0,
|
|
@@ -282,7 +281,10 @@ var DataStorage = class {
|
|
|
282
281
|
this.setAll(data, true);
|
|
283
282
|
return this;
|
|
284
283
|
};
|
|
285
|
-
this.find = (predicateOrOptions) => find(
|
|
284
|
+
this.find = (predicateOrOptions) => find(
|
|
285
|
+
this.getAll(),
|
|
286
|
+
predicateOrOptions
|
|
287
|
+
);
|
|
286
288
|
this.filter = (predicate, limit, asArray, result) => filter(this.getAll(), predicate, limit, asArray, result);
|
|
287
289
|
this.get = (key) => this.getAll().get(key);
|
|
288
290
|
this.getAll = (forceRead = false) => {
|
|
@@ -323,9 +325,9 @@ var DataStorage = class {
|
|
|
323
325
|
if (!isMap(data)) return this.subject.next(/* @__PURE__ */ new Map());
|
|
324
326
|
this.write(data);
|
|
325
327
|
fallbackIfFails3(
|
|
326
|
-
|
|
328
|
+
() => {
|
|
327
329
|
var _a2;
|
|
328
|
-
return
|
|
330
|
+
return (_a2 = this.onChange) == null ? void 0 : _a2.call(this, data);
|
|
329
331
|
},
|
|
330
332
|
[],
|
|
331
333
|
this.triggerOnError("onChange")
|
|
@@ -368,10 +370,10 @@ var DataStorage = class {
|
|
|
368
370
|
this.subject.next(new Map(data));
|
|
369
371
|
return this;
|
|
370
372
|
};
|
|
371
|
-
this.sort = ((
|
|
373
|
+
this.sort = ((byKeyOrNameOrComparator, options) => {
|
|
372
374
|
const result = sort(
|
|
373
375
|
this.getAll(),
|
|
374
|
-
|
|
376
|
+
byKeyOrNameOrComparator,
|
|
375
377
|
options
|
|
376
378
|
);
|
|
377
379
|
(options == null ? void 0 : options.save) && this.setAll(result, true);
|
|
@@ -395,12 +397,17 @@ var DataStorage = class {
|
|
|
395
397
|
this.triggerOnError("stringify-json")
|
|
396
398
|
);
|
|
397
399
|
};
|
|
400
|
+
this.toObject = () => {
|
|
401
|
+
const obj = {};
|
|
402
|
+
for (const [key, value] of this.getAll()) obj[key] = value;
|
|
403
|
+
return obj;
|
|
404
|
+
};
|
|
398
405
|
this.toString = (data) => this.toJSON(void 0, void 0, data);
|
|
399
406
|
this.triggerOnError = (type) => (err) => {
|
|
400
407
|
this.onError && fallbackIfFails3(this.onError, [err, type], "");
|
|
401
408
|
};
|
|
402
409
|
this.unsubscribe = () => unsubscribeAll_default(this.subscriptions);
|
|
403
|
-
this.values = () =>
|
|
410
|
+
this.values = () => getValues(this.getAll());
|
|
404
411
|
this.write = (data) => {
|
|
405
412
|
try {
|
|
406
413
|
!this.initialized && this.init();
|
package/package.json
CHANGED
|
@@ -2,8 +2,8 @@
|
|
|
2
2
|
"author": "Toufiqur Rahaman Chowdhury",
|
|
3
3
|
"description": "RxJS utilities and hooks for React applications.",
|
|
4
4
|
"dependencies": {
|
|
5
|
-
"@superutils/core": "^1.2.
|
|
6
|
-
"@superutils/promise": "^1.3.
|
|
5
|
+
"@superutils/core": "^1.2.9",
|
|
6
|
+
"@superutils/promise": "^1.3.7",
|
|
7
7
|
"@types/react": "^18.0.0",
|
|
8
8
|
"react": ">=16.8.0",
|
|
9
9
|
"rxjs": "^7.8.2"
|
|
@@ -49,5 +49,6 @@
|
|
|
49
49
|
"module": "./dist/index.js",
|
|
50
50
|
"type": "module",
|
|
51
51
|
"types": "./dist/index.d.ts",
|
|
52
|
-
"version": "0.1.
|
|
52
|
+
"version": "0.1.3",
|
|
53
|
+
"gitHead": "5065d39fb7486020cdc0aef690398dedb731b1e8"
|
|
53
54
|
}
|