npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

iota-utools

v0.0.8

Published

### 类型判断:

Downloads

166

Readme

iota-tools

类型判断:

// 数据类型
function etTypeof(value: any): string

// 是否是数组
function isArray(value: any): boolean

// 是否是布尔值
function isBoolean(value: any): boolean

// 是否是字符串类型
function isString(value: any): boolean

// 是否是数字
function isNumber(value: any): boolean

// 是否是object 类型 - @::
function isObject(value: any): boolean

// 是否是一个方法
function isFunction(value: any): boolean

// 是否是一个Map
function isMap(value: any): boolean

// 是否是一个Set 类型
function isSet(value: any): boolean

// 是否是一个Symbol 类型
function isSymbol(value: any): boolean

复制文本的方法

// 复制文本
function copyText(text: string): void

阻塞进程方法

// 进程阻塞
function sleep(ms: number): void

LocalStorage 存取

// 向 localStorage 存数据
function setLocalStorage(key: string, data: any)

// 向 localStorage 取数据
function getLocalStorage(key: string): any

// 移除 localStorage 数据
function removeLocalStorageKey(...args: string[])

SessionStorage 存取

// 向 sessionStorage 存数据
function setSessionStorage(key: string, data: any)

// 向 sessionStorage 取数据
function getSessionStorage(key: string): any

// 移除 sessionStorage 数据
function removeSessionStorageKey(...args: string[])

拉流、文件流下载

// 下载文件流
function downFile(stream: string | ArrayBuffer, name: string, mimeType: string = "text/plain;charset=utf-8")

// 拉流且下载文件流
function downStream(path: string, defaultName: string, token?: string, params?: Record<string, any>)

数组处理方法

// 根据key 类型数据去去重
function uniqueArrayByProperty<T>(array: T[], key: keyof T): T[]

object 数据处理

// 对象扁平话
function flattenObject(obj: any, parentKey: string = "", res: any = {})

// 扁平反转
function unflattenObject(obj: any)

字符处理

// 字符串format 替换
function format(str:string,...args:string[]):string

// 模版字符串替换
function templateReplace(str:string, data:Record<string,any>,egex: RegExp = /\(\((\w+)\)\)/g):string

// 将字符串转成对象 {key:value}
function decodeParams(queryString: string)

// 将对象转成 ?key=value&key=value
function encodeParams(query: Record<string, any>)

Tree 数据处理

// 树 -> 扁平树
function toFlatTree(origin: TreeData[]

// 扁平树 -> 树
function toTreeFlat<T extends TreeData>(origin: T[], parentId: number | string = "root")

// 深拷贝
function deepClone<T = any>(obj: T): T

// 删除某个节点 纯函数
function deleteTreeNode<T extends TreeData>(origin: T[], id: string | number, key: keyof T = "id"): T[]

// 查找某个节点 - 返回同指针数据
function findTreeNode<T extends TreeData>(origin: T[], findValue: any, key: keyof T = "id"): T | null

// 模糊查询 树节点
function fuzzySearchTree<T extends TreeData>(treeData: T[], findStr: string, label: keyof T = "title"): T[]

异步

// promsie 借鉴awit-to的设计 向作者致敬
function awitto<T>(promise: Promise<T>):  Promise<[any, T | null]>