@alterior/common 3.9.1 → 3.13.4

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.
Files changed (162) hide show
  1. package/dist/base64.d.ts +6 -6
  2. package/dist/base64.js +52 -52
  3. package/dist/base64.js.map +1 -1
  4. package/dist/base64.test.d.ts +1 -1
  5. package/dist/cache.d.ts +84 -84
  6. package/dist/cache.js +148 -148
  7. package/dist/cache.js.map +1 -1
  8. package/dist/cache.test.d.ts +1 -1
  9. package/dist/check-native-async.d.ts +1 -1
  10. package/dist/check-native-async.js +27 -28
  11. package/dist/check-native-async.js.map +1 -1
  12. package/dist/clone.d.ts +23 -23
  13. package/dist/clone.js +59 -60
  14. package/dist/clone.js.map +1 -1
  15. package/dist/clone.test.d.ts +1 -1
  16. package/dist/coalesce.d.ts +5 -5
  17. package/dist/coalesce.js +15 -16
  18. package/dist/coalesce.js.map +1 -1
  19. package/dist/coalesce.test.d.ts +1 -1
  20. package/dist/colors.d.ts +62 -62
  21. package/dist/colors.js +66 -66
  22. package/dist/console.d.ts +31 -31
  23. package/dist/console.d.ts.map +1 -1
  24. package/dist/console.js +65 -86
  25. package/dist/console.js.map +1 -1
  26. package/dist/constructor.d.ts +6 -6
  27. package/dist/constructor.js +2 -2
  28. package/dist/decorators.d.ts +1 -1
  29. package/dist/decorators.d.ts.map +1 -1
  30. package/dist/decorators.js +6 -7
  31. package/dist/decorators.js.map +1 -1
  32. package/dist/environment.d.ts +11 -11
  33. package/dist/environment.d.ts.map +1 -1
  34. package/dist/environment.js +27 -27
  35. package/dist/environment.js.map +1 -1
  36. package/dist/errors.d.ts +66 -66
  37. package/dist/errors.js +133 -133
  38. package/dist/errors.test.d.ts +1 -1
  39. package/dist/get-param-names.d.ts +5 -5
  40. package/dist/get-param-names.js +48 -49
  41. package/dist/get-param-names.js.map +1 -1
  42. package/dist/index.d.ts +20 -20
  43. package/dist/index.js +23 -23
  44. package/dist/is-constructor.d.ts +12 -12
  45. package/dist/is-constructor.js +28 -29
  46. package/dist/is-constructor.js.map +1 -1
  47. package/dist/is-constructor.test.d.ts +1 -1
  48. package/dist/lazy-promise.d.ts +14 -14
  49. package/dist/lazy-promise.js +32 -32
  50. package/dist/lazy-promise.js.map +1 -1
  51. package/dist/lazy-subject.d.ts +22 -22
  52. package/dist/lazy-subject.js +22 -23
  53. package/dist/lazy-subject.js.map +1 -1
  54. package/dist/locks.d.ts +23 -23
  55. package/dist/locks.js +76 -76
  56. package/dist/locks.js.map +1 -1
  57. package/dist/locks.test.d.ts +1 -1
  58. package/dist/locks.test.js.map +1 -1
  59. package/dist/padding.d.ts +22 -22
  60. package/dist/padding.js +42 -43
  61. package/dist/padding.js.map +1 -1
  62. package/dist/presentation.d.ts +49 -49
  63. package/dist/presentation.d.ts.map +1 -1
  64. package/dist/presentation.js +132 -132
  65. package/dist/presentation.js.map +1 -1
  66. package/dist/presentation.test.d.ts +1 -1
  67. package/dist/presentation.test.js.map +1 -1
  68. package/dist/serializer.d.ts +8 -8
  69. package/dist/serializer.js +23 -24
  70. package/dist/serializer.js.map +1 -1
  71. package/dist/test.d.ts +2 -2
  72. package/dist/time.d.ts +9 -9
  73. package/dist/time.js +22 -22
  74. package/dist/time.js.map +1 -1
  75. package/dist/timeout.d.ts +13 -13
  76. package/dist/timeout.js +27 -28
  77. package/dist/timeout.js.map +1 -1
  78. package/dist/zones.d.ts +46 -46
  79. package/dist/zones.js +139 -139
  80. package/dist/zones.js.map +1 -1
  81. package/dist.esm/base64.d.ts +6 -6
  82. package/dist.esm/base64.js +48 -48
  83. package/dist.esm/base64.js.map +1 -1
  84. package/dist.esm/base64.test.d.ts +1 -1
  85. package/dist.esm/cache.d.ts +84 -84
  86. package/dist.esm/cache.js +144 -144
  87. package/dist.esm/cache.js.map +1 -1
  88. package/dist.esm/cache.test.d.ts +1 -1
  89. package/dist.esm/check-native-async.d.ts +1 -1
  90. package/dist.esm/check-native-async.js +24 -24
  91. package/dist.esm/check-native-async.js.map +1 -1
  92. package/dist.esm/clone.d.ts +23 -23
  93. package/dist.esm/clone.js +53 -53
  94. package/dist.esm/clone.js.map +1 -1
  95. package/dist.esm/clone.test.d.ts +1 -1
  96. package/dist.esm/coalesce.d.ts +5 -5
  97. package/dist.esm/coalesce.js +12 -12
  98. package/dist.esm/coalesce.js.map +1 -1
  99. package/dist.esm/coalesce.test.d.ts +1 -1
  100. package/dist.esm/colors.d.ts +62 -62
  101. package/dist.esm/colors.js +63 -63
  102. package/dist.esm/console.d.ts +31 -31
  103. package/dist.esm/console.d.ts.map +1 -1
  104. package/dist.esm/console.js +60 -80
  105. package/dist.esm/console.js.map +1 -1
  106. package/dist.esm/constructor.d.ts +6 -6
  107. package/dist.esm/constructor.js +1 -1
  108. package/dist.esm/decorators.d.ts +1 -1
  109. package/dist.esm/decorators.d.ts.map +1 -1
  110. package/dist.esm/decorators.js +3 -3
  111. package/dist.esm/environment.d.ts +11 -11
  112. package/dist.esm/environment.d.ts.map +1 -1
  113. package/dist.esm/environment.js +24 -24
  114. package/dist.esm/environment.js.map +1 -1
  115. package/dist.esm/errors.d.ts +66 -66
  116. package/dist.esm/errors.js +115 -115
  117. package/dist.esm/errors.test.d.ts +1 -1
  118. package/dist.esm/get-param-names.d.ts +5 -5
  119. package/dist.esm/get-param-names.js +45 -45
  120. package/dist.esm/get-param-names.js.map +1 -1
  121. package/dist.esm/index.d.ts +20 -20
  122. package/dist.esm/index.js +20 -20
  123. package/dist.esm/is-constructor.d.ts +12 -12
  124. package/dist.esm/is-constructor.js +24 -24
  125. package/dist.esm/is-constructor.js.map +1 -1
  126. package/dist.esm/is-constructor.test.d.ts +1 -1
  127. package/dist.esm/lazy-promise.d.ts +14 -14
  128. package/dist.esm/lazy-promise.js +28 -28
  129. package/dist.esm/lazy-promise.js.map +1 -1
  130. package/dist.esm/lazy-subject.d.ts +22 -22
  131. package/dist.esm/lazy-subject.js +19 -19
  132. package/dist.esm/locks.d.ts +23 -23
  133. package/dist.esm/locks.js +71 -71
  134. package/dist.esm/locks.js.map +1 -1
  135. package/dist.esm/locks.test.d.ts +1 -1
  136. package/dist.esm/locks.test.js.map +1 -1
  137. package/dist.esm/padding.d.ts +22 -22
  138. package/dist.esm/padding.js +37 -37
  139. package/dist.esm/presentation.d.ts +49 -49
  140. package/dist.esm/presentation.d.ts.map +1 -1
  141. package/dist.esm/presentation.js +126 -126
  142. package/dist.esm/presentation.js.map +1 -1
  143. package/dist.esm/presentation.test.d.ts +1 -1
  144. package/dist.esm/presentation.test.js.map +1 -1
  145. package/dist.esm/serializer.d.ts +8 -8
  146. package/dist.esm/serializer.js +20 -20
  147. package/dist.esm/test.d.ts +2 -2
  148. package/dist.esm/time.d.ts +9 -9
  149. package/dist.esm/time.js +19 -19
  150. package/dist.esm/time.js.map +1 -1
  151. package/dist.esm/timeout.d.ts +13 -13
  152. package/dist.esm/timeout.js +23 -23
  153. package/dist.esm/tsconfig.esm.tsbuildinfo +1 -0
  154. package/dist.esm/zones.d.ts +46 -46
  155. package/dist.esm/zones.js +135 -135
  156. package/dist.esm/zones.js.map +1 -1
  157. package/package.json +11 -8
  158. package/src/console.ts +2 -22
  159. package/src/environment.ts +2 -0
  160. package/tsconfig.esm.json +0 -3
  161. package/tsconfig.json +0 -2
  162. package/tsconfig.tsbuildinfo +1 -3791
