-
Notifications
You must be signed in to change notification settings - Fork 1
Updates #8
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Updates #8
Changes from all commits
Commits
Show all changes
3 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Some comments aren't visible on the classic Files Changed page.
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,67 @@ | ||
| name: CI | ||
|
|
||
| on: | ||
| push: | ||
| branches: ['main'] | ||
| tags: ['v*'] | ||
| pull_request: | ||
| branches: ['*'] | ||
|
|
||
| workflow_dispatch: | ||
|
|
||
| concurrency: | ||
| group: ${{ github.ref }} | ||
| cancel-in-progress: true | ||
|
|
||
| jobs: | ||
| validate: | ||
| runs-on: ubuntu-latest | ||
| steps: | ||
| - uses: actions/checkout@v4 | ||
|
|
||
| - uses: pnpm/action-setup@v4 | ||
| with: | ||
| version: 10 | ||
| run_install: false | ||
|
|
||
| - uses: actions/setup-node@v4 | ||
| with: | ||
| node-version: 22 | ||
| cache: pnpm | ||
|
|
||
| - run: pnpm install | ||
|
|
||
| - run: pnpm validate | ||
|
|
||
| - uses: SonarSource/sonarqube-scan-action@v7.0.0 | ||
| if: "!startsWith(github.ref, 'refs/tags/')" | ||
| env: | ||
| GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | ||
| SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }} | ||
|
|
||
| publish: | ||
| runs-on: ubuntu-latest | ||
| if: startsWith(github.ref, 'refs/tags/v') | ||
| needs: validate | ||
| permissions: | ||
| id-token: write | ||
| contents: read | ||
| steps: | ||
| - uses: actions/checkout@v4 | ||
|
|
||
| - uses: pnpm/action-setup@v4 | ||
| with: | ||
| version: 10 | ||
| run_install: false | ||
|
|
||
| - uses: actions/setup-node@v4 | ||
| with: | ||
| node-version: 22 | ||
| cache: pnpm | ||
| registry-url: https://registry.npmjs.org | ||
|
|
||
| - run: npm install -g npm@11 | ||
|
|
||
| - run: pnpm install | ||
|
|
||
| - run: npm publish --provenance | ||
This file was deleted.
Oops, something went wrong.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,46 @@ | ||
| # CLAUDE.md | ||
|
|
||
| This file provides guidance to Claude Code (claude.ai/code) when working with code in this repository. | ||
|
|
||
| ## Commands | ||
|
|
||
| ```bash | ||
| pnpm build # Clean and build with tsup (outputs dist/) | ||
| pnpm lint # ESLint with auto-fix | ||
| pnpm typecheck # TypeScript check (noEmit) | ||
| pnpm test # Runs vitest once | ||
| pnpm test:watch # Runs vitest watch mode | ||
| pnpm test:coverage # Runs tests with coverage | ||
| pnpm validate # Full validation: lint + typecheck + test:coverage + build + size | ||
| ``` | ||
|
|
||
| Run a single test file: | ||
| ```bash | ||
| pnpm test test/arrays.spec.ts | ||
| ``` | ||
|
|
||
| Run tests matching a pattern: | ||
| ```bash | ||
| pnpm test -t "should return true" | ||
| ``` | ||
|
|
||
| ## Architecture | ||
|
|
||
| Single-purpose library exporting one default function `equal(left, right)` that performs deep equality comparison. | ||
|
|
||
| **Source structure:** | ||
| - `src/index.ts` - Main `equal` function with specialized comparators for arrays, Maps, Sets, ArrayBuffers, and objects | ||
| - `src/helpers.ts` - Type guard utilities (`isObject`, `isRegex`, etc.) | ||
| - `src/types.ts` - TypeScript type definitions | ||
|
|
||
| **Key implementation details:** | ||
| - Circular references: Handled via WeakMap/WeakSet tracking to prevent infinite recursion in self-referential or cross-referential structures | ||
| - React elements: Skips `_owner` property (contains circular refs) when `$$typeof` is present | ||
| - NaN handling: `NaN === NaN` returns true | ||
| - Comparison order: Reference equality → constructor match → type-specific comparison → valueOf/toString fallback → key-by-key recursion | ||
|
|
||
| **Tests** are organized by data type in `test/*.spec.ts` (scalars, objects, arrays, dates, regex, functions, bigint, maps, sets, typed-arrays). | ||
|
|
||
| ## Build | ||
|
|
||
| Uses `tsup` with dual output (CJS + ESM). Size limit: 1kB per format. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,15 @@ | ||
| import config from '@gilbarbara/eslint-config'; | ||
| import testingLibrary from '@gilbarbara/eslint-config/testing-library'; | ||
| import vitest from '@gilbarbara/eslint-config/vitest'; | ||
|
|
||
| export default [ | ||
| ...config, | ||
| ...vitest, | ||
| ...testingLibrary, | ||
| { | ||
| files: ['**/?(*.)+(spec|test).[jt]s?(x)'], | ||
| rules: { | ||
| 'no-console': 'off', | ||
| }, | ||
| }, | ||
| ]; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.