Important: This documentation covers Yarn 1 (Classic).
For Yarn 2+ docs and migration guide, see yarnpkg.com.

Package detail

ast-compare

codsen1.6kMIT4.0.30TypeScript support: included

Compare anything: AST, objects, arrays, strings and nested thereof

array, ast, compare, equal, html, nested, object, parse, parsed, parser, plain, posthtml, posthtml-tree, posthtmltree, subset, tree, xml

readme

ast-compare

Compare anything: AST, objects, arrays, strings and nested thereof

page on codsen.com page on npm page on github Downloads per month changelog MIT Licence

Install

This package is pure ESM. If you're not ready yet, install an older version of this program, 2.1.0 (npm i ast-compare@2.1.0).

npm i ast-compare

Quick Take

import { strict as assert } from "assert";

import { compare } from "ast-compare";

// Find out, does an object/array/string/nested-mix is a subset or equal to another input:
assert.equal(
  compare(
    {
      a: {
        b: "d",
        c: [],
        e: "f",
        g: "h",
      },
    },
    {
      a: {
        b: "d",
        c: [],
      },
    },
  ),
  true,
);

Documentation

Please visit codsen.com for a full description of the API.

Contributing

To report bugs or request features or assistance, raise an issue on GitHub.

Licence

MIT License.

Copyright © 2010-2025 Roy Revelt and other contributors.

ok codsen star

changelog

Change Log

All notable changes to this project will be documented in this file. See Conventional Commits for commit guidelines.

4.0.0 (2022-12-01)

BREAKING CHANGES

  • Minimum supported Node version is v14.18; we're dropping v12 support

3.2.0 (2022-08-12)

Features

3.1.3 (2022-04-18)

Fixed

3.1.0 (2022-04-10)

Features

  • export defaults and version (191d365)

3.0.0 (2021-09-09)

Features

BREAKING CHANGES

  • programs now are in ES Modules and won't work with Common JS require()

2.1.0 (2021-05-24)

Features

  • config file based major bump blacklisting (e15f9bb)

2.0.15 (2021-04-11)

Reverts

  • Revert "chore: setup refresh" (23cf206)

2.0.1 (2021-01-28)

Fixed

  • add testStats to npmignore (f3c84e9)

2.0.0 (2021-01-23)

Features

  • rewrite in TS and start using named exports (6a75380)

BREAKING CHANGES

  • previously you'd import like: import compare from ... - now do: import { compare } from ...

1.14.0 (2020-11-28)

Accidental version bump during migration to SourceHut. Sorry about that.

1.13.0 (2020-01-26)

Features

  • make the run 11 times faster (a9ea3f0)

1.12.19 (2019-10-07)

Performance Improvements

  • remove check-types-mini (0503752)

1.12.0 (2019-06-29)

Features

  • add perf measurement, recording and historical comparison (8266d21)

1.11.0 (2019-01-20)

  • various documentation and setup tweaks after we migrated to monorepo
  • updated dependencies and all config files using automated tools

1.7.0 (2018-12-26)

1.6.0 (2018-10-12)

  • Updated all dependencies and restored unit test coverage tracking, both via terminal and via coveralls.io

1.5.0 (2018-06-13)

GitHub sold us out. In the meantime, we:

  • Migrated to BitBucket (to host repo + perform CI) and Codacy (for code quality audit)
  • Dropped BitHound (RIP) and Travis
  • Removed package-lock

1.4.0 (2018-05-14)

Improvements

  • Now pointing unit tests at ES Modules build, not CommonJS-one. This means, unit test coverage will be correct (higher) because there won't be any missing rows that Babel added which are impossible to cover.
  • Tweaks to ava config in package.json, properly enabling the dev Rollup builds.

1.3.0 (2018-05-01)

Features

  • Set up Prettier
  • Removed package.lock and .editorconfig
  • Wired Rollup to remove comments from non-dev builds. This means we can now leave the console.logs in the source code — Rollup will remove them during the builds.

1.2.0 (2018-02-11)

Features

  • opts.useWildcards is driven by matcher and matcher up until today was case-insensitive. Today they released the case-sensitive mode and we switched to that. Now all behaviour in wildcards should match non-glob behaviour, case-wise.

1.1.0 (2017-10-29)

Features

  • opts.useWildcards (off by default)

1.0.0 (2017-10-24)

Features

  • Public release