@@ -1,38 +1,38 @@
1
- /**
2
- * Pad the given string until its at least `length` characters long by adding spaces to the end.
3
- *
4
- * @param str
5
- * @param length
6
- * @returns
7
- */
8
- export function rightPad(str, length) {
9
- str = String(str);
10
- while (str.length < length)
11
- str += ' ';
12
- return str;
13
- }
14
- /**
15
- * Pad the given string until its at least `length` characters long by adding spaces to the beginning.
16
- * @param str
17
- * @param length
18
- * @returns
19
- */
20
- export function leftPad(str, length) {
21
- str = String(str);
22
- while (str.length < length)
23
- str = ' ' + str;
24
- return str;
25
- }
26
- /**
27
- * Pad the given number (creating a string) until its at least `length` digits long by adding zeros to the beginning.
28
- * @param number
29
- * @param digits
30
- * @returns
31
- */
32
- export function zeroPad(number, digits = 2) {
33
- let str = `${number}`;
34
- while (str.length < digits)
35
- str = '0' + str;
36
- return str;
37
- }
1
+ /**
2
+ * Pad the given string until its at least `length` characters long by adding spaces to the end.
3
+ *
4
+ * @param str
5
+ * @param length
6
+ * @returns
7
+ */
8
+ export function rightPad(str, length) {
9
+ str = String(str);
10
+ while (str.length < length)
11
+ str += ' ';
12
+ return str;
13
+ }
14
+ /**
15
+ * Pad the given string until its at least `length` characters long by adding spaces to the beginning.
16
+ * @param str
17
+ * @param length
18
+ * @returns
19
+ */
20
+ export function leftPad(str, length) {
21
+ str = String(str);
22
+ while (str.length < length)
23
+ str = ' ' + str;
24
+ return str;
25
+ }
26
+ /**
27
+ * Pad the given number (creating a string) until its at least `length` digits long by adding zeros to the beginning.
28
+ * @param number
29
+ * @param digits
30
+ * @returns
31
+ */
32
+ export function zeroPad(number, digits = 2) {
33
+ let str = `${number}`;
34
+ while (str.length < digits)
35
+ str = '0' + str;
36
+ return str;
37
+ }
38
38
  //# sourceMappingURL=padding.js.map
