oculus42 / short-uuid

Translate standard UUIDs into shorter formats and back.
MIT License
450 stars 13 forks source link

enlargeUUID() can be simplified #35

Closed jonagoldman closed 4 years ago

jonagoldman commented 4 years ago

https://github.com/oculus42/short-uuid/blob/6171268f2dfe30b1880f2b2d1ff1127f5eeaff5f/index.js#L30-L45

can be simplified to:

function enlargeUUID(shortId, translator) { 
    return translator(shortId).padStart(32, '0').replace(/^(.{8})(.{4})(.{4})(.{4})(.{12})/, '$1-$2-$3-$4-$5')
}

right?

nojacko commented 4 years ago

From README:

short-uuid has been tested to work on Node 0.10.x and later

According to https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/padStart, padStart was added in node 8.0.0 so would break for old versions.

jonagoldman commented 4 years ago

I think Node 8 is not longer maintained but I don't know, I use it in the browser.