# parsegraph-fuzzyequals

> Compares numbers within a set tolerance

Latest version **1.4.13** (published 2023-02-01) · MIT license · 0 weekly downloads

## Install

```sh
npm install parsegraph-fuzzyequals
pnpm add parsegraph-fuzzyequals
yarn add parsegraph-fuzzyequals
bun add parsegraph-fuzzyequals
```

## Health

**Score 20/100 (F)** — status: abandoned.

Positive: has types; no vulnerabilities.

Warnings: low downloads; no esm support.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 1.4.13 |
| Published | 2023-02-01 |
| First published | 2020-12-06 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | bundled |
| Module format | CommonJS |
| Dependencies | 0 |
| Unpacked size | 10 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| Author | Rainback, Inc. |
| Maintainers | dafrito, tracy3 |

## Links

- npm: https://www.npmjs.com/package/parsegraph-fuzzyequals
- Repository: https://github.com/parsegraph/fuzzyequals
- Homepage: https://github.com/parsegraph/fuzzyequals#readme
- Issues: https://github.com/parsegraph/fuzzyequals/issues
- npm.io page: https://npm.io/package/parsegraph-fuzzyequals

## Recent versions

- 1.4.13 (latest) — 2023-02-01
- 1.4.13-dev (dev) — 2023-02-01
- 1.4.6 (next) — 2021-07-14
- 1.4.12 — 2023-01-22
- 1.4.12-dev — 2023-01-22
- 1.4.11 — 2023-01-14
- 1.4.11-dev — 2023-01-14
- 1.4.10 — 2022-12-30
- 1.4.10-dev — 2022-12-30
- 1.4.9 — 2022-02-28
- 1.4.9-dev — 2022-02-28
- 1.4.8 — 2022-02-21
- 1.4.8-dev — 2022-02-21
- 1.4.7 — 2022-02-21
- 1.4.7-dev — 2022-02-21
- … 6 more at https://npm.io/package/parsegraph-fuzzyequals/versions

## README

# fuzzyEquals

Compares two values, allowing for a variable amount of tolerance.

    import fuzzyEquals from 'parsegraph-fuzzyequals';

    let iters = 0;
    let delta = 1;
    const a = 1;
    let isFuzzyEqual = false;
    while(a !== a + delta) {
      iters++;
      const b = a + delta;
      if (!isFuzzyEqual && fuzzyEquals(a, b)) {
        console.log(`Iteration ${iters}. delta=${delta}`);
        console.log(`fuzzyEquals(${a}, ${b})=${fuzzyEquals(a, b)}`);
        isFuzzyEqual = true;
      }
      delta = delta / 2;
    }
    console.log(`Iteration ${iters}. delta=${delta}`);
    console.log(`${a} === ${a + delta}: ${a === a + delta}`);

Output:

    Iteration 21. delta=9.5367431640625e-7
    fuzzyEquals(1, 1.0000009536743164)=true
    Iteration 53. delta=1.1102230246251565e-16
    1 === 1: true

---
_Source: https://npm.io/package/parsegraph-fuzzyequals · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
