mechanical-tolerance-calculator 1.1.2 → 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.
- package/index.js +18 -8
- 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
|
|
375
|
-
|
|
376
|
-
|
|
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);
|
|
@@ -388,6 +400,9 @@ function checkMultipleMeasurementsFor(materialType, measurements) {
|
|
|
388
400
|
let count = 0;
|
|
389
401
|
let withInSpecs = [];
|
|
390
402
|
const results = measurements.map((measurement) => {
|
|
403
|
+
if (!isValidMeasurement(measurement)) {
|
|
404
|
+
return { error: "Measurement must be between 0 to 1000." };
|
|
405
|
+
}
|
|
391
406
|
const result = processIndividualMeasurement(
|
|
392
407
|
camcoStandardTolerances.type,
|
|
393
408
|
measurement,
|
|
@@ -496,11 +511,6 @@ function validateMeasurements(measurements) {
|
|
|
496
511
|
};
|
|
497
512
|
}
|
|
498
513
|
|
|
499
|
-
measurements.forEach((a) => {
|
|
500
|
-
if (!isValidMeasurement(a)) {
|
|
501
|
-
return { error: "Measurement must be between 0 to 1000." };
|
|
502
|
-
}
|
|
503
|
-
});
|
|
504
514
|
return null;
|
|
505
515
|
}
|
|
506
516
|
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "mechanical-tolerance-calculator",
|
|
3
|
-
"version": "1.1.
|
|
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": {
|