@akadenia/helpers 1.2.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.
@@ -0,0 +1,27 @@
1
+ import { convertCamelToSnakeCase, convertSnakeToCamelCase, fileNameFromPath, formatPosition, handleNullDisplay, pluralizeOnCondition, replaceSpacesWithUnderscore, replaceUnderscoreWithSpaces, truncateText, uuidv4, enforceCharacterLimit, capitalizeText, generateIDFromWord, generateWordFromId, convertCamelToKebabCase, convertKebabToCamelCase, isAcronym, acronymToKebabCase } from "./text";
2
+ import * as DateHelpers from "./date";
3
+ import * as ObjectHelpers from "./object";
4
+ import * as MapHelpers from "./map";
5
+ import * as GenericHelpers from "./generic";
6
+ import * as FileHelpers from "./file";
7
+ declare const TextHelpers: {
8
+ convertCamelToSnakeCase: typeof convertCamelToSnakeCase;
9
+ convertSnakeToCamelCase: typeof convertSnakeToCamelCase;
10
+ fileNameFromPath: typeof fileNameFromPath;
11
+ formatPosition: typeof formatPosition;
12
+ handleNullDisplay: typeof handleNullDisplay;
13
+ pluralizeOnCondition: typeof pluralizeOnCondition;
14
+ replaceSpacesWithUnderscore: typeof replaceSpacesWithUnderscore;
15
+ replaceUnderscoreWithSpaces: typeof replaceUnderscoreWithSpaces;
16
+ truncateText: typeof truncateText;
17
+ uuidv4: typeof uuidv4;
18
+ enforceCharacterLimit: typeof enforceCharacterLimit;
19
+ capitalizeText: typeof capitalizeText;
20
+ convertCamelToKebabCase: typeof convertCamelToKebabCase;
21
+ convertKebabToCamelCase: typeof convertKebabToCamelCase;
22
+ isAcronym: typeof isAcronym;
23
+ acronymToKebabCase: typeof acronymToKebabCase;
24
+ generateIDFromWord: typeof generateIDFromWord;
25
+ generateWordFromId: typeof generateWordFromId;
26
+ };
27
+ export { ObjectHelpers, DateHelpers, MapHelpers, TextHelpers, GenericHelpers, FileHelpers };
package/dist/index.js ADDED
@@ -0,0 +1,58 @@
1
+ "use strict";
2
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
+ if (k2 === undefined) k2 = k;
4
+ var desc = Object.getOwnPropertyDescriptor(m, k);
5
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
+ desc = { enumerable: true, get: function() { return m[k]; } };
7
+ }
8
+ Object.defineProperty(o, k2, desc);
9
+ }) : (function(o, m, k, k2) {
10
+ if (k2 === undefined) k2 = k;
11
+ o[k2] = m[k];
12
+ }));
13
+ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
14
+ Object.defineProperty(o, "default", { enumerable: true, value: v });
15
+ }) : function(o, v) {
16
+ o["default"] = v;
17
+ });
18
+ var __importStar = (this && this.__importStar) || function (mod) {
19
+ if (mod && mod.__esModule) return mod;
20
+ var result = {};
21
+ if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
22
+ __setModuleDefault(result, mod);
23
+ return result;
24
+ };
25
+ Object.defineProperty(exports, "__esModule", { value: true });
26
+ exports.FileHelpers = exports.GenericHelpers = exports.TextHelpers = exports.MapHelpers = exports.DateHelpers = exports.ObjectHelpers = void 0;
27
+ const text_1 = require("./text");
28
+ const DateHelpers = __importStar(require("./date"));
29
+ exports.DateHelpers = DateHelpers;
30
+ const ObjectHelpers = __importStar(require("./object"));
31
+ exports.ObjectHelpers = ObjectHelpers;
32
+ const MapHelpers = __importStar(require("./map"));
33
+ exports.MapHelpers = MapHelpers;
34
+ const GenericHelpers = __importStar(require("./generic"));
35
+ exports.GenericHelpers = GenericHelpers;
36
+ const FileHelpers = __importStar(require("./file"));
37
+ exports.FileHelpers = FileHelpers;
38
+ const TextHelpers = {
39
+ convertCamelToSnakeCase: text_1.convertCamelToSnakeCase,
40
+ convertSnakeToCamelCase: text_1.convertSnakeToCamelCase,
41
+ fileNameFromPath: text_1.fileNameFromPath,
42
+ formatPosition: text_1.formatPosition,
43
+ handleNullDisplay: text_1.handleNullDisplay,
44
+ pluralizeOnCondition: text_1.pluralizeOnCondition,
45
+ replaceSpacesWithUnderscore: text_1.replaceSpacesWithUnderscore,
46
+ replaceUnderscoreWithSpaces: text_1.replaceUnderscoreWithSpaces,
47
+ truncateText: text_1.truncateText,
48
+ uuidv4: text_1.uuidv4,
49
+ enforceCharacterLimit: text_1.enforceCharacterLimit,
50
+ capitalizeText: text_1.capitalizeText,
51
+ convertCamelToKebabCase: text_1.convertCamelToKebabCase,
52
+ convertKebabToCamelCase: text_1.convertKebabToCamelCase,
53
+ isAcronym: text_1.isAcronym,
54
+ acronymToKebabCase: text_1.acronymToKebabCase,
55
+ generateIDFromWord: text_1.generateIDFromWord,
56
+ generateWordFromId: text_1.generateWordFromId,
57
+ };
58
+ exports.TextHelpers = TextHelpers;
package/dist/map.d.ts ADDED
@@ -0,0 +1,7 @@
1
+ export declare const getDistanceBetweenPoints: (point1: number[] | undefined, point2: number[] | undefined) => number | null;
2
+ export declare const compareLocations: (location1: number[] | undefined, location2: number[] | undefined, precision?: number) => boolean;
3
+ export interface IGetBearingToCoordinate {
4
+ startCoordinate: number[] | undefined;
5
+ endCoordinate: number[] | undefined;
6
+ }
7
+ export declare const getBearingToCoordinate: ({ startCoordinate, endCoordinate }: IGetBearingToCoordinate) => number;
package/dist/map.js ADDED
@@ -0,0 +1,53 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.getBearingToCoordinate = exports.compareLocations = exports.getDistanceBetweenPoints = void 0;
4
+ const DEFAULT_COMPARE_LOCATIONS_PRECISION = 6;
5
+ // This function implements the Haversine formula to calculate distance between two points
6
+ // https://en.wikipedia.org/wiki/Haversine_formula
7
+ const getDistanceBetweenPoints = (point1, point2) => {
8
+ if (!point1 || !point2)
9
+ return null;
10
+ const [lat1, lon1] = point1;
11
+ const [lat2, lon2] = point2;
12
+ const earthRadius = 6371e3; // in metres
13
+ const lat1InRadians = (lat1 * Math.PI) / 180; // φ, λ in radians
14
+ const lat2InRadians = (lat2 * Math.PI) / 180;
15
+ const long1InRadians = ((lat2 - lat1) * Math.PI) / 180;
16
+ const long2InRadians = ((lon2 - lon1) * Math.PI) / 180;
17
+ const a = Math.sin(long1InRadians / 2) * Math.sin(long1InRadians / 2) +
18
+ Math.cos(lat1InRadians) * Math.cos(lat2InRadians) * Math.sin(long2InRadians / 2) * Math.sin(long2InRadians / 2);
19
+ const c = 2 * Math.atan2(Math.sqrt(a), Math.sqrt(1 - a));
20
+ return earthRadius * c; // distance in metres
21
+ };
22
+ exports.getDistanceBetweenPoints = getDistanceBetweenPoints;
23
+ const compareLocations = (location1, location2, precision = DEFAULT_COMPARE_LOCATIONS_PRECISION) => {
24
+ if (!location1 || !location2) {
25
+ throw new Error("location1 and location2 are required");
26
+ }
27
+ return (location1[0].toFixed(precision) === location2[0].toFixed(precision) &&
28
+ location1[1].toFixed(precision) === location2[1].toFixed(precision));
29
+ };
30
+ exports.compareLocations = compareLocations;
31
+ const getBearingToCoordinate = ({ startCoordinate, endCoordinate }) => {
32
+ if (!startCoordinate || !endCoordinate) {
33
+ throw new Error("startCoordinate and endCoordinate are required");
34
+ }
35
+ // Converts from degrees to radians
36
+ const toRadians = (degrees) => {
37
+ return (degrees * Math.PI) / 180;
38
+ };
39
+ // Converts from radians to degrees
40
+ const toDegrees = (radians) => {
41
+ return (radians * 180) / Math.PI;
42
+ };
43
+ const startLatitude = toRadians(startCoordinate[1]);
44
+ const startLongitude = toRadians(startCoordinate[0]);
45
+ const endLatitude = toRadians(endCoordinate[1]);
46
+ const endLongitude = toRadians(endCoordinate[0]);
47
+ const y = Math.sin(endLongitude - startLongitude) * Math.cos(endLatitude);
48
+ const x = Math.cos(startLatitude) * Math.sin(endLatitude) -
49
+ Math.sin(startLatitude) * Math.cos(endLatitude) * Math.cos(endLongitude - startLongitude);
50
+ const bearing = Math.atan2(y, x);
51
+ return (toDegrees(bearing) + 360) % 360;
52
+ };
53
+ exports.getBearingToCoordinate = getBearingToCoordinate;
@@ -0,0 +1,76 @@
1
+ /**
2
+ *
3
+ * @function
4
+ * @param {any} object - The object to check if it is a pure object (not an array, date, or function)
5
+ * @returns {boolean} - Whether or not the provided object is a pure object
6
+ */
7
+ export declare const isPureObject: (object: any) => boolean;
8
+ /**
9
+ * @function
10
+ * @param {string} str - The string of cookies to parse
11
+ * @returns {Object} - The object containing key-value pairs of the parsed cookies
12
+ */
13
+ export declare const parseCookie: (str: string) => Object;
14
+ /**
15
+ * Filters an array of objects based on a specified property and value.
16
+ * @template T extends Record<string, any> - The type of objects in the array.
17
+ * @param {T[]} array - The array of objects to filter.
18
+ * @param {keyof T} propertyName - The name of the property to filter on.
19
+ * @param {T[keyof T]} propertyValue - The value of the property to filter on.
20
+ * @returns {T[]} - The filtered array of objects.
21
+ */
22
+ export declare function filterObjectsByProperty<T extends Record<string, any>>(array: T[], propertyName: keyof T, propertyValue: T[keyof T]): T[];
23
+ /**
24
+ * Checks if the main object contains the sub object.
25
+ * @template T extends Record<string, any> - The type of the main object.
26
+ * @param {T} mainObject - The main object to check.
27
+ * @param {Partial<T>} subObject - The sub object to look for in the main object.
28
+ * @returns {boolean} - True if the main object contains the sub object, false otherwise.
29
+ */
30
+ export declare function containsSubObject<T extends Record<string, any>>(mainObject: T, subObject: Partial<T>): boolean;
31
+ /**
32
+ * Finds the object containing the given sub object in the array.
33
+ * @template T extends Record<string, any> - The type of objects in the array.
34
+ * @param {T[]} array - The array of objects.
35
+ * @param {Partial<T>} subObject - The sub object used to search the array.
36
+ * @returns {T | null} - The object containing the given sub object or null.
37
+ */
38
+ export declare function findObjectBySubObject<T extends Record<string, any>>(array: T[], subObject: Partial<T>): T | null;
39
+ /**
40
+ * Filters an array of objects based on the objects containing the given sub object
41
+ * @template T extends Record<string, any>
42
+ * @param {T[]} array - The array of objects
43
+ * @param {Partial<T>} subObject - The sub object used to search the array
44
+ * @returns {Object | null} - An array of objects containing the given sub object
45
+ */
46
+ export declare function filterObjectsBySubObject<T extends Record<string, any>>(array: T[], subObject: Partial<T>): T[];
47
+ /**
48
+ * Checks if the object has the key with the value.
49
+ * @param {Object} object - The object to check
50
+ * @param {string} key - The key to check
51
+ * @param {any} value - The value to check
52
+ * @returns {boolean} - Whether or not the object has the key with the value
53
+ * @example
54
+ * const object = { a: 1, b: 2, c: 3 }
55
+ * objectPropHasValue(object, 'a', 1) // true
56
+ * objectPropHasValue(object, 'b', 3) // false
57
+ */
58
+ export declare const objectPropHasValue: <ObjectType>({ object, propName, value, }: {
59
+ object: ObjectType;
60
+ propName: keyof ObjectType;
61
+ value: ObjectType[keyof ObjectType];
62
+ }) => boolean;
63
+ /**
64
+ * Finds the first entry in the array that satisfies the predicate.
65
+ * @template EntryType - The type of the entries in the array.
66
+ * @callback PredicateFunction - The predicate function to use to search the array.
67
+ * @param {EntryType} item - The entry in the array to search.
68
+ * @returns {boolean} - True if the entry satisfies the predicate, false otherwise.
69
+ * @param {EntryType[]} array - The array of entries to search.
70
+ * @param {PredicateFunction} predicate - The predicate function to use to search the array.
71
+ * @returns {EntryType | null} - The first entry that satisfies the predicate, or null if not found.
72
+ */
73
+ export declare const findEntry: <EntryType>(array: EntryType[], predicate: (item: EntryType) => boolean) => EntryType | null;
74
+ export declare function convertArrayToMap<T extends object>(arrayData: T[], keyProp: keyof T): {
75
+ [key: string]: T;
76
+ };
package/dist/object.js ADDED
@@ -0,0 +1,123 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.convertArrayToMap = exports.findEntry = exports.objectPropHasValue = exports.filterObjectsBySubObject = exports.findObjectBySubObject = exports.containsSubObject = exports.filterObjectsByProperty = exports.parseCookie = exports.isPureObject = void 0;
4
+ /**
5
+ *
6
+ * @function
7
+ * @param {any} object - The object to check if it is a pure object (not an array, date, or function)
8
+ * @returns {boolean} - Whether or not the provided object is a pure object
9
+ */
10
+ const isPureObject = function (object) {
11
+ const isDateObject = object instanceof Date;
12
+ return object === Object(object) && !Array.isArray(object) && typeof object !== "function" && !isDateObject;
13
+ };
14
+ exports.isPureObject = isPureObject;
15
+ /**
16
+ * @function
17
+ * @param {string} str - The string of cookies to parse
18
+ * @returns {Object} - The object containing key-value pairs of the parsed cookies
19
+ */
20
+ const parseCookie = (str) => str
21
+ .split(";")
22
+ .map((v) => v.split("="))
23
+ .reduce((acc, v) => {
24
+ if (v.length > 1) {
25
+ acc[decodeURIComponent(v[0].trim())] = decodeURIComponent(v[1].trim());
26
+ }
27
+ return acc;
28
+ }, {});
29
+ exports.parseCookie = parseCookie;
30
+ /**
31
+ * Filters an array of objects based on a specified property and value.
32
+ * @template T extends Record<string, any> - The type of objects in the array.
33
+ * @param {T[]} array - The array of objects to filter.
34
+ * @param {keyof T} propertyName - The name of the property to filter on.
35
+ * @param {T[keyof T]} propertyValue - The value of the property to filter on.
36
+ * @returns {T[]} - The filtered array of objects.
37
+ */
38
+ function filterObjectsByProperty(array, propertyName, propertyValue) {
39
+ const predicate = (obj) => Object.getOwnPropertyDescriptor(obj, propertyName) && obj[propertyName] === propertyValue;
40
+ return array.filter(predicate);
41
+ }
42
+ exports.filterObjectsByProperty = filterObjectsByProperty;
43
+ /**
44
+ * Checks if the main object contains the sub object.
45
+ * @template T extends Record<string, any> - The type of the main object.
46
+ * @param {T} mainObject - The main object to check.
47
+ * @param {Partial<T>} subObject - The sub object to look for in the main object.
48
+ * @returns {boolean} - True if the main object contains the sub object, false otherwise.
49
+ */
50
+ function containsSubObject(mainObject, subObject) {
51
+ if (!((0, exports.isPureObject)(mainObject) && (0, exports.isPureObject)(subObject))) {
52
+ return false;
53
+ }
54
+ for (let key of Object.keys(subObject)) {
55
+ if (!(Object.getOwnPropertyDescriptor(mainObject, key) && mainObject[key] === subObject[key])) {
56
+ return false;
57
+ }
58
+ }
59
+ return true;
60
+ }
61
+ exports.containsSubObject = containsSubObject;
62
+ /**
63
+ * Finds the object containing the given sub object in the array.
64
+ * @template T extends Record<string, any> - The type of objects in the array.
65
+ * @param {T[]} array - The array of objects.
66
+ * @param {Partial<T>} subObject - The sub object used to search the array.
67
+ * @returns {T | null} - The object containing the given sub object or null.
68
+ */
69
+ function findObjectBySubObject(array, subObject) {
70
+ const predicate = (obj) => containsSubObject(obj, subObject);
71
+ return array.find(predicate) || null;
72
+ }
73
+ exports.findObjectBySubObject = findObjectBySubObject;
74
+ /**
75
+ * Filters an array of objects based on the objects containing the given sub object
76
+ * @template T extends Record<string, any>
77
+ * @param {T[]} array - The array of objects
78
+ * @param {Partial<T>} subObject - The sub object used to search the array
79
+ * @returns {Object | null} - An array of objects containing the given sub object
80
+ */
81
+ function filterObjectsBySubObject(array, subObject) {
82
+ const predicate = (obj) => containsSubObject(obj, subObject);
83
+ return array.filter(predicate);
84
+ }
85
+ exports.filterObjectsBySubObject = filterObjectsBySubObject;
86
+ /**
87
+ * Checks if the object has the key with the value.
88
+ * @param {Object} object - The object to check
89
+ * @param {string} key - The key to check
90
+ * @param {any} value - The value to check
91
+ * @returns {boolean} - Whether or not the object has the key with the value
92
+ * @example
93
+ * const object = { a: 1, b: 2, c: 3 }
94
+ * objectPropHasValue(object, 'a', 1) // true
95
+ * objectPropHasValue(object, 'b', 3) // false
96
+ */
97
+ const objectPropHasValue = ({ object, propName, value, }) => object[propName] === value;
98
+ exports.objectPropHasValue = objectPropHasValue;
99
+ /**
100
+ * Finds the first entry in the array that satisfies the predicate.
101
+ * @template EntryType - The type of the entries in the array.
102
+ * @callback PredicateFunction - The predicate function to use to search the array.
103
+ * @param {EntryType} item - The entry in the array to search.
104
+ * @returns {boolean} - True if the entry satisfies the predicate, false otherwise.
105
+ * @param {EntryType[]} array - The array of entries to search.
106
+ * @param {PredicateFunction} predicate - The predicate function to use to search the array.
107
+ * @returns {EntryType | null} - The first entry that satisfies the predicate, or null if not found.
108
+ */
109
+ const findEntry = (array, predicate) => array.find(predicate) || null;
110
+ exports.findEntry = findEntry;
111
+ function convertArrayToMap(arrayData, keyProp) {
112
+ if (typeof keyProp !== "string") {
113
+ throw new Error("keyProp can only be strings or numbers");
114
+ }
115
+ const dataAsObject = {};
116
+ arrayData.reduce((prev, curr) => {
117
+ const key = curr[keyProp];
118
+ prev[key] = curr;
119
+ return prev;
120
+ }, dataAsObject);
121
+ return dataAsObject;
122
+ }
123
+ exports.convertArrayToMap = convertArrayToMap;
package/dist/text.d.ts ADDED
@@ -0,0 +1,146 @@
1
+ /**
2
+ *
3
+ * @function
4
+ * @param {T} input - The string, object, or array of objects that needs to have its casing changed
5
+ * @param {"toSnakeCase" | "toCamelCase"} type - The type of casing the string, object, or array of objects should be converted to (snake_case or camelCase)
6
+ * @returns {T} - A new string, object, or array of objects in the specified casing
7
+ */
8
+ export declare const convertKeyCasing: <T extends string | Object | Object[]>(input: T, type: "toSnakeCase" | "toCamelCase") => T;
9
+ /**
10
+ *
11
+ * @function
12
+ * @returns {string} - A randomly generated string.
13
+ */
14
+ export declare const uuidv4: () => string;
15
+ /**
16
+ *
17
+ * @function
18
+ * @param {number} position - A position number.
19
+ * @returns {string} - A string representing the position with the appropriate suffix (st, nd, rd, or th) e.g "1st", "2nd", "3rd", "4th", etc.
20
+ */
21
+ export declare const formatPosition: (position: number) => string;
22
+ /**
23
+ *
24
+ * @function
25
+ * @param {string} text - The text to be truncated
26
+ * @param {number} characterLimit - The maximum number of characters that the text can have
27
+ * @returns {string} - The truncated text with "..." added at the end if the text has exceeded the character limit
28
+ */
29
+ export declare const truncateText: (text: string, characterLimit: number) => string;
30
+ /**
31
+ *
32
+ * @function
33
+ * @param {string} path - The path of the file
34
+ * @returns {string} - The file name
35
+ */
36
+ export declare const fileNameFromPath: (path: string) => string;
37
+ /**
38
+ *
39
+ * @function
40
+ * @param {string} s - The string that needs to have spaces replaced with underscores
41
+ * @returns {string} - The string with spaces replaced with underscores
42
+ */
43
+ export declare const replaceSpacesWithUnderscore: (s?: string) => string;
44
+ /**
45
+ *
46
+ * @function
47
+ * @param {string} s - The string that needs to have underscores replaced with spaces
48
+ * @returns {string} - The string with underscores replaced with spaces
49
+ */
50
+ export declare const replaceUnderscoreWithSpaces: (s?: string) => string;
51
+ /**
52
+ *
53
+ * @function
54
+ * @param {string} word - The word that needs to be pluralized
55
+ * @param {boolean} condition - The condition that determines if the word needs to be pluralized
56
+ * @returns {string} - The word with "s" added to the end if the condition is true
57
+ */
58
+ export declare const pluralizeOnCondition: (word: string, condition: boolean) => string;
59
+ /**
60
+ * @function
61
+ * @param {Object | Array<Object> | string} data - The object or array of objects to convert key cases
62
+ * @returns {Object | Array<Object> | string} - The object or array of objects with the keys in camelCase
63
+ */
64
+ export declare const convertSnakeToCamelCase: (data: string | Object | Array<Object>) => string | Object | Object[];
65
+ /**
66
+ * @function
67
+ * @param {Object | Array<Object> | string} data - The object or array of objects to convert key cases
68
+ * @returns {Object | Array<Object> | string} - The object or array of objects with the keys in snake_case
69
+ */
70
+ export declare const convertCamelToSnakeCase: (data: string | Object | Array<Object>) => string | Object | Object[];
71
+ /**
72
+ * Convert camel case to kebab case
73
+ * @function
74
+ * @param {string} word - The word needed to be converted to kebab case from camel case
75
+ * @returns {string} - The word returned as kebab case
76
+ */
77
+ export declare function convertCamelToKebabCase(word: string): string;
78
+ /**
79
+ * Convert kebab case to camel case
80
+ * @function
81
+ * @param {string} word - The word needed to be converted from kebab case to camel case
82
+ * @returns {string} - The word returned as camel case
83
+ */
84
+ export declare function convertKebabToCamelCase(word: string): string;
85
+ /**
86
+ * Validate if a word is acronym
87
+ * @function
88
+ * @param {string} word - The word that is being validated as acronym
89
+ * @returns {string} - The boolean value when the condition is met
90
+ */
91
+ export declare function isAcronym(word: string): boolean;
92
+ /**
93
+ * Convert acronym to kebab case
94
+ * @function
95
+ * @param {string} word - The acronym to be converted to kebab case
96
+ * @returns {string} - The word returned as camel case
97
+ */
98
+ export declare function acronymToKebabCase(word: string): string;
99
+ /**
100
+ * @function
101
+ * @param value The string to be displayed
102
+ * @returns The passed string or the default string if the passed string is null or undefined
103
+ */
104
+ export declare const handleNullDisplay: (value: string | null | undefined, defaultValue?: string) => string;
105
+ /**
106
+ * @function
107
+ * @param text The string to be capitalized
108
+ * @returns The string in a capitalized form
109
+ */
110
+ export declare const capitalizeText: (text: string | undefined) => string;
111
+ /**
112
+ * Enforces a character limit on a given string.
113
+ * @function
114
+ * @param {object} options - The options for the function.
115
+ * @param {string} options.text - The text to limit.
116
+ * @param {number} options.characterLimit - The maximum number of characters allowed.
117
+ * @param {function} options.onCharacterLimit - The function to call when the character limit is exceeded.
118
+ * @returns {string} The original string if it is shorter than the character limit, or a truncated version of the string if it is longer.
119
+ */
120
+ export declare const enforceCharacterLimit: ({ text, characterLimit, onCharacterLimit, }: {
121
+ text: string;
122
+ characterLimit: number;
123
+ onCharacterLimit: () => void;
124
+ }) => string;
125
+ /**
126
+ * Validate email if its a proper email or not
127
+ * @function
128
+ * @param email The email to be validated
129
+ * @returns The boolean value when the condition is met
130
+ */
131
+ export declare const isValidEmail: (email: string) => boolean;
132
+ /**
133
+ * Generate ID from word
134
+ * @function
135
+ * @param word The word needed to generate ID from
136
+ * @returns The generated ID from the word
137
+ */
138
+ export declare function generateIDFromWord(text: string): string;
139
+ /**
140
+ * Get the word from the generated ID
141
+ * @function
142
+ * @param id The id that is needed to get the word from.
143
+ * @param customList The word lists that are used to check the original words from.
144
+ * @returns The word that is got from the id
145
+ */
146
+ export declare function generateWordFromId(id: string, customList?: Record<string, string>): string;