<commit_before>/*-----------------------------------------------------------------------------
| Copyright (c) 2014-2015, PhosphorJS Contributors
|
| Distributed under the terms of the BSD 3-Clause License.
|
| The full license is in the file LICENSE, distributed with this software.
|----------------------------------------------------------------------------*/
'use strict';


/**
 * An object which implements the disposable pattern.
 */
export
interface IDisposable {
  /**
   * Test whether the object has been disposed.
   *
   * @returns `true` if the object has been disposed, `false` otherwise.
   *
   * #### Notes
   * This is a read-only property which is always safe to access.
   */
  isDisposed: boolean;

  /**
   * Dispose of the resources held by the object.
   *
   * #### Notes
   * It is generally unsafe to use the object after it has been
   * disposed.
   *
   * If the object's `dispose` method is called more than once, all
   * calls made after the first will be a no-op.
   */
  dispose(): void;
}


/**
 * A disposable object which delegates to a callback.
 */
export
class DisposableDelegate implements IDisposable {
  /**
   * Construct a new disposable delegate.
   *
   * @param callback - The function to invoke when the delegate is
   *   disposed.
   */
  constructor(callback: () => void) {
    this._callback = callback;
  }

  /**
   * Test whether the delegate has been disposed.
   *
   * @returns `true` if the delegate has been disposed, `false`
   *   otherwise.
   *
   * #### Notes
   * This is a read-only property which is always safe to access.
   */
  get isDisposed(): boolean {
    return !this._callback;
  }

  /**
   * Dispose of the delegate and invoke its callback.
   *
   * #### Notes
   * If this method is called more than once, all calls made after the
   * first will be a no-op.
   */
  dispose(): void {
    var callback = this._callback;
    this._callback = null;
    if (callback) callback();
  }

  private _callback: () => void;
}


/**
 * An object which manages a collection of disposable items.
 */
export
class DisposableSet implements IDisposable {
  /**
   * Construct a new disposable set.
   *
   * @param items - The initial disposable items for the set.
   */
  constructor(items?: IDisposable[]) {
    if (items) items.forEach(item => this._set.add(item));
  }

  /**
   * Test whether the set has been disposed.
   *
   * @returns `true` if the set has been disposed, `false` otherwise.
   *
   * #### Notes
   * This is a read-only property which is always safe to access.
   */
  get isDisposed(): boolean {
    return !this._set;
  }
<commit_msg>update docs<commit_after>/*-----------------------------------------------------------------------------
| Copyright (c) 2014-2015, PhosphorJS Contributors
|
| Distributed under the terms of the BSD 3-Clause License.
|
| The full license is in the file LICENSE, distributed with this software.
|----------------------------------------------------------------------------*/
'use strict';


/**
 * An object which implements the disposable pattern.
 */
export
interface IDisposable {
  /**
   * Test whether the object has been disposed.
   *
   * #### Notes
   * This is a read-only property which is always safe to access.
   */
  isDisposed: boolean;

  /**
   * Dispose of the resources held by the object.
   *
   * #### Notes
   * It is generally unsafe to use the object after it has been
   * disposed.
   *
   * If the object's `dispose` method is called more than once, all
   * calls made after the first will be a no-op.
   */
  dispose(): void;
}


/**
 * A disposable object which delegates to a callback.
 */
export
class DisposableDelegate implements IDisposable {
  /**
   * Construct a new disposable delegate.
   *
   * @param callback - The function to invoke when the delegate is
   *   disposed.
   */
  constructor(callback: () => void) {
    this._callback = callback;
  }

  /**
   * Test whether the delegate has been disposed.
   *
   * #### Notes
   * This is a read-only property which is always safe to access.
   */
  get isDisposed(): boolean {
    return !this._callback;
  }

  /**
   * Dispose of the delegate and invoke its callback.
   *
   * #### Notes
   * If this method is called more than once, all calls made after the
   * first will be a no-op.
   */
  dispose(): void {
    var callback = this._callback;
    this._callback = null;
    if (callback) callback();
  }

  private _callback: () => void;
}


/**
 * An object which manages a collection of disposable items.
 */
export
class DisposableSet implements IDisposable {
  /**
   * Construct a new disposable set.
   *
   * @param items - The initial disposable items for the set.
   */
  constructor(items?: IDisposable[]) {
    if (items) items.forEach(item => this._set.add(item));
  }

  /**
   * Test whether the set has been disposed.
   *
   * #### Notes
   * This is a read-only property which is always safe to access.
   */
  get isDisposed(): boolean {
    return !this._set;
  }

{'fraction_non_alphanumeric': 0.16288331342094783, 'fraction_numerical': 0.0035842293906810036, 'mean_word_length': 2.145272385723231, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 9, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '1297718', 'n_tokens_mistral': 1447, 'n_tokens_neox': 1378, 'n_words': 549}