@zthun/helpful-fn 9.11.7 → 9.11.8
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/dist/enum/enum-info.d.mts +87 -0
- package/dist/index.cjs +93 -2
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.mts +1 -0
- package/dist/index.js +93 -3
- package/dist/index.js.map +1 -1
- package/package.json +2 -2
|
@@ -0,0 +1,87 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Information for an enum value.
|
|
3
|
+
*
|
|
4
|
+
* This is useful for front end development when
|
|
5
|
+
* you want to map an enumeration like value to
|
|
6
|
+
* things like a display name, description, and
|
|
7
|
+
* avatar. ECMAScript does not support decorators
|
|
8
|
+
* for literal fields so this is an alternative
|
|
9
|
+
* to describe that kind of information.
|
|
10
|
+
*
|
|
11
|
+
* This is similar to Metadata from helpful-query,
|
|
12
|
+
* but it's much more specific and specialized
|
|
13
|
+
* to enumerations.
|
|
14
|
+
*/
|
|
15
|
+
export interface IZEnumInformation<TEnum> {
|
|
16
|
+
/**
|
|
17
|
+
* The display name of the enum value.
|
|
18
|
+
*/
|
|
19
|
+
name?: string;
|
|
20
|
+
/**
|
|
21
|
+
* The avatar representation of the enum.
|
|
22
|
+
*
|
|
23
|
+
* This can be anything and is contextual of how
|
|
24
|
+
* this object is used.
|
|
25
|
+
*/
|
|
26
|
+
avatar?: any;
|
|
27
|
+
/**
|
|
28
|
+
* The description of the enum value.
|
|
29
|
+
*/
|
|
30
|
+
description?: string;
|
|
31
|
+
/**
|
|
32
|
+
* The value being described.
|
|
33
|
+
*/
|
|
34
|
+
value: TEnum;
|
|
35
|
+
}
|
|
36
|
+
/**
|
|
37
|
+
* Builds information for an enum.
|
|
38
|
+
*/
|
|
39
|
+
export declare class ZEnumInfoBuilder<TEnum> {
|
|
40
|
+
private _metadata;
|
|
41
|
+
/**
|
|
42
|
+
* Initializes a new instance of this object.
|
|
43
|
+
*
|
|
44
|
+
* @param value -
|
|
45
|
+
* The value to initialize with.
|
|
46
|
+
*/
|
|
47
|
+
constructor(value: TEnum);
|
|
48
|
+
/**
|
|
49
|
+
* The display name of the enum.
|
|
50
|
+
*
|
|
51
|
+
* @param name -
|
|
52
|
+
* The display name of the enum.
|
|
53
|
+
*
|
|
54
|
+
* @returns
|
|
55
|
+
* This object.
|
|
56
|
+
*/
|
|
57
|
+
name(name: string): this;
|
|
58
|
+
/**
|
|
59
|
+
* Text description of the enum.
|
|
60
|
+
*
|
|
61
|
+
* @param description -
|
|
62
|
+
* Text description of what the value means.
|
|
63
|
+
*
|
|
64
|
+
* @returns
|
|
65
|
+
* This object.
|
|
66
|
+
*/
|
|
67
|
+
description(description: string): this;
|
|
68
|
+
/**
|
|
69
|
+
* The avatar representation of the enum.
|
|
70
|
+
*
|
|
71
|
+
* @param avatar -
|
|
72
|
+
* The avatar representation of what the value
|
|
73
|
+
* is. This can be anything but should be related
|
|
74
|
+
* to the framework it is being developed for.
|
|
75
|
+
*
|
|
76
|
+
* @returns
|
|
77
|
+
* This object.
|
|
78
|
+
*/
|
|
79
|
+
avatar(avatar: any): this;
|
|
80
|
+
/**
|
|
81
|
+
* Returns a shallow copy of the metadata.
|
|
82
|
+
*
|
|
83
|
+
* @returns
|
|
84
|
+
* A shallow copy of the metadata.
|
|
85
|
+
*/
|
|
86
|
+
build(): IZEnumInformation<TEnum>;
|
|
87
|
+
}
|
package/dist/index.cjs
CHANGED
|
@@ -44,7 +44,7 @@ const dateFns = require('date-fns');
|
|
|
44
44
|
return ZHorizontalAnchor;
|
|
45
45
|
}({});
|
|
46
46
|
|
|
47
|
-
function _define_property$
|
|
47
|
+
function _define_property$7(obj, key, value) {
|
|
48
48
|
if (key in obj) {
|
|
49
49
|
Object.defineProperty(obj, key, {
|
|
50
50
|
value: value,
|
|
@@ -117,7 +117,7 @@ function _define_property$6(obj, key, value) {
|
|
|
117
117
|
/**
|
|
118
118
|
* Initializes a new instance of this object.
|
|
119
119
|
*/ constructor(){
|
|
120
|
-
_define_property$
|
|
120
|
+
_define_property$7(this, "_messages", []);
|
|
121
121
|
}
|
|
122
122
|
}
|
|
123
123
|
|
|
@@ -604,6 +604,96 @@ function _define_property$6(obj, key, value) {
|
|
|
604
604
|
return candidate == null || candidateType === "object" && Object.keys(candidate).length === 0;
|
|
605
605
|
}
|
|
606
606
|
|
|
607
|
+
/**
|
|
608
|
+
* Information for an enum value.
|
|
609
|
+
*
|
|
610
|
+
* This is useful for front end development when
|
|
611
|
+
* you want to map an enumeration like value to
|
|
612
|
+
* things like a display name, description, and
|
|
613
|
+
* avatar. ECMAScript does not support decorators
|
|
614
|
+
* for literal fields so this is an alternative
|
|
615
|
+
* to describe that kind of information.
|
|
616
|
+
*
|
|
617
|
+
* This is similar to Metadata from helpful-query,
|
|
618
|
+
* but it's much more specific and specialized
|
|
619
|
+
* to enumerations.
|
|
620
|
+
*/ function _define_property$6(obj, key, value) {
|
|
621
|
+
if (key in obj) {
|
|
622
|
+
Object.defineProperty(obj, key, {
|
|
623
|
+
value: value,
|
|
624
|
+
enumerable: true,
|
|
625
|
+
configurable: true,
|
|
626
|
+
writable: true
|
|
627
|
+
});
|
|
628
|
+
} else {
|
|
629
|
+
obj[key] = value;
|
|
630
|
+
}
|
|
631
|
+
return obj;
|
|
632
|
+
}
|
|
633
|
+
/**
|
|
634
|
+
* Builds information for an enum.
|
|
635
|
+
*/ class ZEnumInfoBuilder {
|
|
636
|
+
/**
|
|
637
|
+
* The display name of the enum.
|
|
638
|
+
*
|
|
639
|
+
* @param name -
|
|
640
|
+
* The display name of the enum.
|
|
641
|
+
*
|
|
642
|
+
* @returns
|
|
643
|
+
* This object.
|
|
644
|
+
*/ name(name) {
|
|
645
|
+
this._metadata.name = name;
|
|
646
|
+
return this;
|
|
647
|
+
}
|
|
648
|
+
/**
|
|
649
|
+
* Text description of the enum.
|
|
650
|
+
*
|
|
651
|
+
* @param description -
|
|
652
|
+
* Text description of what the value means.
|
|
653
|
+
*
|
|
654
|
+
* @returns
|
|
655
|
+
* This object.
|
|
656
|
+
*/ description(description) {
|
|
657
|
+
this._metadata.description = description;
|
|
658
|
+
return this;
|
|
659
|
+
}
|
|
660
|
+
/**
|
|
661
|
+
* The avatar representation of the enum.
|
|
662
|
+
*
|
|
663
|
+
* @param avatar -
|
|
664
|
+
* The avatar representation of what the value
|
|
665
|
+
* is. This can be anything but should be related
|
|
666
|
+
* to the framework it is being developed for.
|
|
667
|
+
*
|
|
668
|
+
* @returns
|
|
669
|
+
* This object.
|
|
670
|
+
*/ avatar(avatar) {
|
|
671
|
+
this._metadata.avatar = avatar;
|
|
672
|
+
return this;
|
|
673
|
+
}
|
|
674
|
+
/**
|
|
675
|
+
* Returns a shallow copy of the metadata.
|
|
676
|
+
*
|
|
677
|
+
* @returns
|
|
678
|
+
* A shallow copy of the metadata.
|
|
679
|
+
*/ build() {
|
|
680
|
+
return {
|
|
681
|
+
...this._metadata
|
|
682
|
+
};
|
|
683
|
+
}
|
|
684
|
+
/**
|
|
685
|
+
* Initializes a new instance of this object.
|
|
686
|
+
*
|
|
687
|
+
* @param value -
|
|
688
|
+
* The value to initialize with.
|
|
689
|
+
*/ constructor(value){
|
|
690
|
+
_define_property$6(this, "_metadata", void 0);
|
|
691
|
+
this._metadata = {
|
|
692
|
+
value
|
|
693
|
+
};
|
|
694
|
+
}
|
|
695
|
+
}
|
|
696
|
+
|
|
607
697
|
const BYTES_PER_KIBIBYTE = 1024;
|
|
608
698
|
const BYTES_PER_MEBIBYTE = 1048576; // 1024 ^ 2
|
|
609
699
|
const BYTES_PER_GIBIBYTE = 1073741824; // 1024 ^ 3
|
|
@@ -2061,6 +2151,7 @@ exports.ZAssert = ZAssert;
|
|
|
2061
2151
|
exports.ZDateFormats = ZDateFormats;
|
|
2062
2152
|
exports.ZDeserializeJson = ZDeserializeJson;
|
|
2063
2153
|
exports.ZDeserializeTry = ZDeserializeTry;
|
|
2154
|
+
exports.ZEnumInfoBuilder = ZEnumInfoBuilder;
|
|
2064
2155
|
exports.ZHorizontalAnchor = ZHorizontalAnchor;
|
|
2065
2156
|
exports.ZLazy = ZLazy;
|
|
2066
2157
|
exports.ZOrientation = ZOrientation;
|