law-common 10.13.1-beta.3 → 10.13.1-beta.4

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.
@@ -173,3 +173,19 @@ export declare function transformDate<T extends {
173
173
  }>(obj: T): Modify<T, {
174
174
  date: string;
175
175
  }>;
176
+ /**
177
+ * Checks if two decimal numbers are approximately equal within a given tolerance.
178
+ *
179
+ * @param {number} firstValue - The first number to compare.
180
+ * @param {number} secondValue - The second number to compare.
181
+ * @param {number} allowedDifference - The maximum difference allowed for the numbers
182
+ * to be considered equal.
183
+ *
184
+ * @returns {boolean} Returns `true` if the numbers are within the allowed difference;
185
+ * otherwise, returns `false`.
186
+ *
187
+ * @example
188
+ * areDecimalNumbersEqual(5483.86, 5483.87, 0.5); // true
189
+ * areDecimalNumbersEqual(5483.86, 5484.5, 0.5); // false
190
+ */
191
+ export declare function areDecimalNumbersEqual(firstValue: number, secondValue: number, allowedDifference?: number): boolean;
@@ -31,6 +31,7 @@ exports.numberToWordsIndian = numberToWordsIndian;
31
31
  exports.minutesToHoursMinutes = minutesToHoursMinutes;
32
32
  exports.createKeyLabelMap = createKeyLabelMap;
33
33
  exports.transformDate = transformDate;
34
+ exports.areDecimalNumbersEqual = areDecimalNumbersEqual;
34
35
  const util_constants_1 = require("../constants/util.constants");
35
36
  function groupByFunction(list, keyGetter) {
36
37
  const map = new Map();
@@ -374,3 +375,24 @@ function createKeyLabelMap() {
374
375
  function transformDate(obj) {
375
376
  return Object.assign(Object.assign({}, obj), { date: obj.date.toISOString() });
376
377
  }
378
+ /**
379
+ * Checks if two decimal numbers are approximately equal within a given tolerance.
380
+ *
381
+ * @param {number} firstValue - The first number to compare.
382
+ * @param {number} secondValue - The second number to compare.
383
+ * @param {number} allowedDifference - The maximum difference allowed for the numbers
384
+ * to be considered equal.
385
+ *
386
+ * @returns {boolean} Returns `true` if the numbers are within the allowed difference;
387
+ * otherwise, returns `false`.
388
+ *
389
+ * @example
390
+ * areDecimalNumbersEqual(5483.86, 5483.87, 0.5); // true
391
+ * areDecimalNumbersEqual(5483.86, 5484.5, 0.5); // false
392
+ */
393
+ function areDecimalNumbersEqual(firstValue, secondValue, allowedDifference = 0.5) {
394
+ // Calculate the absolute difference between both values
395
+ const actualDifference = Math.abs(firstValue - secondValue);
396
+ // Return true if the actual difference is less than or equal to the allowed difference
397
+ return actualDifference <= allowedDifference;
398
+ }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "law-common",
3
- "version": "10.13.1-beta.3",
3
+ "version": "10.13.1-beta.4",
4
4
  "description": "",
5
5
  "main": "dist/index.js",
6
6
  "files": [