tty-utils
TypeScript icon, indicating that this package has built-in type declarations

1.0.9 • Public • Published

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

Readme

Keywords

none

Package Sidebar

Install

npm i tty-utils

Weekly Downloads

3

Version

1.0.9

License

ISC

Unpacked Size

5.64 kB

Total Files

6

Last publish

Collaborators

  • z764069592