@alextheman/utility 5.22.0 → 5.23.0

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/index.cjs CHANGED
@@ -1110,6 +1110,27 @@ function omitProperties(object, keysToOmit) {
1110
1110
  return outputObject;
1111
1111
  }
1112
1112
  //#endregion
1113
+ //#region src/root/functions/objectHelpers/pickProperties.ts
1114
+ /**
1115
+ * Picks properties from a given object.
1116
+ *
1117
+ * @category Object Helpers
1118
+ *
1119
+ * @template ObjectType - The type of the input object.
1120
+ * @template KeysToPick - A type representing the keys to pick from the object.
1121
+ *
1122
+ * @param object - The object to pick properties from.
1123
+ * @param keysToPick - The keys to pick from the object. Can either be a single string to pick one, or an array to pick multiple.
1124
+ *
1125
+ * @returns An object with a new reference in memory, with the chosen properties present.
1126
+ */
1127
+ function pickProperties(object, keysToPick) {
1128
+ const keysArray = Array.isArray(keysToPick) ? keysToPick : [keysToPick];
1129
+ const outputObject = {};
1130
+ for (const key of keysArray) outputObject[key] = object[key];
1131
+ return outputObject;
1132
+ }
1133
+ //#endregion
1113
1134
  //#region src/root/functions/objectHelpers/removeUndefinedFromObject.ts
1114
1135
  /**
1115
1136
  * Removes entries whose values are `undefined` from a given object (not including null etc.).
@@ -2078,6 +2099,7 @@ exports.parseUUID = parseUUID;
2078
2099
  exports.parseVersionType = parseVersionType;
2079
2100
  exports.parseZodSchema = parseZodSchema;
2080
2101
  exports.parseZodSchemaAsync = parseZodSchemaAsync;
2102
+ exports.pickProperties = pickProperties;
2081
2103
  exports.randomiseArray = randomiseArray;
2082
2104
  exports.range = range;
2083
2105
  exports.removeDuplicates = removeDuplicates;
package/dist/index.d.cts CHANGED
@@ -732,6 +732,22 @@ declare function getRecordKeys<InputRecordType extends Record<PropertyKey, unkno
732
732
  */
733
733
  declare function omitProperties<ObjectType extends object, KeysToOmit extends keyof ObjectType>(object: ObjectType, keysToOmit: KeysToOmit | ReadonlyArray<KeysToOmit>): Omit<ObjectType, KeysToOmit>;
734
734
  //#endregion
735
+ //#region src/root/functions/objectHelpers/pickProperties.d.ts
736
+ /**
737
+ * Picks properties from a given object.
738
+ *
739
+ * @category Object Helpers
740
+ *
741
+ * @template ObjectType - The type of the input object.
742
+ * @template KeysToPick - A type representing the keys to pick from the object.
743
+ *
744
+ * @param object - The object to pick properties from.
745
+ * @param keysToPick - The keys to pick from the object. Can either be a single string to pick one, or an array to pick multiple.
746
+ *
747
+ * @returns An object with a new reference in memory, with the chosen properties present.
748
+ */
749
+ declare function pickProperties<ObjectType extends object, KeysToPick extends keyof ObjectType>(object: ObjectType, keysToPick: KeysToPick | ReadonlyArray<KeysToPick>): Pick<ObjectType, KeysToPick>;
750
+ //#endregion
735
751
  //#region src/root/functions/objectHelpers/removeUndefinedFromObject.d.ts
736
752
  type RemoveUndefined<RecordType extends Record<PropertyKey, unknown>> = { [Key in keyof RecordType]: Exclude<RecordType[Key], undefined> };
