Skip to content

Commit

Permalink
deps: bump dependencies
Browse files Browse the repository at this point in the history
  • Loading branch information
Niklas Kiefer committed Nov 28, 2023
1 parent e8d2a56 commit 7937693
Show file tree
Hide file tree
Showing 4 changed files with 506 additions and 496 deletions.
30 changes: 11 additions & 19 deletions dist/client.js
Original file line number Diff line number Diff line change
Expand Up @@ -3691,88 +3691,80 @@ hat.rack = function (bits, base, expandBy) {
*
* @param {Seed} seed
*/

function Ids(seed) {
if (!(this instanceof Ids)) {
return new Ids(seed);
}

seed = seed || [128, 36, 1];
this._seed = seed.length ? hat_1.rack(seed[0], seed[1], seed[2]) : seed;
}

/**
* Generate a next id.
*
* @param {Object} [element] element to bind the id to
*
* @return {String} id
*/

Ids.prototype.next = function (element) {
return this._seed(element || true);
};

/**
* Generate a next id with a given prefix.
*
* @param {Object} [element] element to bind the id to
*
* @return {String} id
*/


Ids.prototype.nextPrefixed = function (prefix, element) {
var id;

do {
id = prefix + this.next(true);
} while (this.assigned(id)); // claim {prefix}{random}

} while (this.assigned(id));

this.claim(id, element); // return
// claim {prefix}{random}
this.claim(id, element);

// return
return id;
};

/**
* Manually claim an existing id.
*
* @param {String} id
* @param {String} [element] element the id is claimed by
*/


Ids.prototype.claim = function (id, element) {
this._seed.set(id, element || true);
};

/**
* Returns true if the given id has already been assigned.
*
* @param {String} id
* @return {Boolean}
*/


Ids.prototype.assigned = function (id) {
return this._seed.get(id) || false;
};

/**
* Unclaim an id.
*
* @param {String} id the id to unclaim
*/


Ids.prototype.unclaim = function (id) {
delete this._seed.hats[id];
};

/**
* Clear all claimed ids.
*/


Ids.prototype.clear = function () {
var hats = this._seed.hats,
id;

id;
for (id in hats) {
this.unclaim(id);
}
Expand Down
2 changes: 1 addition & 1 deletion dist/client.js.map

Large diffs are not rendered by default.

Loading

0 comments on commit 7937693

Please sign in to comment.