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

y-node-tool

v1.0.0

Published

nodejs工具封装合集

Downloads

17

Readme

nodeTool

github gitee

nodejs常用或常见工具类集合体

介绍

在使用node开发中会遇到各种需要封装,在这些常用/常见的方法进行封装成工具类,提供参考;

~~均采用原生js手撸(996当中摸鱼)~~

:cold_sweat: 比如,我们在判断一个字符串是否为空值的时候

  • 我们需要判断字符是是否未定义undefined

  • 是否是null值

  • 是否是空字符串等

    let str=null;
    if(undefined === str || null === str || '' === str){
    	console.log('str is empty !');
    }

:yum: 当我们使用封装的方法后

const {StringUtil} = require('nodeTool');

let str = null ;
if(StringUtil.isEmpty(str)){
   console.log('str is empty !');
}

工具类实现列表

  • StringUtil 字符串工具
  • MapUtil] map工具
  • BufferUtil buffer工具
  • DateUtil 日期工具
  • UUID UUID
  • Snowflake 推特雪花算法
  • ObjectUtil 对象工具
  • ArrayUtil array工具
  • PageUtil] 分页工具
  • RandomUtil 随机工具
  • PhoneUtil 手机号工具
  • RandomWeightUtil 随机权重工具
  • BufferUtil buffer工具
  • NetUtil 网络工具
  • IPV4Util ipv4工具
  • OSUtil] 系统操作工具(~~好像并不需要怎么封装呀~~)
  • ReUtil 正则工具(~~莫名发现好像js的正不是全匹配的不知道是不是姿势不太对~~)
  • StringFormatUtil 字符串格式化工具 (~~就是感觉没有就写一个~~)
  • ErrorUtil 错误工具
  • Base64 base64

API文档

一些方法的实现列表,使用jsdoc生成

Github Pages

为什么用原生JS不用TS

本人太懒,JS已经够好了

如何使用

当然这里提供两种方案 :

  • 查看源码并且cv(~~cv大法,哈哈哈,没什么值得的~~)

  • 获取已经向npm发布的版本 :

    npm install nodeTool
    const {StringUtil} = require('nodeTool');

用例

所有用例在源码 test 目录下可以找到

其他

这些封装,实现的方式可能不是最好的,或者说,可能还有什么bug,如果可以,欢迎用nodeJS作为服务端的你进行指正或者提交一些非常nice的code给我(~~注意不要引用第三方库提交哦,只做小小的封装就好啦~~)