react-native-uuid icon indicating copy to clipboard operation
react-native-uuid copied to clipboard

Why would you ever want a UUID in the form of a number array?

Open saltz opened this issue 4 years ago • 27 comments

In the latest release: version 2.0.0, the type signature of the return parameter in the v4 UUID function changed from string to string | number[]. Why? I'm curious what use case would require the UUID to be represented as a number array? As the change in the return signature is breaking for typescript projects that depend on the typed return signature. (which could be interpreted from the major release bump)

saltz avatar May 06 '21 12:05 saltz

Hey @saltz idea behind number[] was to make it backward compatible with the ArrayBuffer and a choice went to going with number[] as a simplified version of bytes array that was used in the original version of uuid.

I'm working on a new native implementation right now, so I'd love to know more about your use case.

I get the point about that string | number[] is confusing. I'll probably refactor those into two separate functions too.

eugenehp avatar May 06 '21 15:05 eugenehp

This signature totally breaks my usage of UUIDs. A lot of places expect UUIDs to be a string, a common one is <Component key={uuid} /> which is now broken.

danieljvdm avatar May 27 '21 14:05 danieljvdm

Thanks for reporting Daniel. I’ve new version in the works. Should be released this weekend.

On Thu, May 27, 2021 at 7:57 AM Daniel van der Merwe < @.***> wrote:

This signature totally breaks my usage of UUIDs. A lot of places expect UUIDs to be a string, a common one is <Component key={uuid} /> which is now broken.

— You are receiving this because you commented.

Reply to this email directly, view it on GitHub https://github.com/eugenehp/react-native-uuid/issues/16#issuecomment-849704803, or unsubscribe https://github.com/notifications/unsubscribe-auth/AAOFN3Y74VQUKVER4EEBZV3TPZMT7ANCNFSM44G6PAQA .

eugenehp avatar May 27 '21 16:05 eugenehp

This is going to be a part of 2.0.2

eugenehp avatar May 28 '21 00:05 eugenehp

Thanks!

danieljvdm avatar Jun 01 '21 22:06 danieljvdm

@eugenehp is there any update on when 2.0.2 will be released?

katiawheeler avatar Jun 11 '21 19:06 katiawheeler

Hey Katia,

I’ve got a refactored version ready, but need to run more tests this weekend and then push to the NPM.

On Fri, Jun 11, 2021 at 12:34 PM Katia Wheeler @.***> wrote:

@eugenehp https://github.com/eugenehp is there any update on when 2.0.2 will be released?

— You are receiving this because you were mentioned.

Reply to this email directly, view it on GitHub https://github.com/eugenehp/react-native-uuid/issues/16#issuecomment-859796957, or unsubscribe https://github.com/notifications/unsubscribe-auth/AAOFN3ZK7AYPLC2NHJNOX3LTSJQMVANCNFSM44G6PAQA .

eugenehp avatar Jun 11 '21 19:06 eugenehp

Ok, have a fresh version refactored! Going to do some more tests this week with a planned release for the weekend.

eugenehp avatar Jun 15 '21 04:06 eugenehp

@eugenehp any update on this or any way that I can help assist in testing?

katiawheeler avatar Jun 28 '21 19:06 katiawheeler

Thanks @katiawheeler I've a drafty new version ready, I'll circle back for your feedback in the next few days.

I've also found a new way to optimize and ensure cryptographic stability, but that will come later in a next major release 🚀

eugenehp avatar Jun 28 '21 22:06 eugenehp

alright, good news is that we've made some progress, bad news is that it's new branch, and not the current release. I plan to get a little bit more time next week to work on this, and will try to do a pre-release and could use some help to do the testing.

eugenehp avatar Jul 26 '21 22:07 eugenehp

@eugenehp happy to provide assistance where I can!

katiawheeler avatar Jul 27 '21 20:07 katiawheeler

I was curious to see what kind of benefit string | number[] would provide. It'd be nice to see this in the README Doc.

leochoo avatar Oct 03 '21 04:10 leochoo

Thanks Leonard. You are right. That was an effort to sort out the types and provide a better flexibility on how to consume it.

It sucked and it didn’t result in what most of the devs wanted.

So I’m working to get back the updated version with a single type return.

Would you be down to do the early tests and give some feedback?

On Sat, Oct 2, 2021 at 9:11 PM Leonard Choo @.***> wrote:

