1.1.1 • Published 6 months ago

diffoo v1.1.1

Weekly downloads
-
License
MIT
Repository
-
Last release
6 months ago

DIFFOO

A library for diffing most JS object changes.

Installation

To install the library, you can use package managers such as npm or yarn:

npm install diffoo

or

yarn add diffoo

Usage

Here is an example of how to use the library:

Example 1: Simple base type diff

import DefaultPolicyFactory from 'diffoo'

const policyFactory = new DefaultPolicyFactory();
const result = policyFactory.produce("String1", "String2");
console.log(result.diffObj) 

result:

StringDiffBaseField {
    originRawObj: 'String1',
    comparingRawObj: 'String2',
    compareOptions: { policyFactory: DefaultPolicyFactory {} },
    policyFactory: DefaultPolicyFactory {},
    valueType: 'string',
    diffType: 'Update',
    diffObj: [Circular *1],
    originObj: [Circular *1],
    comparingObj: [Circular *1]
  }

Example 2: Complex type diff

 const result = policyFactory.produce(
  [{
    key: 'new value1',
    name: '1',
    number: 123,
    boolean: true,
  }, {
    key: 'new value2',
    name: '1',
    number: 123,
    boolean: true,
  }],
  [{
    key: 'new value1',
    name: '1',
    number: 123,
    boolean: true,
  }, {
    key: 'new value2',
    name: '1',
    number: 123,
    boolean: true,
  }],
  {
    // Support combined PK definition
    primaryKeyFields: {
      key: true,
      number:true
    }
  }); 
  console.log(result)

result:

  ArrayDiffBaseField {
        originRawObj: [
          { key: 'new value1', name: '1', number: 123, boolean: true },
          { key: 'new value2', name: '1', number: 123, boolean: true }
        ],
        comparingRawObj: [
          { key: 'new value1', name: '1', number: 123, boolean: true },
          { key: 'new value2', name: '1', number: 123, boolean: true }
        ],
        compareOptions: {
          primaryKeyFields: { key: true, number: true },
          policyFactory: DefaultPolicyFactory {}
        },
        policyFactory: DefaultPolicyFactory {},
        valueType: 'array',
        diffType: 'Equal',
        diffObj: [
          ObjectDiffBaseField {
            originRawObj: [Object],
            comparingRawObj: [Object],
            compareOptions: [Object],
            policyFactory: DefaultPolicyFactory {},
            valueType: 'object',
            diffType: 'Equal',
            diffObj: [Object],
            originObj: null,
            comparingObj: null
          },
          ObjectDiffBaseField {
            originRawObj: [Object],
            comparingRawObj: [Object],
            compareOptions: [Object],
            policyFactory: DefaultPolicyFactory {},
            valueType: 'object',
            diffType: 'Equal',
            diffObj: [Object],
            originObj: null,
            comparingObj: null
          }
        ],
        originObj: [],
        comparingObj: []
      }

Documentation

The author is too lazy and will improve this part of the content in their lifetime.

For detailed documentation, please refer to the official documentation.

API Reference

The author is too lazy and will improve this part of the content in their lifetime.

For detailed information on the library's API, please refer to the API documentation.

Contributing

Contributions are welcome! Please follow the guidelines outlined in the CONTRIBUTING.md file.

License

This library is licensed under the MIT License.

1.1.1

6 months ago

1.0.19

6 months ago

1.1.0

6 months ago

1.0.18

6 months ago

1.0.17

6 months ago

1.0.21

6 months ago

1.0.20

6 months ago

1.0.16

8 months ago

1.0.11

10 months ago

1.0.15

9 months ago

1.0.14

9 months ago

1.0.13

9 months ago

1.0.12

9 months ago

1.0.10

10 months ago

1.0.9

10 months ago

1.0.8-beta.2

10 months ago

1.0.8-beta.1

10 months ago

1.0.8-INTERNAL

10 months ago

1.0.7

10 months ago

1.0.6

10 months ago

1.0.5

11 months ago

1.0.4

11 months ago

1.0.3

11 months ago

1.0.2

11 months ago

1.0.1

11 months ago

1.0.0

11 months ago