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

@pigjs/utils

v1.2.2

Published

A front-end utils library for business scenarios

Downloads

12

Readme

@pigjs/utils

一款面向业务场景的前端实用 utils 库

目前已经支持:

  • 浏览器
    • getUrlParam 获取 url 参数
    • getUrlParams 获取 url 所有参数
    • setUrlParams 设置 url 参数
  • 实用函数
    • digitUppercase 金额中文大写
    • formatMoney 金额添加千分号
    • getObjectValue 对象安全取值
    • mergeProps 合并默认值和 props
    • omit 忽略对象属性
    • sleep 睡眠函数
  • react 相关
    • attachPropertiesToComponent 把属性连接到 组件上 + useEvent 返回一个函数,自动 useCallback 解决闭包陷阱
    • useMemo 缓存计算结果,自定义更新
    • useMount 只在组件 mount 时执行的 hook
    • usePropsValue 数据双向绑定
    • useSetState 和 class this.setState 功能相同
    • useUnmount 只在组件 unmount 时执行的 hook
    • useUpdate 返回一个函数,调用该函数会强制组件重新渲染
    • useUrlParam 获取 url 参数 hook
    • useUrlState 管理 url 参数状态的 hook
    • withNativeProps 合并 props 的 className、style 和 element 的 className、style
    • withStopPropagation 阻止组件事件冒泡
  • 类型
    • isArray 检查输入值是否为 数组
    • isBase64 检查输入值是否为 base64 字符串
    • isBlob 检查输入值是否为 Blob
    • isBoolean 检查输入值是否为 布尔值
    • isEmpty 检查输入的值是否为空
    • isEmptyArray 检查输入的值是否为 空数组
    • isEmptyObject 检查输入的值是否为 空对象
    • isEmptyString 检查输入的值是否为 空字符串
    • isFile 检查输入的值是否为 File
    • isFunction 检查输入的值是否为 function
    • isNil 检查输入值是否为 'null' 或 'undefined'
    • isNull 检查输入的值是否为 null
    • isNumber 检查输入的值是否为 数字 不包括 NaN
    • isObject 检查输入的值是否为 对象
    • isRegExp 检查输入的值是否为 正则
    • isString 检查输入的值是否为 字符串
    • isUndefined 检查输入的值是否为 undefined

查看我们的网站@pigjs/utils了解更多信息