@hichchi/utils 0.0.1-beta.2 → 0.0.2

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 (90) hide show
  1. package/index.cjs.default.js +1 -0
  2. package/index.cjs.js +3645 -0
  3. package/index.cjs.mjs +2 -0
  4. package/index.d.ts +1 -5
  5. package/index.esm.js +3575 -0
  6. package/package.json +13 -8
  7. package/src/index.d.ts +5 -0
  8. package/{interfaces → src/interfaces}/infinite-object.interface.d.ts +3 -3
  9. package/{interfaces → src/interfaces}/path-value-set.interface.d.ts +12 -12
  10. package/{types → src/types}/deep-partial.type.d.ts +6 -0
  11. package/{types → src/types}/literal-object.type.d.ts +2 -2
  12. package/{utils → src/utils}/index.d.ts +1 -0
  13. package/{utils → src/utils}/object.utils.d.ts +23 -19
  14. package/CHANGELOG.md +0 -19
  15. package/README.md +0 -7944
  16. package/constants/constants.js +0 -227
  17. package/constants/constants.js.map +0 -1
  18. package/constants/english-inflection-rules.js +0 -360
  19. package/constants/english-inflection-rules.js.map +0 -1
  20. package/constants/index.js +0 -6
  21. package/constants/index.js.map +0 -1
  22. package/enums/index.js +0 -5
  23. package/enums/index.js.map +0 -1
  24. package/enums/template-tag.enum.js +0 -39
  25. package/enums/template-tag.enum.js.map +0 -1
  26. package/index.js +0 -9
  27. package/index.js.map +0 -1
  28. package/interfaces/index.js +0 -7
  29. package/interfaces/index.js.map +0 -1
  30. package/interfaces/infinite-object.interface.js +0 -3
  31. package/interfaces/infinite-object.interface.js.map +0 -1
  32. package/interfaces/inflection-rule.interfaces.js +0 -3
  33. package/interfaces/inflection-rule.interfaces.js.map +0 -1
  34. package/interfaces/path-value-set.interface.js +0 -3
  35. package/interfaces/path-value-set.interface.js.map +0 -1
  36. package/readme-top.md +0 -187
  37. package/types/deep-partial.type.js +0 -3
  38. package/types/deep-partial.type.js.map +0 -1
  39. package/types/index.js +0 -38
  40. package/types/index.js.map +0 -1
  41. package/types/is-already-in-path.type.js +0 -3
  42. package/types/is-already-in-path.type.js.map +0 -1
  43. package/types/is-empty.type.js +0 -3
  44. package/types/is-empty.type.js.map +0 -1
  45. package/types/is-primitive.type.js +0 -4
  46. package/types/is-primitive.type.js.map +0 -1
  47. package/types/literal-object.type.js +0 -3
  48. package/types/literal-object.type.js.map +0 -1
  49. package/types/loose-autocomplete.type.js +0 -3
  50. package/types/loose-autocomplete.type.js.map +0 -1
  51. package/types/partial-with-null.type.js +0 -3
  52. package/types/partial-with-null.type.js.map +0 -1
  53. package/types/prettify.type.js +0 -3
  54. package/types/prettify.type.js.map +0 -1
  55. package/types/type.type.js +0 -3
  56. package/types/type.type.js.map +0 -1
  57. package/utils/assertions.utils.js +0 -163
  58. package/utils/assertions.utils.js.map +0 -1
  59. package/utils/file.utils.js +0 -1315
  60. package/utils/file.utils.js.map +0 -1
  61. package/utils/index.js +0 -9
  62. package/utils/index.js.map +0 -1
  63. package/utils/object.utils.js +0 -1069
  64. package/utils/object.utils.js.map +0 -1
  65. package/utils/string-template.utils.js +0 -269
  66. package/utils/string-template.utils.js.map +0 -1
  67. package/utils/string.utils.js +0 -1255
  68. package/utils/string.utils.js.map +0 -1
  69. package/utils/url.utils.js +0 -112
  70. package/utils/url.utils.js.map +0 -1
  71. /package/{constants → src/constants}/constants.d.ts +0 -0
  72. /package/{constants → src/constants}/english-inflection-rules.d.ts +0 -0
  73. /package/{constants → src/constants}/index.d.ts +0 -0
  74. /package/{enums → src/enums}/index.d.ts +0 -0
  75. /package/{enums → src/enums}/template-tag.enum.d.ts +0 -0
  76. /package/{interfaces → src/interfaces}/index.d.ts +0 -0
  77. /package/{interfaces → src/interfaces}/inflection-rule.interfaces.d.ts +0 -0
  78. /package/{types → src/types}/index.d.ts +0 -0
  79. /package/{types → src/types}/is-already-in-path.type.d.ts +0 -0
  80. /package/{types → src/types}/is-empty.type.d.ts +0 -0
  81. /package/{types → src/types}/is-primitive.type.d.ts +0 -0
  82. /package/{types → src/types}/loose-autocomplete.type.d.ts +0 -0
  83. /package/{types → src/types}/partial-with-null.type.d.ts +0 -0
  84. /package/{types → src/types}/prettify.type.d.ts +0 -0
  85. /package/{types → src/types}/type.type.d.ts +0 -0
  86. /package/{utils → src/utils}/assertions.utils.d.ts +0 -0
  87. /package/{utils → src/utils}/file.utils.d.ts +0 -0
  88. /package/{utils → src/utils}/string-template.utils.d.ts +0 -0
  89. /package/{utils → src/utils}/string.utils.d.ts +0 -0
  90. /package/{utils → src/utils}/url.utils.d.ts +0 -0
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@hichchi/utils",
3
- "version": "0.0.1-beta.2",
3
+ "version": "0.0.2",
4
4
  "publishConfig": {
5
5
  "access": "public"
6
6
  },
