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

ft-util

v1.0.1

Published

javaScript 工具库

Downloads

2

Readme

ft.js

JavaScript 工具库测试

  • ft

    • data 静态数据

      • week Array ['星期天', '星期一', '星期二', '星期三', '星期四', '星期五', '星期六']
      • encoding Array
      • MIME Array
    • is 构造类型判断

      • array
      • object
      • number
      • string
      • boolean
      • regExp
    • regExp 正则判断

      • email 电子邮箱
      • phone 手机号码
      • telephone 固话+手机号
      • chinese 中文
      • idCard 18位身份证
      • http 是否http开头(包含https)
      • idCard 18位身份证
      • rgb 是否是rgb颜色
      • hex hex颜色 返回各颜色值
      • money 金额两位小数验证(去除多余小数,过滤非数字)
    • array 数组处理

      • group(array,by:每组数量|分组关键字) 一维数组转二维数组
      • sum(number...,+|-) 求和
      • minMax(array) 数组的最大、最小值和索引
      • sortMinMax({array,limit,type}) 数组排序索引
        • 参数 array Number数组
        • limit 个数限制
        • type 0升序;1降序
        • 返回{Array}数组索引
      • average(array, n, type) 平均值
        • 参数 array
        • 参数 n=2 保留小数位数
        • 参数 m=0 0||round,1||floor,2||ceil
      • variance({array, standardDeviation: opt}) 计算方差、标准差
        • 参数 array
        • 参数 standardDeviation=false 是否是标准差
    • object 对象

      • size(Object|Array|String) 获取对象大小(外层)
    • cal 计算

      • addSub(number...,-|+) 加、减法运算
      • mulDiv({}) 乘法、除法运算
        • 参数 number:Array
        • 参数 type=* *|/
        • 参数 fix=7 最大保留小数位数
        • 参数 fixType=0 0||round,1||floor,2||ceil
      • fix() 保留小数位数
        • 参数 number:Number
        • 参数 n=2 保留位数
        • 参数 type=0 0||round,1||floor,2||ceil
      • getDec() 获取小数位数
    • random(minNumber = 0, maxNumber = 1) 随机数
    • for(arr,callback) for循环
      • 参数 arr:(Array|String|Object)
      • 参数 callback(value,index,array) return true时终止循环并返回value
    • date 日期

      • get(Date, days:提前/延后天数) 返回 {year,month,day,hour,min,sec,week,timeStamp}
      • format({}) 日期格式化
        • 参数 date:Date
        • 参数 days=0 提前/延后天数
        • 参数 hour=24 12|24小时制
        • 参数 connector=/ 连接符
        • 参数 pad0=false 是否补0
      • UTC UTC时间 返回 [year, month, day, hour, min, sec, ms]
      • localTime(longitude=120) 本地时间 返回 {year,month,day,hour,min,sec,week,timeStamp}
      • calendar({}) 日历
        • 参数 year 年
        • 参数 month 月
        • 参数 y +-年
        • 参数 m +-月
        • 返回 {data:[{date,week}], year, month}
    • toUrlParam(obj, delimiter = ['&', '=']) 对象转key=value格式
    • fetch({}) 请求
      • 参数 baseUrl:{String|undefined} 请求地址前缀
      • 参数 url:String 请求地址
      • 参数 timeout 超时
      • 参数 params url拼接参数
      • 参数 data body 参数
      • 参数 response:{'json','text','blob','arrayBuffer','formData'|any} 响应
      • 参数 init:fetch.init
    • permutation() 二维数组组合
    • urlParse() url解析
    • getParams(str, delimiter = ['&', '=']) url 参数转object
    • encrypt(String|Number) 数据加密
    • decrypt(String) 数据解密
    • tableHead() 用于生成xlsx.js表头 JSON转table格式
      • 参数 thead:Array
      • 参数 children 下级字段
      • 参数 label 单元格内容字段
      • 返回 {merges:合并格式, headTxt:表头文字}
      •   const head = fx([{label:'1',children:[]}]);
          let workbook = xlsx.utils.book_new(), ws = xlsx.utils.aoa_to_sheet(head.headTxt);
          ws["!merges"] = head.merges;
          xlsx.utils.book_append_sheet(workbook, ws, 'sheet1');



```javascript