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

jm-utils-pack

v1.0.4

Published

utils

Downloads

4

Readme

randomNumber

/**
 * 生成任意位数随机数(数字)
 *
 * @param {Number} n 可选长度位数
 * @return {Number} 返回随机值
 *
 */
const randomNumber = (n: number) => {};

randomId

/**
 * 随机生成一个自定义长度,不重复的字母加数字组合,可用来做id标识
 *
 * @param {Number} randomLength 可选长度位数,默认10
 * @return {String} 返回随机值
 *
 */
const randomId = (randomLength = 10) => {};

shallowCopy

/**
 * 浅拷贝
 *
 * @param {Array | Object} objOrArr 要拷贝的对象或数组
 * @return {Array | Object} 返回拷贝结果
 *
 */
const shallowCopy = (objOrArr: any) => [];

deepCopy

/**
 * 深拷贝
 *
 * @param {Array | Object} objOrArr 要拷贝的对象或数组
 * @return {Array | Object} 返回拷贝结果
 *
 */
const deepCopy = (objOrArr: any) => {};

debounce

/**
 * 防抖 (debounce)将多次高频操作优化为只在最后一次执行
 *
 * @param {Function} fn 需要防抖函数
 * @param {Number} wait  需要延迟的毫秒数
 * @param {Boolean} immediate 可选参,设为true,debounce会在wait时间间隔的开始时立即调用这个函数
 * @return {Function}
 *
 */
const debounce = (fn: Function, wait: number, immediate?: boolean) => {};

throttle

/**
 * 节流(throttle)将高频操作优化成低频操作,每隔 100~500 ms执行一次即可
 *
 * @param {Function} fn 需要防抖函数
 * @param {Number} wait  需要延迟的毫秒数
 * @param {Boolean} immediate 可选参立即执行,设为true,debounce会在wait时间间隔的开始时立即调用这个函数
 * @return {Function}
 *
 */

const throttle = (fn: Function, wait: number, immediate?: boolean) => {};

cardNumber

// 银行卡只显示后四位
function cardNumber(value: string) {}

telKeep

// 电话号保留前三位后四位,中间*表示
function telKeep(value: string) {}

formatDecimal

// 保留小数点后几位
function formatDecimal(num: number | string, decimal: number) {}

params2json

// 参数转换为json
function params2json(params = "", slice = "&") {}

searchAssign

// 清除空属性
function searchAssign(value: any) {}

Object 转 formData

/**
 * Object 转 formData
 * @param obj
 * @param form
 * @param namespace
 * @returns
 */
function objectToFormData(obj: any, form?: FormData, namespace?: any) {}

获取 Cookie

/**
 * getCookie
 * @param name
 * @returns
 */
function getCookie(name: string | number) {}

设置 Cookie

/**
 * setCookie
 * @param name
 * @param value
 */
function setCookie(name: string | number, value: string) {}

移除 Cookie

function delCookie(name: string | number) {}

对象拉平

/**
 * 对象拉平
 * @param source
 * @returns
 */

const flatObjectification = (source: { [key: string]: any }): object => {};

文件流下载

/**
 * 文件流下载
 * @param res
 * @param type
 * @param filename
 */
const download = (res: any, type: string, filename: string) => {};