pmcf 4.25.17 → 4.25.18

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": "4.25.17",
3
+ "version": "4.25.18",
4
4
  "publishConfig": {
5
5
  "access": "public"
6
6
  },
package/src/base.mjs CHANGED
@@ -55,7 +55,7 @@ export class Base {
55
55
  }
56
56
 
57
57
  static get typeName() {
58
- return this.typeDefinition?.name || this.name;
58
+ return this.name;
59
59
  }
60
60
 
61
61
  static get typeFileName() {
@@ -213,7 +213,7 @@ export class Base {
213
213
 
214
214
  get typeName() {
215
215
  // @ts-ignore
216
- return this.constructor.typeDefinition.name;
216
+ return this.constructor.name;
217
217
  }
218
218
 
219
219
  /**
@@ -236,15 +236,8 @@ export class Base {
236
236
  * @return {Iterable<[string,any]>} values
237
237
  */
238
238
  *attributeIterator(filter) {
239
- for (
240
- let typeDefinition = this.constructor.typeDefinition;
241
- typeDefinition;
242
- typeDefinition = typeDefinition.extends
243
- ) {
244
- for (const [path, def] of attributeIterator(
245
- typeDefinition.attributes,
246
- filter
247
- )) {
239
+ for (let type = this.constructor; type; type = type.extends) {
240
+ for (const [path, def] of attributeIterator(type.attributes, filter)) {
248
241
  const name = path.join(".");
249
242
  const value = this.attribute(name);
250
243
 
@@ -545,14 +538,11 @@ export class Base {
545
538
  }
546
539
 
547
540
  toJSON() {
548
- return extractFrom(this, this.constructor.typeDefinition);
541
+ return extractFrom(this, this.constructor);
549
542
  }
550
543
  }
551
544
 
552
- export function extractFrom(
553
- object,
554
- typeDefinition = object?.constructor?.typeDefinition
555
- ) {
545
+ export function extractFrom(object, type = object?.constructor) {
556
546
  switch (typeof object) {
557
547
  case "undefined":
558
548
  case "string":
@@ -572,12 +562,12 @@ export function extractFrom(
572
562
  return undefined;
573
563
  }
574
564
 
575
- if (typeDefinition?.key) {
565
+ if (type?.key) {
576
566
  return Object.fromEntries(
577
567
  object.map(o => {
578
568
  o = extractFrom(o);
579
- const name = o[typeDefinition.key];
580
- delete o[typeDefinition.key];
569
+ const name = o[type.key];
570
+ delete o[type.key];
581
571
  return [name, o];
582
572
  })
583
573
  );
@@ -588,9 +578,9 @@ export function extractFrom(
588
578
 
589
579
  const json = {};
590
580
 
591
- for (; typeDefinition; typeDefinition = typeDefinition.extends) {
581
+ for (; type; type = type.extends) {
592
582
  for (const [path, def] of attributeIterator(
593
- typeDefinition.attributes,
583
+ type.attributes,
594
584
  filterPublic
595
585
  )) {
596
586
  const name = path.join(".");
@@ -188,7 +188,7 @@ export class InitializationContext {
188
188
  return object;
189
189
  }
190
190
 
191
- read(object, data, type = object.constructor.typeDefinition) {
191
+ read(object, data, type = object.constructor) {
192
192
  if (data?.properties) {
193
193
  Object.assign(object.properties, data.properties);
194
194
  }
@@ -200,7 +200,7 @@ export class InitializationContext {
200
200
  }
201
201
  }
202
202
 
203
- _read(object, data, type = object.constructor.typeDefinition) {
203
+ _read(object, data, type) {
204
204
  if (type.extends) {
205
205
  this._read(object, data, type.extends);
206
206
  }