@rimbu/deep
Advanced tools
Comparing version 0.14.0 to 0.14.1
@@ -101,26 +101,28 @@ "use strict"; | ||
// matcher is plain object | ||
if ("every" in matcher) { | ||
return matchCompound(source, parent, root, tslib_1.__spreadArray(['every'], tslib_1.__read(matcher.every), false), failureLog); | ||
if (typeof matcher === 'object' && null !== matcher) { | ||
if ("every" in matcher) { | ||
return matchCompound(source, parent, root, tslib_1.__spreadArray(['every'], tslib_1.__read(matcher.every), false), failureLog); | ||
} | ||
if ("some" in matcher) { | ||
return matchCompound(source, parent, root, tslib_1.__spreadArray(['some'], tslib_1.__read(matcher.some), false), failureLog); | ||
} | ||
if ("none" in matcher) { | ||
return matchCompound(source, parent, root, tslib_1.__spreadArray(['none'], tslib_1.__read(matcher.none), false), failureLog); | ||
} | ||
if ("single" in matcher) { | ||
return matchCompound(source, parent, root, tslib_1.__spreadArray(['single'], tslib_1.__read(matcher.single), false), failureLog); | ||
} | ||
if ("someItem" in matcher) { | ||
return matchTraversal(source, root, 'someItem', matcher.someItem, failureLog); | ||
} | ||
if ("everyItem" in matcher) { | ||
return matchTraversal(source, root, 'everyItem', matcher.everyItem, failureLog); | ||
} | ||
if ("noneItem" in matcher) { | ||
return matchTraversal(source, root, 'noneItem', matcher.noneItem, failureLog); | ||
} | ||
if ("singleItem" in matcher) { | ||
return matchTraversal(source, root, 'singleItem', matcher.singleItem, failureLog); | ||
} | ||
} | ||
if ("some" in matcher) { | ||
return matchCompound(source, parent, root, tslib_1.__spreadArray(['some'], tslib_1.__read(matcher.some), false), failureLog); | ||
} | ||
if ("none" in matcher) { | ||
return matchCompound(source, parent, root, tslib_1.__spreadArray(['none'], tslib_1.__read(matcher.none), false), failureLog); | ||
} | ||
if ("single" in matcher) { | ||
return matchCompound(source, parent, root, tslib_1.__spreadArray(['single'], tslib_1.__read(matcher.single), false), failureLog); | ||
} | ||
if ("someItem" in matcher) { | ||
return matchTraversal(source, root, 'someItem', matcher.someItem, failureLog); | ||
} | ||
if ("everyItem" in matcher) { | ||
return matchTraversal(source, root, 'everyItem', matcher.everyItem, failureLog); | ||
} | ||
if ("noneItem" in matcher) { | ||
return matchTraversal(source, root, 'noneItem', matcher.noneItem, failureLog); | ||
} | ||
if ("singleItem" in matcher) { | ||
return matchTraversal(source, root, 'singleItem', matcher.singleItem, failureLog); | ||
} | ||
// matcher is plain object with index keys | ||
@@ -127,0 +129,0 @@ for (var index in matcher) { |
@@ -96,26 +96,28 @@ import { isPlainObj, } from '@rimbu/base'; | ||
// matcher is plain object | ||
if (`every` in matcher) { | ||
return matchCompound(source, parent, root, ['every', ...matcher.every], failureLog); | ||
if (typeof matcher === 'object' && null !== matcher) { | ||
if (`every` in matcher) { | ||
return matchCompound(source, parent, root, ['every', ...matcher.every], failureLog); | ||
} | ||
if (`some` in matcher) { | ||
return matchCompound(source, parent, root, ['some', ...matcher.some], failureLog); | ||
} | ||
if (`none` in matcher) { | ||
return matchCompound(source, parent, root, ['none', ...matcher.none], failureLog); | ||
} | ||
if (`single` in matcher) { | ||
return matchCompound(source, parent, root, ['single', ...matcher.single], failureLog); | ||
} | ||
if (`someItem` in matcher) { | ||
return matchTraversal(source, root, 'someItem', matcher.someItem, failureLog); | ||
} | ||
if (`everyItem` in matcher) { | ||
return matchTraversal(source, root, 'everyItem', matcher.everyItem, failureLog); | ||
} | ||
if (`noneItem` in matcher) { | ||
return matchTraversal(source, root, 'noneItem', matcher.noneItem, failureLog); | ||
} | ||
if (`singleItem` in matcher) { | ||
return matchTraversal(source, root, 'singleItem', matcher.singleItem, failureLog); | ||
} | ||
} | ||
if (`some` in matcher) { | ||
return matchCompound(source, parent, root, ['some', ...matcher.some], failureLog); | ||
} | ||
if (`none` in matcher) { | ||
return matchCompound(source, parent, root, ['none', ...matcher.none], failureLog); | ||
} | ||
if (`single` in matcher) { | ||
return matchCompound(source, parent, root, ['single', ...matcher.single], failureLog); | ||
} | ||
if (`someItem` in matcher) { | ||
return matchTraversal(source, root, 'someItem', matcher.someItem, failureLog); | ||
} | ||
if (`everyItem` in matcher) { | ||
return matchTraversal(source, root, 'everyItem', matcher.everyItem, failureLog); | ||
} | ||
if (`noneItem` in matcher) { | ||
return matchTraversal(source, root, 'noneItem', matcher.noneItem, failureLog); | ||
} | ||
if (`singleItem` in matcher) { | ||
return matchTraversal(source, root, 'singleItem', matcher.singleItem, failureLog); | ||
} | ||
// matcher is plain object with index keys | ||
@@ -122,0 +124,0 @@ for (const index in matcher) { |
@@ -9,3 +9,3 @@ import { IsAnyFunc, IsArray, IsPlainObj, NotIterable } from '@rimbu/base'; | ||
*/ | ||
export declare type Match<T, C extends Partial<T> = Partial<T>> = Match.Entry<T, C, T, T>; | ||
export type Match<T, C extends Partial<T> = Partial<T>> = Match.Entry<T, C, T, T>; | ||
export declare namespace Match { | ||
@@ -12,0 +12,0 @@ /** |
@@ -8,3 +8,3 @@ import { IsAnyFunc, IsArray, IsPlainObj } from '@rimbu/base'; | ||
*/ | ||
export declare type Patch<T, C = T> = Patch.Entry<T, C, T, T>; | ||
export type Patch<T, C = T> = Patch.Entry<T, C, T, T>; | ||
export declare namespace Patch { | ||
@@ -11,0 +11,0 @@ /** |
@@ -13,3 +13,3 @@ import type { IsAny, IsPlainObj } from '@rimbu/base'; | ||
*/ | ||
export declare type Protected<T> = IsAny<T> extends true ? T : T extends readonly any[] & infer A ? { | ||
export type Protected<T> = IsAny<T> extends true ? T : T extends readonly any[] & infer A ? { | ||
readonly [K in keyof A]: Protected<A[K]>; | ||
@@ -16,0 +16,0 @@ } : T extends Map<infer K, infer V> ? Omit<Map<Protected<K>, Protected<V>>, 'clear' | 'delete' | 'set'> : T extends Set<infer E> ? Omit<Set<Protected<E>>, 'add' | 'clear' | 'delete'> : T extends Promise<infer E> ? Promise<Protected<E>> : IsPlainObj<T> extends true ? { |
@@ -12,3 +12,3 @@ import type { IsAnyFunc, IsArray } from '@rimbu/base'; | ||
*/ | ||
export declare type Selector<T> = Path.Get<T> | ((value: Protected<T>) => any) | readonly Selector<T>[] | { | ||
export type Selector<T> = Path.Get<T> | ((value: Protected<T>) => any) | readonly Selector<T>[] | { | ||
readonly [key: string | symbol]: Selector<T>; | ||
@@ -15,0 +15,0 @@ }; |
@@ -5,3 +5,3 @@ import type { Update } from '@rimbu/common'; | ||
*/ | ||
export declare type Tuple<T extends Tuple.Source> = Readonly<T>; | ||
export type Tuple<T extends Tuple.Source> = Readonly<T>; | ||
export declare namespace Tuple { | ||
@@ -8,0 +8,0 @@ /** |
{ | ||
"name": "@rimbu/deep", | ||
"version": "0.14.0", | ||
"version": "0.14.1", | ||
"description": "Tools to use handle plain JS objects as immutable objects", | ||
@@ -60,5 +60,5 @@ "keywords": [ | ||
"dependencies": { | ||
"@rimbu/base": "^0.11.0", | ||
"@rimbu/common": "^0.12.0", | ||
"tslib": "^2.4.0" | ||
"@rimbu/base": "^0.11.1", | ||
"@rimbu/common": "^0.12.1", | ||
"tslib": "^2.5.0" | ||
}, | ||
@@ -68,3 +68,3 @@ "publishConfig": { | ||
}, | ||
"gitHead": "442ffd299583458d458e9bbe3dd02c67828707f3" | ||
"gitHead": "f7a7662f81e9246b244cab22c14776617652833f" | ||
} |
146
src/match.ts
@@ -331,74 +331,76 @@ import { | ||
if (`every` in matcher) { | ||
return matchCompound( | ||
source, | ||
parent, | ||
root, | ||
['every', ...(matcher.every as any)], | ||
failureLog | ||
); | ||
if (typeof matcher === 'object' && null !== matcher) { | ||
if (`every` in matcher) { | ||
return matchCompound( | ||
source, | ||
parent, | ||
root, | ||
['every', ...(matcher.every as any)], | ||
failureLog | ||
); | ||
} | ||
if (`some` in matcher) { | ||
return matchCompound( | ||
source, | ||
parent, | ||
root, | ||
['some', ...(matcher.some as any)], | ||
failureLog | ||
); | ||
} | ||
if (`none` in matcher) { | ||
return matchCompound( | ||
source, | ||
parent, | ||
root, | ||
['none', ...(matcher.none as any)], | ||
failureLog | ||
); | ||
} | ||
if (`single` in matcher) { | ||
return matchCompound( | ||
source, | ||
parent, | ||
root, | ||
['single', ...(matcher.single as any)], | ||
failureLog | ||
); | ||
} | ||
if (`someItem` in matcher) { | ||
return matchTraversal( | ||
source, | ||
root, | ||
'someItem', | ||
matcher.someItem as any, | ||
failureLog | ||
); | ||
} | ||
if (`everyItem` in matcher) { | ||
return matchTraversal( | ||
source, | ||
root, | ||
'everyItem', | ||
matcher.everyItem as any, | ||
failureLog | ||
); | ||
} | ||
if (`noneItem` in matcher) { | ||
return matchTraversal( | ||
source, | ||
root, | ||
'noneItem', | ||
matcher.noneItem as any, | ||
failureLog | ||
); | ||
} | ||
if (`singleItem` in matcher) { | ||
return matchTraversal( | ||
source, | ||
root, | ||
'singleItem', | ||
matcher.singleItem as any, | ||
failureLog | ||
); | ||
} | ||
} | ||
if (`some` in matcher) { | ||
return matchCompound( | ||
source, | ||
parent, | ||
root, | ||
['some', ...(matcher.some as any)], | ||
failureLog | ||
); | ||
} | ||
if (`none` in matcher) { | ||
return matchCompound( | ||
source, | ||
parent, | ||
root, | ||
['none', ...(matcher.none as any)], | ||
failureLog | ||
); | ||
} | ||
if (`single` in matcher) { | ||
return matchCompound( | ||
source, | ||
parent, | ||
root, | ||
['single', ...(matcher.single as any)], | ||
failureLog | ||
); | ||
} | ||
if (`someItem` in matcher) { | ||
return matchTraversal( | ||
source, | ||
root, | ||
'someItem', | ||
matcher.someItem as any, | ||
failureLog | ||
); | ||
} | ||
if (`everyItem` in matcher) { | ||
return matchTraversal( | ||
source, | ||
root, | ||
'everyItem', | ||
matcher.everyItem as any, | ||
failureLog | ||
); | ||
} | ||
if (`noneItem` in matcher) { | ||
return matchTraversal( | ||
source, | ||
root, | ||
'noneItem', | ||
matcher.noneItem as any, | ||
failureLog | ||
); | ||
} | ||
if (`singleItem` in matcher) { | ||
return matchTraversal( | ||
source, | ||
root, | ||
'singleItem', | ||
matcher.singleItem as any, | ||
failureLog | ||
); | ||
} | ||
@@ -452,3 +454,3 @@ // matcher is plain object with index keys | ||
*/ | ||
function matchPlainObj<T, C, P, R>( | ||
function matchPlainObj<T extends object, C, P, R>( | ||
source: T, | ||
@@ -455,0 +457,0 @@ parent: P, |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
221121
4718
Updated@rimbu/base@^0.11.1
Updated@rimbu/common@^0.12.1
Updatedtslib@^2.5.0