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

us-home-safety-score

v1.0.0

Published

Compute residential Home Safety Scores (0-100, A-F) from federal data: EPA water violations, lead/copper levels, EPA radon zones, and FEMA flood claims.

Readme

us-home-safety-score

Compute residential Home Safety Scores (0-100, A-F) from U.S. federal data. Zero dependencies. Works in Node.js 14+.

The Home Safety Score is a composite index that evaluates environmental risk for any U.S. ZIP code across four dimensions:

  • Water quality — EPA SDWIS violation history
  • Lead exposure — EPA Lead and Copper Rule sampling
  • Radon risk — EPA county-level radon zones
  • Flood risk — FEMA NFIP historical claims

Higher score = safer. The algorithm is the same one used on ZipCheckup.com to score 33,000+ ZIP codes.

Quick Start

npm install us-home-safety-score
const { computeSafetyScore } = require('us-home-safety-score');

const result = computeSafetyScore({
  totalViolations: 3,
  healthViolations: 1,
  leadLevel: 0.008,     // mg/L (90th percentile)
  radonZone: 2,         // EPA zone: 1=High, 2=Moderate, 3=Low
  floodClaims: 25,      // FEMA NFIP historical claims
});

console.log(result);
// {
//   score: 56,
//   grade: 'C',
//   components: {
//     water: { score: 21, maxPoints: 25, weight: 0.25 },
//     lead:  { score: 18, maxPoints: 25, weight: 0.25 },
//     radon: { score: 13, maxPoints: 25, weight: 0.25 },
//     flood: { score: 15, maxPoints: 25, weight: 0.25 },
//   },
//   componentCount: 4,
// }

Methodology

Scoring Components

| Component | Weight | Max Points | Source | |-----------|--------|-----------|--------| | Water Quality | 25% | 25 | EPA SDWIS (5-year violations) | | Lead/Copper | 25% | 25 | EPA LCR (90th percentile lead) | | Radon | 25% | 25 | EPA radon zones (county-level) | | Flood | 25% | 25 | FEMA NFIP (historical claims) |

When FEMA flood data is unavailable, the score uses a 3-component fallback where each remaining component contributes up to 33 points (~33% weight).

Grade Scale

| Grade | Score Range | Meaning | |-------|-----------|---------| | A | 85-100 | Low risk | | B | 70-84 | Below-average risk | | C | 55-69 | Moderate risk | | D | 40-54 | Elevated risk | | F | 0-39 | High risk |

Resolved Violation Decay

Violations that have been resolved (returned to compliance) are weighted at 0.25x instead of 1.0x. This reflects that the system corrected the issue, while still penalizing historical infrastructure problems.

For the complete methodology with formulas, rationale, limitations, and validation cases, see METHODOLOGY.md.

API

computeSafetyScore(data)

Compute the composite Home Safety Score.

Parameters:

| Field | Type | Required | Description | |-------|------|----------|-------------| | totalViolations | number | Yes | Total SDWIS violations (past 5 years) | | healthViolations | number | Yes | Health-based violations (past 5 years) | | resolvedViolations | number | No (default 0) | Resolved total violations | | resolvedHealthViolations | number | No (default 0) | Resolved health violations | | leadLevel | number\|null | No | 90th-percentile lead level (mg/L) | | radonZone | 1\|2\|3\|null | No | EPA radon zone | | floodClaims | number\|null | No | FEMA NFIP historical claims count |

Returns: { score, grade, components, componentCount }

computeLeadRisk(data)

Evaluate lead exposure risk from LCR sampling data.

const { computeLeadRisk } = require('us-home-safety-score');

computeLeadRisk({ leadLevel: 0.012 });
// { risk: 'elevated', probability: 0.55, exceedsActionLevel: false,
//   description: 'Lead level is near the EPA action level of 15 ppb...' }

Returns: { risk, probability, exceedsActionLevel, description }

computeFloodRisk(data)

Evaluate flood risk from FEMA NFIP claims.

const { computeFloodRisk } = require('us-home-safety-score');

computeFloodRisk({ floodClaims: 500, floodAvgPaid: 45000 });
// { risk: 'high', estimatedAnnualCost: 750000, claims: 500, description: '...' }

Returns: { risk, estimatedAnnualCost, claims, description }

computeComplianceRisk(data)

Evaluate water system regulatory compliance.

const { computeComplianceRisk } = require('us-home-safety-score');

computeComplianceRisk({ totalViolations: 8, healthViolations: 3, unresolvedViolations: 2 });
// { risk: 'poor', score: 28, unresolved: 2, description: '...' }

Returns: { risk, score, unresolved, description }

computeEnergyBurden(data)

Compute energy cost as a percentage of household income.

const { computeEnergyBurden } = require('us-home-safety-score');

computeEnergyBurden({ annualEnergyCost: 3600, medianIncome: 45000 });
// { burden: 8, risk: 'high', description: '...' }

Returns: { burden, risk, description }

scoreToGrade(score)

Convert a numeric score (0-100) to a letter grade.

scoreToGrade(72); // 'B'
scoreToGrade(38); // 'F'

Data Sources

| # | Source | Agency | What It Provides | |---|--------|--------|-----------------| | 1 | SDWIS | EPA | Water system violations | | 2 | Lead & Copper Rule | EPA | 90th-percentile lead/copper levels | | 3 | Radon Zones | EPA | County-level radon classification | | 4 | NFIP Claims | FEMA | Flood insurance claims by ZIP | | 5 | ECHO | EPA | Enforcement actions | | 6 | CCR Data | EPA | Consumer Confidence Reports | | 7 | Census ACS | Census | Median income, demographics | | 8 | EIA SEDS | EIA | State energy costs | | 9 | NWS API | NOAA | Active weather alerts | | 10 | TIGER/Line | Census | ZIP boundaries, coordinates | | 11 | ZIP-County Crosswalk | HUD | ZIP-to-county mapping | | 12 | Contaminant MCLs | EPA | Maximum contaminant levels | | 13 | SDWA Compliance | EPA | Safe Drinking Water Act data | | 14 | LCRR | EPA | Revised Lead and Copper Rule | | 15 | County FIPS | Census | County identification codes |

Tests

node test.js

Tests cover:

  • Flint, MI scenario (expected: F grade)
  • Clean suburb scenario (expected: A, score 100)
  • 3-component fallback (no flood data)
  • Missing data defaults
  • Resolved violation decay
  • Lead/flood/compliance risk tiers
  • Energy burden calculation
  • Grade boundary values
  • Error handling

Contributing

Contributions are welcome. Please:

  1. Fork the repository
  2. Create a feature branch (git checkout -b feature/improvement)
  3. Add tests for any new functionality
  4. Ensure node test.js passes
  5. Submit a pull request

For methodology changes, please open an issue first to discuss the rationale.

Links

License

MIT. See LICENSE.


Built by ZipCheckup. Federal data, zero opinions.