How to use the @phenyl/utils.randomString function in @phenyl/utils

To help you get started, we’ve selected a few @phenyl/utils examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github phenyl / phenyl / modules / memory-db / src / kvs-client.ts View on Github external
async create(value: PreEntity): Promise {
    if (value.id != null) {
      if (this.pool[value.id] != null) {
        throw new Error(
          `The given id "${value.id}" already exists in memory pool.`
        );
      }
      // @ts-ignore value.id exists
      return this.set(value);
    }

    const newValue = updateAndRestore(value, { id: randomString() });
    // @ts-ignore value.id exists
    return this.set(newValue);
  }