@hichchi/utils 0.0.1-alpha.1 → 0.0.1-beta.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.
Files changed (103) hide show
  1. package/CHANGELOG.md +5 -1
  2. package/README.md +6239 -1031
  3. package/package.json +1 -1
  4. package/readme-top.md +182 -6
  5. package/src/lib/constants/constants.d.ts +223 -0
  6. package/src/lib/constants/constants.js +227 -0
  7. package/src/lib/constants/constants.js.map +1 -0
  8. package/src/lib/constants/english-inflection-rules.d.ts +53 -0
  9. package/src/lib/constants/english-inflection-rules.js +360 -0
  10. package/src/lib/constants/english-inflection-rules.js.map +1 -0
  11. package/src/lib/constants/index.d.ts +2 -0
  12. package/src/lib/constants/index.js +6 -0
  13. package/src/lib/constants/index.js.map +1 -0
  14. package/src/lib/enums/index.d.ts +1 -0
  15. package/src/lib/enums/index.js +5 -0
  16. package/src/lib/enums/index.js.map +1 -0
  17. package/src/lib/enums/template-tag.enum.d.ts +33 -0
  18. package/src/lib/enums/template-tag.enum.js +39 -0
  19. package/src/lib/enums/template-tag.enum.js.map +1 -0
  20. package/src/lib/index.d.ts +3 -5
  21. package/src/lib/index.js +3 -5
  22. package/src/lib/index.js.map +1 -1
  23. package/src/lib/interfaces/index.d.ts +3 -0
  24. package/src/lib/interfaces/index.js +7 -0
  25. package/src/lib/interfaces/index.js.map +1 -0
  26. package/src/lib/interfaces/infinite-object.interface.d.ts +45 -0
  27. package/src/lib/interfaces/infinite-object.interface.js +3 -0
  28. package/src/lib/interfaces/infinite-object.interface.js.map +1 -0
  29. package/src/lib/interfaces/inflection-rule.interfaces.d.ts +142 -0
  30. package/src/lib/interfaces/inflection-rule.interfaces.js +3 -0
  31. package/src/lib/interfaces/inflection-rule.interfaces.js.map +1 -0
  32. package/src/lib/interfaces/path-value-set.interface.d.ts +79 -0
  33. package/src/lib/interfaces/path-value-set.interface.js +3 -0
  34. package/src/lib/interfaces/path-value-set.interface.js.map +1 -0
  35. package/src/lib/types/deep-partial.type.d.ts +47 -0
  36. package/src/lib/types/deep-partial.type.js +3 -0
  37. package/src/lib/types/deep-partial.type.js.map +1 -0
  38. package/src/lib/types/index.d.ts +34 -0
  39. package/src/lib/types/index.js +38 -0
  40. package/src/lib/types/index.js.map +1 -0
  41. package/src/lib/types/is-already-in-path.type.d.ts +24 -0
  42. package/src/lib/types/is-already-in-path.type.js +3 -0
  43. package/src/lib/types/is-already-in-path.type.js.map +1 -0
  44. package/src/lib/types/is-empty.type.d.ts +25 -0
  45. package/src/lib/types/is-empty.type.js +3 -0
  46. package/src/lib/types/is-empty.type.js.map +1 -0
  47. package/src/lib/types/is-primitive.type.d.ts +27 -0
  48. package/src/lib/types/is-primitive.type.js +4 -0
  49. package/src/lib/types/is-primitive.type.js.map +1 -0
  50. package/src/lib/types/literal-object.type.d.ts +49 -0
  51. package/src/lib/types/literal-object.type.js +3 -0
  52. package/src/lib/types/literal-object.type.js.map +1 -0
  53. package/src/lib/{types.d.ts → types/loose-autocomplete.type.d.ts} +18 -6
  54. package/src/lib/types/loose-autocomplete.type.js +3 -0
  55. package/src/lib/types/loose-autocomplete.type.js.map +1 -0
  56. package/src/lib/types/partial-with-null.type.d.ts +27 -0
  57. package/src/lib/types/partial-with-null.type.js +3 -0
  58. package/src/lib/types/partial-with-null.type.js.map +1 -0
  59. package/src/lib/types/prettify.type.d.ts +23 -0
  60. package/src/lib/types/prettify.type.js +3 -0
  61. package/src/lib/types/prettify.type.js.map +1 -0
  62. package/src/lib/types/type.type.d.ts +21 -0
  63. package/src/lib/{interfaces.js → types/type.type.js} +1 -1
  64. package/src/lib/types/type.type.js.map +1 -0
  65. package/src/lib/utils/assertions.utils.d.ts +150 -0
  66. package/src/lib/utils/assertions.utils.js +163 -0
  67. package/src/lib/utils/assertions.utils.js.map +1 -0
  68. package/src/lib/utils/file.utils.d.ts +87 -0
  69. package/src/lib/{file.utils.js → utils/file.utils.js} +78 -26
  70. package/src/lib/utils/file.utils.js.map +1 -0
  71. package/src/lib/utils/index.d.ts +5 -0
  72. package/src/lib/utils/index.js +9 -0
  73. package/src/lib/utils/index.js.map +1 -0
  74. package/src/lib/utils/object.utils.d.ts +912 -0
  75. package/src/lib/utils/object.utils.js +1069 -0
  76. package/src/lib/utils/object.utils.js.map +1 -0
  77. package/src/lib/utils/string-template.utils.d.ts +169 -0
  78. package/src/lib/utils/string-template.utils.js +269 -0
  79. package/src/lib/utils/string-template.utils.js.map +1 -0
  80. package/src/lib/utils/string.utils.d.ts +932 -0
  81. package/src/lib/utils/string.utils.js +1255 -0
  82. package/src/lib/utils/string.utils.js.map +1 -0
  83. package/src/lib/utils/url.utils.d.ts +101 -0
  84. package/src/lib/utils/url.utils.js +114 -0
  85. package/src/lib/utils/url.utils.js.map +1 -0
  86. package/src/lib/assertions.utils.d.ts +0 -55
  87. package/src/lib/assertions.utils.js +0 -68
  88. package/src/lib/assertions.utils.js.map +0 -1
  89. package/src/lib/file.utils.d.ts +0 -25
  90. package/src/lib/file.utils.js.map +0 -1
  91. package/src/lib/interfaces.d.ts +0 -6
  92. package/src/lib/interfaces.js.map +0 -1
  93. package/src/lib/object.utils.d.ts +0 -265
  94. package/src/lib/object.utils.js +0 -414
  95. package/src/lib/object.utils.js.map +0 -1
  96. package/src/lib/string-template.utils.d.ts +0 -25
  97. package/src/lib/string-template.utils.js +0 -40
  98. package/src/lib/string-template.utils.js.map +0 -1
  99. package/src/lib/string.utils.d.ts +0 -217
  100. package/src/lib/string.utils.js +0 -314
  101. package/src/lib/string.utils.js.map +0 -1
  102. package/src/lib/types.js +0 -4
  103. package/src/lib/types.js.map +0 -1
