Socket
Socket
Sign inDemoInstall

concordance

Package Overview
Dependencies
Maintainers
1
Versions
15
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

concordance

Compare, format, diff and serialize any JavaScript value


Version published
Maintainers
1
Created

What is concordance?

Concordance is a powerful assertion library for JavaScript that provides detailed and human-readable diffs for objects, arrays, and other data structures. It is particularly useful for testing and debugging, as it helps developers quickly identify differences between expected and actual values.

What are concordance's main functionalities?

Detailed Object Comparison

This feature allows you to compare two objects and get a detailed diff of their differences. The output is human-readable and helps in quickly identifying discrepancies.

const concordance = require('concordance');
const actual = { a: 1, b: 2 };
const expected = { a: 1, b: 3 };
const result = concordance.diff(actual, expected);
console.log(result);

Array Comparison

This feature allows you to compare two arrays and get a detailed diff of their differences. It is useful for testing and debugging array data structures.

const concordance = require('concordance');
const actual = [1, 2, 3];
const expected = [1, 2, 4];
const result = concordance.diff(actual, expected);
console.log(result);

Custom Serializers

This feature allows you to create custom serializers to handle specific data types in your comparisons. It provides flexibility in how data is represented in the diffs.

const concordance = require('concordance');
const customSerializer = {
  describe(value) {
    return { text: `Custom: ${value}` };
  },
  test(value) {
    return typeof value === 'string';
  }
};
const actual = 'hello';
const expected = 'world';
const result = concordance.diff(actual, expected, { serializers: [customSerializer] });
console.log(result);

Other packages similar to concordance

FAQs

Package last updated on 13 Feb 2021

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc