Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

lazy-js-utils

Package Overview
Dependencies
Maintainers
0
Versions
127
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

lazy-js-utils

A collection of lazy-loaded JavaScript utilities for efficient development

  • 0.1.27
  • latest
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
241
increased by12.09%
Maintainers
0
Weekly downloads
 
Created
Source

lazy-js-utils

NPM version NPM version NPM version

🖥 文档

English | 简体中文

目前整理了200 左右的常用函数,还在持续更新中...,你的认可是对我最大的鼓励 :hearts:

:100: 亮点

  • 纯 js 的工具函数,可使用在任何可执行 js 的环境
  • 大量减少ref<HTMLElment>onMounted的使用,可以 script 标签直接调用
  • 所有的副作用函数都能返回一个 stop 函数,可以在任意地方停止事件的执行,并且在页面销毁时自动销毁事件
  • api 设计简单、实用、类型友好

✋ 例子

import {
  insertElement,
  useEventListener,
  useMutationObserver,
  useRaf,
} from 'lazy-js-utils'

// 监听container的变化, 你不在需要const container = ref<HTMLElement>
useMutationObserver('#container', (mutationsList, observer) => {
  console.log(mutationsList)
})
// requestAnimationFrame
useRaf(
  (timestamp) => {
    // 每针相隔1s执行
    console.log('animationFrame', timestamp)
  },
  1000,
  true /* 只执行一次后被销毁 */,
)
// 注册事件
useEventListener('#container', 'click', () => {
  console.log('click')
})
// 插入元素
insertElement('#container', '.content')
// 删除元素
removeElement('.content')
<div id="container"></div>
<div class="content">hello world</div>

:book: 使用说明

npm i lazy-js-utils // 安装

import {
  deepCompare
 } from 'lazy-js-utils' // 按需引入

👉 文档

:coffee:

请我喝一杯咖啡

License

MIT

GitHub 地址

欢迎 PR

Keywords

FAQs

Package last updated on 04 Dec 2024

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc