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

quad-solver

v1.0.0

Published

Solve quadratic equations ax² + bx + c = 0

Readme

quad-solver

Solve quadratic equations of the form ax² + bx + c = 0 — via CLI or REST API.


Installation

Global — to use the CLI from anywhere:

npm install -g quad-solver

Local — to run the API server in a project:

npm install quad-solver

CLI

quad-solver <a> <b> <c>

Solves ax² + bx + c = 0 and prints the result.

Examples

quad-solver 1 -5 6
# { roots: [ 3, 2 ], discriminant: 1 }

quad-solver 1 -2 1
# { roots: [ 1 ], discriminant: 0 }

quad-solver 1 0 1
# { roots: 'no real roots', discriminant: -4 }

REST API

Start the server:

npx quad-solver-server
# or, if installed locally:
npm start

Server runs on http://localhost:3000 by default.
Set a custom port with the PORT environment variable:

PORT=4000 npm start

POST /solve

Request

POST /solve
Content-Type: application/json

{
  "a": 1,
  "b": -5,
  "c": 6
}

Responses

| Case | roots | discriminant | | ------------------ | ----------------- | -------------- | | Two distinct roots | [3, 2] | > 0 | | Double root | [1] | 0 | | No real roots | "no real roots" | < 0 |

Example with curl:

curl -X POST http://localhost:3000/solve \
  -H "Content-Type: application/json" \
  -d '{"a": 1, "b": -5, "c": 6}'
{ "roots": [3, 2], "discriminant": 1 }

Error (400) — when a, b, or c is missing:

{ "error": "Provide a, b, and c in the request body." }

API Reference

solve(a, b, c)

The core function exported by this package.

import { solve } from "quad-solver";

solve(1, -5, 6); // { roots: [3, 2],          discriminant: 1  }
solve(1, -2, 1); // { roots: [1],             discriminant: 0  }
solve(1, 0, 1); // { roots: 'no real roots', discriminant: -4 }

| Parameter | Type | Description | | --------- | -------- | ----------------- | | a | number | Coefficient of x² | | b | number | Coefficient of x | | c | number | Constant term |

Returns:

{
  roots: number[] | "no real roots",
  discriminant: number
}

Throws Error if any coefficient is not a finite number.


Author

Temiloluwa Tomilola David [Mac]


License

MIT