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

jt-utils

v0.9.16-alpha

Published

中后台工具库

Downloads

4

Readme

jtutil 工具类

快速入门

npm安装:

npm i jt-utils --save

使用说明

// 方式一
const  utils = require('jt-utils');

// 方式二

const  { http ,date} = require('jt-utils');

cookie 模块

本模块即支持浏览器也支持node环境

  • cookie.set(name, value, time)

    name: cookie 的名字. value : cookie 的值. time: cookie存储时间(按天计算)

  • cookie.get(name)

    name: cookie 的名字.

  • cookie.remove(name)

    name: cookie 的名字.

localStorage 模块

本模块只支持浏览器模式,因为node环境下不支持

  • localStorage.set(name,content)

  • localStorage.get(name)

  • localStorage.delete(name)

date 模块

本模块即支持浏览器也支持node环境

  • date.formatPassTime(startTime)

    可计算此时离目标时间的差距

  • date.formatTime(time, fmt = 'yyyy-MM-dd hh:mm:ss')

    格式化时间

tools 模块

  • deepCopyBy(data) 深拷贝

  • deepCopy(data) JSON 深拷贝

  • checkType(str, type) 正则检测 以下type可选:

    • ip
    • port
    • phone
    • number
    • email
    • IDCard
    • url
  • formatPhone(phone) 将手机号中间部分替换为星号

  • debounce(func, wait) 防抖

  • throttle(func, wait) 节流

  • getType(obj) 类型检测

http 模块

基于axios ,对axios的二次封装

  • init 方法
//  初始化方法
 jtutil.http.init({
            url: 'http://localhost:8888/',
            timeout: 20000,
            withCredentials: false,
});
  • isInterceptor 方法
jtutil.http.isInterceptor(false)

此方法是开启拦截器的功能,默认为true,开启封装的拦截器,对请求进行简单的拦截 如果你想增加一些复杂的逻辑,可以关闭为false。 当为false的时候,我们会给你返回一个拦截对象,你可以接收他,并进行自我的拦截封装。

    const Interceptor =  jtutil.http.isInterceptor(false);
  • Get 方法

  • Post 方法

  • Put 方法

  • Delete 方法

random 模块

  • get 方法

    jtutil.random.get(0,1)

    随机得到一定范围的整数

  • getArrayItem 方法

jtutil.random.getArrayItem([1,2,3])

随机得到目标数组的数据