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 🙏

© 2024 – Pkg Stats / Ryan Hefner

@webtanzhi/utils

v1.0.7

Published

Javascript Utils

Downloads

4

Readme

utils

  • 支持 node 环境

开发规则

  • 必须ts开发
  • 必须写测试脚本,必须测试通过方可发布
  • 尽可能少的调用外部仓库

构建

根据 webpack 优先加载 module 和 browser

https://github.com/SunshowerC/blog/issues/8

使用

npm i @webtanzhi/utils

功能列表

  • isFunction (value) => boolean value是不是一个方法
  • isObject (value) => boolean value是不是一个对象
  • isNullOrUndefined (value) => boolean value是否已经定义
  • isPromise (value) => boolean 简单判断是否是Promise(通过.then)
  • isBrowser boolean 是否为浏览器环境
  • isNumber (value) => boolean 判断类型是否数字
  • getDocumentHeight () => number document的高度
  • unShownHeight () => number document没有展示出的高度
  • getTopDomain (domainStr) => string 获取顶级域名
  • (node)sha1 (string|Buffer) => string sha1加密计算
  • (browser)sha1 (string) => string sha1字符加密计算
  • formatUrl (string) => FormatedUrl 把url转换为location
  • setSession (key: string, value: any, options:{maxAge?: number;,expire?: number;}) => void 存放数据到sessionStorage中,并设置存储时长(node环境之下不生效,不报错)
  • getSession (key: string) => any | null 获取存入的数据,不存在的话返回null
  • setLocalStorage (key: string, value: any, options:{maxAge?: number;,expire?: number;}) => void 存放数据到localStorage中,并设置存储时长(node环境之下不生效,不报错)
  • getLocalStorage (key: string) => any | null 获取存入的数据,不存在的话返回null
  • centPrice (value: number|string, multiple = 100) => number
  • formatAmount (price,{sectionSize: number 位数 = 3,separator: string 分割符号 = ','}) => string
  • formatPrice formatPrice(originPrice:sting|number,opt?:FormatPriceOption) 根据配置项返回格式化后的价格结果
  • generateFormatPrice 返回一个带自定义配置项的customFormatPrice方法,返回的customFormatPrice与formatPrice用法完全相同
  • generateCentPrice 返回一个带自定义配置项的customCentPrice方法,返回的customCentPrice与centPrice用法完全相同