Skip to content
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

🚸 Shorter stringified values for null-prototype #5603

Merged
merged 3 commits into from
Jan 14, 2025
Merged

🚸 Shorter stringified values for null-prototype #5603

merged 3 commits into from
Jan 14, 2025

Conversation

dubzzz
Copy link
Owner

@dubzzz dubzzz commented Jan 14, 2025

Description

As specified on MDN Web Doc @ Object # null-prototype objects, there are two main ways to build instances having null-prototype:

However, you may create null-prototype objects using Object.create(null) or the object initializer syntax with proto: null [...]

const obj = Object.create(null);
const obj2 = { __proto__: null };

Up-to-now, fc.stringify has been using the first notation with Object.assign added to it to add keys within the instance. But as Object.create + Object.assign tend to be longer than the ___proto__:null, we swicth to that shorter notation in that PR.

ChecklistDon't delete this checklist and make sure you do the following before opening the PR

  • The name of my PR follows gitmoji specification
  • My PR references one of several related issues (if any)
    • New features or breaking changes must come with an associated Issue or Discussion
    • My PR does not add any new dependency without an associated Issue or Discussion
  • My PR includes bumps details, please run yarn bump and flag the impacts properly
  • My PR adds relevant tests and they would have failed without my PR (when applicable)

Advanced

  • Category: ✨ Introduce new features
  • Impacts: Lighter display for prototype-less instances

