@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
package/dist/index.js
CHANGED
|
@@ -40,7 +40,7 @@ import { startOfToday, parse, formatDate } from 'date-fns';
|
|
|
40
40
|
return ZHorizontalAnchor;
|
|
41
41
|
}({});
|
|
42
42
|
|
|
43
|
-
function _define_property$
|
|
43
|
+
function _define_property$7(obj, key, value) {
|
|
44
44
|
if (key in obj) {
|
|
45
45
|
Object.defineProperty(obj, key, {
|
|
46
46
|
value: value,
|
|
@@ -113,7 +113,7 @@ function _define_property$6(obj, key, value) {
|
|
|
113
113
|
/**
|
|
114
114
|
* Initializes a new instance of this object.
|
|
115
115
|
*/ constructor(){
|
|
116
|
-
_define_property$
|
|
116
|
+
_define_property$7(this, "_messages", []);
|
|
117
117
|
}
|
|
118
118
|
}
|
|
119
119
|
|
|
@@ -600,6 +600,96 @@ function _define_property$6(obj, key, value) {
|
|
|
600
600
|
return candidate == null || candidateType === "object" && Object.keys(candidate).length === 0;
|
|
601
601
|
}
|
|
602
602
|
|
|
603
|
+
/**
|
|
604
|
+
* Information for an enum value.
|
|
605
|
+
*
|
|
606
|
+
* This is useful for front end development when
|
|
607
|
+
* you want to map an enumeration like value to
|
|
608
|
+
* things like a display name, description, and
|
|
609
|
+
* avatar. ECMAScript does not support decorators
|
|
610
|
+
* for literal fields so this is an alternative
|
|
611
|
+
* to describe that kind of information.
|
|
612
|
+
*
|
|
613
|
+
* This is similar to Metadata from helpful-query,
|
|
614
|
+
* but it's much more specific and specialized
|
|
615
|
+
* to enumerations.
|
|
616
|
+
*/ function _define_property$6(obj, key, value) {
|
|
617
|
+
if (key in obj) {
|
|
618
|
+
Object.defineProperty(obj, key, {
|
|
619
|
+
value: value,
|
|
620
|
+
enumerable: true,
|
|
621
|
+
configurable: true,
|
|
622
|
+
writable: true
|
|
623
|
+
});
|
|
624
|
+
} else {
|
|
625
|
+
obj[key] = value;
|
|
626
|
+
}
|
|
627
|
+
return obj;
|
|
628
|
+
}
|
|
629
|
+
/**
|
|
630
|
+
* Builds information for an enum.
|
|
631
|
+
*/ class ZEnumInfoBuilder {
|
|
632
|
+
/**
|
|
633
|
+
* The display name of the enum.
|
|
634
|
+
*
|
|
635
|
+
* @param name -
|
|
636
|
+
* The display name of the enum.
|
|
637
|
+
*
|
|
638
|
+
* @returns
|
|
639
|
+
* This object.
|
|
640
|
+
*/ name(name) {
|
|
641
|
+
this._metadata.name = name;
|
|
642
|
+
return this;
|
|
643
|
+
}
|
|
644
|
+
/**
|
|
645
|
+
* Text description of the enum.
|
|
646
|
+
*
|
|
647
|
+
* @param description -
|
|
648
|
+
* Text description of what the value means.
|
|
649
|
+
*
|
|
650
|
+
* @returns
|
|
651
|
+
* This object.
|
|
652
|
+
*/ description(description) {
|
|
653
|
+
this._metadata.description = description;
|
|
654
|
+
return this;
|
|
655
|
+
}
|
|
656
|
+
/**
|
|
657
|
+
* The avatar representation of the enum.
|
|
658
|
+
*
|
|
659
|
+
* @param avatar -
|
|
660
|
+
* The avatar representation of what the value
|
|
661
|
+
* is. This can be anything but should be related
|
|
662
|
+
* to the framework it is being developed for.
|
|
663
|
+
*
|
|
664
|
+
* @returns
|
|
665
|
+
* This object.
|
|
666
|
+
*/ avatar(avatar) {
|
|
667
|
+
this._metadata.avatar = avatar;
|
|
668
|
+
return this;
|
|
669
|
+
}
|
|
670
|
+
/**
|
|
671
|
+
* Returns a shallow copy of the metadata.
|
|
672
|
+
*
|
|
673
|
+
* @returns
|
|
674
|
+
* A shallow copy of the metadata.
|
|
675
|
+
*/ build() {
|
|
676
|
+
return {
|
|
677
|
+
...this._metadata
|
|
678
|
+
};
|
|
679
|
+
}
|
|
680
|
+
/**
|
|
681
|
+
* Initializes a new instance of this object.
|
|
682
|
+
*
|
|
683
|
+
* @param value -
|
|
684
|
+
* The value to initialize with.
|
|
685
|
+
*/ constructor(value){
|
|
686
|
+
_define_property$6(this, "_metadata", void 0);
|
|
687
|
+
this._metadata = {
|
|
688
|
+
value
|
|
689
|
+
};
|
|
690
|
+
}
|
|
691
|
+
}
|
|
692
|
+
|
|
603
693
|
const BYTES_PER_KIBIBYTE = 1024;
|
|
604
694
|
const BYTES_PER_MEBIBYTE = 1048576; // 1024 ^ 2
|
|
605
695
|
const BYTES_PER_GIBIBYTE = 1073741824; // 1024 ^ 3
|
|
@@ -2052,5 +2142,5 @@ function _define_property(obj, key, value) {
|
|
|
2052
2142
|
return tryFallback(()=>JSON.parse(buffer), fallback);
|
|
2053
2143
|
}
|
|
2054
2144
|
|
|
2055
|
-
export { $global, ZAssert, ZDateFormats, ZDeserializeJson, ZDeserializeTry, ZHorizontalAnchor, ZLazy, ZOrientation, ZQuadrilateralBuilder, ZQuadrilateralCornersBuilder, ZRectangle, ZSerializeJson, ZVerticalAnchor, bash, castEnum, castExtension, castNumber, commaJoinDefined, countBuckets, createError, createGuid, css, cssJoinDefined, culture, cultures, detokenize, firstDefined, firstTruthy, firstWhere, formatDateTime, gib, gibibytes, guessDateTime, html, isEmptyObject, isEnum, javascript, joinDefined, js, kib, kibibytes, markdown, md, mebibytes, mib, optional, parseDateTime, pebibytes, peel, peelBetween, pib, pickBy, pickDataAttributes, pickDefined, pickEvents, pipeJoinDefined, purge, required, semiColonJoinDefined, setFirst, sh, sleep, spaceJoinDefined, tag, tebibytes, tib, timeZones, tryFallback, tryFallbackAsync, tryJsonParse, ts, typescript, userTimeZone, zsh };
|
|
2145
|
+
export { $global, ZAssert, ZDateFormats, ZDeserializeJson, ZDeserializeTry, ZEnumInfoBuilder, ZHorizontalAnchor, ZLazy, ZOrientation, ZQuadrilateralBuilder, ZQuadrilateralCornersBuilder, ZRectangle, ZSerializeJson, ZVerticalAnchor, bash, castEnum, castExtension, castNumber, commaJoinDefined, countBuckets, createError, createGuid, css, cssJoinDefined, culture, cultures, detokenize, firstDefined, firstTruthy, firstWhere, formatDateTime, gib, gibibytes, guessDateTime, html, isEmptyObject, isEnum, javascript, joinDefined, js, kib, kibibytes, markdown, md, mebibytes, mib, optional, parseDateTime, pebibytes, peel, peelBetween, pib, pickBy, pickDataAttributes, pickDefined, pickEvents, pipeJoinDefined, purge, required, semiColonJoinDefined, setFirst, sh, sleep, spaceJoinDefined, tag, tebibytes, tib, timeZones, tryFallback, tryFallbackAsync, tryJsonParse, ts, typescript, userTimeZone, zsh };
|
|
2056
2146
|
//# sourceMappingURL=index.js.map
|