vimcord 1.0.48 → 1.0.49

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.cjs CHANGED
@@ -3072,7 +3072,6 @@ var MongoDatabase = class _MongoDatabase {
3072
3072
 
3073
3073
  // src/db/mongo/mongoSchema.builder.ts
3074
3074
  var import_mongoose2 = require("mongoose");
3075
- var import_node_crypto4 = require("crypto");
3076
3075
  var import_qznt6 = require("qznt");
3077
3076
  try {
3078
3077
  import("mongoose");
@@ -3179,16 +3178,15 @@ var MongoSchemaBuilder = class _MongoSchemaBuilder {
3179
3178
  return await this.db.useTransaction((session) => fn(session, model));
3180
3179
  });
3181
3180
  }
3182
- async createHexId(bytes, path2, maxRetries = 10) {
3181
+ async createUniqueId(collisionPath, fn, maxRetries = 10) {
3183
3182
  return this.execute(async (model) => {
3184
- const createHex = () => (0, import_node_crypto4.randomBytes)(bytes).toString("hex");
3185
- let id = createHex();
3183
+ let id;
3186
3184
  let tries = 0;
3187
- while (await model.exists({ [path2]: id })) {
3188
- if (tries >= maxRetries) throw Error(`Failed to generate a unique hex ID after ${tries} attempt(s)`);
3189
- id = createHex();
3185
+ do {
3186
+ if (tries >= maxRetries) throw new Error(`Failed to generate a unique ID after ${tries} attempt(s)`);
3187
+ id = fn();
3190
3188
  tries++;
3191
- }
3189
+ } while (await model.exists({ [collisionPath]: id }));
3192
3190
  return id;
3193
3191
  });
3194
3192
  }