nhb-toolbox 2.8.1 → 2.8.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.
@@ -1,37 +1,32 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports._find2NumbersLCM = exports._find2NumbersHCF = exports._applyMultiples = void 0;
4
- exports._convertLessThanThousand = _convertLessThanThousand;
5
- const constants_1 = require("./constants");
1
+ import { ones, teens, tens } from './constants';
6
2
  /**
7
3
  * Apply multiples of a number if there is any.
8
4
  * @param array Array of numbers to apply the condition on.
9
5
  * @param multiples The multiples of which number.
10
6
  * @returns Array of multiples of the desired number
11
7
  */
12
- const _applyMultiples = (array, multiples) => {
8
+ export const _applyMultiples = (array, multiples) => {
13
9
  if (!multiples)
14
10
  return array;
15
11
  return array.filter((n) => n % multiples === 0);
16
12
  };
17
- exports._applyMultiples = _applyMultiples;
18
13
  /**
19
14
  * - Converts a number less than 1000 to words.
20
15
  * @param num - The number to convert (less than 1000).
21
16
  * @param isLast - Whether this is the last group (thousands, millions, etc.).
22
17
  * @returns Numbers less than 1000 in words.
23
18
  */
24
- function _convertLessThanThousand(num, isLast) {
19
+ export function _convertLessThanThousand(num, isLast) {
25
20
  if (num < 10)
26
- return constants_1.ones[num];
21
+ return ones[num];
27
22
  if (num < 20)
28
- return constants_1.teens[num - 10];
29
- let result = constants_1.tens[Math.floor(num / 10)];
23
+ return teens[num - 10];
24
+ let result = tens[Math.floor(num / 10)];
30
25
  const remainder = num % 10;
31
26
  if (remainder > 0)
32
- result += `-${constants_1.ones[remainder]}`;
27
+ result += `-${ones[remainder]}`;
33
28
  if (num >= 100) {
34
- const hundredsPart = `${constants_1.ones[Math.floor(num / 100)]} hundred`;
29
+ const hundredsPart = `${ones[Math.floor(num / 100)]} hundred`;
35
30
  return num % 100 === 0 ?
36
31
  hundredsPart
37
32
  : `${hundredsPart} ${isLast ? 'and' : ''} ${_convertLessThanThousand(num % 100, false)}`;
@@ -45,7 +40,7 @@ function _convertLessThanThousand(num, isLast) {
45
40
  * @param b - Second number.
46
41
  * @returns The HCF of the two numbers.
47
42
  */
48
- const _find2NumbersHCF = (a, b) => {
43
+ export const _find2NumbersHCF = (a, b) => {
49
44
  let x = Math.abs(a);
50
45
  let y = Math.abs(b);
51
46
  while (y !== 0) {
@@ -55,7 +50,6 @@ const _find2NumbersHCF = (a, b) => {
55
50
  }
56
51
  return x;
57
52
  };
58
- exports._find2NumbersHCF = _find2NumbersHCF;
59
53
  /**
60
54
  * * Calculate the LCM (Least Common Multiple) of two numbers using the Euclidean algorithm.
61
55
  *
@@ -63,9 +57,8 @@ exports._find2NumbersHCF = _find2NumbersHCF;
63
57
  * @param b - Second number.
64
58
  * @returns The LCM of the two numbers.
65
59
  */
66
- const _find2NumbersLCM = (a, b) => {
60
+ export const _find2NumbersLCM = (a, b) => {
67
61
  const x = Math.abs(a);
68
62
  const y = Math.abs(b);
69
- return (x * y) / (0, exports._find2NumbersHCF)(x, y);
63
+ return (x * y) / _find2NumbersHCF(x, y);
70
64
  };
71
- exports._find2NumbersLCM = _find2NumbersLCM;
@@ -1,13 +1,10 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.findPrimeNumbers = exports.isPrime = void 0;
4
1
  /**
5
2
  * * Checks if a number is prime.
6
3
  *
7
4
  * @param number The number to check.
8
5
  * @returns Boolean: `true` if the number is prime, otherwise `false`.
9
6
  */
10
- const isPrime = (number) => {
7
+ export const isPrime = (number) => {
11
8
  if (number < 2)
12
9
  return false;
13
10
  if (number === 2 || number === 3)
@@ -20,7 +17,6 @@ const isPrime = (number) => {
20
17
  }
21
18
  return true;
22
19
  };
23
- exports.isPrime = isPrime;
24
20
  /**
25
21
  * * Find prime numbers in a given range.
26
22
  *
@@ -28,11 +24,10 @@ exports.isPrime = isPrime;
28
24
  * @param end The ending number of the range. Default is `1000`.
29
25
  * @returns An array of prime numbers within the range (inclusive).
30
26
  */
31
- const findPrimeNumbers = (start = 1, end = 1000) => {
27
+ export const findPrimeNumbers = (start = 1, end = 1000) => {
32
28
  let startNumber = start, endNumber = end;
33
29
  if (start > end) {
34
30
  [startNumber, endNumber] = [end, start];
35
31
  }
36
- return Array.from({ length: endNumber - startNumber + 1 }, (_, i) => startNumber + i).filter(exports.isPrime);
32
+ return Array.from({ length: endNumber - startNumber + 1 }, (_, i) => startNumber + i).filter(isPrime);
37
33
  };
38
- exports.findPrimeNumbers = findPrimeNumbers;
@@ -1,11 +1,8 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.getNumbersInRange = getNumbersInRange;
4
- const basics_1 = require("../array/basics");
5
- const utils_1 = require("../utils");
6
- const basics_2 = require("./basics");
7
- const helpers_1 = require("./helpers");
8
- const prime_1 = require("./prime");
1
+ import { shuffleArray } from '../array/basics';
2
+ import { convertArrayToString } from '../utils';
3
+ import { getRandomNumber, isEven, isOdd } from './basics';
4
+ import { _applyMultiples } from './helpers';
5
+ import { isPrime } from './prime';
9
6
  /**
10
7
  * * Function to get numbers within a range based on the provided `NumberType` and options.
11
8
  * * Returns either a string or an array of numbers based on the `getAs` property in options.
@@ -14,7 +11,7 @@ const prime_1 = require("./prime");
14
11
  * @param options - Options to configure number generation, including range and formatting.
15
12
  * @returns Either a string or an array of numbers.
16
13
  */
17
- function getNumbersInRange(type = 'any', options) {
14
+ export function getNumbersInRange(type = 'any', options) {
18
15
  const { getAs = 'array', min = 0, max = 100, includeMin = true, includeMax = true, separator = ',', multiples, } = options || {};
19
16
  let output = [];
20
17
  /**
@@ -46,7 +43,7 @@ function getNumbersInRange(type = 'any', options) {
46
43
  }
47
44
  switch (type) {
48
45
  case 'random':
49
- output = (0, basics_1.shuffleArray)(_applyRangeOptions(min, max).map((n) => (0, basics_2.getRandomNumber)({
46
+ output = shuffleArray(_applyRangeOptions(min, max).map((n) => getRandomNumber({
50
47
  min: n,
51
48
  max: n,
52
49
  includeMin,
@@ -54,13 +51,13 @@ function getNumbersInRange(type = 'any', options) {
54
51
  })));
55
52
  break;
56
53
  case 'prime':
57
- output = _applyRangeOptions(min, max).filter(prime_1.isPrime);
54
+ output = _applyRangeOptions(min, max).filter(isPrime);
58
55
  break;
59
56
  case 'odd':
60
- output = _applyRangeOptions(min, max).filter(basics_2.isOdd);
57
+ output = _applyRangeOptions(min, max).filter(isOdd);
61
58
  break;
62
59
  case 'even':
63
- output = _applyRangeOptions(min, max).filter(basics_2.isEven);
60
+ output = _applyRangeOptions(min, max).filter(isEven);
64
61
  break;
65
62
  case 'natural':
66
63
  output = _applyRangeOptions(Math.max(min, 1), max);
@@ -70,9 +67,9 @@ function getNumbersInRange(type = 'any', options) {
70
67
  break;
71
68
  }
72
69
  if (type !== 'prime') {
73
- output = (0, helpers_1._applyMultiples)(output, multiples);
70
+ output = _applyMultiples(output, multiples);
74
71
  }
75
72
  return getAs === 'string' ?
76
- (0, utils_1.convertArrayToString)(output, separator)
73
+ convertArrayToString(output, separator)
77
74
  : output;
78
75
  }
@@ -1,2 +1 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
1
+ export {};
@@ -1,7 +1,4 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.isObject = exports.countObjectFields = exports.isEmptyObject = exports.cloneObject = exports.generateQueryParams = void 0;
4
- const objectify_1 = require("./objectify");
1
+ import { flattenObjectKeyValue } from './objectify';
5
2
  /**
6
3
  * * Utility to generate query parameters from an object.
7
4
  *
@@ -16,9 +13,9 @@ const objectify_1 = require("./objectify");
16
13
  * generateQueryParams({ key1: true, key2: false }); // "?key1=true&key2=false"
17
14
  * generateQueryParams({ filters: { category: 'laptop', price: 1000 } }); // "?category=laptop&price=1000"
18
15
  */
19
- const generateQueryParams = (params = {}) => {
16
+ export const generateQueryParams = (params = {}) => {
20
17
  // Flatten the nested object into key-value pairs
21
- const flattenedParams = (0, objectify_1.flattenObjectKeyValue)(params);
18
+ const flattenedParams = flattenObjectKeyValue(params);
22
19
  // Generate the query string
23
20
  const queryParams = Object.entries(flattenedParams)
24
21
  .filter(([_, value]) => value !== undefined &&
@@ -34,48 +31,43 @@ const generateQueryParams = (params = {}) => {
34
31
  .join('&');
35
32
  return queryParams ? `?${queryParams}` : '';
36
33
  };
37
- exports.generateQueryParams = generateQueryParams;
38
34
  /**
39
35
  * * Deep clone an object.
40
36
  *
41
37
  * @param obj Object to clone.
42
38
  * @returns Deep cloned object.
43
39
  */
44
- const cloneObject = (obj) => {
40
+ export const cloneObject = (obj) => {
45
41
  return JSON.parse(JSON.stringify(obj));
46
42
  };
47
- exports.cloneObject = cloneObject;
48
43
  /**
49
44
  * * Check if an object is empty.
50
45
  *
51
46
  * @param obj Object to check.
52
47
  * @returns Whether the object is empty.
53
48
  */
54
- const isEmptyObject = (obj) => {
49
+ export const isEmptyObject = (obj) => {
55
50
  if (obj != null)
56
- return (0, exports.countObjectFields)(obj) === 0;
51
+ return countObjectFields(obj) === 0;
57
52
  return false;
58
53
  };
59
- exports.isEmptyObject = isEmptyObject;
60
54
  /**
61
55
  * * Count the number of fields in an object.
62
56
  *
63
57
  * @param obj Object to check.
64
58
  * @returns Number of fields in the object.
65
59
  */
66
- const countObjectFields = (obj) => {
60
+ export const countObjectFields = (obj) => {
67
61
  if (obj != null)
68
62
  return Object.keys(obj).length;
69
63
  return 0;
70
64
  };
71
- exports.countObjectFields = countObjectFields;
72
65
  /**
73
66
  * * Check whether data is object and not array.
74
67
  *
75
68
  * @param data Data to check if its an object and not array.
76
69
  * @returns Boolean: `true` if it's an object, `false` if not.
77
70
  */
78
- const isObject = (data) => {
71
+ export const isObject = (data) => {
79
72
  return typeof data === 'object' && !Array.isArray(data);
80
73
  };
81
- exports.isObject = isObject;
@@ -1,6 +1,3 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.convertObjectValues = convertObjectValues;
4
1
  /**
5
2
  * * Converts the values of specified keys in an object or array of objects to either string or number.
6
3
  * * Supports nested objects using dot-notation keys.
@@ -11,7 +8,7 @@ exports.convertObjectValues = convertObjectValues;
11
8
  * - `convertTo`: The target type, either "string" or "number".
12
9
  * @returns The modified object or array of objects with the converted values, with updated types.
13
10
  */
14
- function convertObjectValues(data, options) {
11
+ export function convertObjectValues(data, options) {
15
12
  const { keys, convertTo } = options;
16
13
  /** * Helper function to determine if value should be preserved. */
17
14
  const _shouldPreserveValue = (value) => convertTo === 'number' &&
@@ -1,15 +1,12 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.extractUpdatedAndNewFields = exports.extractNewFields = exports.extractUpdatedFields = exports.flattenObjectDotNotation = exports.flattenObjectKeyValue = exports.mergeAndFlattenObjects = exports.mergeObjects = void 0;
4
- const utils_1 = require("../utils");
5
- const basics_1 = require("./basics");
1
+ import { isDeepEqual } from '../utils';
2
+ import { isEmptyObject, isObject } from './basics';
6
3
  /**
7
4
  * * Deeply merge two or more objects using `Map`.
8
5
  *
9
6
  * @param objects Objects to merge.
10
7
  * @returns Merged object.
11
8
  */
12
- const mergeObjects = (...objects) => {
9
+ export const mergeObjects = (...objects) => {
13
10
  const map = new Map();
14
11
  objects.forEach((obj) => {
15
12
  for (const key in obj) {
@@ -19,7 +16,7 @@ const mergeObjects = (...objects) => {
19
16
  if (existingValue &&
20
17
  existingValue instanceof Object &&
21
18
  !Array.isArray(existingValue)) {
22
- map.set(key, (0, exports.mergeObjects)(existingValue, obj[key]));
19
+ map.set(key, mergeObjects(existingValue, obj[key]));
23
20
  }
24
21
  else {
25
22
  // Otherwise, just set the value
@@ -38,7 +35,6 @@ const mergeObjects = (...objects) => {
38
35
  });
39
36
  return result;
40
37
  };
41
- exports.mergeObjects = mergeObjects;
42
38
  /**
43
39
  * * Deeply merge objects and flatten nested objects.
44
40
  * * Useful for flattening a single object or merging multiple objects with duplicate key(s).
@@ -47,7 +43,7 @@ exports.mergeObjects = mergeObjects;
47
43
  * @param objects Objects to merge.
48
44
  * @returns Merged object with flattened structure.
49
45
  */
50
- const mergeAndFlattenObjects = (...objects) => {
46
+ export const mergeAndFlattenObjects = (...objects) => {
51
47
  const map = new Map();
52
48
  const _flattenObject = (obj, parentKey = '') => {
53
49
  for (const key in obj) {
@@ -69,21 +65,20 @@ const mergeAndFlattenObjects = (...objects) => {
69
65
  });
70
66
  return result;
71
67
  };
72
- exports.mergeAndFlattenObjects = mergeAndFlattenObjects;
73
68
  /**
74
69
  * * Flattens a nested object into key-value format.
75
70
  *
76
71
  * @param object - The `object` to flatten.
77
72
  * @returns A `flattened object` in key-value format.
78
73
  */
79
- const flattenObjectKeyValue = (object) => {
74
+ export const flattenObjectKeyValue = (object) => {
80
75
  const flattened = {};
81
76
  for (const [key, value] of Object.entries(object)) {
82
77
  if (typeof value === 'object' &&
83
78
  value !== null &&
84
79
  !Array.isArray(value)) {
85
80
  // Recursively flatten nested objects
86
- const nestedFlattened = (0, exports.flattenObjectKeyValue)(value);
81
+ const nestedFlattened = flattenObjectKeyValue(value);
87
82
  Object.assign(flattened, nestedFlattened);
88
83
  }
89
84
  else {
@@ -93,14 +88,13 @@ const flattenObjectKeyValue = (object) => {
93
88
  }
94
89
  return flattened;
95
90
  };
96
- exports.flattenObjectKeyValue = flattenObjectKeyValue;
97
91
  /**
98
92
  * * Flattens a nested object into a dot notation format.
99
93
  *
100
94
  * @param object - The `object` to flatten.
101
95
  * @returns A `flattened object` with dot notation keys.
102
96
  */
103
- const flattenObjectDotNotation = (object) => {
97
+ export const flattenObjectDotNotation = (object) => {
104
98
  /**
105
99
  * * Recursively flattens an object, transforming nested structures into dot-notation keys.
106
100
  *
@@ -130,7 +124,6 @@ const flattenObjectDotNotation = (object) => {
130
124
  // Call the recursive function with an empty prefix initially
131
125
  return _flattenObject(object);
132
126
  };
133
- exports.flattenObjectDotNotation = flattenObjectDotNotation;
134
127
  /**
135
128
  * * Extracts only the fields that have changed between the original and updated object.
136
129
  *
@@ -138,14 +131,14 @@ exports.flattenObjectDotNotation = flattenObjectDotNotation;
138
131
  * @param updatedObject The modified object containing potential updates.
139
132
  * @returns A new object containing only the changed fields.
140
133
  */
141
- const extractUpdatedFields = (baseObject, updatedObject) => {
134
+ export const extractUpdatedFields = (baseObject, updatedObject) => {
142
135
  const updatedFields = {};
143
136
  for (const key in updatedObject) {
144
137
  if (key in baseObject &&
145
- !(0, utils_1.isDeepEqual)(updatedObject[key], baseObject[key])) {
146
- if (updatedObject[key] && (0, basics_1.isObject)(updatedObject[key])) {
147
- updatedFields[key] = (0, exports.extractUpdatedFields)(baseObject[key], updatedObject[key]);
148
- if (updatedFields[key] && (0, basics_1.isEmptyObject)(updatedFields[key])) {
138
+ !isDeepEqual(updatedObject[key], baseObject[key])) {
139
+ if (updatedObject[key] && isObject(updatedObject[key])) {
140
+ updatedFields[key] = extractUpdatedFields(baseObject[key], updatedObject[key]);
141
+ if (updatedFields[key] && isEmptyObject(updatedFields[key])) {
149
142
  delete updatedFields[key];
150
143
  }
151
144
  }
@@ -156,7 +149,6 @@ const extractUpdatedFields = (baseObject, updatedObject) => {
156
149
  }
157
150
  return updatedFields;
158
151
  };
159
- exports.extractUpdatedFields = extractUpdatedFields;
160
152
  /**
161
153
  * * Extracts only new fields that exist in updatedObject but not in baseObject.
162
154
  *
@@ -164,17 +156,17 @@ exports.extractUpdatedFields = extractUpdatedFields;
164
156
  * @param updatedObject The modified object containing potential new fields.
165
157
  * @returns A new object containing only the new fields.
166
158
  */
167
- const extractNewFields = (baseObject, updatedObject) => {
159
+ export const extractNewFields = (baseObject, updatedObject) => {
168
160
  const newFields = {};
169
161
  for (const key in updatedObject) {
170
162
  if (!(key in baseObject)) {
171
163
  // Directly assign new fields
172
164
  newFields[key] = updatedObject[key];
173
165
  }
174
- else if ((0, basics_1.isObject)(updatedObject[key]) && (0, basics_1.isObject)(baseObject[key])) {
166
+ else if (isObject(updatedObject[key]) && isObject(baseObject[key])) {
175
167
  // Recursively extract new fields inside nested objects
176
- const nestedNewFields = (0, exports.extractNewFields)(baseObject[key], updatedObject[key]);
177
- if (!(0, basics_1.isEmptyObject)(nestedNewFields)) {
168
+ const nestedNewFields = extractNewFields(baseObject[key], updatedObject[key]);
169
+ if (!isEmptyObject(nestedNewFields)) {
178
170
  newFields[key] =
179
171
  nestedNewFields;
180
172
  }
@@ -182,7 +174,6 @@ const extractNewFields = (baseObject, updatedObject) => {
182
174
  }
183
175
  return newFields;
184
176
  };
185
- exports.extractNewFields = extractNewFields;
186
177
  /**
187
178
  * * Extracts changed fields from the updated object while also identifying newly added keys.
188
179
  *
@@ -190,17 +181,17 @@ exports.extractNewFields = extractNewFields;
190
181
  * @param updatedObject The modified object containing potential updates.
191
182
  * @returns An object containing modified fields and new fields separately.
192
183
  */
193
- const extractUpdatedAndNewFields = (baseObject, updatedObject) => {
184
+ export const extractUpdatedAndNewFields = (baseObject, updatedObject) => {
194
185
  const updatedFields = {};
195
186
  const newFields = {};
196
187
  for (const key in updatedObject) {
197
188
  if (!(key in baseObject)) {
198
189
  newFields[key] = updatedObject[key];
199
190
  }
200
- else if (!(0, utils_1.isDeepEqual)(updatedObject[key], baseObject[key])) {
201
- if (updatedObject[key] && (0, basics_1.isObject)(updatedObject[key])) {
202
- updatedFields[key] = (0, exports.extractUpdatedAndNewFields)(baseObject[key], updatedObject[key]);
203
- if (updatedFields[key] && (0, basics_1.isEmptyObject)(updatedFields[key])) {
191
+ else if (!isDeepEqual(updatedObject[key], baseObject[key])) {
192
+ if (updatedObject[key] && isObject(updatedObject[key])) {
193
+ updatedFields[key] = extractUpdatedAndNewFields(baseObject[key], updatedObject[key]);
194
+ if (updatedFields[key] && isEmptyObject(updatedFields[key])) {
204
195
  delete updatedFields[key];
205
196
  }
206
197
  }
@@ -211,4 +202,3 @@ const extractUpdatedAndNewFields = (baseObject, updatedObject) => {
211
202
  }
212
203
  return { ...updatedFields, ...newFields };
213
204
  };
214
- exports.extractUpdatedAndNewFields = extractUpdatedAndNewFields;
@@ -1,8 +1,5 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.sanitizeData = sanitizeData;
4
- const basics_1 = require("../string/basics");
5
- const basics_2 = require("./basics");
1
+ import { trimString } from '../string/basics';
2
+ import { isEmptyObject } from './basics';
6
3
  /**
7
4
  * * Sanitizes a string, array of strings, an object or array of objects by ignoring specified keys and trimming string values.
8
5
  * * Also excludes nullish values (null, undefined) if specified. Always ignores empty nested object(s).
@@ -11,7 +8,7 @@ const basics_2 = require("./basics");
11
8
  * @param options - Options for processing.
12
9
  * @returns A new string, object or array of strings or objects with the specified modifications.
13
10
  */
14
- function sanitizeData(input, options) {
11
+ export function sanitizeData(input, options) {
15
12
  const { keysToIgnore: ignoreKeys = [], trimStrings = true, ignoreNullish = false, } = options || {};
16
13
  // Flatten the object keys and use the keys for comparison
17
14
  const ignoreKeySet = new Set(ignoreKeys);
@@ -34,7 +31,7 @@ function sanitizeData(input, options) {
34
31
  }
35
32
  // Trim string values if enabled
36
33
  if (typeof value === 'string' && trimStrings) {
37
- acc[key] = (0, basics_1.trimString)(value);
34
+ acc[key] = trimString(value);
38
35
  }
39
36
  else if (value &&
40
37
  typeof value === 'object' &&
@@ -42,7 +39,7 @@ function sanitizeData(input, options) {
42
39
  // Recursively process nested objects
43
40
  const processedValue = _processObject(value, fullKeyPath);
44
41
  // Only add the property if it's not an empty object
45
- if (!(0, basics_2.isEmptyObject)(processedValue)) {
42
+ if (!isEmptyObject(processedValue)) {
46
43
  acc[key] = processedValue;
47
44
  }
48
45
  }
@@ -54,18 +51,18 @@ function sanitizeData(input, options) {
54
51
  }, {});
55
52
  // Process strings
56
53
  if (typeof input === 'string') {
57
- return (0, basics_1.trimString)(input);
54
+ return trimString(input);
58
55
  }
59
56
  // Process array of strings and objects
60
57
  if (Array.isArray(input)) {
61
58
  // Process array of strings
62
59
  if (typeof input[0] === 'string') {
63
- return (0, basics_1.trimString)(input);
60
+ return trimString(input);
64
61
  }
65
62
  // Process array of objects
66
63
  return input
67
64
  .map((obj) => _processObject(obj))
68
- .filter((obj) => !(0, basics_2.isEmptyObject)(obj));
65
+ .filter((obj) => !isEmptyObject(obj));
69
66
  }
70
67
  // Process object
71
68
  if (typeof input === 'object' && input !== null) {
@@ -1,2 +1 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
1
+ export {};
@@ -1,13 +1,10 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.generateAnagrams = generateAnagrams;
4
1
  /**
5
2
  * * Utility to generate unique anagrams of a word.
6
3
  * @param word The word for generating anagrams.
7
4
  * @param limit The maximum number of anagrams to return ('all' for unlimited). Default is `100`.
8
5
  * @returns An array of generated anagrams. The first element is always the given word.
9
6
  */
10
- function generateAnagrams(word, limit = 100) {
7
+ export function generateAnagrams(word, limit = 100) {
11
8
  if (word.length <= 1)
12
9
  return [word];
13
10
  const uniqueAnagrams = new Set();
@@ -1,8 +1,3 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.generateRandomID = exports.truncateString = void 0;
4
- exports.capitalizeString = capitalizeString;
5
- exports.trimString = trimString;
6
1
  /**
7
2
  * * Utility to convert the first letter of any string to uppercase and the rest lowercase (unless specified).
8
3
  * * Handles surrounding symbols like quotes or parentheses.
@@ -11,7 +6,7 @@ exports.trimString = trimString;
11
6
  * @param options Options to customize the capitalization.
12
7
  * @returns Capitalized string or fully uppercased string depending on `capitalizeAll` option.
13
8
  */
14
- function capitalizeString(string, options) {
9
+ export function capitalizeString(string, options) {
15
10
  if (typeof string !== 'string' || !string)
16
11
  return '';
17
12
  const trimmedString = string.trim();
@@ -48,7 +43,7 @@ function capitalizeString(string, options) {
48
43
  * @param maxLength The maximum length of the truncated string.
49
44
  * @returns Truncated string with ellipsis (`...`) (only if it has more length than `maxLength`).
50
45
  */
51
- const truncateString = (string, maxLength) => {
46
+ export const truncateString = (string, maxLength) => {
52
47
  if (typeof string !== 'string' || !string)
53
48
  return '';
54
49
  const trimmedString = string.trim();
@@ -58,14 +53,13 @@ const truncateString = (string, maxLength) => {
58
53
  return trimmedString;
59
54
  return trimmedString.slice(0, maxLength).concat('...');
60
55
  };
61
- exports.truncateString = truncateString;
62
56
  /**
63
57
  * * Generates a random alphanumeric (16 characters long, this length is customizable in the options) ID string composed of an optional `prefix`, `suffix`, a `timestamp`, `caseOption` and a customizable `separator`.
64
58
  *
65
59
  * @param options Configuration options for random ID generation.
66
60
  * @returns The generated ID string composed of the random alphanumeric string of specified length with optional `timeStamp`, `prefix`, and `suffix`, `caseOption` and `separator`.
67
61
  */
68
- const generateRandomID = (options) => {
62
+ export const generateRandomID = (options) => {
69
63
  const { prefix = '', suffix = '', timeStamp = false, length = 16, separator = '', caseOption = null, } = options || {};
70
64
  // generate timestamp
71
65
  const date = timeStamp ? Date.now() : '';
@@ -88,14 +82,13 @@ const generateRandomID = (options) => {
88
82
  return ID;
89
83
  }
90
84
  };
91
- exports.generateRandomID = generateRandomID;
92
85
  /**
93
86
  * * Trims all the words in a string or an array of strings.
94
87
  *
95
88
  * @param input String or array of strings.
96
89
  * @returns Trimmed string or array of strings.
97
90
  */
98
- function trimString(input) {
91
+ export function trimString(input) {
99
92
  if (!input)
100
93
  return '';
101
94
  // If the input is a string, trim each word
@@ -1,7 +1,4 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.LOWERCASE = void 0;
4
- exports.LOWERCASE = [
1
+ export const LOWERCASE = [
5
2
  // Conjunctions
6
3
  'and',
7
4
  'but',
@@ -1,8 +1,4 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.replaceAllInString = void 0;
4
- exports.convertStringCase = convertStringCase;
5
- const constants_1 = require("./constants");
1
+ import { LOWERCASE } from './constants';
6
2
  /**
7
3
  * Converts a string to a specified case format such as `camelCase`, `snake_case`, `kebab-case`, `PascalCase`, `Title Case`, `lowercase`, or `UPPERCASE`.
8
4
  *
@@ -27,7 +23,7 @@ const constants_1 = require("./constants");
27
23
  * convertStringCase('my example string', 'lowercase'); // returns 'my example string'
28
24
  * convertStringCase('my example string', 'UPPERCASE'); // returns 'MY EXAMPLE STRING'
29
25
  */
30
- function convertStringCase(string, format) {
26
+ export function convertStringCase(string, format) {
31
27
  if (!string || typeof string !== 'string')
32
28
  return '';
33
29
  const start = string.match(/^[^\d\w\s]+/)?.[0] || '';
@@ -39,7 +35,7 @@ function convertStringCase(string, format) {
39
35
  const startSymbol = part.match(/^[^\d\w\s]+/)?.[0] || ''; // Capture leading symbols
40
36
  const endSymbol = part.match(/[^\d\w\s]+$/)?.[0] || ''; // Capture trailing symbols
41
37
  const coreWord = part.replace(/^[^\d\w\s]+|[^\d\w\s]+$/g, ''); // Remove them for processing
42
- if (constants_1.LOWERCASE.includes(coreWord.toLowerCase())) {
38
+ if (LOWERCASE.includes(coreWord.toLowerCase())) {
43
39
  return startSymbol + coreWord.toLowerCase() + endSymbol;
44
40
  }
45
41
  return (startSymbol +
@@ -98,7 +94,7 @@ function convertStringCase(string, format) {
98
94
  * @param replace - The string to replace matches with.
99
95
  * @returns The modified/refined string with replacements applied.
100
96
  */
101
- const replaceAllInString = (input, find, replace) => {
97
+ export const replaceAllInString = (input, find, replace) => {
102
98
  if (!input)
103
99
  return '';
104
100
  const trimmedString = input?.trim();
@@ -109,4 +105,3 @@ const replaceAllInString = (input, find, replace) => {
109
105
  : new RegExp(find, find.flags.includes('g') ? find.flags : find.flags + 'g');
110
106
  return trimmedString?.replace(regex, replace);
111
107
  };
112
- exports.replaceAllInString = replaceAllInString;
@@ -1,2 +1 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
1
+ export {};
@@ -1,2 +1 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
1
+ export {};