mechanical-tolerance-calculator 1.1.3 → 1.1.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.
Files changed (2) hide show
  1. package/index.js +15 -8
  2. package/package.json +1 -1
package/index.js CHANGED
@@ -371,10 +371,22 @@ function processIndividualMeasurement(materialType, measurement, tolerances) {
371
371
  }
372
372
 
373
373
  function checkMultipleMeasurementsFor(materialType, measurements) {
374
- const validation = validateMeasurements(measurements);
375
- if (validation?.error) {
376
- return validation;
374
+ const errors = [];
375
+
376
+ measurements.forEach((m, index) => {
377
+ if (!isValidMeasurement(m)) {
378
+ errors.push({
379
+ index,
380
+ value: m,
381
+ error: "Invalid measurement: must be 0–1000",
382
+ });
383
+ }
384
+ });
385
+
386
+ if (errors.length > 0) {
387
+ return { error: "Some measurements are invalid.", details: errors };
377
388
  }
389
+
378
390
  const camcoStandardTolerances = getCamcoStandardTolerancesFor(materialType);
379
391
 
380
392
  let largestMeasurement = Math.max(...measurements);
@@ -499,11 +511,6 @@ function validateMeasurements(measurements) {
499
511
  };
500
512
  }
501
513
 
502
- measurements.forEach((a) => {
503
- if (!isValidMeasurement(a)) {
504
- return { error: "Measurement must be between 0 to 1000." };
505
- }
506
- });
507
514
  return null;
508
515
  }
509
516
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "mechanical-tolerance-calculator",
3
- "version": "1.1.3",
3
+ "version": "1.1.4",
4
4
  "description": "Calculates international standard specification and tolerances for bores, round bars and metals of mechanical units. For examples; H7, H8, H9, h8, h9 specifications and IT5/IT6 tolerances.",
5
5
  "main": "index.js",
6
6
  "scripts": {