I was curious to see what kind of benefit string | number[] would provide. It'd be nice to see this in the README Doc.

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/eugenehp/react-native-uuid/issues/16#issuecomment-932859352, or unsubscribe https://github.com/notifications/unsubscribe-auth/AAOFN3Z2XUMVJQUKBEV7BVTUE7JVNANCNFSM44G6PAQA . Triage notifications on the go with GitHub Mobile for iOS https://apps.apple.com/app/apple-store/id1477376905?ct=notification-email&mt=8&pt=524675 or Android https://play.google.com/store/apps/details?id=com.github.android&referrer=utm_campaign%3Dnotification-email%26utm_medium%3Demail%26utm_source%3Dgithub.

eugenehp avatar Oct 04 '21 19:10 eugenehp

@eugenehp Sure! How could I help? I'm an entry level dev so I'm not super experienced but I'd be happy to help.

leochoo avatar Oct 05 '21 12:10 leochoo

@eugenehp Hi! Is there any progress on this? Is the current recommended usage to cast uuid.v4() to string?

martinmidtsund avatar Jan 11 '22 11:01 martinmidtsund

Hey Martin,

Thanks for bumping this up. There’s a draft version. Need to test it more this weekend.

Would you be available to run few tests on your side?

Eugene

On Tue, Jan 11, 2022 at 3:46 AM Martin Akre Midtsund < @.***> wrote:

@eugenehp https://github.com/eugenehp Hi! Is there any progress on this? Is the current recommended usage to cast uuid.v4() to string?

— Reply to this email directly, view it on GitHub https://github.com/eugenehp/react-native-uuid/issues/16#issuecomment-1009884931, or unsubscribe https://github.com/notifications/unsubscribe-auth/AAOFN3YG6UTQSWM7W3VPAHTUVQKCXANCNFSM44G6PAQA . Triage notifications on the go with GitHub Mobile for iOS https://apps.apple.com/app/apple-store/id1477376905?ct=notification-email&mt=8&pt=524675 or Android https://play.google.com/store/apps/details?id=com.github.android&referrer=utm_campaign%3Dnotification-email%26utm_medium%3Demail%26utm_source%3Dgithub.

You are receiving this because you were mentioned.Message ID: @.***>

eugenehp avatar Jan 11 '22 15:01 eugenehp

@eugenehp That sounds great! Of course, just ping me and I will assist with what I can.

martinmidtsund avatar Jan 11 '22 20:01 martinmidtsund

Hi @eugenehp ,

Thanks for this awesome library. Any updates with the draft version ?

Best regards

OnurVar avatar Mar 31 '22 19:03 OnurVar

Any update on this?

yasircodingcrafts avatar May 20 '22 19:05 yasircodingcrafts

If anyone is still stuck on this, I just switched to using uuid, @types/uuid, and react-native-get-random-values polyfill which works as expected.

robertn702 avatar Aug 11 '22 07:08 robertn702

@eugenehp

With a little function overloading, the return type can be inferred from the arguments.

let result1: string = uuid.v4()
let result2: number[] = uuid.v4(undefined, [1, 1], undefined)

I made a mock example at the typescript playground.

cdosborn avatar Nov 07 '22 20:11 cdosborn

Here's my workaround for manipulating uuid's string:

const uniqueId = uuid.v4()
const editedUuid = typeof uniqueId === 'string' ? uniqueId.replace(/-/g, '') : ''

If someone has a better idea, a flag or something, please tell me

fershibli avatar Jan 19 '24 16:01 fershibli

upping this case @eugenehp, I can see that there is 2 years of discussion on the subject 💀 Is it still in work or do some help are still required on this subject ?

Also a simple workaround could be to break it into two function, one for string and one for array number, as we want to avoid to have any params to provide

mvp-studio-repo avatar Mar 13 '24 18:03 mvp-studio-repo

Surprised and confused to stumble upon this problem and GitHub issue. A uuid is uncontroversially a string. This problem seems to have arisen from poor dev decisions, but it is shocking that it has been unresolved for so long.

@eugenehp Do you have any response as to if/when this will be fixed?

isaachinman avatar Apr 29 '24 15:04 isaachinman

@eugenehp any update on this?

dyarfaradj avatar May 01 '24 14:05 dyarfaradj

@eugenehp, any updates??

TheMiksa avatar Jun 14 '24 12:06 TheMiksa