@rimbu/deep 0.14.4 → 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 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
+ [![npm version](https://badge.fury.io/js/@rimbu%2Fdeep.svg)](https://www.npmjs.com/package/@rimbu/deep) [![Deno](https://shield.deno.dev/x/rimbu)](http://deno.land/x/rimbu)
6
+
7
+ ![Licence](https://img.shields.io/github/license/rimbu-org/rimbu)
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
- All types are exported through `@rimbu/core`. It is recommended to use that package.
19
+ ### Compabitity
20
+
21
+ - [`Node >= 16` ![NodeJS](https://img.shields.io/badge/node.js-6DA55F?logo=node.js&logoColor=white)](https://nodejs.org)
22
+ - [`Deno` ![Deno JS](https://img.shields.io/badge/deno%20js-000000?logo=deno&logoColor=white)](https://deno.com/runtime)
23
+ - [`Bun >= 0.6.0` ![Bun](https://img.shields.io/badge/Bun-%23000000.svg?logoColor=white)](https://bun.sh/)
24
+ - `Web` ![HTML5](https://img.shields.io/badge/html5-%23E34F26.svg?logoColor=white)
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
- ### Yarn/NPM
32
+ For `yarn`:
20
33
 
21
34
  > `yarn add @rimbu/deep`
22
35
 
23
- or
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:
@@ -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> ? 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 ? {
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.4",
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.3",
70
- "@rimbu/common": "^0.12.3",
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": "8f83f7bc9812a739279a64e2e52d83f631dfb4f6"
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
- ? // return keys and values as `Protected` and omit mutable methods
22
- Omit<Map<Protected<K>, Protected<V>>, 'clear' | 'delete' | 'set'>
21
+ ? ReadonlyMap<Protected<K>, Protected<V>>
23
22
  : T extends Set<infer E>
24
- ? // return values as `Protected` and omit mutable methods
25
- Omit<Set<Protected<E>>, 'add' | 'clear' | 'delete'>
23
+ ? ReadonlySet<Protected<E>>
26
24
  : T extends Promise<infer E>
27
- ? // return promise value as `Protected`
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]> }