A typescript Guid class? -
does know of good, solid, implementation of c# guid in typescript?
could myself figured i'd spare time if else done before.
thanks!
there implementation in typescript utilities based on javascript guid generators.
here code:
class guid { static newguid() { homecoming 'xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx'.replace(/[xy]/g, function(c) { var r = math.random()*16|0, v = c == 'x' ? r : (r&0x3|0x8); homecoming v.tostring(16); }); } } // illustration of bunch of guids (var = 0; < 100; i++) { var id = guid.newguid(); console.log(id); }
please note following:
c# guids guaranteed unique. solution very likely unique. there huge gap between "very likely" , "guaranteed" , don't want fall through gap.
javascript-generated guids great utilize temporary key utilize while waiting server respond, wouldn't trust them primary key in database. if going rely on javascript-generated guid, tempted check register each time guid created ensure haven't got duplicate (an issue has come in chrome browser in cases).
typescript guid
No comments:
Post a Comment