@rimbu/deep 0.9.2 → 0.10.0
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/main/index.js +12 -3
- package/dist/main/index.js.map +1 -1
- package/dist/main/internal.js +2 -4
- package/dist/main/internal.js.map +1 -1
- package/dist/main/match.js +197 -132
- package/dist/main/match.js.map +1 -1
- package/dist/main/patch.js +125 -106
- package/dist/main/patch.js.map +1 -1
- package/dist/main/path.js +12 -38
- package/dist/main/path.js.map +1 -1
- package/dist/main/protected.js +12 -0
- package/dist/main/protected.js.map +1 -0
- package/dist/module/index.js +3 -2
- package/dist/module/index.js.map +1 -1
- package/dist/module/internal.js +2 -4
- package/dist/module/internal.js.map +1 -1
- package/dist/module/match.js +180 -97
- package/dist/module/match.js.map +1 -1
- package/dist/module/patch.js +113 -87
- package/dist/module/patch.js.map +1 -1
- package/dist/module/path.js +12 -34
- package/dist/module/path.js.map +1 -1
- package/dist/module/protected.js +8 -0
- package/dist/module/protected.js.map +1 -0
- package/dist/types/index.d.ts +3 -2
- package/dist/types/internal.d.ts +2 -4
- package/dist/types/match.d.ts +93 -80
- package/dist/types/patch.d.ts +64 -61
- package/dist/types/path.d.ts +9 -20
- package/dist/types/protected.d.ts +13 -0
- package/package.json +4 -4
- package/src/index.ts +12 -2
- package/src/internal.ts +3 -4
- package/src/match.ts +254 -163
- package/src/patch.ts +204 -147
- package/src/path.ts +18 -43
- package/src/protected.ts +25 -0
- package/dist/main/immutable.js +0 -12
- package/dist/main/immutable.js.map +0 -1
- package/dist/main/literal.js +0 -41
- package/dist/main/literal.js.map +0 -1
- package/dist/module/immutable.js +0 -8
- package/dist/module/immutable.js.map +0 -1
- package/dist/module/literal.js +0 -37
- package/dist/module/literal.js.map +0 -1
- package/dist/types/immutable.d.ts +0 -13
- package/dist/types/literal.d.ts +0 -48
- package/src/immutable.ts +0 -21
- package/src/literal.ts +0 -70
package/dist/types/literal.d.ts
DELETED
|
@@ -1,48 +0,0 @@
|
|
|
1
|
-
declare const LITERAL: unique symbol;
|
|
2
|
-
declare type LITERAL = typeof LITERAL;
|
|
3
|
-
/**
|
|
4
|
-
* Type to represent Literal values for the match and patch functions.
|
|
5
|
-
*/
|
|
6
|
-
export interface Literal<T> {
|
|
7
|
-
readonly [LITERAL]: T;
|
|
8
|
-
}
|
|
9
|
-
export declare namespace Literal {
|
|
10
|
-
/**
|
|
11
|
-
* Returns a Literal value embedding the given `value`.
|
|
12
|
-
* @param value - the value to embed in a Literal type
|
|
13
|
-
*/
|
|
14
|
-
function of<T>(value: T): Literal<T>;
|
|
15
|
-
/**
|
|
16
|
-
* Excludes Iterable types
|
|
17
|
-
*/
|
|
18
|
-
interface NoIterable {
|
|
19
|
-
readonly [Symbol.iterator]?: never;
|
|
20
|
-
}
|
|
21
|
-
/**
|
|
22
|
-
* A plain object that is not iterable
|
|
23
|
-
*/
|
|
24
|
-
type Obj = Record<string, unknown> & NoIterable;
|
|
25
|
-
/**
|
|
26
|
-
* Type to determine whether a value needs to be a Literal instance or may be a Literal instance.
|
|
27
|
-
* @typeparam T - the value type
|
|
28
|
-
*/
|
|
29
|
-
type Value<T> = T extends {
|
|
30
|
-
readonly [Symbol.iterator]: any;
|
|
31
|
-
} | Obj | readonly any[] | undefined | (() => any) ? T extends string ? T | Literal<T> : Literal<T> : T | Literal<T>;
|
|
32
|
-
/**
|
|
33
|
-
* Returns true if the given `obj` value is a Literal instance.
|
|
34
|
-
* @param obj - the object to check
|
|
35
|
-
*/
|
|
36
|
-
function isLiteral<T>(obj: any): obj is Literal<T>;
|
|
37
|
-
/**
|
|
38
|
-
* Returns the value embedded in a Literal instance
|
|
39
|
-
* @param obj - the Literal instance
|
|
40
|
-
*/
|
|
41
|
-
function getValue<T>(obj: Literal<T>): T;
|
|
42
|
-
/**
|
|
43
|
-
* Returns true if the given `obj` is a plain JS object
|
|
44
|
-
* @param obj - the object to check
|
|
45
|
-
*/
|
|
46
|
-
function isPlainObject(obj: any): boolean;
|
|
47
|
-
}
|
|
48
|
-
export {};
|
package/src/immutable.ts
DELETED
|
@@ -1,21 +0,0 @@
|
|
|
1
|
-
import type { Literal } from './internal';
|
|
2
|
-
|
|
3
|
-
/**
|
|
4
|
-
* An immutably typed version of given type T. Makes all properties or elements read only.
|
|
5
|
-
* @typeparam T - the input type
|
|
6
|
-
*/
|
|
7
|
-
export type Immutable<T> = T extends (infer E)[]
|
|
8
|
-
? readonly Immutable<E>[]
|
|
9
|
-
: T extends Literal.Obj
|
|
10
|
-
? { readonly [K in keyof T]: Immutable<T[K]> }
|
|
11
|
-
: T extends boolean
|
|
12
|
-
? boolean
|
|
13
|
-
: T;
|
|
14
|
-
|
|
15
|
-
/**
|
|
16
|
-
* Returns the same value wrapped in the Immutable type
|
|
17
|
-
* @param value - the value to wrap
|
|
18
|
-
*/
|
|
19
|
-
export function Immutable<T>(value: T): Immutable<T> {
|
|
20
|
-
return value as any;
|
|
21
|
-
}
|
package/src/literal.ts
DELETED
|
@@ -1,70 +0,0 @@
|
|
|
1
|
-
const LITERAL = Symbol('LITERAL');
|
|
2
|
-
type LITERAL = typeof LITERAL;
|
|
3
|
-
|
|
4
|
-
/**
|
|
5
|
-
* Type to represent Literal values for the match and patch functions.
|
|
6
|
-
*/
|
|
7
|
-
export interface Literal<T> {
|
|
8
|
-
readonly [LITERAL]: T;
|
|
9
|
-
}
|
|
10
|
-
|
|
11
|
-
export namespace Literal {
|
|
12
|
-
/**
|
|
13
|
-
* Returns a Literal value embedding the given `value`.
|
|
14
|
-
* @param value - the value to embed in a Literal type
|
|
15
|
-
*/
|
|
16
|
-
export function of<T>(value: T): Literal<T> {
|
|
17
|
-
return { [LITERAL]: value };
|
|
18
|
-
}
|
|
19
|
-
|
|
20
|
-
/**
|
|
21
|
-
* Excludes Iterable types
|
|
22
|
-
*/
|
|
23
|
-
export interface NoIterable {
|
|
24
|
-
readonly [Symbol.iterator]?: never;
|
|
25
|
-
}
|
|
26
|
-
|
|
27
|
-
/**
|
|
28
|
-
* A plain object that is not iterable
|
|
29
|
-
*/
|
|
30
|
-
export type Obj = Record<string, unknown> & NoIterable;
|
|
31
|
-
|
|
32
|
-
/**
|
|
33
|
-
* Type to determine whether a value needs to be a Literal instance or may be a Literal instance.
|
|
34
|
-
* @typeparam T - the value type
|
|
35
|
-
*/
|
|
36
|
-
export type Value<T> = T extends
|
|
37
|
-
| { readonly [Symbol.iterator]: any }
|
|
38
|
-
| Obj
|
|
39
|
-
| readonly any[]
|
|
40
|
-
| undefined
|
|
41
|
-
| (() => any)
|
|
42
|
-
? T extends string
|
|
43
|
-
? T | Literal<T>
|
|
44
|
-
: Literal<T>
|
|
45
|
-
: T | Literal<T>;
|
|
46
|
-
|
|
47
|
-
/**
|
|
48
|
-
* Returns true if the given `obj` value is a Literal instance.
|
|
49
|
-
* @param obj - the object to check
|
|
50
|
-
*/
|
|
51
|
-
export function isLiteral<T>(obj: any): obj is Literal<T> {
|
|
52
|
-
return LITERAL in obj;
|
|
53
|
-
}
|
|
54
|
-
|
|
55
|
-
/**
|
|
56
|
-
* Returns the value embedded in a Literal instance
|
|
57
|
-
* @param obj - the Literal instance
|
|
58
|
-
*/
|
|
59
|
-
export function getValue<T>(obj: Literal<T>): T {
|
|
60
|
-
return obj[LITERAL];
|
|
61
|
-
}
|
|
62
|
-
|
|
63
|
-
/**
|
|
64
|
-
* Returns true if the given `obj` is a plain JS object
|
|
65
|
-
* @param obj - the object to check
|
|
66
|
-
*/
|
|
67
|
-
export function isPlainObject(obj: any): boolean {
|
|
68
|
-
return obj.constructor === Object && !(Symbol.iterator in obj);
|
|
69
|
-
}
|
|
70
|
-
}
|