@@ -0,0 +1,142 @@
1
+ /**
2
+ * Rule type for word inflection transformation
3
+ *
4
+ * This interface defines the structure of a single inflection rule, which consists of:
5
+ * - A regular expression pattern to match words that the rule applies to
6
+ * - A replacement string or function to transform the matched word
7
+ *
8
+ * The replacement can be either a static string with capture group references
9
+ * (e.g., "$1s") or a function that takes the matched string and returns the
10
+ * transformed version.
11
+ *
12
+ * @example
13
+ * ```typescript
14
+ * // Simple string replacement rule (add 's' to the end)
15
+ * const pluralRule: InflectionRule = {
16
+ * regex: /(.*)$/i,
17
+ * replacement: "$1s"
18
+ * };
19
+ *
20
+ * // Function-based replacement rule
21
+ * const singularRule: InflectionRule = {
22
+ * regex: /(buses|dishes|matches)$/i,
23
+ * replacement: (match: string): string => match.slice(0, -2)
24
+ * };
25
+ * ```
26
+ *
27
+ * @see {@link PluralSingularRulePair} Interface that uses InflectionRule for rule pairs
28
+ * @see {@link EnglishInflectionRules} Constant that implements these rules
29
+ */
30
+ export interface InflectionRule {
31
+ /**
32
+ * Regular expression pattern to match words this rule applies to
33
+ */
34
+ regex: RegExp;
35
+ /**
36
+ * Replacement string with capture group references or function to transform the matched word
37
+ */
38
+ replacement: string | ((match: string) => string);
39
+ }
40
+ /**
41
+ * Pair of rule sets for bidirectional singular/plural transformations
42
+ *
43
+ * This interface defines a pair of rule sets for transforming words between
44
+ * singular and plural forms:
45
+ * - toPlural: Rules for converting singular words to plural form
46
+ * - toSingular: Rules for converting plural words to singular form
47
+ *
48
+ * Each rule set is an array of InflectionRule objects that are applied in order
49
+ * until a matching rule is found.
50
+ *
51
+ * @example
52
+ * ```typescript
53
+ * // Rule pair for words ending in -y
54
+ * const yRules: PluralSingularRulePair = {
55
+ * toPlural: [
56
+ * { regex: /([^aeiou])y$/i, replacement: "$1ies" }, // city -> cities
57
+ * { regex: /([aeiou]y)$/i, replacement: "$1s" } // boy -> boys
58
+ * ],
59
+ * toSingular: [
60
+ * { regex: /([^aeiou])ies$/i, replacement: "$1y" } // cities -> city
61
+ * ]
62
+ * };
63
+ * ```
64
+ *
65
+ * @see {@link InflectionRule} Interface for individual transformation rules
66
+ * @see {@link InflectionRuleCategories} Interface that uses PluralSingularRulePair for categories
67
+ */
68
+ export interface PluralSingularRulePair {
69
+ /**
70
+ * Array of rules for converting singular words to plural form
71
+ */
72
+ toPlural: InflectionRule[];
73
+ /**
74
+ * Array of rules for converting plural words to singular form
75
+ */
76
+ toSingular: InflectionRule[];
77
+ }
78
+ /**
79
+ * Categories of English inflection rules
80
+ *
81
+ * This interface defines the structure for organizing English inflection rules
82
+ * into linguistic categories. Each category represents a different type of
83
+ * inflection pattern in English:
84
+ *
85
+ * - INVARIANT: Words that are the same in singular and plural form (e.g., "fish", "sheep")
86
+ * - IRREGULAR: Words with irregular plural forms (e.g., "child/children", "man/men")
87
+ * - LATIN_GREEK: Words borrowed from Latin and Greek (e.g., "cactus/cacti", "analysis/analyses")
88
+ * - PATTERN_RULES: Words with specific ending patterns (e.g., words ending in -y, -f, -o)
89
+ * - DEFAULT: Default rules for standard transformations (adding/removing 's')
90
+ *
91
+ * Rules are typically applied in the order listed above, from most specific to most general.
92
+ *
93
+ * @example
94
+ * ```typescript
95
+ * // Using the categories in a word inflection function
96
+ * function plural(word: string): string {
97
+ * // Combine all rules in priority order
98
+ * const rules: InflectionRule[] = [
99
+ * ...EnglishInflectionRules.INVARIANT,
100
+ * ...EnglishInflectionRules.IRREGULAR.toPlural,
101
+ * ...EnglishInflectionRules.LATIN_GREEK.toPlural,
102
+ * ...EnglishInflectionRules.PATTERN_RULES.toPlural,
103
+ * ...EnglishInflectionRules.DEFAULT.toPlural,
104
+ * ];
105
+ *
106
+ * // Apply the first matching rule
107
+ * for (const rule of rules) {
108
+ * if (rule.regex.test(word)) {
109
+ * return word.replace(rule.regex, rule.replacement as string);
110
+ * }
111
+ * }
112
+ *
113
+ * return word;
114
+ * }
115
+ * ```
116
+ *
117
+ * @see {@link EnglishInflectionRules} Constant that implements this interface
118
+ * @see {@link plural} Function that uses these categories for pluralization
119
+ * @see {@link singular} Function that uses these categories for singularization
120
+ */
121
+ export interface InflectionRuleCategories {
122
+ /**
123
+ * Words that are the same in singular and plural form
124
+ */
125
+ INVARIANT: InflectionRule[];
126
+ /**
127
+ * Words with irregular plural forms
128
+ */
129
+ IRREGULAR: PluralSingularRulePair;
130
+ /**
131
+ * Words borrowed from Latin and Greek
132
+ */
133
+ LATIN_GREEK: PluralSingularRulePair;
134
+ /**
135
+ * Words with specific ending patterns
136
+ */
137
+ PATTERN_RULES: PluralSingularRulePair;
138
+ /**
139
+ * Default rules for standard transformations
140
+ */
141
+ DEFAULT: PluralSingularRulePair;
142
+ }
@@ -0,0 +1,3 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ //# sourceMappingURL=inflection-rule.interfaces.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"inflection-rule.interfaces.js","sourceRoot":"","sources":["../../../../../../libs/utils/src/lib/interfaces/inflection-rule.interfaces.ts"],"names":[],"mappings":""}
@@ -0,0 +1,79 @@
1
+ /**
2
+ * Represents a flattened object where keys are dot-notation paths and values are primitive types.
3
+ *
4
+ * This interface defines a data structure that transforms nested objects into a flat, key-value
5
+ * dictionary where:
6
+ * - Keys are string paths using dot notation to represent the original object hierarchy
7
+ * - Values are limited to primitive types (string, number, boolean)
8
+ *
9
+ * PathValueSet provides a serialization-friendly format for complex nested objects, making them
10
+ * easier to store, transmit, or manipulate in certain contexts (like databases, query params,
11
+ * or form handling).
12
+ *
13
+ * @remarks
14
+ * The PathValueSet format offers several benefits:
15
+ *
16
+ * - **Simplicity**: Eliminates nested structure complexity, making it easier to iterate over all properties
17
+ * - **Queryability**: Enables direct access to deeply nested values without traversal logic
18
+ * - **Serializability**: Flattened structure is more amenable to certain serialization formats
19
+ * - **Transformability**: Easier to apply transformations to all values regardless of nesting level
20
+ *
21
+ * Common use cases include:
22
+ * - Flattening complex objects for storage in key-value databases
23
+ * - Representing form data with nested field structures
24
+ * - Simplifying diff operations between complex objects
25
+ * - Creating update operations that target specific nested properties
26
+ *
27
+ * @see {@link InfiniteObject} The complementary nested object representation
28
+ * @see {@link objectToPathValueSet} Utility to convert nested objects to PathValueSet
29
+ * @see {@link pathValueSetToObject} Utility to convert PathValueSet back to nested objects
30
+ *
31
+ * @example
32
+ * ```typescript
33
+ * // A PathValueSet representing a nested user object
34
+ * const userPathValues: PathValueSet = {
35
+ * 'id': 123,
36
+ * 'name': 'John Doe',
37
+ * 'isActive': true,
38
+ * 'profile.age': 30,
39
+ * 'profile.address.city': 'New York',
40
+ * 'profile.address.zip': '10001'
41
+ * };
42
+ * ```
43
+ *
44
+ * @example
45
+ * ```typescript
46
+ * // Converting between nested objects and PathValueSet
47
+ * import { objectToPathValueSet, pathValueSetToObject } from './object.utils';
48
+ *
49
+ * const user = {
50
+ * id: 123,
51
+ * name: 'John Doe',
52
+ * profile: {
53
+ * age: 30,
54
+ * address: {
55
+ * city: 'New York',
56
+ * zip: '10001'
57
+ * }
58
+ * }
59
+ * };
60
+ *
61
+ * // Convert to PathValueSet
62
+ * const pathValues = objectToPathValueSet(user);
63
+ *
64
+ * // Convert back to nested object
65
+ * const reconstructedUser = pathValueSetToObject(pathValues);
66
+ * ```
67
+ *
68
+ * @example
69
+ * ```typescript
70
+ * // Directly accessing a deeply nested value
71
+ * const cityValue = userPathValues['profile.address.city']; // 'New York'
72
+ *
73
+ * // Updating a specific nested value without touching the rest
74
+ * userPathValues['profile.address.city'] = 'Boston';
75
+ * ```
76
+ */
77
+ export interface PathValueSet {
78
+ [path: string]: string | number | boolean;
79
+ }
@@ -0,0 +1,3 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ //# sourceMappingURL=path-value-set.interface.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"path-value-set.interface.js","sourceRoot":"","sources":["../../../../../../libs/utils/src/lib/interfaces/path-value-set.interface.ts"],"names":[],"mappings":""}
@@ -0,0 +1,47 @@
1
+ /**
2
+ * A utility type that recursively makes all properties of an object optional.
3
+ *
4
+ * Unlike TypeScript's built-in `Partial<T>` type which only makes top-level properties
5
+ * optional, `DeepPartial<T>` recursively applies the transformation to nested objects,
6
+ * arrays, maps, and sets. This makes it ideal for working with complex nested data
7
+ * structures where you only want to provide a subset of the data.
8
+ *
9
+ * Features:
10
+ * - Makes all object properties optional at every level of nesting
11
+ * - Handles arrays by making each element a deep partial
12
+ * - Supports Map objects by making both keys and values deep partials
13
+ * - Supports Set objects by making each member a deep partial
14
+ * - Preserves primitive values unchanged
15
+ *
16
+ * Common use cases:
17
+ * - Creating update DTOs where only changed fields need to be provided
18
+ * - Building test fixtures with minimal required properties
19
+ * - Implementing patch operations for REST APIs
20
+ * - Constructing partial configuration objects
21
+ *
22
+ * @template T The type to transform into a deep partial
23
+ *
24
+ * @example
25
+ * ```typescript
26
+ * interface User {
27
+ * id: string;
28
+ * name: string;
29
+ * profile: {
30
+ * avatar: string;
31
+ * preferences: {
32
+ * theme: string;
33
+ * notifications: boolean;
34
+ * };
35
+ * };
36
+ * roles: string[];
37
+ * }
38
+ *
39
+ * // All these are valid DeepPartial<User>
40
+ * const update1: DeepPartial<User> = { name: 'New Name' };
41
+ * const update2: DeepPartial<User> = { profile: { preferences: { theme: 'dark' } } };
42
+ * const update3: DeepPartial<User> = { roles: ['admin'] };
43
+ * ```
44
+ */
45
+ export type DeepPartial<T> = T | (T extends Array<infer U> ? DeepPartial<U>[] : T extends Map<infer K, infer V> ? Map<DeepPartial<K>, DeepPartial<V>> : T extends Set<infer M> ? Set<DeepPartial<M>> : T extends object ? {
46
+ [K in keyof T]?: DeepPartial<T[K]>;
47
+ } : T);
@@ -0,0 +1,3 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ //# sourceMappingURL=deep-partial.type.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"deep-partial.type.js","sourceRoot":"","sources":["../../../../../../libs/utils/src/lib/types/deep-partial.type.ts"],"names":[],"mappings":""}
@@ -0,0 +1,34 @@
1
+ /**
2
+ * Utility types for TypeScript development
3
+ *
4
+ * This module exports a collection of utility types that enhance TypeScript's
5
+ * type system with additional functionality. These types help with common
6
+ * type manipulation tasks and provide solutions for advanced typing scenarios.
7
+ *
8
+ * Key categories of types included:
9
+ * - Object type utilities (DeepPartial, PartialWithNull, LiteralObject)
10
+ * - Type predicates (IsEmpty, IsPrimitive, IsAlreadyInPath)
11
+ * - Type transformation utilities (Prettify, LooseAutocomplete)
12
+ * - Constructor and class utilities (Type)
13
+ *
14
+ * Import these types individually or from this barrel file to enhance
15
+ * your TypeScript code with more expressive and precise type definitions.
16
+ *
17
+ * @example
18
+ * ```typescript
19
+ * // Import all types
20
+ * import * as Types from '@hichchi/utils/types';
21
+ *
22
+ * // Or import specific types
23
+ * import { DeepPartial, LiteralObject } from '@hichchi/utils/types';
24
+ * ```
25
+ */
26
+ export * from "./type.type";
27
+ export * from "./is-empty.type";
28
+ export * from "./prettify.type";
29
+ export * from "./deep-partial.type";
30
+ export * from "./is-primitive.type";
31
+ export * from "./literal-object.type";
32
+ export * from "./partial-with-null.type";
33
+ export * from "./is-already-in-path.type";
34
+ export * from "./loose-autocomplete.type";
@@ -0,0 +1,38 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ const tslib_1 = require("tslib");
4
+ /**
5
+ * Utility types for TypeScript development
6
+ *
7
+ * This module exports a collection of utility types that enhance TypeScript's
8
+ * type system with additional functionality. These types help with common
9
+ * type manipulation tasks and provide solutions for advanced typing scenarios.
10
+ *
11
+ * Key categories of types included:
12
+ * - Object type utilities (DeepPartial, PartialWithNull, LiteralObject)
13
+ * - Type predicates (IsEmpty, IsPrimitive, IsAlreadyInPath)
14
+ * - Type transformation utilities (Prettify, LooseAutocomplete)
15
+ * - Constructor and class utilities (Type)
16
+ *
17
+ * Import these types individually or from this barrel file to enhance
18
+ * your TypeScript code with more expressive and precise type definitions.
19
+ *
20
+ * @example
21
+ * ```typescript
22
+ * // Import all types
23
+ * import * as Types from '@hichchi/utils/types';
24
+ *
25
+ * // Or import specific types
26
+ * import { DeepPartial, LiteralObject } from '@hichchi/utils/types';
27
+ * ```
28
+ */
29
+ tslib_1.__exportStar(require("./type.type"), exports);
30
+ tslib_1.__exportStar(require("./is-empty.type"), exports);
31
+ tslib_1.__exportStar(require("./prettify.type"), exports);
32
+ tslib_1.__exportStar(require("./deep-partial.type"), exports);
33
+ tslib_1.__exportStar(require("./is-primitive.type"), exports);
34
+ tslib_1.__exportStar(require("./literal-object.type"), exports);
35
+ tslib_1.__exportStar(require("./partial-with-null.type"), exports);
36
+ tslib_1.__exportStar(require("./is-already-in-path.type"), exports);
37
+ tslib_1.__exportStar(require("./loose-autocomplete.type"), exports);
38
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../../../libs/utils/src/lib/types/index.ts"],"names":[],"mappings":";;;AAAA;;;;;;;;;;;;;;;;;;;;;;;;GAwBG;AACH,sDAA4B;AAC5B,0DAAgC;AAChC,0DAAgC;AAChC,8DAAoC;AACpC,8DAAoC;AACpC,gEAAsC;AACtC,mEAAyC;AACzC,oEAA0C;AAC1C,oEAA0C"}
@@ -0,0 +1,24 @@
1
+ /**
2
+ * Type predicate that detects circular references in type paths.
3
+ *
4
+ * The `IsAlreadyInPath` type evaluates to `true` if type T is already part of the path U,
5
+ * indicating a potential circular reference. It returns `false` otherwise.
6
+ *
7
+ * This utility type is crucial for preventing infinite recursion in recursive type
8
+ * definitions, particularly when working with deeply nested structures or graphs.
9
+ *
10
+ * @template T The type to check if it's in the path
11
+ * @template U The current path of types
12
+ *
13
+ * @example
14
+ * ```typescript
15
+ * // Example usage in a recursive type definition
16
+ * type RecursivelyProcess<T, Path = never> =
17
+ * IsAlreadyInPath<T, Path> extends true
18
+ * ? any // Break recursion to prevent infinite type expansion
19
+ * : T extends object
20
+ * ? { [K in keyof T]: RecursivelyProcess<T[K], Path | T> }
21
+ * : T;
22
+ * ```
23
+ */
24
+ export type IsAlreadyInPath<T, U> = U extends object ? (T extends U ? true : false) : false;
@@ -0,0 +1,3 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ //# sourceMappingURL=is-already-in-path.type.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"is-already-in-path.type.js","sourceRoot":"","sources":["../../../../../../libs/utils/src/lib/types/is-already-in-path.type.ts"],"names":[],"mappings":""}
@@ -0,0 +1,25 @@
1
+ /**
2
+ * Type predicate that determines if a type is an empty object type.
3
+ *
4
+ * The `IsEmpty` type evaluates to `true` if the provided type T has no properties
5
+ * (i.e., it is an empty object type), and `false` otherwise. This is determined by
6
+ * checking if `keyof T extends never`.
7
+ *
8
+ * This utility type is useful for conditional types that need special handling
9
+ * for empty objects versus objects with properties.
10
+ *
11
+ * @template T The type to check
12
+ *
13
+ * @example
14
+ * ```typescript
15
+ * // Example with conditional types
16
+ * type ProcessObject<T> = IsEmpty<T> extends true
17
+ * ? { defaultProp: string } // Provide default for empty objects
18
+ * : T; // Keep non-empty objects as-is
19
+ *
20
+ * // Usage
21
+ * type ProcessedEmpty = ProcessObject<{}>; // { defaultProp: string }
22
+ * type ProcessedNonEmpty = ProcessObject<{ name: string }>; // { name: string }
23
+ * ```
24
+ */
25
+ export type IsEmpty<T> = keyof T extends never ? true : false;
@@ -0,0 +1,3 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ //# sourceMappingURL=is-empty.type.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"is-empty.type.js","sourceRoot":"","sources":["../../../../../../libs/utils/src/lib/types/is-empty.type.ts"],"names":[],"mappings":""}
@@ -0,0 +1,27 @@
1
+ export type Primitive = string | number | boolean | symbol | bigint | null | undefined;
2
+ export type NonNullPrimitive = string | number | boolean | symbol | bigint;
3
+ /**
4
+ * Type predicate that determines if a type is a primitive JavaScript value.
5
+ *
6
+ * The `IsPrimitive` type evaluates to `true` if the provided type T is a primitive
7
+ * JavaScript value (string, number, boolean, symbol, bigint, null, or undefined),
8
+ * and `false` otherwise (objects, arrays, functions, etc.).
9
+ *
10
+ * This utility type is useful for creating conditional types that need to
11
+ * behave differently for primitive vs. non-primitive values.
12
+ *
13
+ * @template T The type to check
14
+ *
15
+ * @example
16
+ * ```typescript
17
+ * // Example with conditional types
18
+ * type SerializeValue<T> = IsPrimitive<T> extends true
19
+ * ? T // For primitives, keep as-is
20
+ * : string; // For non-primitives, convert to string
21
+ *
22
+ * // Usage
23
+ * type SerializedNumber = SerializeValue<number>; // number
24
+ * type SerializedObject = SerializeValue<{foo: string}>; // string
25
+ * ```
26
+ */
27
+ export type IsPrimitive<T> = T extends Primitive ? true : false;
@@ -0,0 +1,4 @@
1
+ "use strict";
2
+ // noinspection JSUnusedGlobalSymbols
3
+ Object.defineProperty(exports, "__esModule", { value: true });
4
+ //# sourceMappingURL=is-primitive.type.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"is-primitive.type.js","sourceRoot":"","sources":["../../../../../../libs/utils/src/lib/types/is-primitive.type.ts"],"names":[],"mappings":";AAAA,qCAAqC"}
@@ -0,0 +1,49 @@
1
+ /**
2
+ * Generic interface for objects with string keys and values of a specified type.
3
+ *
4
+ * `LiteralObject` represents a simple key-value dictionary where all keys are strings
5
+ * and all values are of the same type T. It provides a type-safe way to work with
6
+ * dynamic objects that have arbitrary string keys.
7
+ *
8
+ * Key features:
9
+ * - Allows any string as a key using an index signature
10
+ * - Generic type parameter for values with `any` as the default
11
+ * - Useful for representing dynamic objects with unknown structure
12
+ * - Commonly used in object transformation and manipulation utilities
13
+ *
14
+ * Common use cases:
15
+ * - Working with JSON data
16
+ * - Creating dictionaries or maps with string keys
17
+ * - Representing configuration objects
18
+ * - Handling data with dynamic property names
19
+ *
20
+ * @template T The type of values in the object (defaults to `any`)
21
+ *
22
+ * @example
23
+ * ```typescript
24
+ * // Basic usage with default any type
25
+ * const config: LiteralObject = {
26
+ * apiUrl: 'https://api.example.com',
27
+ * timeout: 5000,
28
+ * retryCount: 3
29
+ * };
30
+ *
31
+ * // With a specific value type
32
+ * const stringMap: LiteralObject<string> = {
33
+ * en: 'Hello',
34
+ * fr: 'Bonjour',
35
+ * es: 'Hola'
36
+ * };
37
+ *
38
+ * // Accessing properties dynamically
39
+ * function getValue(obj: LiteralObject, key: string): any {
40
+ * return obj[key];
41
+ * }
42
+ * ```
43
+ *
44
+ * @see {@link objectToPathValueSet} Utility that uses LiteralObject for object flattening
45
+ * @see {@link PathValueSet} Related interface for flattened object representation
46
+ */
47
+ export interface LiteralObject<T = any> {
48
+ [key: string]: T;
49
+ }
@@ -0,0 +1,3 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ //# sourceMappingURL=literal-object.type.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"literal-object.type.js","sourceRoot":"","sources":["../../../../../../libs/utils/src/lib/types/literal-object.type.ts"],"names":[],"mappings":""}
@@ -1,9 +1,3 @@
1
- export type LiteralObject<T = any> = {
2
- [key: string]: T;
3
- };
4
- export type PartialWithNull<T> = {
5
- [p in keyof T]?: T[p] | null;
6
- };
7
1
  /**
8
2
  * Represents a type for autocompleting string values.
9
3
  *
@@ -15,6 +9,24 @@ export type PartialWithNull<T> = {
15
9
  *
16
10
  * @template T Extends string - The set of predefined literal string options for autocompletion.
17
11
  *
12
+ * @example
13
+ * ```typescript
14
+ * // Define a set of color options
15
+ * type ColorOption = 'red' | 'green' | 'blue';
16
+ *
17
+ * // Function that accepts predefined colors but also allows custom colors
18
+ * function setColor(color: LooseAutocomplete<ColorOption>): void {
19
+ * console.log(`Setting color to: ${color}`);
20
+ * }
21
+ *
22
+ * // Usage with predefined options (gets autocomplete)
23
+ * setColor('red'); // Works, with autocomplete
24
+ * setColor('green'); // Works, with autocomplete
25
+ *
26
+ * // Usage with custom string (allowed, but no autocomplete)
27
+ * setColor('purple'); // Also works, even though not in predefined options
28
+ * ```
29
+ *
18
30
  * @author Matt Pocock (https://www.totaltypescript.com/tips/create-autocomplete-helper-which-allows-for-arbitrary-values)
19
31
  */
