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

@emrys-cloud/eutils

v1.0.2

Published

Emrys云常用的 JavaScript 工具函数库

Downloads

30

Readme

eutils 🛠

maven maven maven

maven maven

简介

☁️ Emrys云常用的 JavaScript 工具函数库 🛠,使用 TypeScript + Rollup.js 开发。☁️

  • 🦾 使用 TypeScript 开发,并提供完善且友好的类型声明,拥有强劲的类型检查与语法提示。
  • 🦿 完善的 JSDoc 注释,即使只使用js开发,也能从编辑器获得良好的语法提示。
  • 🌞 每个核心函数都有 @example 的示例,可以通过注释直观的查看函数使用方法!
  • 🤢 单元测试用例正在完善中~

安装

# npm
npm i @emrys-cloud/eutils -S

# yarn
yarn add -S @emrys-cloud/eutils

其他函数库推荐

API

类型检查

  • isEmpty - 是否为空,包含 undefined、null、空字符串(只有空格的字符串)、空数组、空对象
  • isNotEmpty - 是否不为空,与isEmpty取反
  • isNull - 是否为 null
  • isUndefined - 是否为 undefined
  • isNumber - 是否为 数字
  • isString - 是否为 字符串
  • isBoolean - 是否为 布尔值
  • isArray - 是否为 数组
  • isObject - 是否为 对象
  • isDate - 是否为 Date
  • isFunction - 是否为 函数
  • isRegExp - 是否为 正则
  • isSymbol - 是否为 symbol

字符串API

  • mask - 使用符号遮蔽指定位置的字符串
  • maskLeft - 使用符号遮蔽从最左边到指定位置(从左往右)的字符串
  • maskRight - 使用符号遮蔽从最右边到指定位置(从右往左)的字符串

数字API

  • randomInt - 返回指定范围内的随机数(整数)
  • round - 将数字四舍五入到指定的小数位数
  • sum - 返回数字数组中元素之和(两个或两个以上数字)
  • sumBy - 根据函数映射每个元素,然后返回数组的和
  • toDecimalMark - 将数字转化为千分位格式,可以在数字前面加上符号
  • addNum - 加法运算(解决浮点数计算问题)
  • subNum - 减法运算(解决浮点数计算问题)
  • mulNum - 乘法运算(解决浮点数计算问题)
  • divNum - 除法运算(解决浮点数计算问题)

对象API

  • deepClone - 深克隆(深拷贝)

数组API

  • unique - 数组去重 - 普通
  • uniqueBy - 数组去重 - 根据数组里的对象里的某个key值去重
  • maxNum - 获取数组中的最大值
  • minNum - 获取数组中的最小值
  • shuffle - 打乱数组
  • flatToTree - 扁平化数组 ==> 树形结构
  • treeToFlat - 树形结构 ==> 扁平化数组

函数API

  • debounce - 防抖
  • throttle - 节流

浏览器、设备、操作系统

  • isMobile
  • isPC
  • isAndroid
  • isIOS
  • isChrome
  • isEdge
  • isFirefox
  • isIE
  • isIE11
  • isOpera
  • isSafari
  • isLinux
  • isMac
  • isWindows
  • isWx
  • isQQ
  • isAli

文件流相关

  • blobToDataURL - blob转dataurl
  • dataURLtoBlob - dataurl转blob
  • getImgToBase64 - 图片转base64
  • getImgToBlob - 图片转blob
  • downloadFile - 下载文件

URL相关

  • parseQueryString - 获取url参数对象
  • stringfyQueryString - 对象转url参数

缓存相关

  • getItem - 获取缓存
  • setItem - 设置缓存
  • removeItem - 清除缓存
  • getString - 获取缓存(纯字符串)
  • setString - 设置缓存(纯字符串)

剪贴板相关

  • copyTextToClipboard - 复制文本数据到剪贴板

页面适配相关

  • remAdapt - rem适配代码