typebox 1.2.15 → 1.2.16
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.
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
// deno-fmt-ignore-file
|
|
2
|
-
import { Unreachable } from '../../system/unreachable/index.mjs';
|
|
3
2
|
import { Guard } from '../../guard/index.mjs';
|
|
4
3
|
import { FromType } from './from_type.mjs';
|
|
5
4
|
import { Callback } from './callback.mjs';
|
|
@@ -7,10 +6,8 @@ import { Callback } from './callback.mjs';
|
|
|
7
6
|
// Decode
|
|
8
7
|
// ------------------------------------------------------------------
|
|
9
8
|
function Decode(direction, context, type, value) {
|
|
10
|
-
// deno-coverage-ignore-start - unreachable | checked
|
|
11
9
|
if (!Guard.IsArray(value))
|
|
12
|
-
return
|
|
13
|
-
// deno-coverage-ignore-stop
|
|
10
|
+
return value;
|
|
14
11
|
for (let i = 0; i < value.length; i++) {
|
|
15
12
|
value[i] = FromType(direction, context, type.items, value[i]);
|
|
16
13
|
}
|
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
// deno-fmt-ignore-file
|
|
2
|
-
import { Unreachable } from '../../system/unreachable/index.mjs';
|
|
3
2
|
import { Guard } from '../../guard/index.mjs';
|
|
4
3
|
import { FromType } from './from_type.mjs';
|
|
5
4
|
import { Callback } from './callback.mjs';
|
|
@@ -8,10 +7,8 @@ import { IsOptionalUndefined } from '../shared/optional_undefined.mjs';
|
|
|
8
7
|
// Decode
|
|
9
8
|
// ------------------------------------------------------------------
|
|
10
9
|
function Decode(direction, context, type, value) {
|
|
11
|
-
// deno-coverage-ignore-start - unreachable | checked
|
|
12
10
|
if (!Guard.IsObjectNotArray(value))
|
|
13
|
-
return
|
|
14
|
-
// deno-coverage-ignore-stop
|
|
11
|
+
return value;
|
|
15
12
|
for (const key of Guard.Keys(type.properties)) {
|
|
16
13
|
// Ignore for non-present or optional-undefined
|
|
17
14
|
if (!Guard.HasPropertyKey(value, key) || IsOptionalUndefined(type.properties[key], key, value))
|
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
// deno-fmt-ignore-file
|
|
2
|
-
import { Unreachable } from '../../system/unreachable/index.mjs';
|
|
3
2
|
import { Guard } from '../../guard/index.mjs';
|
|
4
3
|
import { RecordPattern, RecordValue } from '../../type/index.mjs';
|
|
5
4
|
import { FromType } from './from_type.mjs';
|
|
@@ -8,16 +7,12 @@ import { Callback } from './callback.mjs';
|
|
|
8
7
|
// Decode
|
|
9
8
|
// ------------------------------------------------------------------
|
|
10
9
|
function Decode(direction, context, type, value) {
|
|
11
|
-
// deno-coverage-ignore-start - unreachable | checked
|
|
12
10
|
if (!Guard.IsObjectNotArray(value))
|
|
13
|
-
return
|
|
14
|
-
// deno-coverage-ignore-stop
|
|
11
|
+
return value;
|
|
15
12
|
const regexp = new RegExp(RecordPattern(type));
|
|
16
13
|
for (const key of Guard.Keys(value)) {
|
|
17
|
-
// deno-coverage-ignore-start - unreachable | checked
|
|
18
14
|
if (!regexp.test(key))
|
|
19
|
-
|
|
20
|
-
// deno-coverage-ignore-stop
|
|
15
|
+
continue;
|
|
21
16
|
value[key] = FromType(direction, context, RecordValue(type), value[key]);
|
|
22
17
|
}
|
|
23
18
|
return Callback(direction, context, type, value);
|
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
// deno-fmt-ignore-file
|
|
2
|
-
import { Unreachable } from '../../system/unreachable/index.mjs';
|
|
3
2
|
import { Guard } from '../../guard/index.mjs';
|
|
4
3
|
import { FromType } from './from_type.mjs';
|
|
5
4
|
import { Callback } from './callback.mjs';
|
|
@@ -7,10 +6,8 @@ import { Callback } from './callback.mjs';
|
|
|
7
6
|
// Decode
|
|
8
7
|
// ------------------------------------------------------------------
|
|
9
8
|
function Decode(direction, context, type, value) {
|
|
10
|
-
// deno-coverage-ignore-start - unreachable | checked
|
|
11
9
|
if (!Guard.IsArray(value))
|
|
12
|
-
return
|
|
13
|
-
// deno-coverage-ignore-stop
|
|
10
|
+
return value;
|
|
14
11
|
for (let i = 0; i < Math.min(type.items.length, value.length); i++) {
|
|
15
12
|
value[i] = FromType(direction, context, type.items[i], value[i]);
|
|
16
13
|
}
|