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

mg-toolkit

v0.0.2

Published

toolkit

Downloads

3

Readme

mg-toolkit

公共方法库

判断函数

isFunction: (data: any)

对象合并

objectMerge: (origin: any = {}), (newData: any = {})

数据合计

sum: (origin: any[] = [], key?: string | Function, initVal = 0)

根据取余获取数组数据项

getItemBySpare: (arr: any[], index: number)

判断空对象

isEmptyObject: (data: any) => data is any

判断空数组

isEmptyArray: (data: any) => data is any[]

判断空字符串

isEmptyString: (data: any, trim = true) => data is string

判断是 null 或 undefined

isNullOrUndefined: (data: any)

对象转下拉框数据

objectToOptions: (obj: any) => any[]

判断两个数据是否一样

isSame: (data1: any, data2: any) => boolean

judgment 判断数据类型

判断对象,containNull:是否包含 null

isObject: (data: any, containNull?: boolean) => boolean

判断非空对象

isNotEmptyObject: (data: any) => boolean

判断数组

isArray: (data: any) => boolean

判断非空数组

isNotEmptyArray: (data: any) => boolean

判断字符串

isString: (data: any) => boolean

判断非空字符串,trim:是否去除前后空字符串

isNotEmptyString: (data: any, trim?: boolean) => boolean

判断数值,containNaN:是否包含 NaN

isNumber: (data: any, containNaN?: boolean) => boolean

判断布尔值

isBoolean: (data: any) => boolean

判断 undefined

isUndefined: (data: any) => boolean

判断 null

isNull: (data: any) => boolean

判断不是 null 或 undefined

isNotNullOrUndefined: (data: any) => boolean

判断是否含有某个子节点

hasChild: (list: any[], options: any) => boolean

storage 本地存储方法

local 长期存储 / session 短期存储

存储数据长度

size: number

存储数据名集合

keys: Array<string>

存储数据值集合

values: Array<any>

存储数据键值对集合

entries: Array<any>

设置数据存储

set(key: string, val: any): Storage

获取数据存储

get(key: string): any

是否包含某个数据存储

has(key: string): boolean

删除数据存储

delete(key: string): void

清空数据存储,except:需要保留的数据存储

clear(except: Array<string>): void

数据存储循环,cb:回调函数

forEach(cb: (key: string, value: any) => void): void

transform 数据转换方法

对象数组转对象(用户表格过滤下拉框)

arrayToObject: (arr: any[], options: any) => any

对象数组数据转换为下拉框使用数据

arrayToOptions: (arr: any[], options: any) => any

树形数组转对象(用户表格过滤下拉框)

treeToObject: (arr: any[], options: any) => any

树形数组数据转换为下拉框使用数据

treeToOptions: (arr: any[], options: any) => any

数据类型处理中转

transitData: (data: any[], valueType?: string, options: any) => any

经纬度转换-腾讯地图转百度地图

QMapTransBMap: ({ lng: number, lat: number }) => { lng: number, lat: number }

经纬度转换-百度地图转腾讯地图

BMapTransQMap: ({ lng: number, lat: number }) => { lng: number, lat: number }

根据子节点 id 获取含有父级节点 id 列表

getValueListByChildId: (list: any[], options: any) => any[]

设置数值精度

precision(num: any, options: any): any

absolute 获取绝对数据类型

根据数据源获取数据

getDataByOrigin: (origin: any, path: string, defaults?: any)

根据数据源获取数组

getArray: (origin: any, path: string, defaults = [])

根据数据源获取对象

getObject: (origin: any, path: string, defaults = {})

根据数据源获取字符串

getString: (origin: any, path: string, defaults = '')

根据数据源获取数值

getNumber: (origin: any, path: string, defaults = 0)

根据数据源获取布尔值

getBoolean: (origin: any, path: string, defaults = false)

根据数据源获取函数

getFunction: (origin: any, path: string, defaults = ()

echarts echarts 图表快捷方法

获取文本配置

getTextOption: (options?: TextOption | boolean | string)

获取标签配置

getLabelOption: (options?: LabelOption | boolean | string)

获取线配置

getLineOption: (options?: LineOption | boolean | string)

获取阴影配置

getShadowOption: (options?: ShadowOption | boolean | string)

获取刻度线配置

getAxisTick: (options?: AxisTick | boolean | string)

获取轴线配置

getAxisLine: (options?: LineOption | boolean | string)

获取 formatter 方法

getFormatter: (dealFunc?: Function)

获取初始 tooltip 提示框

getTooltip: (options?: TooltipOptions)

获取初始 grid 配置

getGrid: (options?: GridOptions)

设置烛形图名称

setCandleNames: (names: string[])

设置烛形图颜色

setCandleColor: (color: string)