quantible 0.1.5-alpha → 0.1.6-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.
Files changed (48) hide show
  1. package/dist/{index.mjs → index.cjs} +32 -2
  2. package/dist/index.cjs.map +1 -0
  3. package/dist/index.global.js +1054 -0
  4. package/dist/index.global.js.map +1 -0
  5. package/dist/index.js +3 -31
  6. package/dist/index.js.map +1 -0
  7. package/dist/types/config/default.d.ts +40 -0
  8. package/dist/types/config/default.d.ts.map +1 -0
  9. package/dist/types/converters/convertCurrencyToSpokenWord.d.ts +8 -0
  10. package/dist/types/converters/convertCurrencyToSpokenWord.d.ts.map +1 -0
  11. package/dist/types/converters/convertNumberToSpokenWord.d.ts +8 -0
  12. package/dist/types/converters/convertNumberToSpokenWord.d.ts.map +1 -0
  13. package/dist/types/converters/convertNumericUnitToSpokenWord.d.ts +8 -0
  14. package/dist/types/converters/convertNumericUnitToSpokenWord.d.ts.map +1 -0
  15. package/dist/types/converters/convertOperatorToSpokenWord.d.ts +8 -0
  16. package/dist/types/converters/convertOperatorToSpokenWord.d.ts.map +1 -0
  17. package/dist/types/converters/convertScientificExpressionToSpokenWord.d.ts +8 -0
  18. package/dist/types/converters/convertScientificExpressionToSpokenWord.d.ts.map +1 -0
  19. package/dist/types/converters/convertUnitOnlyToSpokenWord.d.ts +8 -0
  20. package/dist/types/converters/convertUnitOnlyToSpokenWord.d.ts.map +1 -0
  21. package/dist/{index.d.ts → types/index.d.ts} +4 -52
  22. package/dist/types/index.d.ts.map +1 -0
  23. package/dist/types/interfaces/configurations/default.d.ts +23 -0
  24. package/dist/types/interfaces/configurations/default.d.ts.map +1 -0
  25. package/dist/types/interfaces/definitions.d.ts +101 -0
  26. package/dist/types/interfaces/definitions.d.ts.map +1 -0
  27. package/dist/types/utils/extraction/patternExtractor.d.ts +22 -0
  28. package/dist/types/utils/extraction/patternExtractor.d.ts.map +1 -0
  29. package/dist/types/utils/extraction/regexPatterns.d.ts +3 -0
  30. package/dist/types/utils/extraction/regexPatterns.d.ts.map +1 -0
  31. package/dist/types/utils/parseSuperscript.d.ts +7 -0
  32. package/dist/types/utils/parseSuperscript.d.ts.map +1 -0
  33. package/dist/types/utils/stringBuilding/exponent.d.ts +3 -0
  34. package/dist/types/utils/stringBuilding/exponent.d.ts.map +1 -0
  35. package/dist/types/utils/stringBuilding/negative.d.ts +2 -0
  36. package/dist/types/utils/stringBuilding/negative.d.ts.map +1 -0
  37. package/dist/types/utils/stringBuilding/perDigit.d.ts +8 -0
  38. package/dist/types/utils/stringBuilding/perDigit.d.ts.map +1 -0
  39. package/dist/types/utils/stringBuilding/positiveInteger.d.ts +7 -0
  40. package/dist/types/utils/stringBuilding/positiveInteger.d.ts.map +1 -0
  41. package/dist/types/utils/stringBuilding/twoDigits.d.ts +7 -0
  42. package/dist/types/utils/stringBuilding/twoDigits.d.ts.map +1 -0
  43. package/dist/types/utils/stringBuilding/zeroTo999.d.ts +7 -0
  44. package/dist/types/utils/stringBuilding/zeroTo999.d.ts.map +1 -0
  45. package/dist/types/utils/validateExtractionResultObject.d.ts +13 -0
  46. package/dist/types/utils/validateExtractionResultObject.d.ts.map +1 -0
  47. package/package.json +16 -12
  48. package/dist/index.d.mts +0 -107
