1.0.9 • Published 2 years ago

tty-utils v1.0.9

Weekly downloads
-
License
ISC
Repository
github
Last release
2 years ago

tty-utils

tty工具库,包含对数据的快速处理、数组操作等

安装

npm i tty-utils --save

使用

import tty from 'tty-utils'

API

tty.copyText()

tty.copyText('文本', () => {
    alert('复制成功');
})

说明:复制文本
由于浏览器自身限制,必须在点击事件等回调中使用
@param text: string 文本内容
@param callback?: () => void 复制完成回调


tty.storage()

tty.storage('token', '4757aabce3633c316c6d6a4b0dd04648');
tty.storage('token')

说明:读写localstorage
传一个参数为获取,两个参数为写入
@param key: string 键名
@param value?: any 键值


tty.sessionStorage()

tty.sessionStorage('token', '4757aabce3633c316c6d6a4b0dd04648');
tty.sessionStorage('token')

说明:读写sessionstorage
传一个参数为获取,两个参数为写入
@param key: string 键名
@param value?: any 键值


tty.pick()

const form = { a:1, b:2, c:3 };
tty.pick(form, ['a:aa', 'b', 'c:ccc'])
返回值:{ aa:1, b:2, ccc:3 }

说明:提取或转换对象的键名
keyArr传入'a:aa', 'b:bb'表示把原始对象的a和b键名转换成aa,bb返回,不加冒号只提取不转换
@param obj: Object 原始对象数据
@param keyArr: string[] 需要提取或转换的key

1.0.9

2 years ago

1.0.2

3 years ago

1.0.1

3 years ago

1.0.8

3 years ago

1.0.7

3 years ago

1.0.6

3 years ago

1.0.5

3 years ago

1.0.4

3 years ago

1.0.3

3 years ago

1.0.0

3 years ago