@@ -1,50 +1,50 @@
1
- import { Constructor } from "./constructor";
2
- export declare const EXPOSE_PROTOTYPE_STORAGE_KEY = "@alterior/common:Expose";
3
- export interface PresentedPropertyOptions {
4
- useProperty?: string;
5
- class?: Constructor<Presentation<any>>;
6
- defaultValue?: any;
7
- }
8
- export interface PresentedProperty {
9
- propertyKey: string;
10
- options: PresentedPropertyOptions;
11
- designType?: any;
12
- }
13
- export declare class PresentationSchema<T> {
14
- readonly type: Constructor<Presentation<T>>;
15
- constructor(type: Constructor<Presentation<T>>);
16
- private populate;
17
- properties: PresentedProperty[];
18
- }
19
- /**
20
- * Allows for transforming data from one form to another using declarative rules.
21
- * To use, you must declare a subclass which has one or more properties annotated
22
- * with the `@Expose()` decorator. When the presentation is converted to JSON,
23
- * the property values from the `instance` given during instantiation will be used
24
- * within the JSON. If any property declaration within the `Presentation<T>` subclass
25
- * has a property type annotation for a type that extends `Presentation<T>`, a
26
- * new instance of that type will be constructed and passed the property value from
27
- * the given `instance`. This allows you to control the presentation of subobjects.
28
- */
29
- export declare class Presentation<T> {
30
- readonly instance: T;
31
- constructor(instance: T);
32
- /**
33
- * Construct a new set of presentations with the type of calling class
34
- * for the items within the given array.
35
- *
36
- * @param this
37
- * @param array
38
- */
39
- static from<T extends Presentation<U>, U>(this: Constructor<T>, array: U[]): T[];
40
- static get properties(): PresentedProperty[];
41
- toJSON(): {};
42
- }
43
- /**
44
- * When used on properties declared within a subclass of `Presentation<T>`,
45
- * specifies that the property should be included in the final JSON presentation.
46
- *
47
- * @see Presentation<T>
48
- */
49
- export declare function Expose(options?: PresentedPropertyOptions): (target: Object, propertyKey: string, descriptor?: PropertyDescriptor) => void;
1
+ import { Constructor } from "./constructor";
2
+ export declare const EXPOSE_PROTOTYPE_STORAGE_KEY = "@alterior/common:Expose";
3
+ export interface PresentedPropertyOptions {
4
+ useProperty?: string;
5
+ class?: Constructor<Presentation<any>>;
6
+ defaultValue?: any;
7
+ }
8
+ export interface PresentedProperty {
9
+ propertyKey: string;
10
+ options: PresentedPropertyOptions;
11
+ designType?: any;
12
+ }
13
+ export declare class PresentationSchema<T> {
14
+ readonly type: Constructor<Presentation<T>>;
15
+ constructor(type: Constructor<Presentation<T>>);
16
+ private populate;
17
+ properties: PresentedProperty[];
18
+ }
19
+ /**
20
+ * Allows for transforming data from one form to another using declarative rules.
21
+ * To use, you must declare a subclass which has one or more properties annotated
22
+ * with the `@Expose()` decorator. When the presentation is converted to JSON,
23
+ * the property values from the `instance` given during instantiation will be used
24
+ * within the JSON. If any property declaration within the `Presentation<T>` subclass
25
+ * has a property type annotation for a type that extends `Presentation<T>`, a
26
+ * new instance of that type will be constructed and passed the property value from
27
+ * the given `instance`. This allows you to control the presentation of subobjects.
28
+ */
29
+ export declare class Presentation<T> {
30
+ readonly instance: T;
31
+ constructor(instance: T);
32
+ /**
33
+ * Construct a new set of presentations with the type of calling class
34
+ * for the items within the given array.
35
+ *
36
+ * @param this
37
+ * @param array
38
+ */
39
+ static from<T extends Presentation<U>, U>(this: Constructor<T>, array: U[]): T[];
40
+ static get properties(): PresentedProperty[];
41
+ toJSON(): {};
42
+ }
43
+ /**
44
+ * When used on properties declared within a subclass of `Presentation<T>`,
45
+ * specifies that the property should be included in the final JSON presentation.
46
+ *
47
+ * @see Presentation<T>
48
+ */
49
+ export declare function Expose(options?: PresentedPropertyOptions): (target: Object, propertyKey: string, descriptor?: PropertyDescriptor) => void;
50
50
  //# sourceMappingURL=presentation.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"presentation.d.ts","sourceRoot":"","sources":["../src/presentation.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,WAAW,EAAE,MAAM,eAAe,CAAC;AAG5C,eAAO,MAAM,4BAA4B,4BAA4B,CAAC;AAEtE,MAAM,WAAW,wBAAwB;IACrC,WAAW,CAAC,EAAG,MAAM,CAAC;IACtB,KAAK,CAAC,EAAG,WAAW,CAAC,YAAY,CAAC,GAAG,CAAC,CAAC,CAAC;IACxC,YAAY,CAAC,EAAG,GAAG,CAAC;CACvB;AAED,MAAM,WAAW,iBAAiB;IAC9B,WAAW,EAAG,MAAM,CAAC;IACrB,OAAO,EAAG,wBAAwB,CAAC;IACnC,UAAU,CAAC,EAAG,GAAG,CAAC;CACrB;AAED,qBAAa,kBAAkB,CAAC,CAAC;IACjB,QAAQ,CAAC,IAAI,EAAG,WAAW,CAAC,YAAY,CAAC,CAAC,CAAC,CAAC;gBAAnC,IAAI,EAAG,WAAW,CAAC,YAAY,CAAC,CAAC,CAAC,CAAC;IAIxD,OAAO,CAAC,QAAQ;IA8ChB,UAAU,EAAG,iBAAiB,EAAE,CAAC;CACpC;AAED;;;;;;;;;GASG;AACH,qBAAa,YAAY,CAAC,CAAC;IAEnB,QAAQ,CAAC,QAAQ,EAAG,CAAC;gBAAZ,QAAQ,EAAG,CAAC;IAIzB;;;;;;OAMG;WACW,IAAI,CAAC,CAAC,SAAS,YAAY,CAAC,CAAC,CAA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CAAC,EAAE,KAAK,EAAG,CAAC,EAAE,GAAI,CAAC,EAAE;IAI1F,WAAkB,UAAU,IAAK,iBAAiB,EAAE,CAEnD;IAEM,MAAM;CA4ChB;AAED;;;;;GAKG;AACH,wBAAgB,MAAM,CAAC,OAAO,GAAG,wBAA6B,IACzC,QAAQ,MAAM,EAAE,aAAa,MAAM,EAAE,aAAa,kBAAkB,UAgBxF"}
