Sha256: f92812ce75d568895711de408fccf80547b1c0525c473d514f7ed7d01a347ed5

Contents?: true

Size: 820 Bytes

Versions: 49

Compression:

Stored size: 820 Bytes

Contents

import { root } from './root';

export interface ISetCtor {
  new<T>(): ISet<T>;
}

export interface ISet<T> {
  add(value: T): void;
  has(value: T): boolean;
  size: number;
  clear(): void;
}

export function minimalSetImpl<T>(): ISetCtor {
  // THIS IS NOT a full impl of Set, this is just the minimum
  // bits of functionality we need for this library.
  return class MinimalSet<T> implements ISet<T> {
    private _values: T[] = [];

    add(value: T): void {
      if (!this.has(value)) {
        this._values.push(value);
      }
    }

    has(value: T): boolean {
      return this._values.indexOf(value) !== -1;
    }

    get size(): number {
      return this._values.length;
    }

    clear(): void {
      this._values.length = 0;
    }
  };
}

export const Set: ISetCtor = root.Set || minimalSetImpl();

Version data entries

49 entries across 49 versions & 4 rubygems

Version Path
govuk_publishing_components-17.8.0 node_modules/rxjs/src/util/Set.ts
govuk_publishing_components-17.7.0 node_modules/rxjs/src/util/Set.ts
govuk_publishing_components-17.6.1 node_modules/rxjs/src/util/Set.ts
govuk_publishing_components-17.6.0 node_modules/rxjs/src/util/Set.ts
govuk_publishing_components-17.5.0 node_modules/rxjs/src/util/Set.ts
govuk_publishing_components-17.4.0 node_modules/rxjs/src/util/Set.ts
govuk_publishing_components-17.3.0 node_modules/rxjs/src/util/Set.ts
govuk_publishing_components-17.2.0 node_modules/rxjs/src/util/Set.ts
govuk_publishing_components-17.1.1 node_modules/rxjs/src/util/Set.ts
govuk_publishing_components-17.1.0 node_modules/rxjs/src/util/Set.ts
govuk_publishing_components-17.0.0 node_modules/rxjs/src/util/Set.ts
govuk_publishing_components-16.29.0 node_modules/rxjs/src/util/Set.ts
govuk_publishing_components-16.28.0 node_modules/rxjs/src/util/Set.ts
govuk_publishing_components-16.27.1 node_modules/rxjs/src/util/Set.ts
govuk_publishing_components-16.27.0 node_modules/rxjs/src/util/Set.ts
govuk_publishing_components-16.26.0 node_modules/rxjs/src/util/Set.ts
govuk_publishing_components-16.25.0 node_modules/rxjs/src/util/Set.ts
govuk_publishing_components-16.24.0 node_modules/rxjs/src/util/Set.ts
govuk_publishing_components-16.23.0 node_modules/rxjs/src/util/Set.ts
govuk_publishing_components-16.22.0 node_modules/rxjs/src/util/Set.ts