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

@juan-jmz/oee-core

v0.1.1

Published

A dependency-free, mathematically correct OEE calculation engine for industrial systems.

Readme

oee-core

A dependency-free, mathematically correct OEE calculation engine for industrial systems, built in TypeScript.

Overview

oee-core is a lightweight, summary-driven library for calculating Overall Equipment Effectiveness (OEE) using production totals.

It is designed to enforce correct mathematical computation and aggregation, avoiding common mistakes such as averaging pre-calculated KPIs.

The library does not handle:

  • Data collection
  • PLC communication
  • MQTT publishing
  • Database access
  • Event timelines

It focuses exclusively on deterministic calculations based on structured input data.

Why this library exists

Most OEE implementations in real systems are incorrect. A common mistake is averaging KPIs across machines, shifts, or lines:

OEE_total = average(OEE_machine_1, OEE_machine_2)

This produces misleading results.

oee-core enforces correct aggregation by requiring base production data and recalculating OEE from first principles.

Installation

npm install @juan-jmz/oee-core

Design Principles

  • Summary-driven (no event timelines)
  • Deterministic and stateless
  • No external dependencies
  • Mathematically correct aggregation
  • Strict input validation
  • Infrastructure-agnostic

Data Model

ProductionRun

Represents production for a specific product or configuration.

export interface ProductionRun {
  idealCycleTime: number
  totalCount: number
  goodCount: number
}

OEESummaryInput

Represents production totals for a defined period (shift, day, machine, etc.).

export interface OEESummaryInput {
  plannedProductionTime: number
  unplannedDowntime: number
  production: ProductionRun[]
  totalCalendarTime?: number
}

OEEResult

export interface OEEResult {
  availability: number
  performance: number
  quality: number
  oee: number
  utilization?: number
  teep?: number
}

Units

The library does not enforce specific units, but all time values must be consistent.

Example:

  • If plannedProductionTime is in seconds
  • idealCycleTime must also be in seconds

Extended Metrics (Utilization & TEEP)

If totalCalendarTime is provided, the library will also compute:

  • Utilization
  • TEEP
const result = calculate({
  plannedProductionTime: 28800,
  unplannedDowntime: 3600,
  totalCalendarTime: 86400,
  production: [
    {
      idealCycleTime: 1.2,
      totalCount: 8000,
      goodCount: 7800
    }
  ]
})

Basic Usage

import { calculate } from "@juanjmz/oee-core"

const result = calculate({
  plannedProductionTime: 28800,
  unplannedDowntime: 3600,
  production: [
    {
      idealCycleTime: 1.2,
      totalCount: 8000,
      goodCount: 7800
    },
    {
      idealCycleTime: 0.9,
      totalCount: 10000,
      goodCount: 9700
    }
  ]
})

console.log(result)

Calculation Model

Availability

$$ Operating\ Time = Planned\ Production\ Time - Unplanned\ Downtime $$

$$ Availability = \frac{Operating\ Time}{Planned\ Production\ Time} $$

Performance

$$ Performance = \frac{\sum (Ideal\ Cycle\ Time \times Total\ Count)}{Operating\ Time} $$

Quality

$$ Quality = \frac{Good\ Count}{Total\ Count} $$

Utilization

$$ Utilization = \frac{Planned\ Production\ Time}{Total\ Calendar\ Time} $$

TEEP

$$ TEEP = OEE \times Utilization $$

Aggregation (Correct Method)

Never average KPIs.

Incorrect:

average(OEE_shift_1, OEE_shift_2)

Correct:

import { aggregate } from "@juanjmz/oee-core"

const result = aggregate([
  shift1,
  shift2,
  shift3
])

Aggregation works by:

  • Summing planned production time
  • Summing unplanned downtime
  • Merging production runs
  • Recalculating OEE from base data

Validation Rules

The library throws errors if:

  • plannedProductionTime <= 0
  • unplannedDowntime < 0
  • unplannedDowntime > plannedProductionTime
  • production array is empty
  • totalCount < 0
  • goodCount < 0
  • goodCount > totalCount
  • idealCycleTime <= 0
  • totalCalendarTime <= 0 (if provided)
  • totalCalendarTime < plannedProductionTime (if provided)

Invalid input fails fast

Edge Cases

Defined behavior:

  • If totalCount = 0 → quality = 0
  • If operatingTime = 0 → performance = 0
  • If plannedProductionTime = 0 → throws error

What This Library Does Not Do

  • No event timeline processing
  • No downtime classification
  • No shift management
  • No production scheduling
  • No data persistence

Those concerns belong to higher-level systems.

Intended Use Cases

  • Industrial backend systems
  • OEE dashboards
  • MES integrations
  • Data pipelines
  • Analytics services

Example Output

{
  availability: 0.875,
  performance: 0.91,
  quality: 0.97,
  oee: 0.77
  utilization: 0.33,
  teep: 0.25
}

Roadmap

  • Extended aggregation utilities
  • Optional strict mode configuration
  • Helper utilities for data normalization
  • Integration helpers (separate packages)

License

  • MIT

Author