@@ -1,127 +1,127 @@
1
- /// <reference types="reflect-metadata" />
2
- import { clone } from "./clone";
3
- export const EXPOSE_PROTOTYPE_STORAGE_KEY = '@alterior/common:Expose';
4
- export class PresentationSchema {
5
- constructor(type) {
6
- this.type = type;
7
- this.populate();
8
- }
9
- populate() {
10
- let exposureSets = [];
11
- let prototype = this.type.prototype;
12
- let prototypes = [];
13
- while (prototype) {
14
- prototypes.push(prototype);
15
- let value = prototype[EXPOSE_PROTOTYPE_STORAGE_KEY];
16
- if (value)
17
- exposureSets.push(value);
18
- prototype = Object.getPrototypeOf(prototype);
19
- }
20
- // Reverse the order so that the super-most properties appear first,
21
- // followed by the subproperties.
22
- exposureSets = exposureSets.reverse();
23
- let exposures = exposureSets
24
- .reduce((pv, cv) => (pv.push(...cv), pv), [])
25
- .map(x => clone(x));
26
- for (let exposure of exposures) {
27
- let key = exposure.propertyKey;
28
- if (exposure.options && exposure.options.useProperty) {
29
- key = exposure.options.useProperty;
30
- }
31
- let designType = null;
32
- for (let prototype of prototypes) {
33
- designType = Reflect.getMetadata('design:type', prototype, key);
34
- if (designType)
35
- break;
36
- }
37
- if (!exposure.designType)
38
- exposure.designType = designType;
39
- }
40
- this.properties = exposures;
41
- }
42
- }
43
- /**
44
- * Allows for transforming data from one form to another using declarative rules.
45
- * To use, you must declare a subclass which has one or more properties annotated
46
- * with the `@Expose()` decorator. When the presentation is converted to JSON,
47
- * the property values from the `instance` given during instantiation will be used
48
- * within the JSON. If any property declaration within the `Presentation<T>` subclass
49
- * has a property type annotation for a type that extends `Presentation<T>`, a
50
- * new instance of that type will be constructed and passed the property value from
51
- * the given `instance`. This allows you to control the presentation of subobjects.
52
- */
53
- export class Presentation {
54
- constructor(instance) {
55
- this.instance = instance;
56
- }
57
- /**
58
- * Construct a new set of presentations with the type of calling class
59
- * for the items within the given array.
60
- *
61
- * @param this
62
- * @param array
63
- */
64
- static from(array) {
65
- return array.map(x => new this(x));
66
- }
67
- static get properties() {
68
- return new PresentationSchema(this).properties;
69
- }
70
- toJSON() {
71
- if (!this.instance)
72
- return null;
73
- let properties = {};
74
- let exposures = this.constructor.properties;
75
- for (let exposure of exposures) {
76
- let key = exposure.propertyKey;
77
- let options = exposure.options;
78
- let prototype = Object.getPrototypeOf(this);
79
- let propertyType = Reflect.getMetadata('design:type', this.constructor.prototype, key);
80
- let propertyDescriptor = Object.getOwnPropertyDescriptor(prototype, key);
81
- let value = this[key];
82
- if (options.useProperty) {
83
- value = this.instance[options.useProperty];
84
- }
85
- else if (!propertyDescriptor || !propertyDescriptor.get) {
86
- // Data property, fill from original object.
87
- value = this.instance[key];
88
- }
89
- let entityType;
90
- if (options.class) {
91
- entityType = options.class;
92
- }
93
- else if (propertyType && propertyType.prototype instanceof Presentation) {
94
- entityType = propertyType;
95
- }
96
- // Transform...
97
- if (entityType)
98
- value = new entityType(value);
99
- if (value && value.toJSON)
100
- value = value.toJSON();
101
- properties[key] = value;
102
- }
103
- return properties;
104
- }
105
- }
106
- /**
107
- * When used on properties declared within a subclass of `Presentation<T>`,
108
- * specifies that the property should be included in the final JSON presentation.
109
- *
110
- * @see Presentation<T>
111
- */
112
- export function Expose(options = {}) {
113
- return function (target, propertyKey, descriptor) {
114
- if (!target.hasOwnProperty(EXPOSE_PROTOTYPE_STORAGE_KEY)) {
115
- Object.defineProperty(target, EXPOSE_PROTOTYPE_STORAGE_KEY, {
116
- enumerable: false,
117
- value: []
118
- });
119
- }
120
- let exposures = target[EXPOSE_PROTOTYPE_STORAGE_KEY];
121
- exposures.push({
122
- propertyKey: propertyKey,
123
- options
124
- });
125
- };
126
- }
1
+ /// <reference types="reflect-metadata" />
2
+ import { clone } from "./clone";
3
+ export const EXPOSE_PROTOTYPE_STORAGE_KEY = '@alterior/common:Expose';
4
+ export class PresentationSchema {
5
+ constructor(type) {
6
+ this.type = type;
7
+ this.populate();
8
+ }
9
+ populate() {
10
+ let exposureSets = [];
11
+ let prototype = this.type.prototype;
12
+ let prototypes = [];
13
+ while (prototype) {
14
+ prototypes.push(prototype);
15
+ let value = prototype[EXPOSE_PROTOTYPE_STORAGE_KEY];
16
+ if (value)
17
+ exposureSets.push(value);
18
+ prototype = Object.getPrototypeOf(prototype);
19
+ }
20
+ // Reverse the order so that the super-most properties appear first,
21
+ // followed by the subproperties.
22
+ exposureSets = exposureSets.reverse();
23
+ let exposures = exposureSets
24
+ .reduce((pv, cv) => (pv.push(...cv), pv), [])
25
+ .map(x => clone(x));
26
+ for (let exposure of exposures) {
27
+ let key = exposure.propertyKey;
28
+ if (exposure.options && exposure.options.useProperty) {
29
+ key = exposure.options.useProperty;
30
+ }
31
+ let designType = null;
32
+ for (let prototype of prototypes) {
33
+ designType = Reflect.getMetadata('design:type', prototype, key);
34
+ if (designType)
35
+ break;
36
+ }
37
+ if (!exposure.designType)
38
+ exposure.designType = designType;
39
+ }
40
+ this.properties = exposures;
41
+ }
42
+ }
43
+ /**
44
+ * Allows for transforming data from one form to another using declarative rules.
45
+ * To use, you must declare a subclass which has one or more properties annotated
46
+ * with the `@Expose()` decorator. When the presentation is converted to JSON,
47
+ * the property values from the `instance` given during instantiation will be used
48
+ * within the JSON. If any property declaration within the `Presentation<T>` subclass
49
+ * has a property type annotation for a type that extends `Presentation<T>`, a
50
+ * new instance of that type will be constructed and passed the property value from
51
+ * the given `instance`. This allows you to control the presentation of subobjects.
52
+ */
53
+ export class Presentation {
54
+ constructor(instance) {
55
+ this.instance = instance;
56
+ }
57
+ /**
58
+ * Construct a new set of presentations with the type of calling class
59
+ * for the items within the given array.
60
+ *
61
+ * @param this
62
+ * @param array
63
+ */
64
+ static from(array) {
65
+ return array.map(x => new this(x));
66
+ }
67
+ static get properties() {
68
+ return new PresentationSchema(this).properties;
69
+ }
70
+ toJSON() {
71
+ if (!this.instance)
72
+ return null;
73
+ let properties = {};
74
+ let exposures = this.constructor.properties;
75
+ for (let exposure of exposures) {
76
+ let key = exposure.propertyKey;
77
+ let options = exposure.options;
78
+ let prototype = Object.getPrototypeOf(this);
79
+ let propertyType = Reflect.getMetadata('design:type', this.constructor.prototype, key);
80
+ let propertyDescriptor = Object.getOwnPropertyDescriptor(prototype, key);
81
+ let value = this[key];
82
+ if (options.useProperty) {
83
+ value = this.instance[options.useProperty];
84
+ }
85
+ else if (!propertyDescriptor || !propertyDescriptor.get) {
86
+ // Data property, fill from original object.
87
+ value = this.instance[key];
88
+ }
89
+ let entityType;
90
+ if (options.class) {
91
+ entityType = options.class;
92
+ }
93
+ else if (propertyType && propertyType.prototype instanceof Presentation) {
94
+ entityType = propertyType;
95
+ }
96
+ // Transform...
97
+ if (entityType)
98
+ value = new entityType(value);
99
+ if (value && value.toJSON)
100
+ value = value.toJSON();
101
+ properties[key] = value;
102
+ }
103
+ return properties;
104
+ }
105
+ }
106
+ /**
107
+ * When used on properties declared within a subclass of `Presentation<T>`,
108
+ * specifies that the property should be included in the final JSON presentation.
109
+ *
110
+ * @see Presentation<T>
111
+ */
112
+ export function Expose(options = {}) {
113
+ return function (target, propertyKey, descriptor) {
114
+ if (!target.hasOwnProperty(EXPOSE_PROTOTYPE_STORAGE_KEY)) {
115
+ Object.defineProperty(target, EXPOSE_PROTOTYPE_STORAGE_KEY, {
116
+ enumerable: false,
117
+ value: []
118
+ });
119
+ }
120
+ let exposures = target[EXPOSE_PROTOTYPE_STORAGE_KEY];
121
+ exposures.push({
122
+ propertyKey: propertyKey,
123
+ options
124
+ });
125
+ };
126
+ }
127
127
  //# sourceMappingURL=presentation.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"presentation.js","sourceRoot":"","sources":["../src/presentation.ts"],"names":[],"mappings":"AA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c,EAAE,WAAmB,EAAE,UAA+B;QAEjF,IAAI,CAAC,MAAM,CAAC,cAAc,CAAC,4BAA4B,CAAC,EAAE,CAAC;YACvD,MAAM,CAAC,cAAc,CAAC,MAAM,EAAE,4BAA4B,EAAE;gBACxD,UAAU,EAAE,KAAK;gBACjB,KAAK,EAAE,EAAE;aACZ,CAAC,CAAC;QACP,CAAC;QAED,IAAI,SAAS,GAAyB,MAAM,CAAC,4BAA4B,CAAC,CAAC;QAEjF,SAAS,CAAC,IAAI,CAAoB;YACjC,WAAW,EAAE,WAAW;YACxB,OAAO;SACD,CAAC,CAAC;IACV,CAAC,CAAC;AACH,CAAC"}
