aboutsummaryrefslogtreecommitdiff
path: root/src/modules/unique
diff options
context:
space:
mode:
authorShinigami <[email protected]>2022-10-15 03:29:21 +0800
committerGitHub <[email protected]>2022-10-14 21:29:21 +0200
commit9c1437d6034ef5537c079746761c4c71347f768b (patch)
tree0a20ebb6b8e2501f15208600b58e5bfc587bbff3 /src/modules/unique
parent1ab33c5caf323d25bd21b3b3afaf8af3686207b4 (diff)
downloadfaker-9c1437d6034ef5537c079746761c4c71347f768b.tar.xz
faker-9c1437d6034ef5537c079746761c4c71347f768b.zip
refactor!: cleanup deprecations (#1440)
Diffstat (limited to 'src/modules/unique')
-rw-r--r--src/modules/unique/index.ts72
1 files changed, 0 insertions, 72 deletions
diff --git a/src/modules/unique/index.ts b/src/modules/unique/index.ts
deleted file mode 100644
index fd817ec4..00000000
--- a/src/modules/unique/index.ts
+++ /dev/null
@@ -1,72 +0,0 @@
-import type { Faker } from '../..';
-import { deprecated } from '../../internal/deprecated';
-import type { RecordKey } from '../helpers/unique';
-
-/**
- * Module to generate unique entries.
- *
- * @deprecated
- */
-export class UniqueModule {
- constructor(private readonly faker: Faker) {
- // Bind `this` so namespaced is working correctly
- for (const name of Object.getOwnPropertyNames(UniqueModule.prototype)) {
- if (
- name === 'constructor' ||
- name === 'maxTime' ||
- name === 'maxRetries' ||
- typeof this[name] !== 'function'
- ) {
- continue;
- }
- this[name] = this[name].bind(this);
- }
- }
-
- /**
- * Generates a unique result using the results of the given method.
- * Used unique entries will be stored internally and filtered from subsequent calls.
- *
- * @template Method The type of the method to execute.
- * @param method The method used to generate the values.
- * @param args The arguments used to call the method.
- * @param options The optional options used to configure this method.
- * @param options.startTime This parameter does nothing.
- * @param options.maxTime The time in milliseconds this method may take before throwing an error. Defaults to `50`.
- * @param options.maxRetries The total number of attempts to try before throwing an error. Defaults to `50`.
- * @param options.currentIterations This parameter does nothing.
- * @param options.exclude The value or values that should be excluded/skipped. Defaults to `[]`.
- * @param options.compare The function used to determine whether a value was already returned. Defaults to check the existence of the key.
- * @param options.store The store of unique entries. Defaults to a global store.
- *
- * @see faker.helpers.unique()
- *
- * @example
- * faker.unique(faker.name.firstName) // 'Corbin'
- *
- * @since 5.0.0
- *
- * @deprecated Use faker.helpers.unique() instead.
- */
- unique<Method extends (...parameters) => RecordKey>(
- method: Method,
- args?: Parameters<Method>,
- options: {
- startTime?: number;
- maxTime?: number;
- maxRetries?: number;
- currentIterations?: number;
- exclude?: RecordKey | RecordKey[];
- compare?: (obj: Record<RecordKey, RecordKey>, key: RecordKey) => 0 | -1;
- store?: Record<RecordKey, RecordKey>;
- } = {}
- ): ReturnType<Method> {
- deprecated({
- deprecated: 'faker.unique()',
- proposed: 'faker.helpers.unique()',
- since: '7.5',
- until: '8.0',
- });
- return this.faker.helpers.unique(method, args, options);
- }
-}