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

aluo-utils

v1.0.2

Published

utils

Readme

📦 Install

npm install aluo-utils
yarn add aluo-utils
  Storage ==> localStorage 相关 可定义过期时间
  isEmail ==> 是否是邮箱
  isMobile==> 是否是手机号
  isURL ==> 是否是URL
  isString ==> 是否是字符串
  isNumber ==> 是否是数字
  isBoolean ==> 是否是boolena类型
  isFunc ==> 是否是函数
  isNull ==> 是否是null
  isUndefuned ==> 是否是undefined
  isArray ==> 是否是Array
  isObj ==> 是否是对象
  isDate ==> 是否是时间
  isRegExp ==> 是否是正则
  isError ==> 是否是错误对象
  isSymbol ==> 是否是symbol函数
  isPromise ==> 是否是premise
  isSet ==> 是否是set
  isWeiXin ==> 是否是微信浏览器
  isQQBrowser ==> 是否是QQ浏览器
  isDeviceMobile ==> 是否是移动端
  isIos ==> 是否是ios
  isPC ==> 是否是pc
  removeHtmlTag ==>去除html标签
  injectScript ==> 动态引入js
  download ==> 下载
  hasClass ==> el是否包含某个class
  addClass ==> el添加某个class
  removeClass ==> el删除某个class
  scrollToTop ==> 回到顶部
  elenentIsvisbleInViewPort ==> el 是否在适口范围内
  shuffle ==> 洗牌算法 打乱arr数据
  isCardId ==>强校验身份证号
  random ==> 获取随机数
  numberToChinese ==> 将阿拉伯数字翻译成中文的大写数字
  removeArrItem ==> 删除数组中其中一个元素
  formArray ==>  将类数组转换为数组
  arrMax ==> 数组中最大的值
  contains ==> 判断元素是否在数组中
  arrSort ==> 数组排序
  unique ==> 数组去重
  changeCase ==> 数组去重
  checkPwd  ==> 检测密码强度
  debounce ==> 防抖 debounce
  throttle ==> 节流 throttle
  insertStr ==> 在字符串中添加新的字符串
  isObjectEqual ==> 判断两个对象是否键值相同
  colorToRGB ==> 16进制颜色转换成 RGB or RGBA字符串

🔨 用法示例

import {scrollToTop} from 'aluo-utils/dist'

// react
<div onClick={() => scrollToTop()}>返回顶部</div>

🖥 index.d.ts

/**
 * @class Storage
 * @classdesc 实现了存入localStorage过期时间
 */
declare class Storage implements StorageCls {
    /**
     *
     * @param {string} key string localStorage的Kye 键名
     * @param {T} value localStorage存入的值 任意
     * @param {number} expire number localStorage的过期时间 时间戳
     * @example storage.set('xx','xxx',new Date().getTime() + 5000)
     */
    set<T>(key: Key, value: T, expire?: Expire): void;
    /**
     *
     * @param {string} key localStorage的key
     * @returns
     * @example { mas: '成功' value: ‘xxxx’ } |  { mas: 'xxx过期了' value: null} | { mas: '值无效' value: null}
     *
     */
    get<T>(key: Key): Result<T | null>;
    /**
     *
     * @param key 需要删除的 对应key
     */
    remove(key: Key): void;
    /**
     * 清空 localStorage
     */
    clear(): void;
}
/**
 * 验证是否是邮箱
 * @param {string} emil Email
 * @returns ture or false
 */
declare const isEmail: EMAIL;
/**
 * 验证是否是电话号码
 * @param {string} phone 手机号
 * @returns ture or false
 */
declare const isMobile: MOBILE;
/**
 * 验证是否是 URL地址
 * @param {string} url url地址
 * @returns ture or false
 */
declare const isURL: URL;
/**
 * 是否是字符串
 * @param {T} s T
 * @returns ture or false
 */
declare const isString: STRING;
/**
 * 是否是数字
 * @param {T} n T
 * @returns ture or false
 */
declare const isNumber: NUMBER;
/**
 *  是否是 boolean
 * @param {T} b T
 * @returns ture or false
 */
declare const isBoolean: BOOLEAN;
/**
 * 是否是函数
 * @param {T} f T
 * @returns ture or false
 */
declare const isFunc: FN;
/**
 * 是否为null
 * @param {T} nu T
 * @returns ture or false
 */
declare const isNull: NULL;
/**
 * 是否为 undefuned
 * @param {T} un T
 * @returns ture or false
 */
declare const isUndefuned: UND;
/**
 * 是否为 Object
 * @param {T} obj T
 * @returns ture or false
 */
declare const isObj: OBJ;
/**
 * 是否为 Array
 * @param {T} arr T
 * @returns ture or false
 */
declare const isArray: ARR;
/**
 * 是否为 Date
 * @param {T} d T
 * @returns ture or false
 */
declare const isDate: DATE;
/**
 * 是否为 正则
 * @param {T} reg T
 * @returns ture or false
 */
declare const isRegExp: REG;
/**
 * 是否为 错误对象
 * @param {T} err T
 * @returns ture or false
 */