737
753
  /**
@@ -1467,4 +1483,4 @@ interface ZodParsingErrorData {
1467
1483
  issues: Array<z.core.$ZodIssue>;
1468
1484
  }
1469
1485
  //#endregion
1470
- export { APIError, type ArrayElement, type CallReturnType, type CamelToKebabOptions, type CreateEnumType, type CreateFormDataOptions, type CreateFormDataOptionsNullableResolution, type CreateFormDataOptionsUndefinedOrNullResolution, DataError, type DisallowUndefined, Env, FILE_PATH_PATTERN, FILE_PATH_REGEX, type FormDataArrayResolutionStrategy, type FormDataNullableResolutionStrategy, type HTTPErrorCode, type IgnoreCase, type IsTypeArgumentString, type KebabToCamelOptions, type NonNull, type NonUndefined, type NormaliseIndentsFunction, type NormaliseIndentsOptions, type NormalizeIndentsFunction, type NormalizeIndentsOptions, type NullableOnCondition, ONE_DAY_IN_MILLISECONDS, type OptionalOnCondition, type ParallelTuple, type RecordKey, type RemoveUndefined, SortDirection, type StringListToArrayOptions, type ToTitleCaseOptions, UUID_PATTERN, UUID_REGEX, VERSION_NUMBER_PATTERN, VERSION_NUMBER_REGEX, VersionNumber, type FormatOptionsBase as VersionNumberToStringOptions, VersionType, type ZodParsingErrorData, addDaysToDate, appendSemicolon, assertNotNull, assertNotNullable, assertNotUndefined, az, calculateMonthlyDifference, camelToKebab, containsKeys, convertFileToBase64, createFormData, createTemplateStringsArray, deepCopy, deepFreeze, escapeHTML, escapeRegexPattern, fillArray, formatDateAndTime, getRandomNumber, getRecordKeys, getStringsAndInterpolations, httpErrorCodeLookup, identity, interpolate, interpolateObjects, isAnniversary, isLeapYear, isMonthlyMultiple, isNonNullableObject, isOrdered, isSameDate, isTemplateStringsArray, kebabToCamel, normaliseIndents, normalizeIndents, objectContainsKeys, omitProperties, paralleliseArrays, parseBoolean, parseEnv, parseFormData, parseIntStrict, parseUUID, parseVersionType, parseZodSchema, parseZodSchemaAsync, randomiseArray, range, removeDuplicates, removeUndefinedFromObject, sayHello, sortBy, stringListToArray, stringifyDotenv, toTitleCase, truncate, wait, zodVersionNumber };
1486
+ export { APIError, type ArrayElement, type CallReturnType, type CamelToKebabOptions, type CreateEnumType, type CreateFormDataOptions, type CreateFormDataOptionsNullableResolution, type CreateFormDataOptionsUndefinedOrNullResolution, DataError, type DisallowUndefined, Env, FILE_PATH_PATTERN, FILE_PATH_REGEX, type FormDataArrayResolutionStrategy, type FormDataNullableResolutionStrategy, type HTTPErrorCode, type IgnoreCase, type IsTypeArgumentString, type KebabToCamelOptions, type NonNull, type NonUndefined, type NormaliseIndentsFunction, type NormaliseIndentsOptions, type NormalizeIndentsFunction, type NormalizeIndentsOptions, type NullableOnCondition, ONE_DAY_IN_MILLISECONDS, type OptionalOnCondition, type ParallelTuple, type RecordKey, type RemoveUndefined, SortDirection, type StringListToArrayOptions, type ToTitleCaseOptions, UUID_PATTERN, UUID_REGEX, VERSION_NUMBER_PATTERN, VERSION_NUMBER_REGEX, VersionNumber, type FormatOptionsBase as VersionNumberToStringOptions, VersionType, type ZodParsingErrorData, addDaysToDate, appendSemicolon, assertNotNull, assertNotNullable, assertNotUndefined, az, calculateMonthlyDifference, camelToKebab, containsKeys, convertFileToBase64, createFormData, createTemplateStringsArray, deepCopy, deepFreeze, escapeHTML, escapeRegexPattern, fillArray, formatDateAndTime, getRandomNumber, getRecordKeys, getStringsAndInterpolations, httpErrorCodeLookup, identity, interpolate, interpolateObjects, isAnniversary, isLeapYear, isMonthlyMultiple, isNonNullableObject, isOrdered, isSameDate, isTemplateStringsArray, kebabToCamel, normaliseIndents, normalizeIndents, objectContainsKeys, omitProperties, paralleliseArrays, parseBoolean, parseEnv, parseFormData, parseIntStrict, parseUUID, parseVersionType, parseZodSchema, parseZodSchemaAsync, pickProperties, randomiseArray, range, removeDuplicates, removeUndefinedFromObject, sayHello, sortBy, stringListToArray, stringifyDotenv, toTitleCase, truncate, wait, zodVersionNumber };
package/dist/index.d.ts CHANGED
@@ -732,6 +732,22 @@ declare function getRecordKeys<InputRecordType extends Record<PropertyKey, unkno
732
732
  */
