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

q-tooljs

v1.0.6

Published

js相关工具

Downloads

3

Readme

q-tooljs作为一个js工具库其中有各种实用的函数

安装:npm install q-tooljs

引入 全局引入: import utils from 'q-tooljs' 按需引入: import { $ajax,$array,$browser,$cookie,$file,$fun,$number,$str } from 'q-tooljs'

函数介绍

请求模块ajax $ajax( url,method,data,flag, callBack)

数组模块array 深拷贝: $array.deepClone(obj) 参数1:需要拷贝的对象 返回值: 一个新的对象 数组去重: $array.dedupe(array) 参数1:需要去重的数组 返回值:一个去重的数组 树转一维数组: $array.jsonToArray(node) 参数1:树结构的json对象 返回值:一维数组 一维数组转树: $array.jsonToTree(list,id,parentId) 参数1:一维数组,参数2:唯一标识属性,参数3:唯一标识父节点的属性 返回值:树结构的json

计算数组每个元素对象中某个属性的值的种类和次数: $array.getArrSum(arr,attrName) 参数1:数组,参数2: 属性名称 返回值:每个属性出现的次数

判断是否为对象 $array.isObject(obj) 返回值:true/false

判断是否为数组 $array.isArray(arr) 返回值:true/false

冒泡排序 $array.bubbleSort(arr) 返回值:排序后的数组

选择排序 $array.selectionSort(arr) 返回值:排序后的数组

插入排序 $array.insertionSort(arr) 返回值:排序后的数组

查找某个树节点 $array.searTreeNode(nodes,child, fn) 参数1:树结构的json对象 参数2:子节点字段 参数2: 返回类型为布尔的函数

找到某个节点的搜索父节点 $array.getParentKey(id,idAttr, child , tree) 参数1:id 参数2:子节点字段 参数2: json树

树转为数组 $array.generateList(jsonobj,child) 参数1: 树 参数2:子节点字段

cookie模块 设置cookie $cookie.setCookie(cname, cvalue, days) 参数1:键名 参数2:键值 参数3:有效期/天 获取cookie $cookie.getCookie(cname)

文件模块 base64文件转换为blob对象 $file.convertBase64UrlToBlob(urlData) 将blob对象转换base64 $file.blobToDataURL(blob, callback) 参数1:blob对象 参数2:回调函数,回传参数base64 将base64转换为file文件对象 $file.dataURLtoFile(dataurl, filename) 参数1:base64 参数2:file文件对象

函数模块 函数节流 $fun.throttle(fn,wait) 防抖 $fun.debounce(fn, wait)

number模块 小数进一法 $number.toCeil(value, num) 参数1:value 参数2:小数位 返回值:值

小数去尾法 $number.toFloor(value, num) 参数1:value 参数2:小数位 返回值:值

多数相乘防止精度丢失 $number.toMuti(value,num) 参数1:相乘值组成的数组 参数2:小数位 返回值:值

字符串模块 计算字符传中某个字母出现次数最多 $str.bestone(str) 返回值:{key,max}