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

tty-utils

Package Overview
Dependencies
Maintainers
1
Versions
10
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

tty-utils

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

  • 1.0.9
  • latest
  • Source
  • npm
  • Socket score

Version published
Maintainers
1
Created
Source

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

FAQs

Package last updated on 17 Oct 2022

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