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

@nora7aki/common

v1.0.3

Published

用于构建项目的常用方法

Readme

@nora7aki/common

用于构建项目的常用方法

安装

yarn add @nora7aki/common

引入

import {debounce} from @nora7aki/common

API

animateCSS

/**
 * 依赖 animate.css 执行动画方法
 * @param {*} node          DOM元素
 * @param {*} animation     动画名称
 * @param {*} prefix        前缀,默认animate__
 * @returns
 */
function animateCSS(node, animation, prefix = 'animate__')

debounce

/**
 * 返回防抖后的方法
 * @param {*} fn    执行方法
 * @param {*} delay 延迟时间
 * @returns
 */
function debounce(fn, delay = 1000)

downloadArrayBufferAsFile

/**
 * env:brower
 * info:将arraybuffer数据打包为文件下载
 * @param {*} data      arraybuffer数据
 * @param {*} filename  打包成为的文件名
 */
function downloadArrayBufferAsFile(data, filename)

isIOS

/**
 * 是否是iOS设备
 * @returns
 */
function isIOS()

isLocalhost

/**
 * 是否是localhost测试环境
 * @returns
 */
function isLocalhost()

isWechat

/**
 * 是否是微信浏览器
 * @returns
 */
function isWechat()

metaType

  • 本质是 Object 对象,但可以通过 keysvaluesobjectsdatas 获取不同类型的数据
  • keys 获取属性列表,有序
  • values 获取值列表,有序
  • objects 获取属性对象键值对
  • datas 获取属性 {id,value} 对象
/**
 * 元数据类型
 * 可实现自动数据缓存和归类
 * 通过datas、objs、keys、values实现对应数据的获取
 */
class MetaType
/**
 * MetaType的工厂函数
 * @returns metatype对象
 */
function metaType()

queryString

/**
 * 获取url参数值
 * @param {*} name 参数名
 * @returns
 */
function queryString(name)

screenSize

/**
 * 根据参数返回相应的屏幕所需尺寸
 * 以及当前设备姿态是否匹配
 * @param {*} direction     none|landscape|portrait
 * @returns
 */
function screenSize(direction = 'none')

colorBasedOnBgColor

/**
 * 根据背景颜色返回字体颜色
 * @param {*} bgColor       背景颜色
 * @param {*} lightColor    亮色字体颜色
 * @param {*} darkColor     暗色字体颜色
 * @returns
 */
function colorBasedOnBgColor(bgColor, lightColor = '#ffffff', darkColor = '#666666')