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

micro-util-ts

v1.8.3

Published

一个常用的工具库

Downloads

155

Readme

micro-util-ts

1、下载

npm i micro-util-ts

2、使用

See

3、bug

{
  "scripts": {
    "build": "npx rimraf lib && webpack --config webpack.config.js",
    "build:tsc": "npx rimraf dist && tsc",
    "start": "tsc --watch",
    "start:webpack": "webpack --watch",
    "publish:build": "npm run build:tsc && npm publish",
    "clear": "npx rimraf node_modules",
    // 不能存在 postinstall,负责使用的时候 会报错,扯淡啊
    "postinstall": "tsc && pnpm run start:webpack",
    "prepublishOnly": "npm run build:tsc && npm run build"
  }
}

4、API

1)类型判断

① isObject

是否对象类型判断

② isFunction

是否函数类型判断

③ isUndefined

是否为 undefined

④ isElement

是否为 DOM

⑤ isNull

判断是否为 null

⑥ isEqual

比较对象是否相等

2)debounce

防抖

3)throttle

节流

4)clone

浅拷贝

5)cloneDeep

深拷贝

6)queryStringToObject

window.location.search 并转换为 Object

7)animationFrameThrottle

创建一个使用 requestAnimationFrame 的函数节流(throttle)版本

函数节流的目的是限制一个函数在特定时间内的调用次数,以避免过于频繁的执行,以确保性能优化或更平滑的动画效果时

8)copyText

文本复制

9)openWindow

用于在浏览器中打开窗口

10)元素监听

① addResizeListener

该函数用于向指定的元素添加尺寸变化的监听器 如果该元素没有注册过监听器,则使用 ResizeObserver 监听元素的尺寸变化。每当尺寸变化时,相关联的回调函数会被执行

② removeResizeListener

从指定的元素中移除尺寸变化的监听器

③ triggerWindowResize

通过模拟触发 resize 事件,手动触发窗口尺寸变化

11)Object

① objectValueToString

obj 中所有 value 转换为 string

② omitBy

从创建的一个从对象中,排除满足某些条件的属性的属性

12)本地储存

① LocalStorageHelper

localStorage 的一些扩展

② CookieHelper

CookieHelper 的一些扩展

13)转换

① dataUrlToBlob

将 base64 编码的图像数据转换为 Blob 对象

② urlToBase64

将图像 URL 转换为 base64 编码的字符串

14)下载

① downloadByOnlineUrl

根据在线图片的 URL 进行下载

② downloadByBase64

根据 Base64 编码的字符串进行下载

② downloadByData

根据文件数据进行下载

② downloadByUrl

根据文件地址进行下载