How to use the @tanker/types.assertDataTypeClass function in @tanker/types

To help you get started, we’ve selected a few @tanker/types 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 TankerHQ / sdk-js / packages / stream / base / src / MergerStream.js View on Github external
constructor(options: { type: Class, mime?: string, name?: string, lastModified?: number }) {
    // Note: can't use Infinity as it will be forwarded to the writableHighWaterMark option
    super(Number.MAX_SAFE_INTEGER);

    // $FlowIKnow Use of Object.prototype
    if (!options || typeof options !== 'object' || Object.getPrototypeOf(options) !== Object.prototype)
      throw new InvalidArgument('options', 'object', options);

    const { type, mime, name, lastModified } = options;

    assertDataTypeClass(type, 'options.type');

    if (mime && typeof mime !== 'string')
      throw new InvalidArgument('options.mime', 'string', mime);

    if (name && typeof name !== 'string')
      throw new InvalidArgument('options.name', 'string', name);

    if (lastModified && typeof lastModified !== 'number')
      throw new InvalidArgument('options.lastModified', 'number', lastModified);

    this._options = options;
  }

@tanker/types

Tanker SDK (types)

Apache-2.0
Latest version published 5 months ago

Package Health Score

65 / 100
Full package analysis

Similar packages