JSPM

debounce-throttle

1.0.4
  • ESM via JSPM
  • ES Module Entrypoint
  • Export Map
  • Keywords
  • License
  • Repository URL
  • TypeScript Types
  • README
  • Created
  • Published
  • Downloads 510
  • Score
    100M100P100Q95044F
  • License MIT

lodash debounce and throttle function built by lodash-cli to support UMD

Package Exports

  • debounce-throttle

This package does not declare an exports field, so the exports above have been automatically detected and optimized by JSPM instead. If any package subpath is missing, it is recommended to post an issue to the original package (debounce-throttle) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.

Readme

debounce-throttle

lodash debounce and throttle function built by lodash-cli to support UMD and gain size benefit.

原因

在使用 lodash 库的节流函数时,感觉有 2 个问题不太友好,所以定制了只包含 debounce 和 throttle 函数的库,方便自己使用。

  • 模块化问题:lodash.debounce 和 lodash.throttle 只支持CMD。

  • 文件大小问题:无论是下载 lodash 还是分别下载 lodash.debounce, lodash.throttle 都有代码冗余。因为 lodash.throttle 是用 lodash.debounce 实现的,分别下载 lodash.debounce, lodash.throttle 相当于下载了 2 份代码!

引用

该定制为 UMD 的,所以支持多种引用方式

import 引入

import {debounce, throttle} from 'debounce-throttle'

require 引入

const {debounce, throttle} = require 'debounce-throttle'

定义在全局对象上

const {debounce, throttle} = window._

使用

具体使用见lodash文档