<commit_before>// Copyright (c) 2016, the Dart project authors.  Please see the AUTHORS file
// for details. All rights reserved. Use of this source code is governed by a
// BSD-style license that can be found in the LICENSE file.

import 'dart:async';

const String _oneShotDisposerMemoryLeakWarning =
    'Possible memory leak detected: A disposable should not be added to '
    'one shot disposers after the dispose() method has been called.';

/// A function, that when called, will cleanup any resources or subscriptions.
typedef void DisposeFunction();

/// A class with a [dispose] method for cleaning up resources or subscriptions.
abstract class Disposable {
  /// A disposable that does nothing.
  static const Disposable Noop = const _NoopDisposable();

  /// Creates a simple disposable that just executes [disposeFn].
  factory Disposable(DisposeFunction disposeFn) = _SingleFunctionDisposable;

  /// Disposes this disposable and any resources it has open.
  void dispose();
}

/// A no-op implementation of [Disposable].
class _NoopDisposable implements Disposable {
  const _NoopDisposable();

  @override
  void dispose() {}
}

/// A simple implementation of [Disposable].
class _SingleFunctionDisposable implements Disposable {
  final DisposeFunction _disposeFn;

  _SingleFunctionDisposable(this._disposeFn);

  @override
  void dispose() {
    _disposeFn();
  }
}

/// Tracks disposables that are added to it for later disposal.
///
/// Example usage:
///     final disposer = new Disposer()
///       ..addDisposable(() => print('Clean up');)
///       ..addDisposable(stream.listen())
///       ..addDiposable(myCustomDisposable);
///
///     disposer.dispose();
///
/// Example usage of 'oneShot' mode.  Please use this for cases where there
/// is a single call to dispose as it will help detect potential memory leaks
/// where a disposable is being added after the disposer has been disposed.
/// This is very typical for Angular components where disposer.dispose() is
/// called in ngOnDestroy.
///
///     final disposer = new Disposer.oneShot()
///       ..addDisposable(() => print('Clean up');)
///       ..addDisposable(stream.listen());
///
///     disposer.dispose();
///     // The following call will assert.
///     disposer.addDiposable(myCustomDisposable);
///
/// Prefer typed functions whenever possible:
///   [addEventSink]
///   [addFunction]
///   [addStreamSubscription]
///
/// Note that you should not rely on the disposal sequence for each added
/// [disposable], just treat it random.
class Disposer implements Disposable {<commit_msg>Fix typo in documenting comment<commit_after>// Copyright (c) 2016, the Dart project authors.  Please see the AUTHORS file
// for details. All rights reserved. Use of this source code is governed by a
// BSD-style license that can be found in the LICENSE file.

import 'dart:async';

const String _oneShotDisposerMemoryLeakWarning =
    'Possible memory leak detected: A disposable should not be added to '
    'one shot disposers after the dispose() method has been called.';

/// A function, that when called, will cleanup any resources or subscriptions.
typedef void DisposeFunction();

/// A class with a [dispose] method for cleaning up resources or subscriptions.
abstract class Disposable {
  /// A disposable that does nothing.
  static const Disposable Noop = const _NoopDisposable();

  /// Creates a simple disposable that just executes [disposeFn].
  factory Disposable(DisposeFunction disposeFn) = _SingleFunctionDisposable;

  /// Disposes this disposable and any resources it has open.
  void dispose();
}

/// A no-op implementation of [Disposable].
class _NoopDisposable implements Disposable {
  const _NoopDisposable();

  @override
  void dispose() {}
}

/// A simple implementation of [Disposable].
class _SingleFunctionDisposable implements Disposable {
  final DisposeFunction _disposeFn;

  _SingleFunctionDisposable(this._disposeFn);

  @override
  void dispose() {
    _disposeFn();
  }
}

/// Tracks disposables that are added to it for later disposal.
///
/// Example usage:
///     final disposer = new Disposer()
///       ..addDisposable(() => print('Clean up');)
///       ..addDisposable(stream.listen())
///       ..addDisposable(myCustomDisposable);
///
///     disposer.dispose();
///
/// Example usage of 'oneShot' mode.  Please use this for cases where there
/// is a single call to dispose as it will help detect potential memory leaks
/// where a disposable is being added after the disposer has been disposed.
/// This is very typical for Angular components where disposer.dispose() is
/// called in ngOnDestroy.
///
///     final disposer = new Disposer.oneShot()
///       ..addDisposable(() => print('Clean up');)
///       ..addDisposable(stream.listen());
///
///     disposer.dispose();
///     // The following call will assert.
///     disposer.addDisposable(myCustomDisposable);
///
/// Prefer typed functions whenever possible:
///   [addEventSink]
///   [addFunction]
///   [addStreamSubscription]
///
/// Note that you should not rely on the disposal sequence for each added
/// [disposable], just treat it random.
class Disposer implements Disposable {
{'fraction_non_alphanumeric': 0.11325115562403698, 'fraction_numerical': 0.0015408320493066256, 'mean_word_length': 3.2600492206726823, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 7, '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': '1664065', 'n_tokens_mistral': 1469, 'n_tokens_neox': 1367, 'n_words': 554}