lucid-extension-sdk 0.0.400 → 0.0.401

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,4 +1,11 @@
1
1
  import { Pruner } from '../guards';
2
+ /**
3
+ * Create a pruner which allows the target to be either null or satisfy the
4
+ * sub-pruner.
5
+ *
6
+ * @return A pruner for the subpruner or a null value
7
+ */
8
+ export declare function nullablePruner(subPruner: Pruner): (data: unknown, invalidFields?: Map<number, unknown[]>, level?: number) => unknown;
2
9
  /**
3
10
  * Creates a pruner function that will remove object fields that are invalid.
4
11
  * If a sub-pruner is provided for a field, then the object field values will be pruned.
@@ -1,7 +1,24 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.pruneObjectField = exports.arrayPruner = exports.objectOfPruner = exports.objectPruner = void 0;
3
+ exports.pruneObjectField = exports.arrayPruner = exports.objectOfPruner = exports.objectPruner = exports.nullablePruner = void 0;
4
4
  const checks_1 = require("../checks");
5
+ /**
6
+ * Create a pruner which allows the target to be either null or satisfy the
7
+ * sub-pruner.
8
+ *
9
+ * @return A pruner for the subpruner or a null value
10
+ */
11
+ function nullablePruner(subPruner) {
12
+ return (data, invalidFields, level = 0) => {
13
+ if (data === null) {
14
+ return data;
15
+ }
16
+ else {
17
+ return subPruner(data, invalidFields, level);
18
+ }
19
+ };
20
+ }
21
+ exports.nullablePruner = nullablePruner;
5
22
  /**
6
23
  * Creates a pruner function that will remove object fields that are invalid.
7
24
  * If a sub-pruner is provided for a field, then the object field values will be pruned.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "lucid-extension-sdk",
3
- "version": "0.0.400",
3
+ "version": "0.0.401",
4
4
  "description": "Utility classes for writing Lucid Software editor extensions",
5
5
  "main": "index.js",
6
6
  "types": "index.d.ts",