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

advance-json-merge

v1.0.4

Published

[![MIT Licence](https://badges.frapsoft.com/os/mit/mit.svg?v=103)](https://opensource.org/licenses/mit-license.php) [![npm version](https://badge.fury.io/js/advance-json-merge.svg)](https://badge.fury.io/js/advance-json-merge)

Downloads

23

Readme

advance-json-merge

MIT Licence npm version

Advance json merge

  • written in Typescript
  • combination Object.assign method
  • can merge with any level

Installation

Node.js / Browserify

npm install advance-json-merge --save
var advanceMerge = require('advance-json-merge');

Global object

Include the pre-built script.

<script src="./dist/index.umd.min.js"></script>

usage


var { mergeWithLevel } = require('advance-json-merge');
const origin = {
      e: {
        a: {
          c: 'o_c',
          d: 'o_d'
        },
        b: {
          e: 'o_e'
        },
        c: {
          h: 'o_h'
        },
        d: {
          j: 'o_j'
        }
      },
      f: 1
    };
const target = {
      e: {
        a: {
          a: 't_a'
        },
        b: {
          e: 't_e',
          f: 't_f'
        },
        d: 2
      },
      f: {
        a: {},
        b: {
          c: 't_c',
          h: 't_h'
        }
      }
    };

// level 0 merge
    const result = mergeWithLevel(origin, target, 0);
    expect(result).toEqual(target);

// level 1 merge
    const result = mergeWithLevel(origin, target, 1);
    expect(result).toEqual(Object.assign({}, origin, target));

// level 2 merge
    const result = mergeWithLevel(origin, target, 2);
    expect(result).toEqual({
      e: {
        a: {
          a: 't_a'
        },
        b: {
          e: 't_e',
          f: 't_f'
        },
        c: {
          h: 'o_h'
        },
        d: 2
      },
      f: {
        a: {},
        b: {
          c: 't_c',
          h: 't_h'
        }
      }
    });

// level 3+ merge
    const levelNum = chance.integer({ min: 3, max: 1000 });
    const result = mergeWithLevel(origin, target, levelNum);
    expect(result).toEqual({
      e: {
        a: {
          a: 't_a',
          c: 'o_c',
          d: 'o_d'
        },
        b: {
          e: 't_e',
          f: 't_f'
        },
        c: {
          h: 'o_h'
        },
        d: 2
      },
      f: {
        a: {},
        b: {
          c: 't_c',
          h: 't_h'
        }
      }
    });  

使用说明

  • 本工具并不会分析数组内部的对象属性,因此如果键值对的值是 数组,此时你将数组当成诸如 int 等原始值去理解;

Build & test

npm run build
npm test

document

npm run doc

then open the generated out/index.html file in your browser.

License

MIT.