@rimbu/deep 0.14.3 → 0.14.5
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/README.md +20 -3
- package/dist/main/internal.js +0 -1
- package/dist/main/internal.js.map +1 -1
- package/dist/module/internal.js +0 -1
- package/dist/module/internal.js.map +1 -1
- package/dist/types/protected.d.ts +1 -1
- package/package.json +4 -4
- package/src/protected.ts +3 -6
package/README.md
CHANGED
|
@@ -2,6 +2,10 @@
|
|
|
2
2
|
<img src="https://github.com/rimbu-org/rimbu/raw/main/assets/rimbu_logo.svg" />
|
|
3
3
|
</p>
|
|
4
4
|
|
|
5
|
+
[](https://www.npmjs.com/package/@rimbu/deep) [](http://deno.land/x/rimbu)
|
|
6
|
+
|
|
7
|
+

|
|
8
|
+
|
|
5
9
|
# @rimbu/deep
|
|
6
10
|
|
|
7
11
|
Offers tools to use handle plain JS objects as immutable objects. The [`Patch` object](https://rimbu.org/docs/deep/patch) allows convenient immutable modification of simple objects. The [`Match` object](https://rimbu.org/docs/deep/match) allows easy matching on plain objects. The [`Path` object](https://rimbu.org/docs/deep/path) allows easy querying of nested values. The [`Immutable` type](https://rimbu.org/docs/deep/immutable) makes it easy to create plain objects that that have compile-time protection against mutation. The [`Tuple` type](https://rimbu.org/docs/deep/tuple) is a utility to have similar functionality as `as const` but less strict.
|
|
@@ -12,18 +16,31 @@ Or [Try Out Rimbu](https://codesandbox.io/s/github/vitoke/rimbu-sandbox/tree/mai
|
|
|
12
16
|
|
|
13
17
|
## Installation
|
|
14
18
|
|
|
15
|
-
|
|
19
|
+
### Compabitity
|
|
20
|
+
|
|
21
|
+
- [`Node >= 16` ](https://nodejs.org)
|
|
22
|
+
- [`Deno` ](https://deno.com/runtime)
|
|
23
|
+
- [`Bun >= 0.6.0` ](https://bun.sh/)
|
|
24
|
+
- `Web` 
|
|
25
|
+
|
|
26
|
+
### Yarn / NPM / Bun
|
|
27
|
+
|
|
28
|
+
For convenience, all main types are also exported through [`@rimbu/core`](../core).
|
|
16
29
|
|
|
17
30
|
To install this package only:
|
|
18
31
|
|
|
19
|
-
|
|
32
|
+
For `yarn`:
|
|
20
33
|
|
|
21
34
|
> `yarn add @rimbu/deep`
|
|
22
35
|
|
|
23
|
-
|
|
36
|
+
For `npm`:
|
|
24
37
|
|
|
25
38
|
> `npm i @rimbu/deep`
|
|
26
39
|
|
|
40
|
+
For `bun`:
|
|
41
|
+
|
|
42
|
+
> `bun add @rimbu/deep`
|
|
43
|
+
|
|
27
44
|
### Deno
|
|
28
45
|
|
|
29
46
|
For Deno, the following approach is recommended:
|
package/dist/main/internal.js
CHANGED
|
@@ -4,7 +4,6 @@ exports.Deep = exports.Path = void 0;
|
|
|
4
4
|
var tslib_1 = require("tslib");
|
|
5
5
|
var path_1 = require("./path");
|
|
6
6
|
Object.defineProperty(exports, "Path", { enumerable: true, get: function () { return path_1.Path; } });
|
|
7
|
-
var match_1 = require("./match");
|
|
8
7
|
var Deep = tslib_1.__importStar(require("./deep"));
|
|
9
8
|
exports.Deep = Deep;
|
|
10
9
|
//# sourceMappingURL=internal.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"internal.js","sourceRoot":"","sources":["../../src/internal.ts"],"names":[],"mappings":";;;;AACA,+BAA8B;AAArB,4FAAA,IAAI,OAAA;
|
|
1
|
+
{"version":3,"file":"internal.js","sourceRoot":"","sources":["../../src/internal.ts"],"names":[],"mappings":";;;;AACA,+BAA8B;AAArB,4FAAA,IAAI,OAAA;AAKb,mDAA+B;AACtB,oBAAI"}
|
package/dist/module/internal.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"internal.js","sourceRoot":"","sources":["../../src/internal.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,IAAI,EAAE,MAAM,QAAQ,CAAC;
|
|
1
|
+
{"version":3,"file":"internal.js","sourceRoot":"","sources":["../../src/internal.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,IAAI,EAAE,MAAM,QAAQ,CAAC;AAK9B,OAAO,KAAK,IAAI,MAAM,QAAQ,CAAC;AAC/B,OAAO,EAAE,IAAI,EAAE,CAAC"}
|
|
@@ -12,6 +12,6 @@ import type { IsAny, IsPlainObj } from '@rimbu/base';
|
|
|
12
12
|
*/
|
|
13
13
|
export type Protected<T> = IsAny<T> extends true ? T : T extends readonly any[] & infer A ? {
|
|
14
14
|
readonly [K in keyof A]: Protected<A[K]>;
|
|
15
|
-
} : T extends Map<infer K, infer V> ?
|
|
15
|
+
} : T extends Map<infer K, infer V> ? ReadonlyMap<Protected<K>, Protected<V>> : T extends Set<infer E> ? ReadonlySet<Protected<E>> : T extends Promise<infer E> ? Promise<Protected<E>> : IsPlainObj<T> extends true ? {
|
|
16
16
|
readonly [K in keyof T]: Protected<T[K]>;
|
|
17
17
|
} : T;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@rimbu/deep",
|
|
3
|
-
"version": "0.14.
|
|
3
|
+
"version": "0.14.5",
|
|
4
4
|
"description": "Tools to use handle plain JS objects as immutable objects",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"immutable",
|
|
@@ -66,12 +66,12 @@
|
|
|
66
66
|
},
|
|
67
67
|
"sideEffects": false,
|
|
68
68
|
"dependencies": {
|
|
69
|
-
"@rimbu/base": "^0.11.
|
|
70
|
-
"@rimbu/common": "
|
|
69
|
+
"@rimbu/base": "^0.11.4",
|
|
70
|
+
"@rimbu/common": "*",
|
|
71
71
|
"tslib": "^2.5.0"
|
|
72
72
|
},
|
|
73
73
|
"publishConfig": {
|
|
74
74
|
"access": "public"
|
|
75
75
|
},
|
|
76
|
-
"gitHead": "
|
|
76
|
+
"gitHead": "5400f8471bdfc7a227f7defc4a3942bdf3ff1423"
|
|
77
77
|
}
|
package/src/protected.ts
CHANGED
|
@@ -18,14 +18,11 @@ export type Protected<T> = IsAny<T> extends true
|
|
|
18
18
|
? // convert all keys to readonly and all values to `Protected`
|
|
19
19
|
{ readonly [K in keyof A]: Protected<A[K]> }
|
|
20
20
|
: T extends Map<infer K, infer V>
|
|
21
|
-
?
|
|
22
|
-
Omit<Map<Protected<K>, Protected<V>>, 'clear' | 'delete' | 'set'>
|
|
21
|
+
? ReadonlyMap<Protected<K>, Protected<V>>
|
|
23
22
|
: T extends Set<infer E>
|
|
24
|
-
?
|
|
25
|
-
Omit<Set<Protected<E>>, 'add' | 'clear' | 'delete'>
|
|
23
|
+
? ReadonlySet<Protected<E>>
|
|
26
24
|
: T extends Promise<infer E>
|
|
27
|
-
?
|
|
28
|
-
Promise<Protected<E>>
|
|
25
|
+
? Promise<Protected<E>>
|
|
29
26
|
: IsPlainObj<T> extends true
|
|
30
27
|
? // convert all keys to readonly and all values to `Protected`
|
|
31
28
|
{ readonly [K in keyof T]: Protected<T[K]> }
|