@@ -1,2 +1,2 @@
1
- export {};
1
+ export {};
2
2
  //# sourceMappingURL=presentation.test.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"presentation.test.js","sourceRoot":"","sources":["../src/presentation.test.ts"],"names":[],"mappings":";AAAA,OAAO,EAAE,KAAK,EAAE,MAAM,QAAQ,CAAC;AAC/B,OAAO,EAAE,MAAM,EAAE,MAAM,MAAM,CAAC;AAC9B,OAAO,EAAE,YAAY,EAAE,MAAM,EAAE,MAAM,gBAAgB,CAAC;AAEtD,KAAK,CAAC,QAAQ,CAAC,EAAE;IACb,QAAQ,CAAC,iBAAiB,EAAE,EAAE,CAAC,EAAE;QAC7B,EAAE,CAAC,4CAA4C,EAAE,GAAG,EAAE;YAQlD,SAAS,OAAO;gBACZ,OAAO,CAAC,MAAM,EAAE,GAAG,IAAI,EAAE,EAAE,CAAC,MAAM,CAAC;YACvC,CAAC;YAGD,IAAM,QAAQ,GAAd,MAAM,QAAS,SAAQ,YAAmB;aAIzC,CAAA;YAHG;gBAAC,MAAM,EAAE;;yDAAsB;YAC/B;gBAAC,MAAM,EAAE;;mDAAgB;YACzB;gBAAC,MAAM,EAAE;;oDAAiB;YAHxB,QAAQ;gBADb,OAAO,EAAE;eACJ,QAAQ,CAIb;YAED,IAAI,KAAK,GAAG,QAAQ,CAAC,UAAU,CA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Q,gBAAgB;aAEtC;YADa;gBAAT,MAAM,EAAE;;yDAAsB;YAGnC,IAAI,iBAAiB,GAAG,IAAI,gBAAgB,CAAC,EAAE,KAAK,EAAE,OAAO,EAAE,WAAW,EAAE,aAAa,EAAE,CAAC,CAAC;YAC7F,IAAI,YAAY,GAAS,iBAAiB,CAAC,MAAM,EAAE,CAAC;YAEpD,MAAM,CAAC,YAAY,CAAC,KAAK,CAAC,CAAC,EAAE,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC;YAC7C,MAAM,CAAC,YAAY,CAAC,WAAW,CAAC,CAAC,EAAE,CAAC,EAAE,CAAC,SAAS,CAAC;YAEjD,IAAI,SAAS,GAAG,IAAI,QAAQ,CAAC,EAAE,KAAK,EAAE,OAAO,EAAE,WAAW,EAAE,aAAa,EAAE,CAAC,CAAC;YAC7E,IAAI,IAAI,GAAS,SAAS,CAAC,MAAM,EAAE,CAAC;YAEpC,MAAM,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC,EAAE,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC;YACrC,MAAM,CAAC,IAAI,CAAC,WAAW,CAAC,CAAC,EAAE,CAAC,KAAK,CAAC,aAAa,CAAC,CAAC;QACrD,CAAC,CAAC,CAAC;IACP,CAAC,CAAC,CAAC;AACP,CAAC,CAAC,CAAC"}
