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

@lazy-random/preset-seedrandom

v3.0.0

Published

以 seedrandom 作為亂數產生器 (Random Number Generator, RNG) 的 random-extra 預設實例 (Preset),載入即可直接使用

Readme

@lazy-random/preset-seedrandom

以 seedrandom 作為亂數產生器 (Random Number Generator, RNG) 的 random-extra 預設實例 (Preset)。

套件載入時即建立好 Random 實例並直接匯出,省去每次自行呼叫 newUse('seedrandom') 的設定步驟。

特色 (Features)

  • 開箱即用:載入即取得已套用 seedrandom 的 Random 實例 (Singleton)
  • 同時提供預設匯出 (Default Export)、具名匯出 (Named Export) seedrandom 與別名 (Alias) random
  • 可直接交給其他 @lazy-random/random-extra API 使用

安裝 (Installation)

yarn add @lazy-random/preset-seedrandom
yarn-tool add @lazy-random/preset-seedrandom
yt add @lazy-random/preset-seedrandom

使用方式 (Usage)

import seedrandom from '@lazy-random/preset-seedrandom';

// 取得下一個亂數 (Random Number)
const n = seedrandom.next();

具名匯出 (Named Export) 與別名 (Alias):

import { seedrandom, random } from '@lazy-random/preset-seedrandom';

// random 與 seedrandom 為同一個實例
console.log(seedrandom === random); // true

API 文件 (API)

seedrandom(亦為預設匯出,別名 random)

  • 型別 (Type):Random<RNGSeedRandom>(來自 random-extra)
  • 於模組載入時建立的單例 (Singleton),三個匯出皆為同一個值
  • 常用方法 (Methods):
    • next(): number — 取得下一個亂數 (Random Number)
    • seed(value) — 重設種子 (Seed)(若底層亂數產生器 (RNG) 支援)

注意 (Note) 未指定種子 (Seed) 時由 seedrandom 自動決定初始狀態;若需要每次重現相同的亂數序列,請自行設定種子。

設定 (Configuration)

本套件本身無需設定;如需變更亂數行為,請在使用時自行設定種子 (Seed) 或改用 random-extra 建立自訂實例。

開發 (Development)

pnpm run build
pnpm run test:jest

變更日誌 (Changelog)

詳細版本紀錄請見 CHANGELOG.md。

FAQ

Q:預設匯出、seedrandom、random 三個匯出有差別嗎?

A:沒有,三者是同一個 Random 實例 (Singleton),可依匯入習慣擇一使用。

Q:如何讓每次執行產生相同的亂數序列?

A:建立後自行設定種子 (Seed),例如呼叫 seedrandom.seed(1234);未設定時由 seedrandom 自動決定初始狀態。

Q:可以改用其他亂數產生器 (RNG) 嗎?

A:本套件固定以 seedrandom 建立實例;如需其他產生器,請直接使用 random-extra 的 newUse() 自行建立。

相關資源 (Related Resources)