733
733
  declare function omitProperties<ObjectType extends object, KeysToOmit extends keyof ObjectType>(object: ObjectType, keysToOmit: KeysToOmit | ReadonlyArray<KeysToOmit>): Omit<ObjectType, KeysToOmit>;
734
734
  //#endregion
735
+ //#region src/root/functions/objectHelpers/pickProperties.d.ts
736
+ /**
737
+ * Picks properties from a given object.
738
+ *
739
+ * @category Object Helpers
740
+ *
741
+ * @template ObjectType - The type of the input object.
742
+ * @template KeysToPick - A type representing the keys to pick from the object.
743
+ *
744
+ * @param object - The object to pick properties from.
745
+ * @param keysToPick - The keys to pick from the object. Can either be a single string to pick one, or an array to pick multiple.
746
+ *
747
+ * @returns An object with a new reference in memory, with the chosen properties present.
748
+ */
749
+ declare function pickProperties<ObjectType extends object, KeysToPick extends keyof ObjectType>(object: ObjectType, keysToPick: KeysToPick | ReadonlyArray<KeysToPick>): Pick<ObjectType, KeysToPick>;
750
+ //#endregion
735
751
  //#region src/root/functions/objectHelpers/removeUndefinedFromObject.d.ts
736
752
  type RemoveUndefined<RecordType extends Record<PropertyKey, unknown>> = { [Key in keyof RecordType]: Exclude<RecordType[Key], undefined> };