@@ -11,12 +11,17 @@
11
11
  "keywords": [],
12
12
  "author": "Waruna Udayanga",
13
13
  "license": "MIT",
14
- "main": "./index.js",
15
- "typings": "./index.d.ts",
16
14
  "sideEffects": false,
17
- "dependencies": {
18
- "tslib": "^2.3.0"
15
+ "exports": {
16
+ "./package.json": "./package.json",
17
+ ".": {
18
+ "module": "./index.esm.js",
19
+ "types": "./index.d.ts",
20
+ "import": "./index.cjs.mjs",
21
+ "default": "./index.cjs.js"
22
+ }
19
23
  },
20
- "types": "./index.d.ts",
21
- "type": "commonjs"
22
- }
24
+ "module": "./index.esm.js",
25
+ "main": "./index.cjs.js",
26
+ "types": "./index.d.ts"
27
+ }
package/src/index.d.ts ADDED
@@ -0,0 +1,5 @@
1
+ export * from "./utils";
2
+ export * from "./interfaces";
3
+ export * from "./types";
4
+ export * from "./enums";
5
+ export * from "./constants";
@@ -18,9 +18,9 @@
18
18
  * This type is often used in conjunction with utility functions for traversing, flattening,
19
19
  * or manipulating deeply nested object structures.
20
20
  *
21
- * @see PathValueSet A flattened representation of nested objects
22
- * @see {@link objectToPathValueSet} Utility to convert nested objects to PathValueSet
23
- * @see {@link pathValueSetToObject} Utility to convert PathValueSet back to nested objects
21
+ * @see DottedPathValueObject A flattened representation of nested objects
22
+ * @see {@link objectToDottedPathValueObject} Utility to convert nested objects to DottedPathValueObject
23
+ * @see {@link dottedPathObjectToNested} Utility to convert DottedPathValueObject back to nested objects
24
24
  *
25
25
  * @example
