Big News: Socket raises $60M Series C at a $1B valuation to secure software supply chains for AI-driven development.Announcement
Sign In

@baiwusanyu/utils-com

Package Overview
Dependencies
Maintainers
1
Versions
13
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@baiwusanyu/utils-com

## Function

latest
Source
npmnpm
Version
1.1.2
Version published
Weekly downloads
377
-39.58%
Maintainers
1
Weekly downloads
 
Created
Source

@baiwusanyu/utils-com

Function

downloadFile

根据下载链接下载文件

参数参数类型默认值说明
urlstring-下载链接

createHash

基于 hash-sum 生成一个随机哈希

参数参数类型默认值说明
idstring \ number(new Date()).getTime().toString()生成hashid
prefixstring''自定义前缀
suffixstring''自定义后缀
返回值返回类型说明
resstring生成的哈希结果

debounce

防抖函数返回一个新的函数,这个新函数会在 wait 时间内被连续调用时,
会取消上一次调用并重新开始等待 wait 时间。

参数参数类型默认值说明
funcT extends (...args: any[]) => any-需要进行防抖的函数
waitnumber''等待时间(毫秒),即在该时间内没有新的调用时才会真正地执行 func
返回值返回类型说明
debounceFn(...args: Parameters<T>) => void防抖函数

throttle

节流函数返回一个新的函数,这个新函数会在 wait 时间内被连续调用时,
只会执行第一次调用,并在 wait 时间后才能再次执行。

参数参数类型默认值说明
funcT extends (...args: any[]) => any-需要进行节流的函数
waitnumber''等待时间(毫秒),即在该时间内只能执行一次 func
返回值返回类型说明
throttleFn(...args: Parameters<T>) => void节流函数

copyText

将字符串复制到粘贴板

参数参数类型默认值说明
contentstring-复制内容
resolve() => void-调用成功回调
err(err: any) => void-调用错误回调

sessionCache

基于 sessionStorage 的缓存函数

sessionCache.set

存储缓存

参数参数类型默认值说明
keystring-key
valuestring-

sessionCache.get

获取缓存

参数参数类型默认值说明
keystring-key
返回值返回类型说明
resstring缓存数据

sessionCache.setJSON

以对象格式存储缓存

参数参数类型默认值说明
keystring-key
valueany-

sessionCache.getJSON

以对象格式获取缓存

参数参数类型默认值说明
keystring-key
返回值返回类型说明
resany缓存数据

sessionCache.remove

移除缓存

参数参数类型默认值说明
keystring-key

localCache

基于 localStorage 的缓存函数, 函数与 sessionCache 相同

Keywords

typescript

FAQs

Package last updated on 12 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