737
753
  /**
@@ -1467,4 +1483,4 @@ interface ZodParsingErrorData {
1467
1483
  issues: Array<z$1.core.$ZodIssue>;
1468
1484
  }
1469
1485
  //#endregion
1470
- export { APIError, type ArrayElement, type CallReturnType, type CamelToKebabOptions, type CreateEnumType, type CreateFormDataOptions, type CreateFormDataOptionsNullableResolution, type CreateFormDataOptionsUndefinedOrNullResolution, DataError, type DisallowUndefined, Env, FILE_PATH_PATTERN, FILE_PATH_REGEX, type FormDataArrayResolutionStrategy, type FormDataNullableResolutionStrategy, type HTTPErrorCode, type IgnoreCase, type IsTypeArgumentString, type KebabToCamelOptions, type NonNull, type NonUndefined, type NormaliseIndentsFunction, type NormaliseIndentsOptions, type NormalizeIndentsFunction, type NormalizeIndentsOptions, type NullableOnCondition, ONE_DAY_IN_MILLISECONDS, type OptionalOnCondition, type ParallelTuple, type RecordKey, type RemoveUndefined, SortDirection, type StringListToArrayOptions, type ToTitleCaseOptions, UUID_PATTERN, UUID_REGEX, VERSION_NUMBER_PATTERN, VERSION_NUMBER_REGEX, VersionNumber, type FormatOptionsBase as VersionNumberToStringOptions, VersionType, type ZodParsingErrorData, addDaysToDate, appendSemicolon, assertNotNull, assertNotNullable, assertNotUndefined, az, calculateMonthlyDifference, camelToKebab, containsKeys, convertFileToBase64, createFormData, createTemplateStringsArray, deepCopy, deepFreeze, escapeHTML, escapeRegexPattern, fillArray, formatDateAndTime, getRandomNumber, getRecordKeys, getStringsAndInterpolations, httpErrorCodeLookup, identity, interpolate, interpolateObjects, isAnniversary, isLeapYear, isMonthlyMultiple, isNonNullableObject, isOrdered, isSameDate, isTemplateStringsArray, kebabToCamel, normaliseIndents, normalizeIndents, objectContainsKeys, omitProperties, paralleliseArrays, parseBoolean, parseEnv, parseFormData, parseIntStrict, parseUUID, parseVersionType, parseZodSchema, parseZodSchemaAsync, randomiseArray, range, removeDuplicates, removeUndefinedFromObject, sayHello, sortBy, stringListToArray, stringifyDotenv, toTitleCase, truncate, wait, zodVersionNumber };
1486
+ export { APIError, type ArrayElement, type CallReturnType, type CamelToKebabOptions, type CreateEnumType, type CreateFormDataOptions, type CreateFormDataOptionsNullableResolution, type CreateFormDataOptionsUndefinedOrNullResolution, DataError, type DisallowUndefined, Env, FILE_PATH_PATTERN, FILE_PATH_REGEX, type FormDataArrayResolutionStrategy, type FormDataNullableResolutionStrategy, type HTTPErrorCode, type IgnoreCase, type IsTypeArgumentString, type KebabToCamelOptions, type NonNull, type NonUndefined, type NormaliseIndentsFunction, type NormaliseIndentsOptions, type NormalizeIndentsFunction, type NormalizeIndentsOptions, type NullableOnCondition, ONE_DAY_IN_MILLISECONDS, type OptionalOnCondition, type ParallelTuple, type RecordKey, type RemoveUndefined, SortDirection, type StringListToArrayOptions, type ToTitleCaseOptions, UUID_PATTERN, UUID_REGEX, VERSION_NUMBER_PATTERN, VERSION_NUMBER_REGEX, VersionNumber, type FormatOptionsBase as VersionNumberToStringOptions, VersionType, type ZodParsingErrorData, addDaysToDate, appendSemicolon, assertNotNull, assertNotNullable, assertNotUndefined, az, calculateMonthlyDifference, camelToKebab, containsKeys, convertFileToBase64, createFormData, createTemplateStringsArray, deepCopy, deepFreeze, escapeHTML, escapeRegexPattern, fillArray, formatDateAndTime, getRandomNumber, getRecordKeys, getStringsAndInterpolations, httpErrorCodeLookup, identity, interpolate, interpolateObjects, isAnniversary, isLeapYear, isMonthlyMultiple, isNonNullableObject, isOrdered, isSameDate, isTemplateStringsArray, kebabToCamel, normaliseIndents, normalizeIndents, objectContainsKeys, omitProperties, paralleliseArrays, parseBoolean, parseEnv, parseFormData, parseIntStrict, parseUUID, parseVersionType, parseZodSchema, parseZodSchemaAsync, pickProperties, randomiseArray, range, removeDuplicates, removeUndefinedFromObject, sayHello, sortBy, stringListToArray, stringifyDotenv, toTitleCase, truncate, wait, zodVersionNumber };
package/dist/index.js CHANGED
@@ -1086,6 +1086,27 @@ function omitProperties(object, keysToOmit) {
1086
1086
  return outputObject;
1087
1087
  }
1088
1088
  //#endregion
1089
+ //#region src/root/functions/objectHelpers/pickProperties.ts
1090
+ /**
1091
+ * Picks properties from a given object.
1092
+ *
1093
+ * @category Object Helpers
1094
+ *
1095
+ * @template ObjectType - The type of the input object.
1096
+ * @template KeysToPick - A type representing the keys to pick from the object.
1097
+ *
1098
+ * @param object - The object to pick properties from.
1099
+ * @param keysToPick - The keys to pick from the object. Can either be a single string to pick one, or an array to pick multiple.
1100
+ *
1101
+ * @returns An object with a new reference in memory, with the chosen properties present.
1102
+ */
1103
+ function pickProperties(object, keysToPick) {
1104
+ const keysArray = Array.isArray(keysToPick) ? keysToPick : [keysToPick];
1105
+ const outputObject = {};
1106
+ for (const key of keysArray) outputObject[key] = object[key];
1107
+ return outputObject;
1108
+ }
1109
+ //#endregion
1089
1110
  //#region src/root/functions/objectHelpers/removeUndefinedFromObject.ts
