summaryrefslogtreecommitdiff
path: root/public/assets/javascripts/rectangles/util/uid.js
blob: 648bf0cf6ef22b2c8cc52dd38107e8b7a7ba69dd (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
(function(){

	var UidGenerator = function(list){
		var id = 0
		return function(s){
			s = s || ""
			var ss
			while (1) {
				ss = s + (id++)
				if (! (ss in list)) {
					return ss
				}
			}
		}
	}

	if ('window' in this) {
		window.UidGenerator = UidGenerator
	}
	else {
		module.exports = UidGenerator
	}
	
})()