summaryrefslogtreecommitdiff
path: root/together/node_modules/hexoid/dist/index.mjs
blob: b5e3feaee4d162c48ca51ad7c781d51e4e3f0d31 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
var IDX=256, HEX=[];
while (IDX--) HEX[IDX] = (IDX + 256).toString(16).substring(1);

export default function (len) {
	len = len || 16;
	var str='', num=0;
	return function () {
		if (!str || num === 256) {
			str=''; num=(1+len)/2 | 0;
			while (num--) str += HEX[256 * Math.random() | 0];
			str = str.substring(num=0, len-2);
		}
		return str + HEX[num++];
	};
}