1090
1111
  /**
1091
1112
  * Removes entries whose values are `undefined` from a given object (not including null etc.).
@@ -1995,4 +2016,4 @@ var DataError = class DataError extends Error {
1995
2016
  }
1996
2017
  };
1997
2018
  //#endregion
1998
- export { APIError, DataError, Env, FILE_PATH_PATTERN, FILE_PATH_REGEX, ONE_DAY_IN_MILLISECONDS, SortDirection, UUID_PATTERN, UUID_REGEX, VERSION_NUMBER_PATTERN, VERSION_NUMBER_REGEX, VersionNumber, VersionType, addDaysToDate, appendSemicolon, assertNotNull, assertNotNullable, assertNotUndefined, az, calculateMonthlyDifference, camelToKebab, containsKeys, convertFileToBase64, createFormData, createTemplateStringsArray, deepCopy, deepFreeze, escapeHTML, escapeRegexPattern, fillArray, formatDateAndTime, getRandomNumber, getRecordKeys, getStringsAndInterpolations, httpErrorCodeLookup, identity, interpolate, interpolateObjects, isAnniversary, isLeapYear, isMonthlyMultiple, isNonNullableObject, isOrdered, isSameDate, isTemplateStringsArray, kebabToCamel, normaliseIndents, normalizeIndents, objectContainsKeys, omitProperties, paralleliseArrays, parseBoolean, parseEnv, parseFormData, parseIntStrict, parseUUID, parseVersionType, parseZodSchema, parseZodSchemaAsync, randomiseArray, range, removeDuplicates, removeUndefinedFromObject, sayHello, sortBy, stringListToArray, stringifyDotenv, toTitleCase, truncate, wait, zodVersionNumber };
2019
+ export { APIError, DataError, Env, FILE_PATH_PATTERN, FILE_PATH_REGEX, ONE_DAY_IN_MILLISECONDS, SortDirection, UUID_PATTERN, UUID_REGEX, VERSION_NUMBER_PATTERN, VERSION_NUMBER_REGEX, VersionNumber, VersionType, addDaysToDate, appendSemicolon, assertNotNull, assertNotNullable, assertNotUndefined, az, calculateMonthlyDifference, camelToKebab, containsKeys, convertFileToBase64, createFormData, createTemplateStringsArray, deepCopy, deepFreeze, escapeHTML, escapeRegexPattern, fillArray, formatDateAndTime, getRandomNumber, getRecordKeys, getStringsAndInterpolations, httpErrorCodeLookup, identity, interpolate, interpolateObjects, isAnniversary, isLeapYear, isMonthlyMultiple, isNonNullableObject, isOrdered, isSameDate, isTemplateStringsArray, kebabToCamel, normaliseIndents, normalizeIndents, objectContainsKeys, omitProperties, paralleliseArrays, parseBoolean, parseEnv, parseFormData, parseIntStrict, parseUUID, parseVersionType, parseZodSchema, parseZodSchemaAsync, pickProperties, randomiseArray, range, removeDuplicates, removeUndefinedFromObject, sayHello, sortBy, stringListToArray, stringifyDotenv, toTitleCase, truncate, wait, zodVersionNumber };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@alextheman/utility",
3
- "version": "5.22.0",
3
+ "version": "5.23.0",
4
4
  "description": "Helpful utility functions.",
5
5
  "repository": {
6
6
  "type": "git",