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 🙏

© 2025 – Pkg Stats / Ryan Hefner

k-cesium-utils

v0.0.1

Published

基于rollup 打包ts 库

Readme

aty-utils.js

Api 列表

	objIsNull()  //判断对象是否为空或者null
	debounce() //函数防抖
	throttle() //函数节流
	formatFileSize() //格式化文件大小
	isValidKey() //判断对象中是否含有该key字段
	sortChinese() //汉字中文排序
	randomString() //生成随机字符串
	addZero() //补零
	msFormat2DateStr() //毫秒数返回年、月、日、时、分、秒
	makeTree() //根据parentId将扁平数据转树
	setToken() //设置token
	getToken() //获取token
	removeToken() //移除token
	setLocal() //设置永久缓存
	getLocal() //获取永久缓存
	removeLocal() //移除永久缓存
	clearLocal() //移除全部永久缓存
	setSession() //设置临时缓存
	getSession() //获取临时缓存
	removeSession() //移除临时缓存
	clearSession() //移除全部临时缓存
  • objIsNull 判断对象是否为空或者null

使用方式

 let a = {}
 console.log(objIsNull(a))  //true
  • debounce 函数防抖

使用方式

const fn = ()=>{
 	console.log("333")
}
const debou = debounce(fn,500,false)
  • throttle 函数节流

    使用方式

const thro = throttle(() => {
	console.log(state.value)
}, 1000)
const testThrottle = () => {
	thro()
}
  • formatFileSize 格式化文件大小

使用方式

console.log(formatFileSize(15468202))
  • isValidKey 判断对象中是否含有该key字段

使用方式

let o = { a:1, b:2 }
console.log(isValidKey("a",o))
  • sortChinese 汉字中文排序

使用方式

let arr = [{ name: "掌声" }, { name: "里斯" }, { name: "百度" }]
console.log(sortChinese(arr, "name"))
  • randomString 生成随机字符串

使用方式

console.log(randomString(64)) //长度为64位的随机字符串
  • addZero 补零

使用方式

console.log(addZero(9)) //09
  • msFormat2DateStr 毫秒数返回年、月、日、时、分、秒

使用方式

console.log(msFormat2DateStr(Date.now()))
  • makeTree 根据parentId将扁平数据转树

使用方式

const list = [
   { id: 1, name: "1", parentId: -1 },
   { id: 2, name: "11", parentId: 1 },
   { id: 3, name: "12", parentId: 1 },
   { id: 4, name: "2", parentId: -1 },
   { id: 5, name: "21", parentId: 4 },
   { id: 6, name: "22", parentId: 4 },
   { id: 7, name: "221", parentId: 6 },
   { id: 8, name: "2221", parentId: 7 }
]
console.log(makeTree(list))

Cookies 设置

  • setToken 设置token

    使用方式

setToken("123131313");
  • getToken 获取token

使用方式

console.log(getToken())
  • removeToken 移除token

使用方式

removeToken()

LocalStorage 设置

  • setLocal 设置永久缓存

使用方式

setLocal("obj", {a:1,b:2}) // 对象类型
setLocal("key", "12312313131") // 字符串类型
setLocal("list", [{a:1,b:2}]) // 数组类型
  • getLocal 获取永久缓存

使用方式

   console.log(getLocal("obj"))
   console.log(getLocal("key"))
  • removeLocal 移除永久缓存

使用方式

   removeLocal("obj")
   removeLocal("key")
  • clearLocal 移除全部永久缓存

使用方式

   clearLocal()

SessionStorage 设置

  • setSession 设置临时缓存

使用方式

setSession("obj", {a:1,b:2}) // 对象类型
  • getSession 获取临时缓存

使用方式

console.log(getSession("obj"))
  • removeSession 移除临时缓存

使用方式

removeSession("obj")
  • clearSession 移除全部临时缓存

使用方式

clearSession()