Skip to content

Commit ab9aa01

Browse files
deep diff arrays, objects, dates & primitives
1 parent 171e501 commit ab9aa01

23 files changed

+2493
-2
lines changed

.changeset/README.md

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
# Changesets
2+
3+
Hello and welcome! This folder has been automatically generated by `@changesets/cli`, a build tool that works
4+
with multi-package repos, or single-package repos to help you version and publish your code. You can
5+
find the full documentation for it [in our repository](https://github.com/changesets/changesets)
6+
7+
We have a quick list of common questions to get you started engaging with this project in
8+
[our documentation](https://github.com/changesets/changesets/blob/main/docs/common-questions.md)

.changeset/config.json

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
{
2+
"$schema": "https://unpkg.com/@changesets/[email protected]/schema.json",
3+
"changelog": "@changesets/cli/changelog",
4+
"commit": false,
5+
"fixed": [],
6+
"linked": [],
7+
"access": "public",
8+
"baseBranch": "main",
9+
"updateInternalDependencies": "patch",
10+
"ignore": ["docs"],
11+
"privatePackages": false,
12+
"bumpVersionsWithWorkspaceProtocolOnly": true
13+
}

.github/FUNDING.yml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
# These are supported funding model platforms
2+
3+
github: [Open-Tech-Foundation]

.github/workflows/build.yml

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
# This workflow will do a clean install of node dependencies, cache/restore them, build the source code and run tests across different versions of node
2+
# For more information see: https://help.github.com/actions/language-and-framework-guides/using-nodejs-with-github-actions
3+
4+
name: Build
5+
6+
on:
7+
push:
8+
branches: [ main ]
9+
paths-ignore:
10+
- 'apps/website/**'
11+
pull_request:
12+
branches: [ main ]
13+
14+
env:
15+
HUSKY: 0
16+
17+
jobs:
18+
build:
19+
20+
runs-on: ubuntu-latest
21+
22+
strategy:
23+
matrix:
24+
node-version: [16.x, 18.x, 20.x]
25+
# See supported Node.js release schedule at https://nodejs.org/en/about/releases/
26+
27+
steps:
28+
- uses: actions/checkout@v3
29+
- uses: pnpm/action-setup@v2
30+
with:
31+
version: 8
32+
- name: Use Node.js ${{ matrix.node-version }}
33+
uses: actions/setup-node@v3
34+
with:
35+
node-version: ${{ matrix.node-version }}
36+
cache: 'pnpm'
37+
- run: pnpm install
38+
- run: pnpm run ci

.github/workflows/release.yml

Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,51 @@
1+
name: Release
2+
3+
on:
4+
workflow_dispatch:
5+
push:
6+
branches:
7+
- main
8+
paths-ignore:
9+
- "apps/docs/**"
10+
11+
concurrency: ${{ github.workflow }}-${{ github.ref }}
12+
13+
env:
14+
HUSKY: 0
15+
16+
jobs:
17+
release:
18+
name: Release
19+
runs-on: ubuntu-latest
20+
permissions:
21+
id-token: write
22+
contents: write
23+
pull-requests: write
24+
repository-projects: write
25+
steps:
26+
- name: Checkout Repo
27+
uses: actions/checkout@v3
28+
29+
- name: Setup pnpm
30+
uses: pnpm/action-setup@v2
31+
with:
32+
version: 8
33+
34+
- name: Setup Node.js 20.x
35+
uses: actions/setup-node@v3
36+
with:
37+
node-version: 20.x
38+
cache: "pnpm"
39+
40+
- name: Install Dependencies
41+
run: pnpm install
42+
43+
- name: Create Release Pull Request or Publish to npm
44+
id: changesets
45+
uses: changesets/action@v1
46+
with:
47+
# This expects you to have a script called publish-packages which does a build for your packages and calls changeset publish
48+
publish: pnpm publish-packages
49+
env:
50+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
51+
NPM_TOKEN: ${{ secrets.NPM_TOKEN }}

.gitignore

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
# Logs
2+
logs
3+
*.log
4+
npm-debug.log*
5+
yarn-debug.log*
6+
yarn-error.log*
7+
8+
# Dependency directories
9+
node_modules/
10+
jspm_packages/
11+
12+
# Artifacts
13+
dist
14+
build
15+
built
16+
lib
17+
18+
.parcel-cache
19+
20+
play.js
21+
.turbo
22+
23+
.next

CODE_OF_CONDUCT.md

Lines changed: 128 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,128 @@
1+
# Contributor Covenant Code of Conduct
2+
3+
## Our Pledge
4+
5+
We as members, contributors, and leaders pledge to make participation in our
6+
community a harassment-free experience for everyone, regardless of age, body
7+
size, visible or invisible disability, ethnicity, sex characteristics, gender
8+
identity and expression, level of experience, education, socio-economic status,
9+
nationality, personal appearance, race, religion, or sexual identity
10+
and orientation.
11+
12+
We pledge to act and interact in ways that contribute to an open, welcoming,
13+
diverse, inclusive, and healthy community.
14+
15+
## Our Standards
16+
17+
Examples of behavior that contributes to a positive environment for our
18+
community include:
19+
20+
* Demonstrating empathy and kindness toward other people
21+
* Being respectful of differing opinions, viewpoints, and experiences
22+
* Giving and gracefully accepting constructive feedback
23+
* Accepting responsibility and apologizing to those affected by our mistakes,
24+
and learning from the experience
25+
* Focusing on what is best not just for us as individuals, but for the
26+
overall community
27+
28+
Examples of unacceptable behavior include:
29+
30+
* The use of sexualized language or imagery, and sexual attention or
31+
advances of any kind
32+
* Trolling, insulting or derogatory comments, and personal or political attacks
33+
* Public or private harassment
34+
* Publishing others' private information, such as a physical or email
35+
address, without their explicit permission
36+
* Other conduct which could reasonably be considered inappropriate in a
37+
professional setting
38+
39+
## Enforcement Responsibilities
40+
41+
Community leaders are responsible for clarifying and enforcing our standards of
42+
acceptable behavior and will take appropriate and fair corrective action in
43+
response to any behavior that they deem inappropriate, threatening, offensive,
44+
or harmful.
45+
46+
Community leaders have the right and responsibility to remove, edit, or reject
47+
comments, commits, code, wiki edits, issues, and other contributions that are
48+
not aligned to this Code of Conduct, and will communicate reasons for moderation
49+
decisions when appropriate.
50+
51+
## Scope
52+
53+
This Code of Conduct applies within all community spaces, and also applies when
54+
an individual is officially representing the community in public spaces.
55+
Examples of representing our community include using an official e-mail address,
56+
posting via an official social media account, or acting as an appointed
57+
representative at an online or offline event.
58+
59+
## Enforcement
60+
61+
Instances of abusive, harassing, or otherwise unacceptable behavior may be
62+
reported to the community leaders responsible for enforcement at
63+
.
64+
All complaints will be reviewed and investigated promptly and fairly.
65+
66+
All community leaders are obligated to respect the privacy and security of the
67+
reporter of any incident.
68+
69+
## Enforcement Guidelines
70+
71+
Community leaders will follow these Community Impact Guidelines in determining
72+
the consequences for any action they deem in violation of this Code of Conduct:
73+
74+
### 1. Correction
75+
76+
**Community Impact**: Use of inappropriate language or other behavior deemed
77+
unprofessional or unwelcome in the community.
78+
79+
**Consequence**: A private, written warning from community leaders, providing
80+
clarity around the nature of the violation and an explanation of why the
81+
behavior was inappropriate. A public apology may be requested.
82+
83+
### 2. Warning
84+
85+
**Community Impact**: A violation through a single incident or series
86+
of actions.
87+
88+
**Consequence**: A warning with consequences for continued behavior. No
89+
interaction with the people involved, including unsolicited interaction with
90+
those enforcing the Code of Conduct, for a specified period of time. This
91+
includes avoiding interactions in community spaces as well as external channels
92+
like social media. Violating these terms may lead to a temporary or
93+
permanent ban.
94+
95+
### 3. Temporary Ban
96+
97+
**Community Impact**: A serious violation of community standards, including
98+
sustained inappropriate behavior.
99+
100+
**Consequence**: A temporary ban from any sort of interaction or public
101+
communication with the community for a specified period of time. No public or
102+
private interaction with the people involved, including unsolicited interaction
103+
with those enforcing the Code of Conduct, is allowed during this period.
104+
Violating these terms may lead to a permanent ban.
105+
106+
### 4. Permanent Ban
107+
108+
**Community Impact**: Demonstrating a pattern of violation of community
109+
standards, including sustained inappropriate behavior, harassment of an
110+
individual, or aggression toward or disparagement of classes of individuals.
111+
112+
**Consequence**: A permanent ban from any sort of public interaction within
113+
the community.
114+
115+
## Attribution
116+
117+
This Code of Conduct is adapted from the [Contributor Covenant][homepage],
118+
version 2.0, available at
119+
https://www.contributor-covenant.org/version/2/0/code_of_conduct.html.
120+
121+
Community Impact Guidelines were inspired by [Mozilla's code of conduct
122+
enforcement ladder](https://github.com/mozilla/diversity).
123+
124+
[homepage]: https://www.contributor-covenant.org
125+
126+
For answers to common questions about this code of conduct, see the FAQ at
127+
https://www.contributor-covenant.org/faq. Translations are available at
128+
https://www.contributor-covenant.org/translations.

CONTRIBUTING.md

Lines changed: 56 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,56 @@
1+
## 🙏 Welcome
2+
3+
Any kind of contributions are valued.
4+
5+
## Table of Contents
6+
7+
- [Code of Conduct](#code-of-conduct)
8+
- [Getting Started](#getting-started)
9+
- [Reporting Issues](#reporting-issues)
10+
- [Pull Requests](#pull-requests)
11+
- [Financial Contributions](#financial-contributions)
12+
13+
## Code of Conduct
14+
15+
By participating and contributing to this project, you agree to uphold our [Code of Conduct](./CODE_OF_CONDUCT.md).
16+
17+
## Getting Started
18+
19+
This project is under the organization called [Open Tech Foundation](https://github.com/Open-Tech-Foundation), please go through this and learn more about our core principles.
20+
21+
- **Star the project**: If you really found this project useful, please star it to move forward.
22+
23+
- **Share**: Please share this project to world by means of any medium.
24+
25+
## Reporting Issues
26+
27+
There is no strict guides to creating an issue in the Github issue tracker.
28+
29+
- The issue can be a `Bug`, `Feature Request`, `Suggestions`, `Question`, etc.
30+
- Please write clear & consice title.
31+
- Please explain the nature of the issue.
32+
- Describe how to reproduce if it is a bug.
33+
- Explain what is the `expected` and the `actual` behaviour.
34+
35+
The maintainers of the project will add appropriate labels to it.
36+
37+
## Pull Requests
38+
39+
We follow the standard `Fork and Clone` method for PRs.
40+
41+
- Make code changes with performance in mind.
42+
- Add `comments` to the code if necessary.
43+
- Add `tests` if necessary.
44+
- Update `docs` if needed.
45+
- Add meaningful commit message & follow the [conventional commit format](https://conventionalcommits.org/)
46+
- Include issue number in the commit message if your working on the existing issue like `fix: remove invalid #1337`.
47+
48+
## Financial Contributions
49+
50+
Supporting financialy is more important for the project's full-time maintainers.
51+
52+
Please support us by donating.
53+
54+
Currently we are accepting financial contributions via [Github sponsers](https://github.com/sponsors/Open-Tech-Foundation).
55+
56+
Thanks for your valuable time.

LICENSE

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
MIT License
22

3-
Copyright (c) 2024 Open Tech Foundation
3+
Copyright (c) 2024 Thanga Ganapathy <[email protected]>
44

55
Permission is hereby granted, free of charge, to any person obtaining a copy
66
of this software and associated documentation files (the "Software"), to deal

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,2 @@
11
# obj-diff
2-
The Fast, Accurate, JavaScript Object Diffing Library.
2+
The Fast,Accurate,JavaScript Object Diffing Library.

benchmark.js

Lines changed: 56 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,56 @@
1+
import { Bench, hrtimeNow } from "tinybench";
2+
import mdiff from "microdiff";
3+
import { diff } from "./packages/obj-diff/src";
4+
import { diff as deepObjDiff } from "deep-object-diff";
5+
import { diff as justDiff } from "just-diff";
6+
import deepDiff from "deep-diff";
7+
8+
const lhs = {
9+
foo: {
10+
bar: {
11+
a: ["a", "b"],
12+
b: 2,
13+
c: ["x", "y"],
14+
e: 100, // deleted
15+
},
16+
},
17+
buzz: "world",
18+
date: new Date("2024-01-01"),
19+
};
20+
21+
const rhs = {
22+
foo: {
23+
bar: {
24+
a: ["a"], // index 1 ('b') deleted
25+
b: 2, // unchanged
26+
c: ["x", "y", "z"], // 'z' added
27+
d: "Hello, world!", // added
28+
},
29+
},
30+
buzz: "fizz", // updated
31+
date: new Date("2024-01-02"),
32+
};
33+
34+
const bench = new Bench({ time: 100, now: hrtimeNow });
35+
36+
bench
37+
.add("diff", () => {
38+
diff(lhs, rhs);
39+
})
40+
.add("microdiff", () => {
41+
mdiff(lhs, rhs);
42+
})
43+
.add("deep-object-diff", () => {
44+
deepObjDiff(lhs, rhs);
45+
})
46+
.add("just-diff", () => {
47+
justDiff(lhs, rhs);
48+
})
49+
.add("deep-diff", () => {
50+
deepDiff(lhs, rhs);
51+
});
52+
53+
await bench.warmup();
54+
await bench.run();
55+
56+
console.table(bench.table());

0 commit comments

Comments
 (0)