Repository navigation
[getAll] Support precision, closes #542 - #548
Conversation
β Deploy Preview for colorjs failed. Why did it fail? β
|
LeaVerou
left a comment
There was a problem hiding this comment.
I don't think we want a separate parameter here, we'd want to make the second param an options object with space and precision as keys. Specifying a color space (either as a string or ColorSpace object should still work.
Agreed. Done. Could you please have another look? |
LeaVerou
left a comment
There was a problem hiding this comment.
Please note that I said:
Specifying a color space (either as a string or
ColorSpaceobject should still work.
Using space as an options param should only be needed when weβre also specifying precision.
|
Something like this in Lines 69 to 71 in 3f97a65 Where a destructured object is used as a parameter, but then |
I was thinking of something like this, too. Thank you so much for the hint! π |
This reverts commit 4c52663.
| * @param {string | ColorSpace | object} [options=color.space] If a string or ColorSpace, the color space to convert to. Defaults to the color's current space. | ||
| * If an object: | ||
| * [options.space=color.space] β the color space to convert to (defaults to the color's current space); | ||
| * [options.precision] β the number of significant digits to round the coordinates to. |
There was a problem hiding this comment.
It doesnβt seem to me like TypeScript is properly understanding the type here. Maybe making a @typedef for the functionβs options would be best? I can add a code suggestion for that you agree
There was a problem hiding this comment.
Yes I think a typedef would make sense here. Though I thought we had found a way to do overloads?
There was a problem hiding this comment.
Overloads would work too, but I still donβt think itβs a bad idea to define the options outside of the functionβs JSDoc just for readability. We can have one overload with string | ColorSpace and another with the new type (eg. GetAllOptions).
Co-authored-by: Adam Thompson-Sharpe <adamthompsonsharpe@gmail.com>
Co-authored-by: Adam Thompson-Sharpe <adamthompsonsharpe@gmail.com>
|
@MysteryBlokHed, could you please check if I get the idea with overloads right? |
MysteryBlokHed
left a comment
There was a problem hiding this comment.
Everything typing-related LGTM!
|
@DmitrySharabin do you have access to edit the release notes for v0.6.0 to mention this? (make sure not to accidentally publish!) |
It looks like I don't β I don't see any drafts of release notes. |
Ensure that itβs something you had in mind, though. My approach is relatively straightforward. We should probably have an optional
optionsparameter withprecisionas a property.