@@ -1,9 +1,9 @@
1
- /**
2
- * Prepare an object for serialization by removing any fields which are undefined
3
- * or functions and return the result. The operation is recursive across all subobjects.
4
- * The original object is not modified.
5
- *
6
- * @param data
7
- */
8
- export declare function prepareForSerialization<T>(data: T): T;
1
+ /**
2
+ * Prepare an object for serialization by removing any fields which are undefined
3
+ * or functions and return the result. The operation is recursive across all subobjects.
4
+ * The original object is not modified.
5
+ *
6
+ * @param data
7
+ */
8
+ export declare function prepareForSerialization<T>(data: T): T;
9
9
  //# sourceMappingURL=serializer.d.ts.map
@@ -1,21 +1,21 @@
1
- /**
2
- * Prepare an object for serialization by removing any fields which are undefined
3
- * or functions and return the result. The operation is recursive across all subobjects.
4
- * The original object is not modified.
5
- *
6
- * @param data
7
- */
8
- export function prepareForSerialization(data) {
9
- if (data === undefined || data === null)
10
- return null;
11
- if (data['toJSON'])
12
- data = data['toJSON']();
13
- if (typeof data !== 'object')
14
- return data;
15
- return Object.entries(data)
16
- .filter(x => x[1] !== undefined)
17
- .filter(x => typeof x[1] !== 'function')
18
- .map(x => [x[0], prepareForSerialization(x[1])])
19
- .reduce((o, [k, v]) => (o[k] = v, o), {});
20
- }
1
+ /**
2
+ * Prepare an object for serialization by removing any fields which are undefined
3
+ * or functions and return the result. The operation is recursive across all subobjects.
4
+ * The original object is not modified.
5
+ *
6
+ * @param data
7
+ */
8
+ export function prepareForSerialization(data) {
9
+ if (data === undefined || data === null)
10
+ return null;
11
+ if (data['toJSON'])
12
+ data = data['toJSON']();
13
+ if (typeof data !== 'object')
14
+ return data;
15
+ return Object.entries(data)
16
+ .filter(x => x[1] !== undefined)
17
+ .filter(x => typeof x[1] !== 'function')
18
+ .map(x => [x[0], prepareForSerialization(x[1])])
19
+ .reduce((o, [k, v]) => (o[k] = v, o), {});
20
+ }
21
21
  //# sourceMappingURL=serializer.js.map
