mechanical-tolerance-calculator 1.0.7 → 1.0.8

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 +31 -1
  2. package/package.json +1 -1
package/index.js CHANGED
@@ -221,6 +221,14 @@ function processMeasurement(materialType, measurement, tolerances) {
221
221
  computedBounds.upperBound
222
222
  );
223
223
 
224
+ const outcome =
225
+ measurement > computedBounds.upperBound
226
+ ? `${materialType} is over-sized.`
227
+ : measurement >= computedBounds.lowerBound &&
228
+ measurement <= computedBounds.upperBound
229
+ ? `${materialType} is in acceptable size.`
230
+ : `${materialType} is under-sized.`;
231
+
224
232
  return {
225
233
  measurement: parseStringFloat(measurement),
226
234
  nominal,
@@ -230,7 +238,11 @@ function processMeasurement(materialType, measurement, tolerances) {
230
238
  uncomputed_specification_bounds: uncomputedBounds,
231
239
  matched_spec: matchedSpec,
232
240
 
233
- meets_specification: { meetsSpec, reason: specMeetingReason },
241
+ meets_specification: {
242
+ meetsSpec,
243
+ reason: specMeetingReason,
244
+ concludedReason: outcome,
245
+ },
234
246
  };
235
247
  }
236
248
 
@@ -391,6 +403,24 @@ function checkMultipleMeasurementsFor(materialType, measurements) {
391
403
  baseSpec.computed_specification_bounds.lowerBound,
392
404
  baseSpec.computed_specification_bounds.upperBound
393
405
  );
406
+
407
+ const isOverSized =
408
+ mostFarMeasurement > baseSpec.computed_specification_bounds.upperBound;
409
+ const isWithinSizeRange =
410
+ mostFarMeasurement <= baseSpec.computed_specification_bounds.upperBound &&
411
+ mostFarMeasurement >= baseSpec.computed_specification_bounds.lowerBound;
412
+ const outcome =
413
+ (isWithinSizeRange
414
+ ? `${materialType} is acceptable in size`
415
+ : isOverSized
416
+ ? `${materialType} is over-sized`
417
+ : `${materialType} is under-sized`) +
418
+ (isWithinSizeRange && meetsIT
419
+ ? `, and `
420
+ : !meetsIT && isWithinSizeRange
421
+ ? `, but `
422
+ : `, and `) +
423
+ (meetsIT ? `meets IT tolerance.` : `doesn't meet IT tolerance.`);
394
424
  return {
395
425
  ...baseSpec,
396
426
  measurement: measurements,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "mechanical-tolerance-calculator",
3
- "version": "1.0.7",
3
+ "version": "1.0.8",
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": {