pmcf 1.94.3 → 1.94.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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "pmcf",
3
- "version": "1.94.3",
3
+ "version": "1.94.5",
4
4
  "publishConfig": {
5
5
  "access": "public"
6
6
  },
package/src/base.mjs CHANGED
@@ -482,7 +482,17 @@ export function extractFrom(
482
482
  object,
483
483
  typeDefinition = object?.constructor?.typeDefinition
484
484
  ) {
485
- if (Array.isArray(object)) {
485
+ switch (typeof object) {
486
+ case "undefined":
487
+ case "string":
488
+ case "number":
489
+ case "boolean":
490
+ return object;
491
+ }
492
+
493
+ if (typeof object[Symbol.iterator] === "function") {
494
+ object = [...object];
495
+
486
496
  if (object.length === 0) {
487
497
  return undefined;
488
498
  }
@@ -498,11 +508,7 @@ export function extractFrom(
498
508
  );
499
509
  }
500
510
 
501
- return object.map(o => extractFrom(o));
502
- }
503
-
504
- if (!typeDefinition || object === undefined) {
505
- return object;
511
+ return object.length ? object : undefined;
506
512
  }
507
513
 
508
514
  const json = {};
@@ -533,8 +539,11 @@ export function extractFrom(
533
539
  json[name].name = value.name;
534
540
  }
535
541
  } else {
536
- if (Array.isArray(value)) {
537
- json[name] = extractFrom(value);
542
+ if (typeof value[Symbol.iterator] === "function") {
543
+ value = extractFrom(value);
544
+ if (value !== undefined) {
545
+ json[name] = value;
546
+ }
538
547
  } else {
539
548
  const resultObject = Object.fromEntries(
540
549
  Object.entries(value).map(([k, v]) => [
package/src/host.mjs CHANGED
@@ -255,7 +255,7 @@ export class Host extends Base {
255
255
  }
256
256
 
257
257
  get os() {
258
- return this.#os || this.extends.find(e => e.os);
258
+ return this.#os || this.extends.find(e => e.os)?.os
259
259
  }
260
260
 
261
261
  set distribution(value) {
@@ -263,7 +263,7 @@ export class Host extends Base {
263
263
  }
264
264
 
265
265
  get distribution() {
266
- return this.#distribution || this.extends.find(e => e.distribution);
266
+ return this.#distribution || this.extends.find(e => e.distribution)?.distribution;
267
267
  }
268
268
 
269
269
  get modelName() {