@@ -0,0 +1,8 @@
1
+ import { baseUnitOnly } from "../interfaces/definitions.js";
2
+ /**
3
+ * Converts a unit-only object into its spoken word representation.
4
+ * @param {baseUnitOnly} unitOnlyObject - The unit-only object to convert.
5
+ * @returns {string} The spoken word representation of the unit.
6
+ */
7
+ export declare function convertUnitOnlyToSpokenWord(unitOnlyObject: baseUnitOnly): string;
8
+ //# sourceMappingURL=convertUnitOnlyToSpokenWord.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"convertUnitOnlyToSpokenWord.d.ts","sourceRoot":"","sources":["../../../src/converters/convertUnitOnlyToSpokenWord.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,YAAY,EAAE,MAAM,8BAA8B,CAAC;AAE5D;;;;GAIG;AACH,wBAAgB,2BAA2B,CAAC,cAAc,EAAE,YAAY,GAAG,MAAM,CAkBhF"}
@@ -1,54 +1,6 @@
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
-
1
+ import { extractFirstMatch, extractAllMatches } from "./utils/extraction/patternExtractor.js";
2
+ import { ExtractionResult } from "./interfaces/definitions.js";
3
+ import { validateExtractionResult } from "./utils/validateExtractionResultObject.js";
52
4
  /**
53
5
  * @namespace extractQuantities
54
6
  * @description Contains functions for extracting numeric data from a string.
@@ -103,5 +55,5 @@ declare const convertQuantities: {
103
55
  */
104
56
  autoReplaceAllMatches: (input: string) => string;
105
57
  };
106
-
107
58
  export { convertQuantities, extractQuantities, validateExtractionResult };