@@ -1,3 +1,3 @@
1
- import "reflect-metadata";
2
- import "source-map-support/register";
1
+ import "reflect-metadata";
2
+ import "source-map-support/register";
3
3
  //# sourceMappingURL=test.d.ts.map
@@ -1,10 +1,10 @@
1
- /**
2
- * A DI service to get the current time.
3
- * Useful if you need to mock or redfine
4
- * the concept of "current time"
5
- */
6
- export declare class Time {
7
- now(): number;
8
- current(): Date;
9
- }
1
+ /**
2
+ * A DI service to get the current time.
3
+ * Useful if you need to mock or redfine
4
+ * the concept of "current time"
5
+ */
6
+ export declare class Time {
7
+ now(): number;
8
+ current(): Date;
9
+ }
10
10
  //# sourceMappingURL=time.d.ts.map
package/dist.esm/time.js CHANGED
@@ -1,20 +1,20 @@
1
- import { __decorate } from "tslib";
2
- import { Injectable } from './decorators';
3
- /**
4
- * A DI service to get the current time.
5
- * Useful if you need to mock or redfine
6
- * the concept of "current time"
7
- */
8
- let Time = class Time {
9
- now() {
10
- return Date.now();
11
- }
12
- current() {
13
- return new Date();
14
- }
15
- };
16
- Time = __decorate([
17
- Injectable()
18
- ], Time);
19
- export { Time };
1
+ import { __decorate } from "tslib";
2
+ import { Injectable } from './decorators';
3
+ /**
4
+ * A DI service to get the current time.
5
+ * Useful if you need to mock or redfine
6
+ * the concept of "current time"
7
+ */
8
+ let Time = class Time {
9
+ now() {
10
+ return Date.now();
11
+ }
12
+ current() {
13
+ return new Date();
14
+ }
15
+ };
16
+ Time = __decorate([
17
+ Injectable()
18
+ ], Time);
19
+ export { Time };
20
20
  //# sourceMappingURL=time.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"time.js","sourceRoot":"","sources":["../src/time.ts"],"names":[],"mappings":";AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,cAAc,CAAC;AAE1C;;;;GAIG;AAEI,IAAM,IAAI,GAAV,MAAM,IAAI;IACb,GAAG;QACC,OAAO,IAAI,CAAC,GAAG,EAAE,CAAC;IACtB,CAAC;IAED,OAAO;QACH,OAAO,IAAI,IAAI,EAAE,CAAC;IACtB,CAAC;CACJ,CAAA;AARY,IAAI;IADhB,UAAU,EAAE;GACA,IAAI,CAQhB;SARY,IAAI"}