26
26
  * ```typescript
@@ -6,12 +6,12 @@
6
6
  * - Keys are string paths using dot notation to represent the original object hierarchy
7
7
  * - Values are limited to primitive types (string, number, boolean)
8
8
  *
9
- * PathValueSet provides a serialization-friendly format for complex nested objects, making them
9
+ * DottedPathValueObject provides a serialization-friendly format for complex nested objects, making them
10
10
  * easier to store, transmit, or manipulate in certain contexts (like databases, query params,
11
11
  * or form handling).
12
12
  *
13
13
  * @remarks
14
- * The PathValueSet format offers several benefits:
14
+ * The DottedPathValueObject format offers several benefits:
15
15
  *
16
16
  * - **Simplicity**: Eliminates nested structure complexity, making it easier to iterate over all properties
17
17
  * - **Queryability**: Enables direct access to deeply nested values without traversal logic
@@ -25,13 +25,13 @@
25
25
  * - Creating update operations that target specific nested properties
26
26
  *
27
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
28
+ * @see {@link objectToDottedPathValueObject} Utility to convert nested objects to DottedPathValueObject
29
+ * @see {@link dottedPathObjectToNested} Utility to convert DottedPathValueObject back to nested objects
30
30
  *
31
31
  * @example
32
32
  * ```typescript
