1 | ;
|
2 |
|
3 | Object.defineProperty(exports, "__esModule", {
|
4 | value: true
|
5 | });
|
6 | exports.unique = unique;
|
7 | var BASE = 16;
|
8 | var INDEX = 0;
|
9 | /**
|
10 | * Generate an identifier from
|
11 | * - customizable prefix
|
12 | * - hexadecimal timestap
|
13 | * - local incrementor
|
14 | * that is
|
15 | * - cheap
|
16 | * - platform agnostic
|
17 | * - unique enough to prevent accidental collision
|
18 | *
|
19 | * @param {string} [prefix=zs]
|
20 | * @return {string}
|
21 | */
|
22 |
|
23 | function unique() {
|
24 | var prefix = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : 'zs';
|
25 | var hexadecimalTimestamp = new Date().getTime().toString(BASE);
|
26 | var index = INDEX++;
|
27 | return [prefix, hexadecimalTimestamp, index].join('-');
|
28 | } |
\ | No newline at end of file |