Necrotizing Pineapple Music

    @mpkit/set-data
    TypeScript icon, indicating that this package has built-in type declarations

    1.1.2 • Public • Published

    @mpkit/set-data

    Build Status image image image

    小程序 setData 优化。

    功能列表

    • 将对象的 key 展开:openMpData(data:any, view?:MpView)
    import { openMpData } from "@mpkit/set-data";
    const res = openMpData({
        show: true,
        "list[0].user.name": "Tom",
    });
    console.log(res);
    /*
    {
        show: true,
        list:[
            user:{
                name:'Tom'
            }
        ]
    }
    */
    • 对比两个对象,返回对比后的结果:diffMpData(source:any,target:any)
    import { diffMpData } from "@mpkit/set-data";
    const res = diffMpData(
        {
            data: 1,
            list: [
                {
                    user: {
                        name: "Tom",
                    },
                },
                {
                    user: {
                        name: "Jeck",
                    },
                },
            ],
        },
        {
            data: 2,
            list: [
                {
                    user: {
                        name: "Alice",
                        age: 10,
                    },
                },
            ],
        }
    );
    console.log(res);
    /*
    {
        "data": 2,
        "list[0].user.name": "Alice",
        "list[0].user.age": 10
    }
    */

    Install

    npm i @mpkit/set-data

    DownloadsWeekly Downloads

    17

    Version

    1.1.2

    License

    MIT

    Unpacked Size

    94.9 kB

    Total Files

    10

    Last publish

    Collaborators

    • imingyu