How to use the @phenyl/utils.timeStampWithRandomString 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 / phenyl-memory-db-client.ts View on Github external
async insertAndGet>(
    command: SingleInsertCommand>
  ): Promise {
    const { entityName, value } = command;
    // @ts-ignore newValue must contain id
    const newValue: M[N] = value.id
      ? value
      : update(value, {
          id: timeStampWithRandomString()
        });
    const operation = PhenylStateUpdater.register(
      this.entityState,
      entityName,
      newValue
    );
    // @ts-ignore operation is nonbreaking
    this.entityState = update(this.entityState, operation);
    return newValue;
  }
  /**
github phenyl / phenyl / modules / central-state / src / versioning.ts View on Github external
>(command: T): T {
    const normalizedOperation = normalizeUpdateOperation(command.operation);
    const version = {
      id: timeStampWithRandomString(),
      op: JSON.stringify(command.operation)
    };
    const $push = Object.assign({}, normalizedOperation.$push, {
      "_PhenylMeta.versions": { $each: [version], $slice: -100 }
    });
    const newOperation = Object.assign({}, normalizedOperation, { $push });
    return Object.assign({}, command, { operation: newOperation });
  }
github phenyl / phenyl / modules / memory-db / src / phenyl-memory-db-client.ts View on Github external
const newValues: M[N][] = values.map(value =>
      value.id
        ? value
        : update(value, {
            id: timeStampWithRandomString()
          })
    );
github phenyl / phenyl / modules / central-state / src / session-client.ts View on Github external
async create(
    preSession: PreSession>
  ): Promise> {
    let value = preSession;
    if (value.id == null) {
      value = Object.assign({}, value, { id: timeStampWithRandomString() });
    }
    return this.set(value);
  }
github phenyl / phenyl / modules / central-state / src / versioning.ts View on Github external
public static attachMetaInfoToNewEntity(
    entity: E
  ): EntityWithMetaInfo {
    const versionId = timeStampWithRandomString();
    const _PhenylMeta = {
      versions: [{ id: versionId, op: "" }]
    };
    return Object.assign({}, entity, { _PhenylMeta });
  }