⚠️ Minor breaking change: As it may slighty impact final users (exposed API), we will wait a major version to release it (major being close, let's wait for it). It seems to be compatible with any version of node, at least from 0.10.48 so the eval(fc.stringify(value)) would still work.

Sorry, something went wrong.

**⚠️ Minor breaking change**

As specified on [MDN Web Doc @ Object # null-prototype objects](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object#null-prototype_objects), there are two main ways to build instances having null-prototype:

> However, you may create null-prototype objects using Object.create(null) or the object initializer syntax with __proto__: null [...]
>
> ```js
> const obj = Object.create(null);
> const obj2 = { __proto__: null };
> ````

Up-to-now, `fc.stringify` has been using the first notation with `Object.assign` added to it to add keys within the instance. But as `Object.create` + `Object.assign` tend to be longer than the `___proto__:null`, we swicth to that shorter notation in that PR.

As it may slighty impact final users (exposed API), we will wait a major version to release it (major being close, let's wait for it). It seems to be compatible with any version of node, at least from 0.10.48 so the `eval(fc.stringify(value))` would still work.
Copy link

changeset-bot bot commented Jan 14, 2025

🦋 Changeset detected

Latest commit: a0461e1

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 5 packages
Name Type
fast-check Major
@fast-check/ava Patch
@fast-check/jest Patch
@fast-check/vitest Patch
@fast-check/worker Patch

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

Verified

This commit was created on GitHub.com and signed with GitHub’s verified signature.

Verified

This commit was created on GitHub.com and signed with GitHub’s verified signature.
@dubzzz dubzzz enabled auto-merge (squash) January 14, 2025 07:39
Copy link

pkg-pr-new bot commented Jan 14, 2025

Open in Stackblitz@fast-check/examples

@fast-check/ava

npm i https://pkg.pr.new/@fast-check/ava@5603

@fast-check/expect-type

npm i https://pkg.pr.new/@fast-check/expect-type@5603

fast-check

npm i https://pkg.pr.new/fast-check@5603

@fast-check/jest

npm i https://pkg.pr.new/@fast-check/jest@5603

@fast-check/packaged

npm i https://pkg.pr.new/@fast-check/packaged@5603

@fast-check/poisoning

npm i https://pkg.pr.new/@fast-check/poisoning@5603

@fast-check/vitest

npm i https://pkg.pr.new/@fast-check/vitest@5603

@fast-check/worker

npm i https://pkg.pr.new/@fast-check/worker@5603

commit: a0461e1

Copy link

codecov bot commented Jan 14, 2025

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 94.77%. Comparing base (c806d57) to head (a0461e1).
Report is 6 commits behind head on main.

Additional details and impacted files
@@            Coverage Diff             @@
##             main    #5603      +/-   ##
==========================================
- Coverage   94.77%   94.77%   -0.01%     
==========================================
  Files         235      235              
  Lines       10036    10033       -3     
  Branches     2826     2826              
==========================================
- Hits         9512     9509       -3     
  Misses        524      524              
Flag Coverage Δ
unit-tests 94.77% <100.00%> (-0.01%) ⬇️
unit-tests-18.x-Linux 94.77% <100.00%> (-0.01%) ⬇️
unit-tests-20.x-Linux 94.77% <100.00%> (-0.01%) ⬇️
unit-tests-22.x-Linux 94.77% <100.00%> (-0.01%) ⬇️
unit-tests-latest-Linux 94.77% <100.00%> (-0.01%) ⬇️

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

Copy link
Contributor

👋 A preview of the new documentation is available at: http://67861955927658c0972b932e--dubzzz-fast-check.netlify.app

@dubzzz dubzzz merged commit 0590841 into main Jan 14, 2025
59 checks passed
@dubzzz dubzzz deleted the pr-4498 branch January 14, 2025 07:59
dubzzz added a commit that referenced this pull request Mar 10, 2025

Verified

This commit was created on GitHub.com and signed with GitHub’s verified signature.
….3, @fast-check/vitest@0.1.6, @fast-check/expect-type@0.2.1, @fast-check/worker@0.4.2, @fast-check/jest@2.1.0, @fast-check/packaged@0.5.0, @fast-check/ava@2.0.2 (#5818)

Resulting CHANGELOG at:
-
https://github.com/dubzzz/fast-check/blob/changelog-178153e45d62/packages/fast-check/CHANGELOG.md
-
https://github.com/dubzzz/fast-check/blob/changelog-178153e45d62/packages/poisoning/CHANGELOG.md
-
https://github.com/dubzzz/fast-check/blob/changelog-178153e45d62/packages/vitest/CHANGELOG.md
-
https://github.com/dubzzz/fast-check/blob/changelog-178153e45d62/packages/expect-type/CHANGELOG.md
-
https://github.com/dubzzz/fast-check/blob/changelog-178153e45d62/packages/worker/CHANGELOG.md
-
https://github.com/dubzzz/fast-check/blob/changelog-178153e45d62/packages/jest/CHANGELOG.md
-
https://github.com/dubzzz/fast-check/blob/changelog-178153e45d62/packages/packaged/CHANGELOG.md
-
https://github.com/dubzzz/fast-check/blob/changelog-178153e45d62/packages/ava/CHANGELOG.md

Got the following errors:
- ⚠️ Unhandled type: 🚨 on
[PR-5803](#5803) with title Fix
lint error in `ConstantArbitrary` class
- ⚠️ Unhandled type: 🚨 on
[PR-5767](#5767) with title
Abide by lint rule `no-unused-vars`
- ⚠️ Unhandled type: 🚨 on
[PR-5763](#5763) with title
Abide by lint rule `no-empty-object-type`
- ⚠️ Unhandled type: 🔖 on
[PR-5654](#5654) with title
Update CHANGELOG.md for @fast-check/vitest@0.1.5
- ⚠️ Unhandled type: 🚸 on
[PR-5603](#5603) with title
Shorter stringified values for null-prototype
- ℹ️ Scanned 277 PRs for fast-check:
- ℹ️ • accepted: 93,
- ℹ️ • skipped ignored: 161,
- ℹ️ • skipped unrelated: 18,
- ℹ️ • failed: 5
- ℹ️ Scanned 397 PRs for @fast-check/poisoning:
- ℹ️ • accepted: 1,
- ℹ️ • skipped ignored: 0,
- ℹ️ • skipped unrelated: 396,
- ℹ️ • failed: 0
- ⚠️ Unhandled type: 🚨(vitest) on
[PR-5764](#5764) with title
Abide by lint rule `no-duplicate-type-constituents`
- ℹ️ Scanned 159 PRs for @fast-check/vitest:
- ℹ️ • accepted: 3,
- ℹ️ • skipped ignored: 0,
- ℹ️ • skipped unrelated: 155,
- ℹ️ • failed: 1
- ℹ️ Scanned 1020 PRs for @fast-check/expect-type:
- ℹ️ • accepted: 1,
- ℹ️ • skipped ignored: 0,
- ℹ️ • skipped unrelated: 1019,
- ℹ️ • failed: 0
- ℹ️ Scanned 397 PRs for @fast-check/worker:
- ℹ️ • accepted: 2,
- ℹ️ • skipped ignored: 0,
- ℹ️ • skipped unrelated: 395,
- ℹ️ • failed: 0
- ℹ️ Scanned 397 PRs for @fast-check/jest:
- ℹ️ • accepted: 4,
- ℹ️ • skipped ignored: 0,
- ℹ️ • skipped unrelated: 393,
- ℹ️ • failed: 0
- ℹ️ Scanned 277 PRs for @fast-check/packaged:
- ℹ️ • accepted: 2,
- ℹ️ • skipped ignored: 0,
- ℹ️ • skipped unrelated: 275,
- ℹ️ • failed: 0
- ℹ️ Scanned 573 PRs for @fast-check/ava:
- ℹ️ • accepted: 3,
- ℹ️ • skipped ignored: 0,
- ℹ️ • skipped unrelated: 570,
- ℹ️ • failed: 0

---------

Co-authored-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com>
Co-authored-by: Nicolas DUBIEN <github@dubien.org>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

1 participant