typebox 1.0.42 → 1.0.43

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,7 +1,7 @@
1
1
  // deno-fmt-ignore-file
2
2
  import { Guard } from '../../guard/index.mjs';
3
3
  // ------------------------------------------------------------------
4
- // Indices
4
+ // Asserts
5
5
  // ------------------------------------------------------------------
6
6
  function AssertNotRoot(indices) {
7
7
  if (indices.length === 0)
@@ -14,6 +14,9 @@ function AssertCanSet(value) {
14
14
  // ------------------------------------------------------------------
15
15
  // Indices
16
16
  // ------------------------------------------------------------------
17
+ function IsNumericIndex(index) {
18
+ return /^(0|[1-9]\d*)$/.test(index);
19
+ }
17
20
  function TakeIndexRight(indices) {
18
21
  return [
19
22
  indices.slice(0, indices.length - 1),
@@ -83,6 +86,11 @@ export function Delete(value, pointer) {
83
86
  const [head, index] = TakeIndexRight(indices);
84
87
  const parent = GetIndices(head, value);
85
88
  AssertCanSet(parent);
86
- delete parent[index];
89
+ if (Guard.IsArray(parent) && IsNumericIndex(index)) {
90
+ parent.splice(+index, 1);
91
+ }
92
+ else {
93
+ delete parent[index];
94
+ }
87
95
  return value;
88
96
  }
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "typebox",
3
3
  "description": "Json Schema Type Builder with Static Type Resolution for TypeScript",
4
- "version": "1.0.42",
4
+ "version": "1.0.43",
5
5
  "keywords": [
6
6
  "typescript",
7
7
  "jsonschema"