runcheck 1.12.0 → 1.14.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/README.md +148 -56
- package/dist/autofixable.cjs +3 -3
- package/dist/autofixable.cjs.map +1 -1
- package/dist/autofixable.d.cts +3 -4
- package/dist/autofixable.d.ts +3 -4
- package/dist/autofixable.js +1 -1
- package/dist/autofixable.js.map +1 -1
- package/dist/chunk-W6HQDNP4.js +4 -0
- package/dist/chunk-W6HQDNP4.js.map +1 -0
- package/dist/runcheck.cjs +3 -3
- package/dist/runcheck.cjs.map +1 -1
- package/dist/runcheck.d.cts +473 -6
- package/dist/runcheck.d.ts +473 -6
- package/dist/runcheck.js +1 -1
- package/package.json +1 -1
- package/dist/chunk-QNKGO7DW.js +0 -4
- package/dist/chunk-QNKGO7DW.js.map +0 -1
package/README.md
CHANGED
|
@@ -2,21 +2,6 @@
|
|
|
2
2
|
|
|
3
3
|
A lib for js/typescript runtime type checks with autofix support. Runcheck has the goal of being very lightweight and fast ⚡. Because of that, it has only around [2.9kb Gzipped](https://bundlephobia.com/package/runcheck) (at v0.30), has no dependencies and is tree-shakeable!
|
|
4
4
|
|
|
5
|
-
Obs: Runcheck is in Beta and it's api can still change
|
|
6
|
-
|
|
7
|
-
# Benchmarks
|
|
8
|
-
|
|
9
|
-
One of the goals of runcheck is to be blazing fast. Here are some benchmarks:
|
|
10
|
-
|
|
11
|
-
<details>
|
|
12
|
-
<summary>Click to see the benchmarks</summary>
|
|
13
|
-
|
|
14
|
-
> `runcheck dist` is the same version as `runcheck` in the benchmarks but bundled
|
|
15
|
-
|
|
16
|
-

|
|
17
|
-
|
|
18
|
-
</details>
|
|
19
|
-
|
|
20
5
|
# Installation
|
|
21
6
|
|
|
22
7
|
```bash
|
|
@@ -31,14 +16,18 @@ pnpm add runcheck
|
|
|
31
16
|
| `rc_number` | `number` |
|
|
32
17
|
| `rc_boolean` | `boolean` |
|
|
33
18
|
| `rc_any` | `any` |
|
|
19
|
+
| `rc_unknown` | `unknown` |
|
|
34
20
|
| `rc_null` | `null` |
|
|
35
21
|
| `rc_undefined` | `undefined` |
|
|
36
22
|
| `rc_date` | `Date` |
|
|
37
|
-
| `
|
|
23
|
+
| `rc_instanceof(instance: T)` | Classes typecheck in general |
|
|
38
24
|
| `rc_literals(...literals: T[])` | Type literal in general like `hello`, `true`, `1` |
|
|
39
25
|
| `rc_union(...types: T[])` | Union types in general like `string \| 1` |
|
|
40
26
|
| `rc_array<T>(type: T)` | `T[]` |
|
|
27
|
+
| `rc_loose_array<T>(type: T)` | `T[]` (filters invalid items) |
|
|
41
28
|
| `rc_tuple<T>(...types: T[])` | `[T, T]` |
|
|
29
|
+
| `rc_record<T>(type: T)` | `Record<string, T>` |
|
|
30
|
+
| `rc_loose_record<T>(type: T)` | `Record<string, T>` (filters invalid values) |
|
|
42
31
|
| `rc_intersection(...types: T[])` | Intersection types like `{a:string} & {b:string}` |
|
|
43
32
|
|
|
44
33
|
# Array types:
|
|
@@ -100,7 +89,7 @@ const shape = rc_object({
|
|
|
100
89
|
})
|
|
101
90
|
```
|
|
102
91
|
|
|
103
|
-
The `rc_object` will allow extra properties but
|
|
92
|
+
The `rc_object` will allow extra properties but any extra properties will be stripped in parsing. To allow extra properties in parsing, use `rc_obj_extends`.
|
|
104
93
|
|
|
105
94
|
# Marking optional keys
|
|
106
95
|
|
|
@@ -114,7 +103,7 @@ const shape = rc_object({
|
|
|
114
103
|
})
|
|
115
104
|
|
|
116
105
|
/*
|
|
117
|
-
|
|
106
|
+
inferred type will be:
|
|
118
107
|
{
|
|
119
108
|
name?: string | undefined,
|
|
120
109
|
age: number,
|
|
@@ -324,11 +313,21 @@ const result = rc_parse(
|
|
|
324
313
|
There are also some predefined autofixed types that you can import:
|
|
325
314
|
|
|
326
315
|
```ts
|
|
327
|
-
import {
|
|
316
|
+
import {
|
|
317
|
+
rc_string_autofix,
|
|
318
|
+
rc_boolean_autofix,
|
|
319
|
+
rc_number_autofix,
|
|
320
|
+
} from 'runcheck/autofixable'
|
|
328
321
|
|
|
329
322
|
// use like any other type
|
|
330
323
|
```
|
|
331
324
|
|
|
325
|
+
| Autofix type | Equivalent to | Autofixes |
|
|
326
|
+
| -------------------- | ------------- | -------------------------------------------------- |
|
|
327
|
+
| `rc_boolean_autofix` | `boolean` | `0 \| 1 \| 'true' \| 'false' \| null \| undefined` |
|
|
328
|
+
| `rc_string_autofix` | `string` | valid `number` inputs |
|
|
329
|
+
| `rc_number_autofix` | `number` | valid numeric `string` inputs |
|
|
330
|
+
|
|
332
331
|
# Performing custom checks
|
|
333
332
|
|
|
334
333
|
You can also use `rc_[type].where(customCheckFunction)` to perform custom checks.
|
|
@@ -357,7 +356,7 @@ You can also use the `RcPrettyInferType<typeof schema>` to get a more readable t
|
|
|
357
356
|
|
|
358
357
|
# Type modifiers
|
|
359
358
|
|
|
360
|
-
You can use also
|
|
359
|
+
You can use also modifiers like `rc_string.optional()` to extend the rc types:
|
|
361
360
|
|
|
362
361
|
| runcheck modifier | ts type equivalent |
|
|
363
362
|
| ----------------------- | ------------------------ |
|
|
@@ -379,7 +378,7 @@ type MenuTree = {
|
|
|
379
378
|
const menuTreeSchema: RcType<MenuTree[]> = rc_array(
|
|
380
379
|
rc_object({
|
|
381
380
|
name: rc_string,
|
|
382
|
-
// you can safely
|
|
381
|
+
// you can safely auto-reference the schema here
|
|
383
382
|
children: rc_recursive(() => menuTreeSchema),
|
|
384
383
|
}),
|
|
385
384
|
)
|
|
@@ -400,45 +399,20 @@ const result = rc_parse(
|
|
|
400
399
|
)
|
|
401
400
|
```
|
|
402
401
|
|
|
403
|
-
|
|
404
|
-
|
|
405
|
-
```ts
|
|
406
|
-
const input = 'hello'
|
|
402
|
+
## `rc_unsafe_transform`
|
|
407
403
|
|
|
408
|
-
|
|
409
|
-
outputSchema: rc_number,
|
|
410
|
-
})
|
|
404
|
+
For simpler cases where you don't need output validation, use `rc_unsafe_transform`:
|
|
411
405
|
|
|
412
|
-
|
|
406
|
+
```ts
|
|
407
|
+
const schema = rc_unsafe_transform(rc_string, (input) => input.toUpperCase())
|
|
413
408
|
|
|
409
|
+
const result = rc_parse('hello', schema)
|
|
414
410
|
if (result.ok) {
|
|
415
|
-
//
|
|
416
|
-
const transformedResult = rc_parse(result.data, schema)
|
|
411
|
+
console.log(result.data) // 'HELLO'
|
|
417
412
|
}
|
|
418
|
-
|
|
419
|
-
// Be carefull: `outputSchema` will be used only if the input type is invalid
|
|
420
|
-
|
|
421
|
-
const schema = rc_transform(
|
|
422
|
-
rc_union(rc_string, rc_number),
|
|
423
|
-
(input) => String(input).toUperCase(),
|
|
424
|
-
{
|
|
425
|
-
// this will be ignored because has an equivalent type to the input
|
|
426
|
-
outputSchema: rc_string,
|
|
427
|
-
},
|
|
428
|
-
)
|
|
429
|
-
|
|
430
|
-
// use a more strict input type to avoid this
|
|
431
|
-
|
|
432
|
-
const schema = rc_transform(
|
|
433
|
-
rc_union(rc_string, rc_number).where((input) => isNotUperCase(input)),
|
|
434
|
-
(input) => String(input).toUperCase(),
|
|
435
|
-
{
|
|
436
|
-
outputSchema: rc_string.where((input) => isUperCase(input)),
|
|
437
|
-
},
|
|
438
|
-
)
|
|
439
413
|
```
|
|
440
414
|
|
|
441
|
-
##
|
|
415
|
+
## Transformed types which result can be validated with same schema
|
|
442
416
|
|
|
443
417
|
You may want to create a transformed type which result can be validated with the same schema. For this you can use the `rc_narrow` type. Example:
|
|
444
418
|
|
|
@@ -481,6 +455,23 @@ if (result.ok) {
|
|
|
481
455
|
|
|
482
456
|
If you need to use default in nullish values you can use `rc_nullish_default`.
|
|
483
457
|
|
|
458
|
+
# Safe fallback types
|
|
459
|
+
|
|
460
|
+
You can use `rc_safe_fallback` to provide a fallback value that is validated against the schema, ensuring type safety.
|
|
461
|
+
|
|
462
|
+
```ts
|
|
463
|
+
const input = 'invalid'
|
|
464
|
+
|
|
465
|
+
const result = rc_parse(
|
|
466
|
+
input,
|
|
467
|
+
rc_safe_fallback(rc_number, 42), // 42 must be a valid number
|
|
468
|
+
)
|
|
469
|
+
|
|
470
|
+
if (result.ok) {
|
|
471
|
+
result.data // = 42 (type-safe)
|
|
472
|
+
}
|
|
473
|
+
```
|
|
474
|
+
|
|
484
475
|
# Advanced object types
|
|
485
476
|
|
|
486
477
|
## `rc_get_from_key_as_fallback`
|
|
@@ -514,9 +505,9 @@ const shape = rc_object(
|
|
|
514
505
|
rc_parse({ name: 'John', age: 20, is_cool: true }, shape) // will not return an error and will normalize the response to { name: 'John', age: 20, isCool: true }
|
|
515
506
|
```
|
|
516
507
|
|
|
517
|
-
## `
|
|
508
|
+
## `rc_get_obj_shape`
|
|
518
509
|
|
|
519
|
-
|
|
510
|
+
Extracts the object shape from an object type for inspection or manipulation:
|
|
520
511
|
|
|
521
512
|
```ts
|
|
522
513
|
const shape = rc_object({
|
|
@@ -525,7 +516,28 @@ const shape = rc_object({
|
|
|
525
516
|
isCool: rc_boolean,
|
|
526
517
|
})
|
|
527
518
|
|
|
528
|
-
const
|
|
519
|
+
const objShape = rc_get_obj_shape(shape)
|
|
520
|
+
// objShape = { name: RcType<string>, age: RcType<number>, isCool: RcType<boolean> }
|
|
521
|
+
const nameSchema = objShape.name
|
|
522
|
+
```
|
|
523
|
+
|
|
524
|
+
## `rc_enable_obj_strict`
|
|
525
|
+
|
|
526
|
+
Enables strict object validation for a type, rejecting excess properties:
|
|
527
|
+
|
|
528
|
+
```ts
|
|
529
|
+
const userSchema = rc_object({ name: rc_string, age: rc_number })
|
|
530
|
+
const strictUser = rc_enable_obj_strict(userSchema)
|
|
531
|
+
// Now rejects objects with excess properties
|
|
532
|
+
|
|
533
|
+
const result = strictUser.parse({ name: 'John', age: 30 }) // valid
|
|
534
|
+
const result2 = strictUser.parse({ name: 'John', age: 30, extra: 'data' }) // invalid
|
|
535
|
+
```
|
|
536
|
+
|
|
537
|
+
Use the `nonRecursive` option to only affect the immediate object type:
|
|
538
|
+
|
|
539
|
+
```ts
|
|
540
|
+
const strictUser = rc_enable_obj_strict(userSchema, { nonRecursive: true })
|
|
529
541
|
```
|
|
530
542
|
|
|
531
543
|
## `rc_obj_extends`
|
|
@@ -660,6 +672,21 @@ const result = rc_unwrap(
|
|
|
660
672
|
// | { state: 'error', code: number }
|
|
661
673
|
```
|
|
662
674
|
|
|
675
|
+
## `rc_discriminated_union_builder`
|
|
676
|
+
|
|
677
|
+
Creates a type-safe discriminated union builder that enforces the structure matches a TypeScript type:
|
|
678
|
+
|
|
679
|
+
```ts
|
|
680
|
+
type Shape =
|
|
681
|
+
| { type: 'circle'; radius: number }
|
|
682
|
+
| { type: 'rectangle'; width: number; height: number }
|
|
683
|
+
|
|
684
|
+
const shapeSchema = rc_discriminated_union_builder<Shape, 'type'>('type')({
|
|
685
|
+
circle: { radius: rc_number },
|
|
686
|
+
rectangle: { width: rc_number, height: rc_number },
|
|
687
|
+
})
|
|
688
|
+
```
|
|
689
|
+
|
|
663
690
|
# `rc_array_filter_from_schema`
|
|
664
691
|
|
|
665
692
|
Creates a two passes array validation. The first will validate the items against the filter schema and filter the item. The second will perform the type check against the filtered items.
|
|
@@ -689,3 +716,68 @@ const result = rc_parse(
|
|
|
689
716
|
|
|
690
717
|
// result.value === [{ value: 'hello' }]
|
|
691
718
|
```
|
|
719
|
+
|
|
720
|
+
# JSON Parsing
|
|
721
|
+
|
|
722
|
+
You can use `rc_parse_json` to parse and validate JSON strings directly:
|
|
723
|
+
|
|
724
|
+
```ts
|
|
725
|
+
import { rc_parse_json } from 'runcheck'
|
|
726
|
+
|
|
727
|
+
const userSchema = rc_object({ name: rc_string, age: rc_number })
|
|
728
|
+
const result = rc_parse_json('{"name":"John","age":30}', userSchema)
|
|
729
|
+
|
|
730
|
+
if (result.ok) {
|
|
731
|
+
console.log(result.data) // { name: 'John', age: 30 }
|
|
732
|
+
}
|
|
733
|
+
```
|
|
734
|
+
|
|
735
|
+
# Standard Schema Integration
|
|
736
|
+
|
|
737
|
+
Runcheck supports Standard Schema V1 for interoperability with other validation libraries:
|
|
738
|
+
|
|
739
|
+
## Converting to Standard Schema
|
|
740
|
+
|
|
741
|
+
```ts
|
|
742
|
+
import { rc_to_standard } from 'runcheck'
|
|
743
|
+
|
|
744
|
+
const rcSchema = rc_object({ name: rc_string, age: rc_number })
|
|
745
|
+
const standardSchema = rc_to_standard(rcSchema)
|
|
746
|
+
|
|
747
|
+
// Use with other Standard Schema compatible libraries
|
|
748
|
+
```
|
|
749
|
+
|
|
750
|
+
## Converting from Standard Schema
|
|
751
|
+
|
|
752
|
+
```ts
|
|
753
|
+
import { rc_from_standard } from 'runcheck'
|
|
754
|
+
|
|
755
|
+
// Convert a Standard Schema to runcheck type
|
|
756
|
+
const rcSchema = rc_from_standard(someStandardSchema)
|
|
757
|
+
```
|
|
758
|
+
|
|
759
|
+
# Additional Utilities
|
|
760
|
+
|
|
761
|
+
## Type Guards
|
|
762
|
+
|
|
763
|
+
Use `isRcType` to check if a value is a runcheck type:
|
|
764
|
+
|
|
765
|
+
```ts
|
|
766
|
+
import { isRcType } from 'runcheck'
|
|
767
|
+
|
|
768
|
+
if (isRcType(someValue)) {
|
|
769
|
+
// someValue is now typed as RcType<any>
|
|
770
|
+
const result = someValue.parse(input)
|
|
771
|
+
}
|
|
772
|
+
```
|
|
773
|
+
|
|
774
|
+
## Schema Inspection
|
|
775
|
+
|
|
776
|
+
Use `getSchemaKind` to get the string representation of a schema:
|
|
777
|
+
|
|
778
|
+
```ts
|
|
779
|
+
import { getSchemaKind } from 'runcheck'
|
|
780
|
+
|
|
781
|
+
const kind = getSchemaKind(rc_string) // returns 'string'
|
|
782
|
+
const kind2 = getSchemaKind(rc_array(rc_number)) // returns 'number[]'
|
|
783
|
+
```
|
package/dist/autofixable.cjs
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
"use strict";var
|
|
2
|
-
`)}`)}function
|
|
3
|
-
`));this.errors=s}name="RcValidationError"};function
|
|
1
|
+
"use strict";var R=Object.defineProperty;var W=Object.getOwnPropertyDescriptor;var U=Object.getOwnPropertyNames;var V=Object.prototype.hasOwnProperty;var C=(e,r)=>{for(var s in r)R(e,s,{get:r[s],enumerable:!0})},F=(e,r,s,t)=>{if(r&&typeof r=="object"||typeof r=="function")for(let n of U(r))!V.call(e,n)&&n!==s&&R(e,n,{get:()=>r[n],enumerable:!(t=W(r,n))||t.enumerable});return e};var K=e=>F(R({},"__esModule",{value:!0}),e);var oe={};C(oe,{rc_boolean_autofix:()=>te,rc_number_autofix:()=>ae,rc_string_autofix:()=>se});module.exports=K(oe);var D=()=>{};function q(e){return{...this,p:e===void 0?D:e}}function M(e){return Y(this,e)}function B(e){return ee(this,e)}function L(e){return X(this,e)}function J(e,r){return S(e,this,r)}function z(e,r){return ne(e,this,r)}function f(e,r){return`${e.n?`$${e.n}: `:""}${r}`}function N(e,r){e.b.push(r.startsWith("$")?r:f(e,r))}function i(e,r,s,t){if(e.c&&r===void 0)return{ok:!0,data:r,errors:void 0};if(e.l&&r==null)return{ok:!0,data:r,errors:void 0};if(e.f&&r===null)return{ok:!0,data:r,errors:void 0};let n=t();if(n&&(n===!0||!n.errors))return{ok:!0,data:n===!0?r:n.data,errors:void 0};if(!s.y){let a=e.p;if(a!==void 0)return N(s,`Fallback used, errors -> ${P(n,s,e,r)}`),{ok:!0,data:b(a)?a(r):a,errors:void 0};if(e.g&&e.d){let o=e.d(r);if(o)return o.safeFix||N(s,`Autofixed from error -> ${P(n,s,e,r)}`),o.errors?{ok:!1,data:void 0,errors:o.errors.map(l=>f(s,l))}:{ok:!0,data:o.fixed,errors:void 0}}}return{ok:!1,data:void 0,errors:n?n.errors:[f(s,O(e,r))]}}function P(e,r,s,t){return e?e.errors.map(n=>n.replace(r.n,"")).join("; "):O(s,t)}function Z(e){return{...this,g:!0,d:e}}function G(e){return{...this,r:(r,s)=>i(this,r,s,()=>{let t=this.r(r,s);if(!t.ok)return{errors:t.errors,data:void 0};let n=e(t.data);return n!==!0?{errors:[f(s,`Predicate failed${n===!1?` for type '${this.e}'`:`: ${n.error}`}`)],data:void 0}:{errors:!1,data:t.data}})}}function x(){return{...this,c:!0,e:`undefined | ${this.e}`}}function O(e,r){return`Type '${A(r,!!e.k)}' is not assignable to '${e.e}'`}function H(){return{...this,f:!0,e:`null | ${this.e}`}}function Q(){return{...this,l:!0,e:`null | undefined | ${this.e}`}}var u={__rc_type:void 0,withFallback:q,where:G,r:void 0,e:void 0,optional:x,optionalKey:x,orNullish:Q,withAutofix:Z,orNull:H,default:M,nullishDefault:B,or:L,parse:J,parseJson:z,R:void 0,p:void 0,m:void 0,c:!1,f:!1,l:!1,g:!1,k:!1,u:void 0,d:void 0,t:void 0,T:void 0,o:!1,_:!1},ue={...u,r(e,r){return i(this,e,r,()=>e===void 0)},e:"undefined"},le={...u,r(e,r){return i(this,e,r,()=>e===null)},e:"null"},fe={...u,r(e){return{ok:!0,data:e,errors:void 0}},e:"any"},de={...u,r(e){return{ok:!0,data:e,errors:void 0}},e:"unknown"},$={...u,r(e,r){return i(this,e,r,()=>typeof e=="boolean")},e:"boolean"},E={...u,r(e,r){return i(this,e,r,()=>typeof e=="string")},e:"string"},I={...u,r(e,r){return i(this,e,r,()=>typeof e=="number"&&!Number.isNaN(e))},e:"number"},ce={...u,r(e,r){return i(this,e,r,()=>typeof e=="object"&&e instanceof Date&&!Number.isNaN(e.getTime()))},e:"date"};var v=1;function X(...e){if(e.length===0)throw new Error("Unions should have at least one type");let r="",s=!1;for(let t of e)r&&(r+=" | "),r+=t.e,!s&&t.o&&(s=!0);return{...u,e:r,o:s,r(t,n){return i(this,t,n,()=>{let a=n.n,o=[],l=0,w=!1,p=[],m=0;for(let h of e){m+=1,h.o&&(n.n=`${a}|union ${m}|`);let j=n.s;n.s=!0,n.a=0;let d=h.r(t,n),k=n.a;if(n.s=j,n.a=0,d.ok)return{data:d.data,errors:!1};h.o&&k!==-1?k>0?p.push(...d.errors):(l<v&&o.push(...d.errors),l+=1):w=!0}return n.n=a,p.length>0||o.length>0?((l>v||w)&&o.push(f(n,"not matches any other union member")),{errors:[...p,...o],data:void 0}):!1})}}}function Y(e,r){return{...e,c:!1,l:!1,f:!1,r(t,n){return i(this,t,n,()=>{if(t===void 0)return s();let a=e.r(t,n);return a.ok?a.data===void 0?s():{data:a.data,errors:!1}:{data:void 0,errors:a.errors}})},e:`${e.e}_default`};function s(){return{data:b(r)?r():r,errors:!1}}}function ee(e,r){return{...e,c:!1,l:!1,f:!1,r(t,n){return i(this,t,n,()=>{if(t==null)return s();let a=e.r(t,n);return a.ok?a.data===null||a.data===void 0?s():{data:a.data,errors:!1}:{data:void 0,errors:a.errors}})},e:`${e.e}_nullish_default`};function s(){return{data:b(r)?r():r,errors:!1}}}function g(e){e.warnings&&e.warnings.length>0&&console.warn(`Unwrap warnings: ${e.warnings.join(`
|
|
2
|
+
`)}`)}function c(){if(this.errors)throw new _(this.errors);return g(this),this.value}function y(e){return this.errors?e:(g(this),this.value)}function T(){return this.errors?null:(g(this),this.value)}function S(e,r,{noWarnings:s=!1}={}){let t={b:[],n:"",s:!1,a:0,y:s,i:!1,h:!1},n=r.r(e,t);return n.ok?{error:!1,errors:!1,ok:!0,data:n.data,value:n.data,warnings:t.b.length>0?t.b:!1,unwrap:c,unwrapOr:y,unwrapOrNull:T}:{ok:!1,error:!0,errors:n.errors,unwrap:c,unwrapOr:y,unwrapOrNull:T}}var _=class extends Error{constructor(s){super(s.join(`
|
|
3
|
+
`));this.errors=s}name="RcValidationError"};function A(e,r){let s=typeof e,t=(()=>{if(s==="object"){if(Array.isArray(e))return"array";if(!e)return"null"}return typeof e=="number"&&Number.isNaN(e)?"NaN":s})();return r&&(t==="string"||t==="number"||t==="boolean")?`${t}(${e})`:t}function re(e){return typeof e=="object"&&e!==null&&!Array.isArray(e)}function ne(e,r,s){try{if(typeof e!="string")return{ok:!1,error:!0,errors:[`expected a json string, got ${A(e,!0)}`],unwrap:c,unwrapOr:y,unwrapOrNull:T};let t=JSON.parse(e);return S(t,r,s)}catch(t){return{ok:!1,error:!0,errors:[`json parsing error: ${re(t)?t.message:""}`],unwrap:c,unwrapOr:y,unwrapOrNull:T}}}function b(e){return typeof e=="function"}var te=$.withAutofix(e=>e==null||e===0||e===1?{fixed:!!e}:e==="true"||e==="false"?{fixed:e==="true"}:!1),se=E.withAutofix(e=>typeof e=="number"&&!Number.isNaN(e)?{fixed:e.toString()}:!1),ae=I.withAutofix(e=>{if(typeof e=="string"){let r=Number(e);if(!Number.isNaN(r))return{fixed:r}}return!1});0&&(module.exports={rc_boolean_autofix,rc_number_autofix,rc_string_autofix});
|
|
4
4
|
//# sourceMappingURL=autofixable.cjs.map
|