quantible 0.1.3-alpha → 0.1.5-alpha
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.d.mts +107 -0
- package/dist/index.d.ts +107 -0
- package/dist/index.js +1057 -0
- package/dist/index.mjs +1028 -0
- package/package.json +7 -5
package/dist/index.d.mts
ADDED
|
@@ -0,0 +1,107 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @interface ExtractionResult
|
|
3
|
+
* @description Represents all possible extraction results
|
|
4
|
+
* and contains all properties that can be extracted from a given input string.
|
|
5
|
+
*/
|
|
6
|
+
interface ExtractionResult {
|
|
7
|
+
input: string;
|
|
8
|
+
matchType: string;
|
|
9
|
+
index: number;
|
|
10
|
+
integer?: string;
|
|
11
|
+
decimal?: string;
|
|
12
|
+
negativeInt?: boolean;
|
|
13
|
+
currency?: string;
|
|
14
|
+
exponent?: string;
|
|
15
|
+
unit?: string;
|
|
16
|
+
unitExponent?: string;
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
/**
|
|
20
|
+
* Returns the first match of a number, currency, unit, or exponent in the given string.
|
|
21
|
+
* The returned object contains the extracted groups and additional information such as
|
|
22
|
+
* the type of match and the index of the match in the string.
|
|
23
|
+
*
|
|
24
|
+
* @param {string} input - The string to search for matches
|
|
25
|
+
* @returns {patternExtraction | null} - The extracted groups and additional information, or null if no match is found
|
|
26
|
+
*/
|
|
27
|
+
declare function extractFirstMatch(input: string): ExtractionResult | null;
|
|
28
|
+
/**
|
|
29
|
+
* Extracts all matches of a number, currency, unit, or exponent in the given string
|
|
30
|
+
* and returns an array of the extracted groups and additional information such as
|
|
31
|
+
* the type of match and the index of the match in the string.
|
|
32
|
+
*
|
|
33
|
+
* If the input string contains no matches, an empty array is returned.
|
|
34
|
+
*
|
|
35
|
+
* @param {string} input - The string to search for matches
|
|
36
|
+
* @returns {patternExtraction[]} - The extracted groups and additional information, or an empty array if no match is found
|
|
37
|
+
*/
|
|
38
|
+
declare function extractAllMatches(input: string): ExtractionResult[];
|
|
39
|
+
|
|
40
|
+
/**
|
|
41
|
+
* Validates an ExtractionResult object.
|
|
42
|
+
*
|
|
43
|
+
* Checks that the object is present, contains the required properties, and that
|
|
44
|
+
* the values of those properties are of the correct type.
|
|
45
|
+
*
|
|
46
|
+
* If the object is invalid, throws an Error with a description of the problem.
|
|
47
|
+
*
|
|
48
|
+
* @param {ExtractionResult} extractionResult - The object to validate.
|
|
49
|
+
*/
|
|
50
|
+
declare function validateExtractionResult(extractionResult: ExtractionResult): void;
|
|
51
|
+
|
|
52
|
+
/**
|
|
53
|
+
* @namespace extractQuantities
|
|
54
|
+
* @description Contains functions for extracting numeric data from a string.
|
|
55
|
+
*/
|
|
56
|
+
declare const extractQuantities: {
|
|
57
|
+
/**
|
|
58
|
+
* Extracts the first match (number || currency || unit || operator || scientific expression) from the input string.
|
|
59
|
+
* @param {string} input - The string to extract from.
|
|
60
|
+
* @returns {ExtractionResult | null} The extracted data or null if no match is found.
|
|
61
|
+
*/
|
|
62
|
+
firstMatch: typeof extractFirstMatch;
|
|
63
|
+
/**
|
|
64
|
+
* Extracts all matches (number || currency || unit || operator || scientific expression) from the input string.
|
|
65
|
+
* @param {string} input - The string to extract from.
|
|
66
|
+
* @returns {ExtractionResult[]} The extracted data.
|
|
67
|
+
*/
|
|
68
|
+
allMatches: typeof extractAllMatches;
|
|
69
|
+
};
|
|
70
|
+
/**
|
|
71
|
+
* @namespace convertQuantities
|
|
72
|
+
* @description Contains functions for converting (number || currency || unit || operator || scientific expression) data from a string or object to spoken word.
|
|
73
|
+
*/
|
|
74
|
+
declare const convertQuantities: {
|
|
75
|
+
/**
|
|
76
|
+
* Translates an ExtractionResult object (number || currency || unit || operator || scientific expression) into its spoken word equivalent.
|
|
77
|
+
*
|
|
78
|
+
* @param {ExtractionResult} extractionResult - The ExtractionResult object to translate.
|
|
79
|
+
* @returns {string} The spoken word equivalent of the ExtractionResult.
|
|
80
|
+
*/
|
|
81
|
+
/**
|
|
82
|
+
* Translates an ExtractionResult object (number || currency || unit || operator || scientific expression) into its spoken word equivalent.
|
|
83
|
+
*
|
|
84
|
+
* @param {ExtractionResult} extractionResult - The ExtractionResult object to translate.
|
|
85
|
+
* @returns {string} The spoken word equivalent of the ExtractionResult.
|
|
86
|
+
*/
|
|
87
|
+
translateMatch: (extractionResult: ExtractionResult) => string;
|
|
88
|
+
/**
|
|
89
|
+
* Extracts the first match (number || currency || unit || operator || scientific expression) from the input string
|
|
90
|
+
* and translates it to its spoken word equivalent.
|
|
91
|
+
*
|
|
92
|
+
* @param {string} input - The string to extract and translate from.
|
|
93
|
+
* @returns {string} The input string with the first match replaced by its spoken word equivalent,
|
|
94
|
+
* or an empty string if no match is found.
|
|
95
|
+
*/
|
|
96
|
+
autoReplaceFirstMatch: (input: string) => string;
|
|
97
|
+
/**
|
|
98
|
+
* Extracts all matches (number || currency || unit || operator || scientific expression) from the input string
|
|
99
|
+
* and translates them to their spoken word equivalents.
|
|
100
|
+
*
|
|
101
|
+
* @param {string} input - The string to extract and translate from.
|
|
102
|
+
* @returns {string} The input string with all matches replaced by their spoken word equivalents. Returns the original string if no matches are found.
|
|
103
|
+
*/
|
|
104
|
+
autoReplaceAllMatches: (input: string) => string;
|
|
105
|
+
};
|
|
106
|
+
|
|
107
|
+
export { convertQuantities, extractQuantities, validateExtractionResult };
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,107 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @interface ExtractionResult
|
|
3
|
+
* @description Represents all possible extraction results
|
|
4
|
+
* and contains all properties that can be extracted from a given input string.
|
|
5
|
+
*/
|
|
6
|
+
interface ExtractionResult {
|
|
7
|
+
input: string;
|
|
8
|
+
matchType: string;
|
|
9
|
+
index: number;
|
|
10
|
+
integer?: string;
|
|
11
|
+
decimal?: string;
|
|
12
|
+
negativeInt?: boolean;
|
|
13
|
+
currency?: string;
|
|
14
|
+
exponent?: string;
|
|
15
|
+
unit?: string;
|
|
16
|
+
unitExponent?: string;
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
/**
|
|
20
|
+
* Returns the first match of a number, currency, unit, or exponent in the given string.
|
|
21
|
+
* The returned object contains the extracted groups and additional information such as
|
|
22
|
+
* the type of match and the index of the match in the string.
|
|
23
|
+
*
|
|
24
|
+
* @param {string} input - The string to search for matches
|
|
25
|
+
* @returns {patternExtraction | null} - The extracted groups and additional information, or null if no match is found
|
|
26
|
+
*/
|
|
27
|
+
declare function extractFirstMatch(input: string): ExtractionResult | null;
|
|
28
|
+
/**
|
|
29
|
+
* Extracts all matches of a number, currency, unit, or exponent in the given string
|
|
30
|
+
* and returns an array of the extracted groups and additional information such as
|
|
31
|
+
* the type of match and the index of the match in the string.
|
|
32
|
+
*
|
|
33
|
+
* If the input string contains no matches, an empty array is returned.
|
|
34
|
+
*
|
|
35
|
+
* @param {string} input - The string to search for matches
|
|
36
|
+
* @returns {patternExtraction[]} - The extracted groups and additional information, or an empty array if no match is found
|
|
37
|
+
*/
|
|
38
|
+
declare function extractAllMatches(input: string): ExtractionResult[];
|
|
39
|
+
|
|
40
|
+
/**
|
|
41
|
+
* Validates an ExtractionResult object.
|
|
42
|
+
*
|
|
43
|
+
* Checks that the object is present, contains the required properties, and that
|
|
44
|
+
* the values of those properties are of the correct type.
|
|
45
|
+
*
|
|
46
|
+
* If the object is invalid, throws an Error with a description of the problem.
|
|
47
|
+
*
|
|
48
|
+
* @param {ExtractionResult} extractionResult - The object to validate.
|
|
49
|
+
*/
|
|
50
|
+
declare function validateExtractionResult(extractionResult: ExtractionResult): void;
|
|
51
|
+
|
|
52
|
+
/**
|
|
53
|
+
* @namespace extractQuantities
|
|
54
|
+
* @description Contains functions for extracting numeric data from a string.
|
|
55
|
+
*/
|
|
56
|
+
declare const extractQuantities: {
|
|
57
|
+
/**
|
|
58
|
+
* Extracts the first match (number || currency || unit || operator || scientific expression) from the input string.
|
|
59
|
+
* @param {string} input - The string to extract from.
|
|
60
|
+
* @returns {ExtractionResult | null} The extracted data or null if no match is found.
|
|
61
|
+
*/
|
|
62
|
+
firstMatch: typeof extractFirstMatch;
|
|
63
|
+
/**
|
|
64
|
+
* Extracts all matches (number || currency || unit || operator || scientific expression) from the input string.
|
|
65
|
+
* @param {string} input - The string to extract from.
|
|
66
|
+
* @returns {ExtractionResult[]} The extracted data.
|
|
67
|
+
*/
|
|
68
|
+
allMatches: typeof extractAllMatches;
|
|
69
|
+
};
|
|
70
|
+
/**
|
|
71
|
+
* @namespace convertQuantities
|
|
72
|
+
* @description Contains functions for converting (number || currency || unit || operator || scientific expression) data from a string or object to spoken word.
|
|
73
|
+
*/
|
|
74
|
+
declare const convertQuantities: {
|
|
75
|
+
/**
|
|
76
|
+
* Translates an ExtractionResult object (number || currency || unit || operator || scientific expression) into its spoken word equivalent.
|
|
77
|
+
*
|
|
78
|
+
* @param {ExtractionResult} extractionResult - The ExtractionResult object to translate.
|
|
79
|
+
* @returns {string} The spoken word equivalent of the ExtractionResult.
|
|
80
|
+
*/
|
|
81
|
+
/**
|
|
82
|
+
* Translates an ExtractionResult object (number || currency || unit || operator || scientific expression) into its spoken word equivalent.
|
|
83
|
+
*
|
|
84
|
+
* @param {ExtractionResult} extractionResult - The ExtractionResult object to translate.
|
|
85
|
+
* @returns {string} The spoken word equivalent of the ExtractionResult.
|
|
86
|
+
*/
|
|
87
|
+
translateMatch: (extractionResult: ExtractionResult) => string;
|
|
88
|
+
/**
|
|
89
|
+
* Extracts the first match (number || currency || unit || operator || scientific expression) from the input string
|
|
90
|
+
* and translates it to its spoken word equivalent.
|
|
91
|
+
*
|
|
92
|
+
* @param {string} input - The string to extract and translate from.
|
|
93
|
+
* @returns {string} The input string with the first match replaced by its spoken word equivalent,
|
|
94
|
+
* or an empty string if no match is found.
|
|
95
|
+
*/
|
|
96
|
+
autoReplaceFirstMatch: (input: string) => string;
|
|
97
|
+
/**
|
|
98
|
+
* Extracts all matches (number || currency || unit || operator || scientific expression) from the input string
|
|
99
|
+
* and translates them to their spoken word equivalents.
|
|
100
|
+
*
|
|
101
|
+
* @param {string} input - The string to extract and translate from.
|
|
102
|
+
* @returns {string} The input string with all matches replaced by their spoken word equivalents. Returns the original string if no matches are found.
|
|
103
|
+
*/
|
|
104
|
+
autoReplaceAllMatches: (input: string) => string;
|
|
105
|
+
};
|
|
106
|
+
|
|
107
|
+
export { convertQuantities, extractQuantities, validateExtractionResult };
|