59
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,iBAAiB,EAAE,iBAAiB,EAAE,MAAM,wCAAwC,CAAC;AAQ9F,OAAO,EAOL,gBAAgB,EACjB,MAAM,6BAA6B,CAAC;AAErC,OAAO,EAAE,wBAAwB,EAAE,MAAM,2CAA2C,CAAC;AAErF;;;GAGG;AACH,QAAA,MAAM,iBAAiB;IACrB;;;;OAIG;;IAEH;;;;OAIG;;CAEJ,CAAC;AAEF;;;GAGG;AACH,QAAA,MAAM,iBAAiB;IACrB;;;;;OAKG;IACH;;;;;OAKG;uCACgC,gBAAgB,KAAG,MAAM;IAiC5D;;;;;;;OAOG;mCAC4B,MAAM,KAAG,MAAM;IAM9C;;;;;;OAMG;mCAC4B,MAAM,KAAG,MAAM;CAmB/C,CAAC;AAEF,OAAO,EAAE,iBAAiB,EAAG,iBAAiB,EAAE,wBAAwB,EAAE,CAAA"}
@@ -0,0 +1,23 @@
1
+ /**
2
+ * Configuration for currency fraction (e.g., cents).
3
+ */
4
+ export interface CurrencyFractionConfig {
5
+ singular: string;
6
+ plural: string;
7
+ }
8
+ /**
9
+ * Configuration for currency (e.g., USD).
10
+ */
11
+ export interface Currency {
12
+ singular: string;
13
+ plural: string;
14
+ fraction: CurrencyFractionConfig | null;
15
+ }
16
+ /**
17
+ * Configuration for a unit (e.g., meter).
18
+ */
19
+ export interface Unit {
20
+ singular: string;
21
+ plural: string;
22
+ }
23
+ //# sourceMappingURL=default.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"default.d.ts","sourceRoot":"","sources":["../../../../src/interfaces/configurations/default.ts"],"names":[],"mappings":"AAAA;;GAEG;AACH,MAAM,WAAW,sBAAsB;IACrC,QAAQ,EAAE,MAAM,CAAC;IACjB,MAAM,EAAE,MAAM,CAAC;CAChB;AAED;;GAEG;AACH,MAAM,WAAW,QAAQ;IACvB,QAAQ,EAAE,MAAM,CAAC;IACjB,MAAM,EAAE,MAAM,CAAC;IACf,QAAQ,EAAE,sBAAsB,GAAG,IAAI,CAAC;CACzC;AAED;;GAEG;AACH,MAAM,WAAW,IAAI;IACnB,QAAQ,EAAE,MAAM,CAAC;IACjB,MAAM,EAAE,MAAM,CAAC;CAChB"}
@@ -0,0 +1,101 @@
1
+ /**
2
+ * Represents the base structure for all extraction results,
3
+ * containing the input string, match type, index, and length of the extracted value.
4
+ */
5
+ interface baseExtraction {
6
+ input: string;
7
+ matchType: string;
8
+ index: number;
9
+ }
10
+ /**
11
+ * @interface numericBaseExtraction
12
+ * @extends {baseExtraction}
13
+ * @description Represents the base structure for numeric extraction results,
14
+ * extending the baseExtraction with properties for integer, decimal, and negative integer indication.
15
+ */
16
+ interface numericBaseExtraction extends baseExtraction {
17
+ integer: string;
18
+ decimal?: string;
19
+ negativeInt: boolean;
20
+ }
21
+ /**
22
+ * @interface baseCurrency
23
+ * @extends {numericBaseExtraction}
24
+ * @description Represents the structure for currency extraction results,
25
+ * extending the numericBaseExtraction with properties for match type (symbol or code) and currency symbol or code.
26
+ */
27
+ export interface baseCurrency extends numericBaseExtraction {
28
+ matchType: "symbolCurrency" | "codeCurrency";
29
+ currency: string;
30
+ }
31
+ /**
32
+ * @interface baseScientific
33
+ * @extends {numericBaseExtraction}
34
+ * @description Represents the structure for scientific notation extraction results,
35
+ * extending the numericBaseExtraction with properties for match type (scientific) and a mandatory exponent value.
36
+ */
37
+ export interface baseScientific extends numericBaseExtraction {
38
+ matchType: "scientific";
39
+ exponent: string;
40
+ }
41
+ /**
42
+ * @interface baseNumberUnit
43
+ * @extends {numericBaseExtraction}
44
+ * @description Represents the structure for quantitative unit extraction results,
45
+ * extending the numericBaseExtraction with properties for match type (unit), unit name, optional exponent, and optional unit exponent.
46
+ */
47
+ export interface baseNumberUnit extends numericBaseExtraction {
48
+ matchType: "unit";
49
+ unit: string;
50
+ exponent?: string;
51
+ unitExponent?: string;
52
+ }
53
+ /**
54
+ * @interface baseUnitOnly
55
+ * @extends {baseExtraction}
56
+ * @description Represents the structure for unit-only extraction results,
57
+ * extending the baseExtraction with properties for match type (unitOnly), unit name, and optional unit exponent.
58
+ */
59
+ export interface baseUnitOnly extends baseExtraction {
60
+ matchType: "unitOnly";
61
+ unit: string;
62
+ unitExponent?: string;
63
+ }
64
+ /**
65
+ * @interface baseOperator
66
+ * @extends {baseExtraction}
67
+ * @description Represents the structure for mathematical operator extraction results,
68
+ * extending the baseExtraction with a property for match type (operator).
69
+ */
70
+ export interface baseOperator extends baseExtraction {
71
+ matchType: "operator";
72
+ }
73
+ /**
74
+ * @interface baseNumber
75
+ * @extends {numericBaseExtraction}
76
+ * @description Represents the structure for number extraction results,
77
+ * extending the numericBaseExtraction with properties for match type (number) and an optional exponent.
78
+ */
79
+ export interface baseNumber extends numericBaseExtraction {
80
+ matchType: "number";
81
+ exponent?: string;
82
+ }
83
+ /**
84
+ * @interface ExtractionResult
85
+ * @description Represents all possible extraction results
86
+ * and contains all properties that can be extracted from a given input string.
87
+ */
88
+ export interface ExtractionResult {
89
+ input: string;
90
+ matchType: string;
91
+ index: number;
92
+ integer?: string;
93
+ decimal?: string;
94
+ negativeInt?: boolean;
95
+ currency?: string;
96
+ exponent?: string;
97
+ unit?: string;
98
+ unitExponent?: string;
99
+ }
100
+ export {};
101
+ //# sourceMappingURL=definitions.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"definitions.d.ts","sourceRoot":"","sources":["../../../src/interfaces/definitions.ts"],"names":[],"mappings":"AAAA;;;GAGG;AACH,UAAU,cAAc;IACtB,KAAK,EAAE,MAAM,CAAC;IACd,SAAS,EAAE,MAAM,CAAC;IAClB,KAAK,EAAE,MAAM,CAAC;CACf;AAED;;;;;GAKG;AACH,UAAU,qBAAsB,SAAQ,cAAc;IACpD,OAAO,EAAE,MAAM,CAAC;IAChB,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,WAAW,EAAE,OAAO,CAAC;CACtB;AAED;;;;;GAKG;AACH,MAAM,WAAW,YAAa,SAAQ,qBAAqB;IACzD,SAAS,EAAE,gBAAgB,GAAG,cAAc,CAAC;IAC7C,QAAQ,EAAE,MAAM,CAAC;CAClB;AAED;;;;;GAKG;AACH,MAAM,WAAW,cAAe,SAAQ,qBAAqB;IAC3D,SAAS,EAAE,YAAY,CAAC;IACxB,QAAQ,EAAE,MAAM,CAAC;CAClB;AAED;;;;;GAKG;AACH,MAAM,WAAW,cAAe,SAAQ,qBAAqB;IAC3D,SAAS,EAAE,MAAM,CAAC;IAClB,IAAI,EAAE,MAAM,CAAC;IACb,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,YAAY,CAAC,EAAE,MAAM,CAAC;CACvB;AAED;;;;;GAKG;AACH,MAAM,WAAW,YAAa,SAAQ,cAAc;IAClD,SAAS,EAAE,UAAU,CAAC;IACtB,IAAI,EAAE,MAAM,CAAC;IACb,YAAY,CAAC,EAAE,MAAM,CAAC;CACvB;AAED;;;;;GAKG;AACH,MAAM,WAAW,YAAa,SAAQ,cAAc;IAClD,SAAS,EAAE,UAAU,CAAC;CACvB;AAED;;;;;GAKG;AACH,MAAM,WAAW,UAAW,SAAQ,qBAAqB;IACvD,SAAS,EAAE,QAAQ,CAAC;IACpB,QAAQ,CAAC,EAAE,MAAM,CAAC;CACnB;AAED;;;;GAIG;AACH,MAAM,WAAW,gBAAgB;IAC/B,KAAK,EAAE,MAAM,CAAC;IACd,SAAS,EAAE,MAAM,CAAC;IAClB,KAAK,EAAE,MAAM,CAAC;IACd,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,WAAW,CAAC,EAAE,OAAO,CAAC;IACtB,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,YAAY,CAAC,EAAE,MAAM,CAAC;CACvB"}
@@ -0,0 +1,22 @@
1
+ import { ExtractionResult } from "../../interfaces/definitions.js";
2
+ /**
3
+ * Returns the first match of a number, currency, unit, or exponent in the given string.
4
+ * The returned object contains the extracted groups and additional information such as
5
+ * the type of match and the index of the match in the string.
6
+ *
7
+ * @param {string} input - The string to search for matches
8
+ * @returns {patternExtraction | null} - The extracted groups and additional information, or null if no match is found
9
+ */
10
+ export declare function extractFirstMatch(input: string): ExtractionResult | null;
11
+ /**
12
+ * Extracts all matches of a number, currency, unit, or exponent in the given string
13
+ * and returns an array of the extracted groups and additional information such as
14
+ * the type of match and the index of the match in the string.
15
+ *
16
+ * If the input string contains no matches, an empty array is returned.
17
+ *
18
+ * @param {string} input - The string to search for matches
19
+ * @returns {patternExtraction[]} - The extracted groups and additional information, or an empty array if no match is found
20
+ */
21
+ export declare function extractAllMatches(input: string): ExtractionResult[];
22
+ //# sourceMappingURL=patternExtractor.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"patternExtractor.d.ts","sourceRoot":"","sources":["../../../../src/utils/extraction/patternExtractor.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,gBAAgB,EAAE,MAAM,iCAAiC,CAAC;AAEnE;;;;;;;GAOG;AAEH,wBAAgB,iBAAiB,CAAC,KAAK,EAAE,MAAM,GAAG,gBAAgB,GAAG,IAAI,CA+DxE;AAED;;;;;;;;;GASG;AACH,wBAAgB,iBAAiB,CAAC,KAAK,EAAE,MAAM,GAAG,gBAAgB,EAAE,CAsBnE"}
@@ -0,0 +1,3 @@
1
+ declare const regexMatches: RegExp;
2
+ export { regexMatches };
3
+ //# sourceMappingURL=regexPatterns.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"regexPatterns.d.ts","sourceRoot":"","sources":["../../../../src/utils/extraction/regexPatterns.ts"],"names":[],"mappings":"AA0BA,QAAA,MAAM,YAAY,QAkDjB,CAAC;AAEF,OAAO,EAAE,YAAY,EAAE,CAAC"}
@@ -0,0 +1,7 @@
1
+ /**
2
+ * Converts a string of superscript digits to regular integer string.
3
+ * @param {string} superscriptString - String containing superscript digits.
4
+ * @returns {string} - String of regular digits.
5
+ */
6
+ export declare function toRegularInteger(superscriptString: string): string;
7
+ //# sourceMappingURL=parseSuperscript.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"parseSuperscript.d.ts","sourceRoot":"","sources":["../../../src/utils/parseSuperscript.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AACH,wBAAgB,gBAAgB,CAAC,iBAAiB,EAAE,MAAM,GAAG,MAAM,CAwBlE"}
@@ -0,0 +1,3 @@
1
+ /** * Converts an exponent integer to its spoken word representation, * optionally using "squared" and "cubed" for exponents 2 and 3. * @param exponent The exponent value as an integer. * @param onlyUsePowerOf A boolean flag. If false, uses "squared" for 2 and "cubed" for 3. * If true, uses "to the power of two", "to the power of three", etc. * @returns The spoken word representation of the exponent. */
2
+ export declare function exponentSpokenWord(exponent: string, onlyUsePowerOf?: boolean): string;
3
+ //# sourceMappingURL=exponent.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"exponent.d.ts","sourceRoot":"","sources":["../../../../src/utils/stringBuilding/exponent.ts"],"names":[],"mappings":"AAGA,sZAAsZ;AAEtZ,wBAAgB,kBAAkB,CAAC,QAAQ,EAAE,MAAM,EAAE,cAAc,GAAE,OAAe,GAAG,MAAM,CAa5F"}
@@ -0,0 +1,2 @@
1
+ export declare const negative: (bool: boolean) => string;
2
+ //# sourceMappingURL=negative.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"negative.d.ts","sourceRoot":"","sources":["../../../../src/utils/stringBuilding/negative.ts"],"names":[],"mappings":"AAAA,eAAO,MAAM,QAAQ,GAAI,MAAM,OAAO,KAAG,MAExC,CAAC"}
@@ -0,0 +1,8 @@
1
+ /**
2
+ * Converts each digit in a number to words, and returns them as a joined string.
3
+ * @param num The number to convert, as a string.
4
+ * @returns A string of space-separated words, where each word is a digit in the original number.
5
+ * @example convertPerDigit("123") => "one two three"
6
+ */
7
+ export declare function perDigit(num: string): string;
8
+ //# sourceMappingURL=perDigit.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"perDigit.d.ts","sourceRoot":"","sources":["../../../../src/utils/stringBuilding/perDigit.ts"],"names":[],"mappings":"AAEA;;;;;GAKG;AAEH,wBAAgB,QAAQ,CAAC,GAAG,EAAE,MAAM,GAAG,MAAM,CAM5C"}
@@ -0,0 +1,7 @@
1
+ /**
2
+ * Converts a non-negative integer into its full English word representation.
3
+ * @param num The integer to convert.
4
+ * @returns The word representation of the number, or an error message for invalid input.
5
+ */
6
+ export declare function positiveInteger(num: number): string;
7
+ //# sourceMappingURL=positiveInteger.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"positiveInteger.d.ts","sourceRoot":"","sources":["../../../../src/utils/stringBuilding/positiveInteger.ts"],"names":[],"mappings":"AAGA;;;;GAIG;AAEH,wBAAgB,eAAe,CAAC,GAAG,EAAE,MAAM,GAAG,MAAM,CAuBnD"}
@@ -0,0 +1,7 @@
1
+ /**
2
+ * Converts a given number of cents to words, provided it is a valid number between 0 and 99.
3
+ * @param num The number of cents to convert, as a string.
4
+ * @returns The word representation of the number of cents, or an empty string if the conversion failed.
5
+ */
6
+ export declare function twoDigit(num: string): string;
7
+ //# sourceMappingURL=twoDigits.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"twoDigits.d.ts","sourceRoot":"","sources":["../../../../src/utils/stringBuilding/twoDigits.ts"],"names":[],"mappings":"AAEA;;;;GAIG;AAEH,wBAAgB,QAAQ,CAAC,GAAG,EAAE,MAAM,GAAG,MAAM,CAM5C"}
@@ -0,0 +1,7 @@
1
+ /**
2
+ * Converts a number less than 1000 into words.
3
+ * @param num The number to convert (0-999).
4
+ * @returns The word representation of the number.
5
+ */
6
+ export declare function zeroTo999(num: number): string;
7
+ //# sourceMappingURL=zeroTo999.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"zeroTo999.d.ts","sourceRoot":"","sources":["../../../../src/utils/stringBuilding/zeroTo999.ts"],"names":[],"mappings":"AAEA;;;;GAIG;AAEH,wBAAgB,SAAS,CAAC,GAAG,EAAE,MAAM,GAAG,MAAM,CA4B7C"}
@@ -0,0 +1,13 @@
1
+ import { ExtractionResult } from "../interfaces/definitions.js";
2
+ /**
3
+ * Validates an ExtractionResult object.
4
+ *
5
+ * Checks that the object is present, contains the required properties, and that
6
+ * the values of those properties are of the correct type.
7
+ *
8
+ * If the object is invalid, throws an Error with a description of the problem.
9
+ *
10
+ * @param {ExtractionResult} extractionResult - The object to validate.
11
+ */
12
+ export declare function validateExtractionResult(extractionResult: ExtractionResult): void;
13
+ //# sourceMappingURL=validateExtractionResultObject.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"validateExtractionResultObject.d.ts","sourceRoot":"","sources":["../../../src/utils/validateExtractionResultObject.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,gBAAgB,EAAE,MAAM,8BAA8B,CAAC;AAehE;;;;;;;;;GASG;AACH,wBAAgB,wBAAwB,CAAC,gBAAgB,EAAE,gBAAgB,GAAG,IAAI,CA8LjF"}
package/package.json CHANGED
@@ -1,27 +1,32 @@
1
1
  {
2
2
  "name": "quantible",
3
- "version": "0.1.5-alpha",
4
3
  "description": "A versatile library for extracting and converting numerical values, units, currency, and mathematical expressions into their spoken word equivalents.",
5
- "main": "dist/cjs/index.js",
6
- "module": "dist/esm/index.js",
4
+ "version": "0.1.6-alpha",
5
+ "type": "module",
6
+ "main": "dist/index.cjs.js",
7
+ "module": "dist/index.esm.js",
8
+ "browser": "dist/index.iife.js",
7
9
  "types": "dist/types/index.d.ts",
8
10
  "exports": {
9
11
  ".": {
10
12
  "types": "./dist/types/index.d.ts",
11
- "import": "./dist/esm/index.js",
12
- "require": "./dist/cjs/index.js",
13
- "default": "./dist/esm/index.js"
13
+ "browser": "./dist/index.iife.js",
14
+ "import": "./dist/index.esm.js",
15
+ "require": "./dist/index.cjs.js",
16
+ "default": "./dist/index.esm.js"
14
17
  }
15
18
  },
16
19
  "files": [
17
- "dist",
18
- "!memlog"
20
+ "dist"
19
21
  ],
22
+ "sideEffects": false,
20
23
  "scripts": {
24
+ "prebuild": "rm -rf dist",
25
+ "build:dts": "npx tsc --emitDeclarationOnly",
26
+ "build:js": "npx tsup",
27
+ "build": "npm run prebuild && npm run build:js && npm run build:dts",
21
28
  "test": "jest _tests_",
22
- "build": "tsup",
23
- "dev": "tsup --watch",
24
- "compile": "tsc && node dist/index.js",
29
+ "compile": "npm run build && node dist/index.js",
25
30
  "lint": "eslint . --ext .ts",
26
31
  "format": "prettier --write ."
27
32
  },
@@ -57,7 +62,6 @@
57
62
  "jest": "^29.7.0",
58
63
  "prettier": "^3.5.3",
59
64
  "ts-jest": "^29.3.1",
60
- "tsup": "^8.4.0",
61
65
  "typescript": "^5.8.2"
62
66
  }
63
67
  }
package/dist/index.d.mts DELETED
@@ -1,107 +0,0 @@
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 };