meodai / color-names

Large list of handpicked color names 🌈
https://meodai.github.io/color-names/
MIT License
2.37k stars 177 forks source link

[issue] `namedColors.find` isn't a function? #177

Closed MordechaiHadad closed 8 months ago

MordechaiHadad commented 8 months ago

I am using this lib and trying to get a color's name with Array.find but my browser console shows that namedColors import doesn't have the find function, why?

Code Example: https://github.com/MordechaiHadad/tints-and-shades-generator/blob/master/src/routes/%2Bpage.svelte#L26

meodai commented 8 months ago

Have you console logged namedColors?

On Wed, 10 Jan 2024 at 10:20, MordechaiHadad @.***> wrote:

I am using this lib and trying to get a color's name with Array.find but my browser console shows that namedColors import doesn't have the find function, why?

Code Example:

https://github.com/MordechaiHadad/tints-and-shades-generator/blob/master/src/routes/%2Bpage.svelte#L26

— Reply to this email directly, view it on GitHub https://github.com/meodai/color-names/issues/177, or unsubscribe https://github.com/notifications/unsubscribe-auth/AAEURAVKL3NU4JSZYQURXVLYNZMNNAVCNFSM6AAAAABBUOEZ4CVHI2DSMVQWIX3LMV43ASLTON2WKOZSGA3TGOJTGMZTGMI . You are receiving this because you are subscribed to this thread.Message ID: @.***>

MordechaiHadad commented 8 months ago

I did the result was:

Object { colorNameList: (30241) […] }
​
colorNameList: Array(30241) [ {…}, {…}, {…}, … ]
​
<prototype>: Object { … }
meodai commented 8 months ago

Objects don't have a find method. You can a) import it property by using

import { colorNameList } from 'color-name-list';

or use

namedColors.colorNameList.find(...)
meodai commented 8 months ago

@MordechaiHadad by the way you can also use the rest API so you don't have to carry a huge file in your codebase:


https://api.color.pizza/v1/?values=ff0000,ff0000&list=bestOf&noduplicates=true

https://github.com/meodai/color-name-api

MordechaiHadad commented 8 months ago

Objects don't have a find method. You can a) import it property by using

import { colorNameList } from 'color-name-list';

or use

namedColors.colorNameList.find(...)

I suggest you update the readme then, not very clear regarding what needs to be imported. Specifically: https://github.com/meodai/color-names#exact-color

meodai commented 8 months ago

@MordechaiHadad https://github.com/meodai/color-names/commit/ca8f60ca1ae25eb5c286206cbe40229a81bbd0f3

github-actions[bot] commented 6 months ago

:tada: This issue has been resolved in version 10.20.0 :tada:

The release is available on:

Your semantic-release bot :package::rocket: