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

expand-exponential

v0.1.1

Published

Expand exponential (scientific) notation to a full decimal string

Readme

expand-exponential

MIT License Node.js Version Coverage

指数表記(例: 1e+20, 1.23e-5)を通常の10進数文字列(例: "100000000000000000000", "0.0000123")に展開する軽量ライブラリです。 JavaScript の number 型では安全に扱えない大きな数や高精度の小数も、文字列として正確に返します。

A lightweight library that expands exponential (scientific) notation (e.g., 1e+20, 1.23e-5) into full decimal strings (e.g., "100000000000000000000", "0.0000123"). Returns results as strings, preserving precision beyond JavaScript's number safe range.


📖 目次 / Table of Contents


📦 インストール / Installation

npm install expand-exponential

🚀 クイックスタート / Quick Start

Node.js (CommonJS)

const { expandExponential } = require("expand-exponential");

console.log(expandExponential("1.23e5")); // "123000"
console.log(expandExponential("5e-7")); // "0.0000005"
console.log(expandExponential(1e21)); // "1000000000000000000000"

Node.js (ESM)

import { expandExponential } from "expand-exponential";

console.log(expandExponential("1.23e5")); // "123000"
console.log(expandExponential("5e-7")); // "0.0000005"
console.log(expandExponential(1e21)); // "1000000000000000000000"

📚 API リファレンス / API Reference

expandExponential(number)

指数表記を展開し、10進数の文字列として返します。 指数表記でない数値文字列はそのまま返します。

Expands exponential notation to a full decimal string. Non-exponential numeric strings are returned as-is.

  • 引数 / Parameters: number (string | number) - 展開する数値または文字列 / The number or string to expand
  • 戻り値 / Returns: string - 展開された10進数文字列 / Expanded decimal string
  • 例外 / Throws:
    • InvalidArgumentError - null, undefined, 空文字の場合 / If null, undefined, or empty string
    • InvalidInputError - NaN, Infinity, 不正な形式の場合 / If NaN, Infinity, or invalid format
    • ResultOverflowError - 結果文字列が最大長を超える場合 / If result exceeds max string length

例 / Examples:

// 正の指数 / Positive exponent
expandExponential("1.23e5"); // "123000"
expandExponential("5e3"); // "5000"
expandExponential("9.87654e6"); // "9876540"

// 負の指数 / Negative exponent
expandExponential("1.23e-2"); // "0.0123"
expandExponential("5e-7"); // "0.0000005"

// 負の数 / Negative numbers
expandExponential("-1.5e4"); // "-15000"
expandExponential("-2.5e-3"); // "-0.0025"

// number型入力 / Number type input
expandExponential(1e21); // "1000000000000000000000"
expandExponential(5e-7); // "0.0000005"

// 指数表記でない入力はそのまま返す / Non-exponential input returned as-is
expandExponential("123.456"); // "123.456"
expandExponential(42); // "42"

📝 入力形式 / Input Format

サポートされている入力 / Supported Input

| 入力タイプ / Input Type | 例 / Example | 結果 / Result | | ----------------------- | ------------ | -------------------------- | | 指数表記 (string) | "1.23e5" | "123000" | | 指数表記 (大文字E) | "2.5E10" | "25000000000" | | 明示的な+記号 | "+1.23e+5" | "123000" | | 負の指数 | "1.23e-2" | "0.0123" | | 負の数 | "-1.5e4" | "-15000" | | number 型 | 1e21 | "1000000000000000000000" | | 通常の数値文字列 | "123.456" | "123.456" |

サポートされていない入力 / Unsupported Input

| 入力 / Input | エラー / Error | | ---------------------------------- | ---------------------- | | null, undefined, "" | InvalidArgumentError | | NaN, Infinity | InvalidInputError | | "abc", "1.2.3e5" | InvalidInputError | | "1e999999999" (結果が巨大すぎる) | ResultOverflowError |


⚠️ エラーハンドリング / Error Handling

すべてのエラーは ExpandExponentialErrorBase を継承しています。 エラーの種別ごとにキャッチできます。

All errors extend ExpandExponentialErrorBase. You can catch errors by specific type.

import { expandExponential } from "expand-exponential";

try {
  expandExponential("abc");
} catch (error) {
  console.log(error.name); // "InvalidInputError"
  console.log(error.message); // "Expected a valid number format."
}

| エラークラス / Error Class | 発生条件 / Condition | | -------------------------- | ----------------------------------------------------------------- | | InvalidArgumentError | null, undefined, 空文字 / null, undefined, empty string | | InvalidInputError | NaN, Infinity, 不正な形式 / NaN, Infinity, invalid format | | ResultOverflowError | 結果が文字列最大長を超過 / Result exceeds max string length |


💻 TypeScript サポート / TypeScript Support

TypeScript の型定義が含まれています。

TypeScript definitions are included.

import { expandExponential } from "expand-exponential";

const result: string = expandExponential("1.23e5"); // "123000"

🌐 CDN 経由での利用 / Use via CDN

jsDelivr や unpkg の CDN から直接ブラウザで利用できます。

You can use the library directly in the browser via jsDelivr or unpkg CDN.

<script src="https://cdn.jsdelivr.net/npm/expand-exponential/dist/index.umd.js"></script>
<script>
  const { expandExponential } = ExpandExponential;
  console.log(expandExponential("1.23e5")); // "123000"
</script>

unpkg も同様に利用可能です:

You can also use unpkg:

<script src="https://unpkg.com/expand-exponential/dist/index.umd.js"></script>

🛠️ 開発 / Development

ビルド / Build

npm run build

テストの実行 / Running Tests

npm test              # 全テストを実行 / Run all tests
npm run test:watch    # ウォッチモードで実行 / Run in watch mode
npm run test:coverage # カバレッジ付きで実行 / Run with coverage

ライセンス / License

MIT License

作者 / Author

dak-ia

リポジトリ / Repository

https://github.com/dak-ia/expand-exponential