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 🙏

© 2025 – Pkg Stats / Ryan Hefner

lg.tool

v0.0.2

Published

综合 lg.contextmenu、lg.data、lg.table-copy、lg.validator

Downloads

29

Readme

综合 lg.contextmenu、lg.data、lg.table-copy、lg.validator

六哥开源前后端脚手架:https://gitee.com/lgx1992/lg-soar

具体使用请参考 对应项目:

import {
    toObject,
    toSet,
    toMap,
    grouping,
    toBoolean,
    toNumber,
    toPromise,
    toOptions,
    toBooleanArray,
    toNumberArray,
    toStringArray,
    toPromiseArray,
    toAge, splice
} from "lg.data";

const list = [];

for (let i = 0; i < 11; i++) {
    list.push({
        value: i,
        label: String(i + 1)
    })
}

console.log('toObject:转对象')
console.log(toObject(list, 'value'))
console.log(toObject(list, x => x.value))
console.log(toObject(list, 'value', 'label'))
console.log(toObject(list, x => x.value, x => x.label))

console.log('toSet:转Set')
console.log(toSet(list))
console.log(toSet(list, 'value'))
console.log(toSet(list, x => x.value))

console.log('toMap:转Map')
console.log(toMap(list, 'value'))
console.log(toMap(list, x => x.value))
console.log(toMap(list, 'value', 'label'))
console.log(toMap(list, x => x.value, x => x.label))

console.log('grouping:分组')
console.log(grouping(list, 'value'))
console.log(grouping(list, x => x.value % 2))
console.log(grouping(list, 'value', 'label'))
console.log(grouping(list, x => x.value % 2, x => x.label))

console.log('toOptions:转选项数组(用于下拉选择)')
console.log(toOptions('a,b,c'))
console.log(toOptions(['a', 'b', 'c']))
console.log(toOptions('a:1,b:2,c:3'))
console.log(toOptions({ a: 1, b: 2, c: 3 }))
console.log(toOptions(list))

console.log('toBoolean:转布尔值')
console.log(toBoolean(true))
console.log(toBoolean(1))
console.log(toBoolean(''))
console.log(toBoolean('false'))

console.log('toBooleanArray:转布尔值数组')
console.log(toBooleanArray([false, true]))
console.log(toBooleanArray(['false', 'true']))
console.log(toBooleanArray('false,true'))

console.log('toNumber:转数值')
console.log(toNumber('1.25'))
console.log(toNumber(1.25))

console.log('toNumberArray:转数值数组')
console.log(toNumberArray([1, 2.25]))
console.log(toNumberArray(['1', '2.25']))
console.log(toNumberArray('1,2.25'))

console.log('toPromise:转Promise')
console.log(toPromise(Promise.resolve(1.25)))
console.log(toPromise(1.25))

console.log('toPromiseArray:转 Promise 数组')
console.log(toPromiseArray(['https://gitee.com/lgx1992/lg-soar', Promise.resolve('https://gitee.com/lgx1992/lg-soar')]))

console.log('toStringArray:转字符串数组')
console.log(toStringArray([1, 2.25]))
console.log(toStringArray(['1', '2.25']))
console.log(toStringArray('1,2.25'))

console.log('toAge:日期转年龄')
console.log(toAge(new Date(1992, 3, 5)))
console.log(toAge(new Date(1992, 3, 5).getTime()))
console.log(toAge(new Date(1992, 3, 5), new Date(2025, 3, 10)))

console.log('splice:数组删除')
const ls1 = [1, 2, 3, 2, 2];
splice(ls1, 2)
console.log(ls1)

const ls2 = [1, 2, 3, 2, 2];
splice(ls2, (x: number) => x === 2)
console.log(ls2)

const ls3 = [1, 2, 3, 2, 2];
splice(ls3, (x: number, i: number) => i === 2)
console.log(ls3)