1
+ {"version":3,"file":"time.js","sourceRoot":"","sources":["../src/time.ts"],"names":[],"mappings":";AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,cAAc,CAAC;AAE1C;;;;GAIG;AAEI,IAAM,IAAI,GAAV,MAAM,IAAI;IACb,GAAG;QACC,OAAO,IAAI,CAAC,GAAG,EAAE,CAAC;IACtB,CAAC;IAED,OAAO;QACH,OAAO,IAAI,IAAI,EAAE,CAAC;IACtB,CAAC;CACJ,CAAA;AARY,IAAI;IADhB,UAAU,EAAE;GACA,IAAI,CAQhB"}
@@ -1,14 +1,14 @@
1
- import { Observable } from 'rxjs';
2
- /**
3
- * Wait a specified amount of time before resolving.
4
- * @param time
5
- */
6
- export declare function timeout(time?: number): Promise<void>;
7
- /**
8
- * Return an observable that fires at regular intervals as long as
9
- * it has subscribers. To stop the interval, remove all subscribers.
10
- *
11
- * @param time
12
- */
13
- export declare function interval(time: number): Observable<void>;
1
+ import { Observable } from 'rxjs';
2
+ /**
3
+ * Wait a specified amount of time before resolving.
4
+ * @param time
5
+ */
6
+ export declare function timeout(time?: number): Promise<void>;
7
+ /**
8
+ * Return an observable that fires at regular intervals as long as
9
+ * it has subscribers. To stop the interval, remove all subscribers.
10
+ *
11
+ * @param time
12
+ */
13
+ export declare function interval(time: number): Observable<void>;
14
14
  //# sourceMappingURL=timeout.d.ts.map