@reekon-tools/boldr-utils 1.4.11 → 1.4.13

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,6 +1,24 @@
1
1
  import { ColumnType, } from '../types/firestore.js';
2
- import { evaluateFormula, parseMixedNumber } from './evaluateFormula.js';
2
+ import { evaluateFormula } from './evaluateFormula.js';
3
3
  import { convertMicrometers } from '../utils/micrometersToUnit.js';
4
+ function parseMixedNumber(str) {
5
+ const parts = str.trim().split(' ');
6
+ let whole = 0;
7
+ let fraction = 0;
8
+ if (parts.length === 2) {
9
+ whole = parseFloat(parts[0]);
10
+ const [num, den] = parts[1].split('/').map(Number);
11
+ fraction = num / den;
12
+ }
13
+ else if (parts[0].includes('/')) {
14
+ const [num, den] = parts[0].split('/').map(Number);
15
+ fraction = num / den;
16
+ }
17
+ else {
18
+ whole = parseFloat(parts[0]);
19
+ }
20
+ return whole + fraction;
21
+ }
4
22
  export const calculateFormula = (formula, formulas, columns, tableConfig, measurements, unit, fractionalTolerance, decimalTolerance) => {
5
23
  // Convert Firestore Map to plain object if necessary
6
24
  let variableToColumnMap = {};
@@ -17,7 +17,6 @@ export interface FormulaEvaluationOptions {
17
17
  formulas?: FormulaDefinition[];
18
18
  scope?: Record<string, number>;
19
19
  }
20
- export declare function parseMixedNumber(str: string): number;
21
20
  export declare function evaluateFormula({ expression, mappings, valueMap, unit, formulas, scope, }: FormulaEvaluationOptions): number | string | null;
22
21
  export declare function createFormulaScope({ mappings, valueMap, unit, }: {
23
22
  mappings: Record<string, string>;
@@ -2,24 +2,6 @@ import { Units } from '../types/firestore.js';
2
2
  import { compile, unit as mathUnit } from 'mathjs';
3
3
  // Cache for evaluated formulas to improve performance
4
4
  const formulaCache = new Map();
5
- export function parseMixedNumber(str) {
6
- const parts = str.trim().split(' ');
7
- let whole = 0;
8
- let fraction = 0;
9
- if (parts.length === 2) {
10
- whole = parseFloat(parts[0]);
11
- const [num, den] = parts[1].split('/').map(Number);
12
- fraction = num / den;
13
- }
14
- else if (parts[0].includes('/')) {
15
- const [num, den] = parts[0].split('/').map(Number);
16
- fraction = num / den;
17
- }
18
- else {
19
- whole = parseFloat(parts[0]);
20
- }
21
- return whole + fraction;
22
- }
23
5
  function normalizeUnitForMathJS(unit) {
24
6
  switch (unit) {
25
7
  case Units.Centimeters:
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@reekon-tools/boldr-utils",
3
- "version": "1.4.11",
3
+ "version": "1.4.13",
4
4
  "description": "Shared utilities for formulas and measurement conversion used in Reekon apps",
5
5
  "author": "REEKON Tools",
6
6
  "license": "MIT",