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

js-helpful-tools

v1.2.1

Published

some js heplful tools

Readme

js-helpful-tools

自己收集的一些js工具方法, 会在以后不断地补充和优化,

安装

npm install js-helpful-tools

现有的使用方法如下

  1. 直接调用
import { isObject } from 'js-helpful-tools'

console.log(isObject({}));   // true
  1. 注册为全局方法, 调用register方法后会将所有工具函数注册在window对象上,也可以通过传参的方式注册在对应的对象上
import { register } from 'js-helpful-tools'

register();
console.log(isObject({}));   // true
// or
register('tools');
console.log(tools.isObject({}));   // true
  1. 注册在Vue原型上,或者通过传参的方式整体注册在Vue原型上
import tools from 'js-helpful-tools'

Vue.use(tools);

// 组件内部调用
console.log(this.isObject({}));  // true

// or
Vue.use(tools, 'tools');

console.log(this.$tools.isObject({}));  // true

API

方法介绍及使用可以点击查看详情

数据相关('点击查看详情')

  • isObject 判断变量是否为对象,包括数组
  • isPlainObject 判断变量是否为对象,不包括数组
  • isEmptyObject 判断变量是否为空对象
  • toString 转字符串类型
  • toNumber 转数字类型
  • selectObj 选择对象属性,生成新对象
  • trim 删除字符串所有空格
  • removeTags 删除字符串中的html标签
  • commasNumber 将数字转换为逗号隔开的字符串

设备相关('点击查看详情')

  • getExplore 获取浏览器
  • getOS 获取操作系统
  • isMobile 判断是否为移动端

随机方法('点击查看详情')

  • randomColor 生成随机颜色
  • randomNumber 生成随机数字
  • randomString 生成随机字符串

页面布局相关('点击查看详情')

  • isScrollBottom 是否滚动到底部
  • scrollToTop 滚动到页面顶部

正则相关('点击查看详情')

  • isEmail 判断是否为邮箱地址
  • isIdCard 判断是否为身份证号
  • isPhone 判断是否为手机号
  • isUrl 判断是否为URL地址

计算相关('点击查看详情')

  • floatAdd 浮点数加法
  • floatSub 浮点数减法
  • floatMul 浮点数乘法
  • floatDiv 浮点数除法

未完待续