MCPcopy
hub / github.com/angular-ui/ui-router / nextUid

Function nextUid

test/angular/1.2/angular.js:376–396  ·  view source on GitHub ↗

* A consistent way of creating unique IDs in angular. The ID is a sequence of alpha numeric * characters such as '012ABC'. The reason why we are not using simply a number counter is that * the number string gets longer over time, and it can also overflow, where as the nextId * will grow much slow

()

Source from the content-addressed store, hash-verified

374 * @returns {string} an unique alpha-numeric string
375 */
376function nextUid() {
377 var index = uid.length;
378 var digit;
379
380 while(index) {
381 index--;
382 digit = uid[index].charCodeAt(0);
383 if (digit == 57 /*'9'*/) {
384 uid[index] = 'A';
385 return uid.join('');
386 }
387 if (digit == 90 /*'Z'*/) {
388 uid[index] = '0';
389 } else {
390 uid[index] = String.fromCharCode(digit + 1);
391 return uid.join('');
392 }
393 }
394 uid.unshift('0');
395 return uid.join('');
396}
397
398
399/**

Callers 3

ScopeFunction · 0.70
$RootScopeProviderFunction · 0.70
radioInputTypeFunction · 0.70

Calls

no outgoing calls

Tested by

no test coverage detected