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

Make color space optional in getAll() + colorSpace.equals() improvements #413

Merged
merged 3 commits into from
Feb 10, 2024

Conversation

LeaVerou
Copy link
Member

@LeaVerou LeaVerou commented Feb 9, 2024

This PR does two things:

  1. Supports string ids in colorSpace.equals() (and adds JSDoc for the method)
  2. Makes the color space optional in getAll().
    Not only does this make getAll() more consistent with the rest of the API, it also sets the stage for option 3 here: Precision lets scientific notation leak for small values #388 (comment) . As a side effect, it also implements a performance improvement when the color passed happens to be in the same color space as the one specified as it now goes through the same code path.

- JSDoc
- Handle comparison with id
This is to set the stage for option 3 here: #388 (comment) but also implements a performance improvement when the color passed *happens* to be in the same color space as the one specified.
@LeaVerou LeaVerou requested a review from jgerigmeyer February 9, 2024 22:34
Copy link

netlify bot commented Feb 9, 2024

Deploy Preview for colorjs ready!

Name Link
🔨 Latest commit b8590c8
🔍 Latest deploy log https://app.netlify.com/sites/colorjs/deploys/65c7b6e2c2cd350008dc9e7d
😎 Deploy Preview https://deploy-preview-413--colorjs.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify site configuration.

Copy link
Member

@MysteryBlokHed MysteryBlokHed left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The JavaScript changes LGTM, but the types should be changed to reflect that the space parameter is now optional:

export default function getAll (
color: Color | ColorObject,
space: string | ColorSpace
): [number, number, number];

 export default function getAll (
 	color: Color | ColorObject,
-	space: string | ColorSpace
+	space?: string | ColorSpace
 ): [number, number, number];

@jgerigmeyer jgerigmeyer merged commit 64780c3 into main Feb 10, 2024
5 checks passed
@jgerigmeyer jgerigmeyer deleted the getall-optional-space branch February 10, 2024 17:51
@LeaVerou
Copy link
Member Author

@MysteryBlokHed Yup, I was hoping that you or @jgerigmeyer would be kind enough to do that 😁

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.

3 participants