npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

mechanical-tolerance-calculator

v1.2.3

Published

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.

Readme

Mechanical Tolerance Calculator

Calculates international standard specifications and tolerances for bores, round bars, and metallic mechanical units.
Supports standard engineering fits and tolerance grades such as H7, H8, H9, h6, h8, h9, and IT5/IT6 based on ISO tolerance systems.


Installation

npm install mechanical-tolerance-calculator

Usage

// CommonJS
const { getAllTolerancesFor } = require("mechanical-tolerance-calculator");

// ES module
// import { getAllTolerancesFor } from "mechanical-tolerance-calculator";

// Example: Housing Bore Tolerances
const housingTolerances = getAllTolerancesFor("housing");
console.log(housingTolerances["housingBoresTolerances"]);

// Example: Checking Shaft Toleranace for a Measurement
const result = checkOneMeasurementFor('shaft', 179.91); 
console.log(result);

// Exmaple: Checking Housing Specification Tolerance for a Collection of Measurements
const result = checkMultipleMeasurementsFor('housing', [240.05, 240.07, 240.09, 240.05, 240.06, 240.02, 240.09]); 
console.log(result);

API Documentation

This section documents the exported public methods of the Mechanical Tolerance Calculator library.


getAllTolerancesFor(materialType: String)

Returns all available ISO/ANSI tolerance specifications for a given material type.

Description

Determines the material category from the provided string and returns the full set of tolerance specifications associated with that category.
Supported material types include housing, shaft, and shell (case-insensitive and partial matches allowed, e.g. "housing bore").

Parameters

  • materialType (string)
    The type of material to retrieve tolerances for.
    Valid values (or substrings):
    • "housing"
    • "shaft"
    • "shell"

Returns

  • object

    On success

    {
      "type": "housingBores" | "shafts" | "shellBores",
      "specifications": {
        "H6": [ { ... } ],
        "H7": [ { ... } ],
        "...": [ { ... } ]
      }
    } ```
    
  • On failure

    {
      "error": "Unknown material type: <value>. Valid types are 'housing', 'shaft', or 'shell'."
    }

Example

const { getAllTolerancesFor } = require("mechanical-tolerance-calculator");

const tolerances = getAllTolerancesFor("housing");
console.log(tolerances.specifications.H7);

checkOneMeasurementFor(materialType: String, measurement: Number)

Checks whether a single measurement complies with the WA standard tolerance and IT grade for the given material type.

Description

  • Uses WA standard specifications:
    • Housing → H8 / IT6
    • Shell → H9 / IT6
    • Shaft → h9 / IT5
  • Infers the nominal size from the measurement.
  • Calculates upper and lower bounds.
  • Evaluates whether the measurement meets specification and IT tolerance.

Parameters

  • materialType (string)
    The type of material to check tolerance and specification for.
    Valid values (or substrings):
    • "housing"
    • "shaft"
    • "shell"
  • measurement (number)
    The measured diameter (must be between 0 and 1000).

Returns

  • object

    On success

    {
      "measurement": 24.982,
      "nominal": 25,
      "specification": "h9",
      "IT_grade": "IT5",
      "computed_specification_bounds": {
        "upperBound": "25.000",
        "lowerBound": "24.970"
      },
      "uncomputed_specification_bounds": {
        "upperBound": "25.000 + 0.000",
        "lowerBound": "25.000 - 0.030"
      },
      "matched_spec": { ... },
      "meets_specification": {
        "meetsSpec": true,
        "reason": "24.982 falls between 24.970 and 25.000",
        "concludedReason": "shaft is in acceptable size."
      },
      "meets_IT_tolerance": true
    }
  • On failure

    {
      "error": "Measurement must be between 0 to 1000."
    }

Example

const { checkOneMeasurementFor } = require("mechanical-tolerance-calculator");

const result = checkOneMeasurementFor("shaft", 179.91);
console.log(result.meets_IT_tolerance);

checkMultipleMeasurementsFor(materialType: String, measurements: Numbers[])

Evaluates multiple measurements against WA standard tolerances and IT limits as a group.

Description

  • Validates all measurements.
  • Computes:
    • Nominal size distribution
    • Maximum and minimum measurements
    • IT difference (max − min)
  • Determines:
    • Whether all measurements meet specification
    • Whether the IT tolerance band is satisfied
    • Overall compliance status

Parameters

  • materialType (string)
    The type of material to check tolerance and specification for.
    Valid values (or substrings):
    • "housing"
    • "shaft"
    • "shell"
  • measurement (number[])
    An array of measured diameters (each between 0 and 1000).

Returns

  • object

    On success

    {
      "measurement": [24.982, 24.990, 24.975],
      "nominal": 25,
      "specification": "h9",
      "IT_grade": "IT5",
      "computed_specification_bounds": {
        "upperBound": "25.000",
        "lowerBound": "24.970"
      },
      "matched_spec": { ... },
      "meets_specification": {
        "meetsSpec": true,
        "reason": "24.990 falls between 24.970 and 25.000"
      },
      "meets_IT_Tolerance": {
        "meetsIT": true,
        "reason": "The difference between 24.990 and 24.975 is less than or equal to 0.021."
      },
      "meets_final_compliance": true
    }
  • On Validation Error

    {
      "error": "Some measurements are invalid.",
      "details": [
        { "index": 1, "value": -5, "error": "Invalid measurement: must be 0–1000" }
      ]
    }

Example

const { checkMultipleMeasurementsFor } = require("mechanical-tolerance-calculator");

const result = checkMultipleMeasurementsFor('housing', [240.05, 240.07, 240.09, 240.05, 240.06, 240.02, 240.09]); 
console.log(result.meets_final_compliance);

Features

  • Compute ISO/ANSI tolerance limits and deviations for common designations.
  • Support for both bores (holes) and shafts (round bars).
  • Returns IT grade, upper/lower deviations, tolerance range, and absolute limits.
  • Lightweight, zero external dependencies.
  • Suitable for design tools, validation scripts, CAD/CAM pipelines, and educational purposes.

Reference Standards

  • ISO 286-1: Geometrical Product Specifications (GPS) — Limits and Fits
  • ANSI B4.2: Preferred Metric Limits and Fits

Examples / Typical Use Cases

  • Engineering tolerance calculators and utilities
  • Automated checks in CAD/CAM export workflows
  • Manufacturing inspection tooling and QA scripts
  • Educational examples for mechanical engineering courses

Development

Clone the repository or use the module directly after installing.

git clone <repo-url>
cd mechanical-tolerance-calculator
npm install

Contributing

Contributions and bug reports are welcome. Please open issues or pull requests on the project repository and follow the repository CONTRIBUTING guidelines if present.


Author

Ajay Ghimire


License

MIT © 2025 Ajay Ghimire


Keywords (suggested for package.json)

mechanical tolerance, ISO 286, limits and fits, H7, h6, IT5, IT6, bore, shaft, tolerances, engineering