constructor()

in source/checksum/lib/shared/baseStateData.js [31:56]


  constructor(state, params = {}) {
    /* sanity check */
    const missing = REQUIRED_PARAMS.filter(x => params[x] === undefined);
    if (missing.length) {
      throw new InvalidArgumentError(`missing ${missing.join(', ')}`);
    }
    if (!state) {
      throw new InvalidArgumentError('missing state parameter');
    }

    this.$original = Object.assign({}, params);
    this.$bucket = params.Bucket;
    this.$key = params.Key;
    this.$etag = params.ETag || undefined;
    this.$fileSize = Number.parseInt(params.FileSize || 0, 10);
    this.$state = state;
    this.$status = params.Status;
    if (this.$state !== params.State) {
      this.$status = 'STARTED';
    } else if (params.Status === 'STARTED') {
      this.$status = 'IN_PROGRESS';
    }
    this.$lastElapsed = Number.parseInt(params.Elapsed || 0, 10);
    this.$t0 = new Date();
    this.$t1 = undefined;
  }