33
- * // A PathValueSet representing a nested user object
34
- * const userPathValues: PathValueSet = {
33
+ * // A DottedPathValueObject representing a nested user object
34
+ * const userPathValues: DottedPathValueObject = {
35
35
  * 'id': 123,
36
36
  * 'name': 'John Doe',
37
37
  * 'isActive': true,
@@ -43,8 +43,8 @@
43
43
  *
44
44
  * @example
45
45
  * ```typescript
46
- * // Converting between nested objects and PathValueSet
47
- * import { objectToPathValueSet, pathValueSetToObject } from './object.utils';
46
+ * // Converting between nested objects and DottedPathValueObject
47
+ * import { objectToDottedPathValueObject, dottedPathObjectToNested } from './object.utils';
48
48
  *
49
49
  * const user = {
50
50
  * id: 123,
@@ -58,11 +58,11 @@
58
58
  * }
59
59
  * };
60
60
  *
61
- * // Convert to PathValueSet
62
- * const pathValues = objectToPathValueSet(user);
61
+ * // Convert to DottedPathValueObject
62
+ * const pathValues = objectToDottedPathValueObject(user);
63
63
  *
64
64
  * // Convert back to nested object
65
- * const reconstructedUser = pathValueSetToObject(pathValues);
65
+ * const reconstructedUser = dottedPathObjectToNested(pathValues);
66
66
  * ```
67
67
  *
68
68
  * @example
@@ -74,6 +74,6 @@
74
74
  * userPathValues['profile.address.city'] = 'Boston';
75
75
  * ```
76
76
  */
77
- export interface PathValueSet {
77
+ export interface DottedPathValueObject {
78
78
  [path: string]: string | number | boolean;
79
79
  }
@@ -45,3 +45,9 @@
45
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
46
  [K in keyof T]?: DeepPartial<T[K]>;
47
47
  } : T);
48
+ /**
49
+ * Lightweight recursive partial type for plain object filtering/comparison use-cases.
50
+ */
51
+ export type SimpleDeepPartial<T> = {
52
+ [K in keyof T]?: T[K] extends object ? SimpleDeepPartial<T[K]> : T[K];
53
+ };
@@ -41,8 +41,8 @@
41
41
  * }
42
42
  * ```
43
43
  *
44
- * @see {@link objectToPathValueSet} Utility that uses LiteralObject for object flattening
45
- * @see {@link PathValueSet} Related interface for flattened object representation
44
+ * @see {@link objectToDottedPathValueObject} Utility that uses LiteralObject for object flattening
45
+ * @see {@link DottedPathValueObject} Related interface for flattened object representation
46
46
  */
47
47
  export interface LiteralObject<T = any> {
48
48
  [key: string]: T;
@@ -1,4 +1,5 @@
1
1
  export * from "./url.utils";
2
+ export * from "./file.utils";
2
3
  export * from "./object.utils";
3
4
  export * from "./string.utils";
4
5
  export * from "./assertions.utils";
@@ -1,5 +1,5 @@
1
- import { InfiniteObject, PathValueSet } from "../interfaces";
2
- import { LiteralObject, PartialWithNull } from "../types";
1
+ import { InfiniteObject, DottedPathValueObject } from "../interfaces";
2
+ import { LiteralObject, PartialWithNull, SimpleDeepPartial } from "../types";
3
3
  /**
4
4
  * Deep copy an object.
5
5
  * @template T Type of the object.
@@ -210,7 +210,7 @@ export declare const getMapKeys: (map: Map<string, string>, partialValue: string
210
210
  * - Works with any type of grouping key (string, number, boolean, objects, etc.)
211
211
  * - Empty arrays will return an empty Map
212
212
  */
213
- export declare const groupBy: <K, V>(list: Array<V>, keyGetter: (input: V) => K) => Map<K | null, Array<V>>;
213
+ export declare const groupBy: <K, V>(list: Array<V>, keyGetter: (input: V) => K) => Map<K, Array<V>>;
214
214
  /**
215
215
  * Retrieves all values from a Map that contain a specified substring.
216
216
  *
@@ -332,7 +332,7 @@ export declare const searchMapValues: (map: Map<string, string>, partialValue: s
332
332
  */
333
333
  export declare const getValueByPath: <T>(obj: InfiniteObject, path: string) => T | undefined;
334
334
  /**
335
- * Converts a nested object into a flattened PathValueSet representation.
335
+ * Converts a nested object into a flattened DottedPathValueObject representation.
336
336
  *
337
337
  * This function transforms a hierarchical object structure into a flat key-value map
338
338
  * where keys represent paths to values in the original object using dot notation.
@@ -342,7 +342,7 @@ export declare const getValueByPath: <T>(obj: InfiniteObject, path: string) => T
342
342
  * path-based entries like `{ 'user.name': 'John' }`.
343
343
  *
344
344
  * @param {LiteralObject} obj - The nested object to flatten
345
- * @returns {PathValueSet} - A flattened representation where:
345
+ * @returns {DottedPathValueObject} - A flattened representation where:
346
346
  * - Keys are dot-notation paths to values in the original object
347
347
  * - Values are primitive values (strings, numbers, booleans) from the original object
348
348
  *
@@ -351,8 +351,8 @@ export declare const getValueByPath: <T>(obj: InfiniteObject, path: string) => T
351
351
  * - Only primitive values (string, number, boolean) are supported as leaf values
352
352
  * - Circular references are not handled and will cause a stack overflow
353
353
  *
354
- * @see {@link pathValueSetToObject} The inverse operation to convert a PathValueSet back to a nested object
355
- * @see {@link PathValueSet} The interface for the returned flattened object
354
+ * @see {@link dottedPathObjectToNested} The inverse operation to convert a DottedPathValueObject back to a nested object
355
+ * @see {@link DottedPathValueObject} The interface for the returned flattened object
356
356
  *
357
357
  * @example
358
358
  * ```typescript
@@ -370,7 +370,7 @@ export declare const getValueByPath: <T>(obj: InfiniteObject, path: string) => T
370
370
  * }
371
371
  * };
372
372
  *
373
- * const flattened = objectToPathValueSet(user);
373
+ * const flattened = objectToDottedPathValueObject(user);
374
374
  *
375
375
  * // Result:
376
376
  * // {
@@ -383,19 +383,19 @@ export declare const getValueByPath: <T>(obj: InfiniteObject, path: string) => T
383
383
  * // }
384
384
  * ```
385
385
  */
386
- export declare function objectToPathValueSet(obj: LiteralObject): PathValueSet;
386
+ export declare function objectToDottedPathValueObject(obj: LiteralObject): DottedPathValueObject;
387
387
  /**
388
- * Converts a flattened PathValueSet back into a nested object structure.
388
+ * Converts a flattened DottedPathValueObject back into a nested object structure.
389
389
  *
390
- * This function is the inverse of `objectToPathValueSet`. It takes a flat map of
390
+ * This function is the inverse of `objectToDottedPathValueObject`. It takes a flat map of
391
391
  * dot-notation paths to values and reconstructs a hierarchical object structure.
392
392
  *
393
- * Each key in the input PathValueSet represents a path through the object hierarchy,
393
+ * Each key in the input DottedPathValueObject represents a path through the object hierarchy,
394
394
  * with dots separating each level. The function builds a nested object structure by
395
395
  * parsing these paths and placing values at the appropriate locations.
396
396
  *
397
397
  * @template R - The type of the returned object (defaults to object)
398
- * @param {PathValueSet} pathValueSet - A flattened object with dot-notation path keys
398
+ * @param {DottedPathValueObject} pathValueSet - A flattened object with dot-notation path keys
399
399
  * @returns {R} - A reconstructed nested object with the original hierarchy
400
400
  *
401
401
  * @remarks
@@ -403,12 +403,12 @@ export declare function objectToPathValueSet(obj: LiteralObject): PathValueSet;
403
403
  * - Invalid paths are silently skipped (not included in the result)
404
404
  * - Path components should contain only alphanumeric characters, underscores, hyphens, and dots
405
405
  *
406
- * @see {@link objectToPathValueSet} The inverse operation to convert an object to PathValueSet
407
- * @see {@link PathValueSet} The interface for the input flattened object
406
+ * @see {@link objectToDottedPathValueObject} The inverse operation to convert an object to DottedPathValueObject
407
+ * @see {@link DottedPathValueObject} The interface for the input flattened object
408
408
  *
409
409
  * @example
410
410
  * ```typescript
411
- * // Convert a flat PathValueSet to a nested object
411
+ * // Convert a flat DottedPathValueObject to a nested object
412
412
  * const flatData = {
413
413
  * "id": 123,
414
414
  * "name": "John Doe",
@@ -417,7 +417,7 @@ export declare function objectToPathValueSet(obj: LiteralObject): PathValueSet;
417
417
  * "profile.address.zip": "10001"
418
418
  * };
419
419
  *
420
- * const nestedObject = pathValueSetToObject(flatData);
420
+ * const nestedObject = dottedPathObjectToNested(flatData);
421
421
  *
422
422
  * Result:
423
423
  * // {
@@ -448,11 +448,11 @@ export declare function objectToPathValueSet(obj: LiteralObject): PathValueSet;
448
448
  * };
449
449
  * }
450
450
  *
451
- * const userData = pathValueSetToObject<User>(flatData);
451
+ * const userData = dottedPathObjectToNested<User>(flatData);
452
452
  * // Returns object with User type
453
453
  * ```
454
454
  */
455
- export declare function pathValueSetToObject<R = object>(pathValueSet: Record<string, any>): R;
455
+ export declare function dottedPathObjectToNested<R = object>(pathValueSet: Record<string, any>): R;
456
456
  /**
457
457
  * Creates a new object by omitting specified properties and undefined values from the original object.
458
458
  *
@@ -910,3 +910,7 @@ export declare function hasOwnAll(obj: Record<PropertyKey, unknown>, props: Prop
910
910
  * @see {@link Object.values} The underlying method used to extract enum entries
911
911
  */
912
912
  export declare function getEnumValues<T extends object>(e: T): T[keyof T][];
913
+ /**
914
+ * Filters items by recursively matching nested property values.
915
+ */
916
+ export declare function filterByObject<T>(items: T[], filters: SimpleDeepPartial<T>): T[];
package/CHANGELOG.md DELETED
@@ -1,19 +0,0 @@
1
- ## 0.0.1-beta.2 (2025-07-18)
2
-
3
- This was a version bump only for utils to align it with other projects, there were no code changes.
4
-
5
- ## 0.0.1-beta.1 (2025-07-16)
6
-
7
- This was a version bump only for utils to align it with other projects, there were no code changes.
8
-
9
- ## 0.0.1-beta.0 (2025-07-15)
10
-
11
- This was a version bump only for utils to align it with other projects, there were no code changes.
12
-
13
- ## 0.0.1-alpha.1 (2025-06-23)
14
-
15
- This was a version bump only for utils to align it with other projects, there were no code changes.
16
-
17
- ## 0.0.1-alpha.0 (2025-06-23)
18
-
19
- This was a version bump only for utils to align it with other projects, there were no code changes.