20
32
  export type LooseAutocomplete<T extends string> = T | Omit<string, T>;
@@ -0,0 +1,3 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ //# sourceMappingURL=loose-autocomplete.type.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"loose-autocomplete.type.js","sourceRoot":"","sources":["../../../../../../libs/utils/src/lib/types/loose-autocomplete.type.ts"],"names":[],"mappings":""}
@@ -0,0 +1,27 @@
1
+ /**
2
+ * Makes all properties of type T optional and allows them to be null.
3
+ *
4
+ * This type is similar to TypeScript's built-in `Partial<T>` type, but it also
5
+ * allows properties to be null in addition to being undefined or their original type.
6
+ *
7
+ * @template T The type to make partial with null.
8
+ *
9
+ * @example
10
+ * ```TypeScript
11
+ * interface User {
12
+ * id: number;
13
+ * name: string;
14
+ * email: string;
15
+ * }
16
+ *
17
+ * // All properties are optional and can be null
18
+ * const partialUser: PartialWithNull<User> = {
19
+ * id: 1,
20
+ * name: null,
21
+ * // email is omitted (undefined)
22
+ * };
23
+ * ```
24
+ */
25
+ export type PartialWithNull<T> = {
26
+ [p in keyof T]?: T[p] | null;
27
+ };
@@ -0,0 +1,3 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ //# sourceMappingURL=partial-with-null.type.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"partial-with-null.type.js","sourceRoot":"","sources":["../../../../../../libs/utils/src/lib/types/partial-with-null.type.ts"],"names":[],"mappings":""}
@@ -0,0 +1,23 @@
1
+ /**
2
+ * Utility type for creating a clean object type from a complex type.
3
+ *
4
+ * The `Prettify` type takes a potentially complex type (with intersections, unions,
5
+ * mapped types, etc.) and converts it into a simple object type with all properties
6
+ * explicitly defined. This makes the resulting type easier to read in IDE tooltips
7
+ * and type errors.
8
+ *
9
+ * @template T The complex type to simplify
10
+ *
11
+ * @author Matt Pocock (https://www.totaltypescript.com/tips/create-autocomplete-helper-which-allows-for-arbitrary-values)
12
+ *
13
+ * @example
14
+ * ```typescript
15
+ * // Instead of seeing: { a: number } & { b: string }
16
+ * // You'll see: { a: number, b: string }
17
+ * type ComplexType = { a: number } & { b: string };
18
+ * type SimpleType = Prettify<ComplexType>;
19
+ * ```
20
+ */
21
+ export type Prettify<T> = {
22
+ [K in keyof T]: T[K];
23
+ } & {};
@@ -0,0 +1,3 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ //# sourceMappingURL=prettify.type.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"prettify.type.js","sourceRoot":"","sources":["../../../../../../libs/utils/src/lib/types/prettify.type.ts"],"names":[],"mappings":""}