declare const isError: ERR;
/**
 * 是否为 Symbol 函数
 * @param {T} sy T
 * @returns ture or false
 */
declare const isSymbol: SYM;
/**
 * 是否为 Promise 对象
 * @param {T} pro T
 * @returns ture or false
 */
declare const isPromise: PRO;
/**
 * 是否为 Set 对象
 * @param {T} set T
 * @returns ture or false
 */
declare const isSet: SET;
/**
 * 是否是微信浏览器
 * @returns ture or false
 */
declare const isWeiXin: WX;
/**
 * 是否是移动端
 * @returns ture or false
 */
declare const isDeviceMobile: MIPHONE;
/**
 * 是否是QQ浏览器
 * @returns ture or false
 */
declare const isQQBrowser: QQBROWESER;
/**
 * 是否是Ios
 * @returns ture or false
 */
declare const isIos: IOS;
/**
 * 是否是PC
 * @returns ture or false
 */
declare const isPC: PC;
/**
 * 去除html标签
 * @param {string} str
 * @returns string
 */
declare const removeHtmlTag: RHTML;
/**
 * 动态引入js
 * @param {string} src src Url
 */
declare const injectScript: ASYSCRIPT;
/**
 * 根据url地址下载
 * @param {string} url Url
 */
declare const download: DOWNLOAD;
/**
 * el是否包含某个class
 * @param {HEMLElement} el HEMLElement
 * @param {str} className str
 * @returns true or false
 */
declare const hasClass: HasClass;
/**
 * el添加某个class
 * @param {HEMLElement} el HEMLElement
 * @param {str} className str
 */
declare const addClass: AddClass;
/**
 * el去除某个class
 * @param {HEMLElement} el HEMLElement
 * @param {str} className str
 */
declare const removeClass: UnClass;
/**
 * 回到顶部
 */
declare const scrollToTop: ToTop;
/**
 * el 是否在适口范围内
 * @param {HEMLElement} el HEMLElement
 * @returns true or false
 */
declare const elenentIsvisbleInViewPort: InViewPort;
/**
 * 洗牌算法 打乱arr数据
 * @param {T[]} arr 数组
 * @returns  {T[random]} arr 数组
 */
declare const shuffle: Shuffle;
/**
 * 强校验身份证号
 * @param {string} sId 身份证号
 * @returns true or false
 */
declare const isCardId: CardID;
/**
 * 获取随机数
 * @param {number} min 最小值
 * @param {number} max 最大值
 * @returns number
 */
declare const random: Random;
/**
 * 将阿拉伯数字翻译成中文的大写数字
 * @param {number} num
 * @returns 一亿一千一百一十一万一千一百一十一
 */
declare const numberToChinese: ToChinese;
/**
 * 删除数组中其中一个元素
 * @param {Array} arr
 * @param {any} ele
 */
declare const removeArrItem: RArrItem;
/**
 * 将类数组转换为数组
 * @param {T[]} ary
 * @returns
 */
declare const formArray: ToArray;
/**
 * 数组中最大的值
 * @param {number[]} arr
 * @returns max Number
 */
declare const arrMax: MAX;
/**
 * 判断元素是否在数组中
 * @param {any[]} arr
 * @param {any} val
 * @returns true or false
 */
declare const contains: IsInArr;
/**
 * 数组排序
 * @param arr
 * @param type 1:从小到大,2:从大到小,3:随机
 * @returns any[]
 */
declare const arrSort: ToSort;
/**
 * 数组去重
 * @param arr anyArray
 * @returns Array
 */
declare const unique: Unique;
/**
 *
 * @param {string} str
 * @param {number} type 1:首字母大写,2:首字母小写,3:大小写转换,4:全部大写,5:全部小写
 * @returns {string} str
 */
declare const changeCase: ChangeCase;
/**
 * 检测密码强度
 * @param {string} str
 * @returns 4 3 2 1
 */
declare const checkPwd: PWD;
/**
 * 防抖 debounce
// 当事件被持续触发,在n秒内只执行一次
 * @param {Function} fn 函数
 * @param {number} delay 时间
 * @returns  Function
 */
declare const debounce: Debounce;
/**
 * 节流 throttle
*  当事件被持续触发,每n秒执行一次
 * @param {Function} fn 函数
 * @param {number} delay 时间
 * @returns Function
 */
declare const throttle: Throttle;
/**
 * 在字符串中添加新的字符串
 * @param {string} source 原字符串
 * @param {number} index 下标
 * @param {string} newStr 需要添加到字符串
 * @returns aaaa => aabbaa
 */
declare const insertStr: InsertStr;
/**
 * 判断两个对象是否键值相同
 * @param {Object} obja
 * @param {Object} objb
 * @returns true or false
 */
declare const isObjectEqual: ObjectEqual;
/**
 * 16进制颜色转换成 RGB or RGBA字符串
 * @param {string} val 16进制颜色
 * @param {number} opa 透明
 * @returns rgb(xxx,xxx,xxx) or rgba(xxx,xxx,xxx,x)
 */
declare const colorToRGB: ToRGB;