2 * Created by onvelocity on 1/28/16.
5 function getInstanceCount(type
, bump
= true) {
6 // keep a global counter
8 const data
= sessionStorage
.getItem('instance-counts');
9 const counts
= JSON
.parse(data
|| '{}');
10 if (counts
.hasOwnProperty(type
)) {
13 counts
[type
] = ++count
;
18 count
= counts
[type
] = 1;
20 sessionStorage
.setItem('instance-counts', JSON
.stringify(counts
));
27 * Get instance count for given type without bumping the number.
33 return getInstanceCount(type
, false);
37 * Get the instance count for the given type - will bump the counter and return the new value.
43 return getInstanceCount(type
);