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 🙏

© 2026 – Pkg Stats / Ryan Hefner

tree-structure-merging

v0.2.6

Published

```javascript npm i tree-structure-merging ```

Readme

1、下载包

npm i tree-structure-merging

2、使用

//以对象的形式存放方法,可以结构也可以完全取出
const {treeDate,time,Money} || name? = require("tree-structure-merging");

2-1 合并数组对象相同项

//treeDate是用于解决数组对象中存在着相同的键名,需要以这个相同键名为目标合并成一个个数组的形式
//三个参数,data(数据),element(相同的键名),sortElement(可选项,根据哪个键名进行排序,一般用于字母排序)
//结构方式
treeDate.SameTreeData(data, element, sortElement);
//完全取出方式
name?.treeDate.SameTreeData(data, element, sortElement);
//参考数据
 let data = [
        {
            type: "Y",
            data: "为去问问去恶趣味"
        },
        {
            type: "S",
            data: "asdadasasa"
        },
        {
            type: "Y",
            data: 32423423523
        },
        {
            type: "A",
            data: 213312412
        },
        {
            type:"S",
            data:"zxczxczxczx"
        }
    ];
console.log(treeDate.SameTreeData(data, "type", "type"));

2-2 时间处理

//用法同上

//获取两个日期之间还有几天
//date,otherDate参数分别为两个时间戳
time.diffDays(date, otherDate);

//将日期转换成YYYY-MM-DD格式
//date参数传入一个时间戳
time.formatYmd(date);

//将数组对象或对象或字符串转换成需要的时间,格式为(年-月-日 时:分:秒);
//三个参数 data(数据) str(时间数据) format(需要的日期格式)
//注:如果数据是时间戳需要先new Date()转换,也可以用formatYmd方法;如果不是数组或对象而且是Date类型只需要传入两个参数(data,format)
//format的格式(yyyy(年)-mm(月)-dd(日) hh(时):ff(分):ss(秒)),分隔符"-"与":"会在传入格式后自动补充
time.dateChange(data, str, format);

//参考数据
let data1 = [{
        id: 1,
        time: new Date(),
        chiidren: [{
                id: 1 - 1,
                time: new Date()
            },
            {
                id: 1 - 2,
                time: new Date()
            },
        ]
    },
    {
        id: 2,
        time: new Date()
    },
    {
        id: 3,
        time: new Date(),
        chiidren: [{
                id: 3 - 1,
                time: new Date()
            },
            {
                id: 3 - 2,
                time: new Date(),
                chiidren: [{
                        id: 3 - 2 - 1,
                        time: new Date()
                    },
                    {
                        id: 3 - 2 - 2,
                        time: new Date()
                    },
                ]
            },
        ]
    },
    {
        id: 4,
        time: new Date()
    },
    {
        id: 5,
        time: new Date()
    },
];
let data2 = {
    id: 1,
    time: new Date()
};
let data3 = new Date();
console.log(time.dateChange(data1, "time", "yyyymmdd"));
console.log(time.dateChange(data2, "time", "yyyymmdd hhffss"));
console.log(time.dateChange(data3, "yyyymm"));

2-3 数字转中文

//一个参数 num(传入一个数字)
Money.toChineseNum(num);

console.log(3992);//三千九百九十二

// 单选计算总价与总数量
//传入四个参数,data(数据),price(指对象中价格的键名),num(指对象中数量的键名),clicked(可选项,指对象中是否选中的键名,如果没有传则直接在每一个对象中添加一个clicked值)
Money.totalPrice(data, price, num, clicked);

// 全选计算总价与数量
// 同上
Money.selectAll(data, price, num, clicked);


//参考数据
let CartList = [{
        id: 1,
        price: 200,
        num: 2
    },
    {
        id: 2,
        price: 100,
        num: 1
    },
    {
        id: 3,
        price: 20,
        num: 1
    },
    {
        id: 4,
        price: 10,
        num: 10,
    }
];

3、作者为初学者,如果方法写的不好,请见谅!

3-1 有需要修正的地方的可以给作者提供,大家互相学习

QQ:337477044

邮箱:[email protected]