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

funny-time-lib

v3.1.1

Published

一些工作中常用的函数,目前包含格式化时间,随机字符串

Readme

####使用方式

//node
npm i funny-time-lib

// 浏览器
<script src="https://cdn.jsdelivr.net/npm/[email protected]/dist/funny-utils.min.js"></script>

格式化时间

const {formatDay} = require('funny-time-lib') 

console.log(formatDay(11123111).join(":"))  
// 3089:45:11

console.log(formatDay(11123111,true))  
// [ '128', '17', '45', '11' ]

随机字符串

const {randomStr,randomType} = require('funny-time-lib') 

// 可以任意组合
interface randomStrParams {
    type?: randomType,          // 随机字符串的类型,包括数字,小写字母,大写字母 ,默认为所有类型
    length?: number,            // 生成随机字符串的长度 默认为10
    otherSource?: string,       // 其他的的数据源,比如 "~@" 默认为''
    overriderSource?: boolean   //是否使用其他数据源覆盖默认的数据源 默认为false
}

// 随机从数字,小写字母,大写字母中返回长度为10的字符串
console.log(randomStr()); // VLGW2XfuCF

// 返回指定长度的数字 ,默认为10
console.log(randomStr({type:randomType.NUMBER}));  // 7219642363

// 返回指定长度的数字
console.log(randomStr({type:randomType.NUMBER,length:5}));  // 24820

// 增加源数据,返回长度为10的数字和提供的源数据字符串
console.log(randomStr({type:randomType.NUMBER,otherSource:"@#$%^&**^%$"}));  // 46%0#14%23

// 使用指定的源数据
console.log(randomStr({otherSource:"@#$%^&**^%$",overriderSource:true}));  // &^%@*^$@$%

//返回小写和数字的随机字符串,可使用类似方式任意组合
console.log(randomStr({type:randomType.NUMBER| randomType.ALPHA}));  // ttci0fpat3

随机返回数组或者字符串中的下标和元素

// 返回 [index,element]
console.log(randomElement([1,2,3,4,5]))  // [ 4, 5 ]
console.log(randomElement("helloworld"))  // [ 3, 'l' ]

随机返回数组或者字符串的子串,不能超过数组或者字符串的长度

// 打乱字符串
console.log(randomManyElements("helloworld"))  // oldeolhwlr

//打乱数组
console.log(randomManyElements([1,2,3,4,5])) // [ 4, 1, 2, 5, 3 ]

// 允许重复使用源数据,有可能得到两个d
console.log(randomManyElements("helloworld",true)) // doodldlowl

// 打乱随机获取指定长度的数组
console.log(randomManyElements([1,2,3,4,5],false, 3)) // [ 2, 4, 5 ]

更新记录

  • v3.1.0 --> 增加example
  • v3.0.0 --> 增加一些随机小工具,增加浏览器导入lib的入口 dist-web