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

hongfangze-random

v1.0.0

Published

comm.random

Downloads

11

Readme

随机数据

介绍

获取随机数据,包括随机字符串、随机数、随机IP地址等

import { getRandomIp,unUsePort } from 'hongfangze-random';
// import * as random from 'hongfangze-random';
// import random from 'hongfangze-random';

/**
 * 获取一个随机的未使用的端口号
 * @returns
 */
export declare const unUsePort: () => Promise<number>;
/**
 * 生成随机字符串
 * @param {Number} len 生成的长度 不传则为默认8 只允许int类型
 * @param {String} chars chars 生成指定字符串允许出现的字符 不传则默认大小写字母与数字
 * @returns
 */
export declare const getRandomStr: (len?: number, chars?: string) => string;
/**
 * 生成随机数
 * @param {*} Min 最小值
 * @param {*} Max 最大值
 * @returns
 */
export declare const getRandomNum: (Min?: number, Max?: number) => number;
/**
 * 获取国内的随机IP地址
 * @param {string} [area_code] 地区代码,如北京=11,内蒙古=15,江苏=32等,非必填,不填时随机地区
 * @return {*}  {{
 *     ip: string, // ip地址
 *     area_name: string, // 地区名称
 *     area_code: string, // 地区代码
 * }}
 */
export declare const getRandomIp: (area_code?: string) => {
    ip: string;
    area_name: string;
    area_code: string;
};

版本迭代记录

2025-04-09 v1.0.0

  • 被移除后更名发布。

2025-03-28 v0.1.1

  • 增加随机IP地址获取接口。
  • 新的打包方式。