aboutsummaryrefslogtreecommitdiff
path: root/src/modules
diff options
context:
space:
mode:
authorShinigami <[email protected]>2024-02-29 11:10:02 +0100
committerGitHub <[email protected]>2024-02-29 11:10:02 +0100
commite99fba9729729e8a3107a659f5e00b9f18047298 (patch)
treeae00c52ff8c1780905e7dc28a6b0724bd6343958 /src/modules
parent5125d6c3e21f4fb947aab0d71e8c3d8b889ecbdb (diff)
downloadfaker-e99fba9729729e8a3107a659f5e00b9f18047298.tar.xz
faker-e99fba9729729e8a3107a659f5e00b9f18047298.zip
refactor(random)!: remove v8 deprecated image methods (#2697)
Diffstat (limited to 'src/modules')
-rw-r--r--src/modules/image/index.ts501
1 files changed, 0 insertions, 501 deletions
diff --git a/src/modules/image/index.ts b/src/modules/image/index.ts
index 46bc06e4..d396d5fa 100644
--- a/src/modules/image/index.ts
+++ b/src/modules/image/index.ts
@@ -1,6 +1,4 @@
-import { deprecated } from '../../internal/deprecated';
import { ModuleBase } from '../../internal/module-base';
-import type { MethodsOf } from '../../utils/types';
/**
* Module to generate images.
@@ -389,503 +387,4 @@ export class ImageModule extends ModuleBase {
'base64'
)}`;
}
-
- /**
- * Generates a random image url from one of the supported categories.
- *
- * @param width The width of the image. Defaults to `640`.
- * @param height The height of the image. Defaults to `480`.
- * @param randomize Whether to randomize the image or not. Defaults to `false`.
- *
- * @example
- * faker.image.image() // 'https://loremflickr.com/640/480/city'
- * faker.image.image(1234, 2345) // 'https://loremflickr.com/1234/2345/sports'
- * faker.image.image(1234, 2345, true) // 'https://loremflickr.com/1234/2345/nature?lock=56789'
- *
- * @since 2.0.1
- *
- * @deprecated Use `faker.image.url` instead.
- */
- image(width?: number, height?: number, randomize?: boolean): string {
- deprecated({
- deprecated: 'faker.image.image',
- proposed: 'faker.image.url',
- since: '8.0',
- until: '9.0',
- });
- const categories: MethodsOf<ImageModule, ImageModule['image']> = [
- 'abstract',
- 'animals',
- 'business',
- 'cats',
- 'city',
- 'food',
- 'nightlife',
- 'fashion',
- 'people',
- 'nature',
- 'sports',
- 'technics',
- 'transport',
- ];
- return this[this.faker.helpers.arrayElement(categories)](
- width,
- height,
- randomize
- );
- }
-
- /**
- * Generates a random image url.
- *
- * @param width The width of the image. Defaults to `640`.
- * @param height The height of the image. Defaults to `480`.
- * @param category The category of the image. By default, a random one will be selected.
- * @param randomize Whether to randomize the image or not. Defaults to `false`.
- *
- * @example
- * faker.image.imageUrl() // 'https://loremflickr.com/640/480'
- * faker.image.imageUrl(1234, 2345) // 'https://loremflickr.com/1234/2345'
- * faker.image.imageUrl(1234, 2345, 'cat') // 'https://loremflickr.com/1234/2345/cat'
- * faker.image.imageUrl(1234, 2345, 'cat', true) // 'https://loremflickr.com/1234/2345/cat?lock=6849'
- *
- * @since 2.0.1
- *
- * @deprecated Use `faker.image.url` instead.
- */
- imageUrl(
- width?: number,
- height?: number,
- category?: string,
- randomize?: boolean
- ): string {
- deprecated({
- deprecated: 'faker.image.imageUrl',
- proposed: 'faker.image.url',
- since: '8.0',
- until: '9.0',
- });
-
- width = width || 640;
- height = height || 480;
- let url = `https://loremflickr.com/${width}/${height}`;
- if (category != null) {
- url += `/${category}`;
- }
-
- if (randomize) {
- url += `?lock=${this.faker.number.int()}`;
- }
-
- return url;
- }
-
- /**
- * Generates a random abstract image url.
- *
- * @param width The width of the image. Defaults to `640`.
- * @param height The height of the image. Defaults to `480`.
- * @param randomize Whether to randomize the image or not. Defaults to `false`.
- *
- * @see faker.image.url(): For generating a random image url (has fewer options, uses multiple image providers).
- * @see faker.image.urlLoremFlickr(): For generating a random image url from LoremFlickr.
- *
- * @example
- * faker.image.abstract() // 'https://loremflickr.com/640/480/abstract'
- * faker.image.abstract(1234, 2345) // 'https://loremflickr.com/1234/2345/abstract'
- * faker.image.abstract(1234, 2345, true) // 'https://loremflickr.com/1234/2345/abstract?lock=56789'
- *
- * @since 2.0.1
- *
- * @deprecated Use `faker.image.urlLoremFlickr({ category: 'abstract' })` if you want an image from LoremFlickr in the correct category, or `faker.image.url()` if you just want any image.
- *
- */
- abstract(width?: number, height?: number, randomize?: boolean): string {
- deprecated({
- deprecated: 'faker.image.abstract',
- proposed:
- "faker.image.urlLoremFlickr({ category: 'abstract' }) or faker.image.url",
- since: '8.0',
- until: '9.0',
- });
- // eslint-disable-next-line deprecation/deprecation
- return this.imageUrl(width, height, 'abstract', randomize);
- }
-
- /**
- * Generates a random animal image url.
- *
- * @param width The width of the image. Defaults to `640`.
- * @param height The height of the image. Defaults to `480`.
- * @param randomize Whether to randomize the image or not. Defaults to `false`.
- *
- * @see faker.image.url(): For generating a random image url (has fewer options, uses multiple image providers).
- * @see faker.image.urlLoremFlickr(): For generating a random image url from LoremFlickr.
- *
- * @example
- * faker.image.animals() // 'https://loremflickr.com/640/480/animals'
- * faker.image.animals(1234, 2345) // 'https://loremflickr.com/1234/2345/animals'
- * faker.image.animals(1234, 2345, true) // 'https://loremflickr.com/1234/2345/animals?lock=56789'
- *
- * @since 2.0.1
- *
- * @deprecated Use `faker.image.urlLoremFlickr({ category: 'animals' })` if you want an image from LoremFlickr in the correct category, or `faker.image.url()` if you just want any image.
- *
- */
- animals(width?: number, height?: number, randomize?: boolean): string {
- deprecated({
- deprecated: 'faker.image.animals',
- proposed:
- "faker.image.urlLoremFlickr({ category: 'animals' }) or faker.image.url",
- since: '8.0',
- until: '9.0',
- });
- // eslint-disable-next-line deprecation/deprecation
- return this.imageUrl(width, height, 'animals', randomize);
- }
-
- /**
- * Generates a random business image url.
- *
- * @param width The width of the image. Defaults to `640`.
- * @param height The height of the image. Defaults to `480`.
- * @param randomize Whether to randomize the image or not. Defaults to `false`.
- *
- * @see faker.image.url(): For generating a random image url (has fewer options, uses multiple image providers).
- * @see faker.image.urlLoremFlickr(): For generating a random image url from LoremFlickr.
- *
- * @example
- * faker.image.business() // 'https://loremflickr.com/640/480/business'
- * faker.image.business(1234, 2345) // 'https://loremflickr.com/1234/2345/business'
- * faker.image.business(1234, 2345, true) // 'https://loremflickr.com/1234/2345/business?lock=56789'
- *
- * @since 2.0.1
- *
- * @deprecated Use `faker.image.urlLoremFlickr({ category: 'business' })` if you want an image from LoremFlickr in the correct category, or `faker.image.url()` if you just want any image.
- *
- *
- */
- business(width?: number, height?: number, randomize?: boolean): string {
- deprecated({
- deprecated: 'faker.image.business',
- proposed:
- "faker.image.urlLoremFlickr({ category: 'business' }) or faker.image.url",
- since: '8.0',
- until: '9.0',
- });
- // eslint-disable-next-line deprecation/deprecation
- return this.imageUrl(width, height, 'business', randomize);
- }
-
- /**
- * Generates a random cat image url.
- *
- * @param width The width of the image. Defaults to `640`.
- * @param height The height of the image. Defaults to `480`.
- * @param randomize Whether to randomize the image or not. Defaults to `false`.
- *
- * @see faker.image.url(): For generating a random image url (has fewer options, uses multiple image providers).
- * @see faker.image.urlLoremFlickr(): For generating a random image url from LoremFlickr.
- *
- * @example
- * faker.image.cats() // 'https://loremflickr.com/640/480/cats'
- * faker.image.cats(1234, 2345) // 'https://loremflickr.com/1234/2345/cats'
- * faker.image.cats(1234, 2345, true) // 'https://loremflickr.com/1234/2345/cats?lock=56789'
- *
- * @since 2.0.1
- *
- * @deprecated Use `faker.image.urlLoremFlickr({ category: 'cats' })` if you want an image from LoremFlickr in the correct category, or `faker.image.url()` if you just want any image.
- */
- cats(width?: number, height?: number, randomize?: boolean): string {
- deprecated({
- deprecated: 'faker.image.cats',
- proposed:
- "faker.image.urlLoremFlickr({ category: 'cats' }) or faker.image.url",
- since: '8.0',
- until: '9.0',
- });
- // eslint-disable-next-line deprecation/deprecation
- return this.imageUrl(width, height, 'cats', randomize);
- }
-
- /**
- * Generates a random city image url.
- *
- * @param width The width of the image. Defaults to `640`.
- * @param height The height of the image. Defaults to `480`.
- * @param randomize Whether to randomize the image or not. Defaults to `false`.
- *
- * @see faker.image.url(): For generating a random image url (has fewer options, uses multiple image providers).
- * @see faker.image.urlLoremFlickr(): For generating a random image url from LoremFlickr.
- *
- * @example
- * faker.image.city() // 'https://loremflickr.com/640/480/city'
- * faker.image.city(1234, 2345) // 'https://loremflickr.com/1234/2345/city'
- * faker.image.city(1234, 2345, true) // 'https://loremflickr.com/1234/2345/city?lock=56789'
- *
- * @since 2.0.1
- *
- * @deprecated Use `faker.image.urlLoremFlickr({ category: 'city' })` if you want an image from LoremFlickr in the correct category, or `faker.image.url()` if you just want any image.
- */
- city(width?: number, height?: number, randomize?: boolean): string {
- deprecated({
- deprecated: 'faker.image.city',
- proposed:
- "faker.image.urlLoremFlickr({ category: 'city' }) or faker.image.url",
- since: '8.0',
- until: '9.0',
- });
- // eslint-disable-next-line deprecation/deprecation
- return this.imageUrl(width, height, 'city', randomize);
- }
-
- /**
- * Generates a random food image url.
- *
- * @param width The width of the image. Defaults to `640`.
- * @param height The height of the image. Defaults to `480`.
- * @param randomize Whether to randomize the image or not. Defaults to `false`.
- *
- * @see faker.image.url(): For generating a random image url (has fewer options, uses multiple image providers).
- * @see faker.image.urlLoremFlickr(): For generating a random image url from LoremFlickr.
- *
- * @example
- * faker.image.food() // 'https://loremflickr.com/640/480/food'
- * faker.image.food(1234, 2345) // 'https://loremflickr.com/1234/2345/food'
- * faker.image.food(1234, 2345, true) // 'https://loremflickr.com/1234/2345/food?lock=56789'
- *
- * @since 2.0.1
- *
- * @deprecated Use `faker.image.urlLoremFlickr({ category: 'food' })` if you want an image from LoremFlickr in the correct category, or `faker.image.url()` if you just want any image.
- */
- food(width?: number, height?: number, randomize?: boolean): string {
- deprecated({
- deprecated: 'faker.image.food',
- proposed:
- "faker.image.urlLoremFlickr({ category: 'food' }) or faker.image.url",
- since: '8.0',
- until: '9.0',
- });
- // eslint-disable-next-line deprecation/deprecation
- return this.imageUrl(width, height, 'food', randomize);
- }
-
- /**
- * Generates a random nightlife image url.
- *
- * @param width The width of the image. Defaults to `640`.
- * @param height The height of the image. Defaults to `480`.
- * @param randomize Whether to randomize the image or not. Defaults to `false`.
- *
- * @see faker.image.url(): For generating a random image url (has fewer options, uses multiple image providers).
- * @see faker.image.urlLoremFlickr(): For generating a random image url from LoremFlickr.
- *
- * @example
- * faker.image.nightlife() // 'https://loremflickr.com/640/480/nightlife'
- * faker.image.nightlife(1234, 2345) // 'https://loremflickr.com/1234/2345/nightlife'
- * faker.image.nightlife(1234, 2345, true) // 'https://loremflickr.com/1234/2345/nightlife?lock=56789'
- *
- * @since 2.0.1
- *
- * @deprecated Use `faker.image.urlLoremFlickr({ category: 'nightlife' })` if you want an image from LoremFlickr in the correct category, or `faker.image.url()` if you just want any image.
- */
- nightlife(width?: number, height?: number, randomize?: boolean): string {
- deprecated({
- deprecated: 'faker.image.nightlife',
- proposed:
- "faker.image.urlLoremFlickr({ category: 'nightlife' }) or faker.image.url",
- since: '8.0',
- until: '9.0',
- });
- // eslint-disable-next-line deprecation/deprecation
- return this.imageUrl(width, height, 'nightlife', randomize);
- }
-
- /**
- * Generates a random fashion image url.
- *
- * @param width The width of the image. Defaults to `640`.
- * @param height The height of the image. Defaults to `480`.
- * @param randomize Whether to randomize the image or not. Defaults to `false`.
- *
- * @see faker.image.url(): For generating a random image url (has fewer options, uses multiple image providers).
- * @see faker.image.urlLoremFlickr(): For generating a random image url from LoremFlickr.
- *
- * @example
- * faker.image.fashion() // 'https://loremflickr.com/640/480/fashion'
- * faker.image.fashion(1234, 2345) // 'https://loremflickr.com/1234/2345/fashion'
- * faker.image.fashion(1234, 2345, true) // 'https://loremflickr.com/1234/2345/fashion?lock=56789'
- *
- * @since 2.0.1
- *
- * @deprecated Use `faker.image.urlLoremFlickr({ category: 'fashion' })` if you want an image from LoremFlickr in the correct category, or `faker.image.url()` if you just want any image.
- */
- fashion(width?: number, height?: number, randomize?: boolean): string {
- deprecated({
- deprecated: 'faker.image.fashion',
- proposed:
- "faker.image.urlLoremFlickr({ category: 'fashion' }) or faker.image.url",
- since: '8.0',
- until: '9.0',
- });
- // eslint-disable-next-line deprecation/deprecation
- return this.imageUrl(width, height, 'fashion', randomize);
- }
-
- /**
- * Generates a random people image url.
- *
- * @param width The width of the image. Defaults to `640`.
- * @param height The height of the image. Defaults to `480`.
- * @param randomize Whether to randomize the image or not. Defaults to `false`.
- *
- * @see faker.image.url(): For generating a random image url (has fewer options, uses multiple image providers).
- * @see faker.image.urlLoremFlickr(): For generating a random image url from LoremFlickr.
- *
- * @example
- * faker.image.people() // 'https://loremflickr.com/640/480/people'
- * faker.image.people(1234, 2345) // 'https://loremflickr.com/1234/2345/people'
- * faker.image.people(1234, 2345, true) // 'https://loremflickr.com/1234/2345/people?lock=56789'
- *
- * @since 2.0.1
- *
- * @deprecated Use `faker.image.urlLoremFlickr({ category: 'people' })` if you want an image from LoremFlickr in the correct category, or `faker.image.url()` if you just want any image.
- */
- people(width?: number, height?: number, randomize?: boolean): string {
- deprecated({
- deprecated: 'faker.image.people',
- proposed:
- "faker.image.urlLoremFlickr({ category: 'people' }) or faker.image.url",
- since: '8.0',
- until: '9.0',
- });
- // eslint-disable-next-line deprecation/deprecation
- return this.imageUrl(width, height, 'people', randomize);
- }
-
- /**
- * Generates a random nature image url.
- *
- * @param width The width of the image. Defaults to `640`.
- * @param height The height of the image. Defaults to `480`.
- * @param randomize Whether to randomize the image or not. Defaults to `false`.
- *
- * @see faker.image.url(): For generating a random image url (has fewer options, uses multiple image providers).
- * @see faker.image.urlLoremFlickr(): For generating a random image url from LoremFlickr.
- *
- * @example
- * faker.image.nature() // 'https://loremflickr.com/640/480/nature'
- * faker.image.nature(1234, 2345) // 'https://loremflickr.com/1234/2345/nature'
- * faker.image.nature(1234, 2345, true) // 'https://loremflickr.com/1234/2345/nature?lock=56789'
- *
- * @since 2.0.1
- *
- * @deprecated Use `faker.image.urlLoremFlickr({ category: 'nature' })` if you want an image from LoremFlickr in the correct category, or `faker.image.url()` if you just want any image.
- */
- nature(width?: number, height?: number, randomize?: boolean): string {
- deprecated({
- deprecated: 'faker.image.nature',
- proposed:
- "faker.image.urlLoremFlickr({ category: 'nature' }) or faker.image.url",
- since: '8.0',
- until: '9.0',
- });
- // eslint-disable-next-line deprecation/deprecation
- return this.imageUrl(width, height, 'nature', randomize);
- }
-
- /**
- * Generates a random sports image url.
- *
- * @param width The width of the image. Defaults to `640`.
- * @param height The height of the image. Defaults to `480`.
- * @param randomize Whether to randomize the image or not. Defaults to `false`.
- *
- * @see faker.image.url(): For generating a random image url (has fewer options, uses multiple image providers).
- * @see faker.image.urlLoremFlickr(): For generating a random image url from LoremFlickr.
- *
- * @example
- * faker.image.sports() // 'https://loremflickr.com/640/480/sports'
- * faker.image.sports(1234, 2345) // 'https://loremflickr.com/1234/2345/sports'
- * faker.image.sports(1234, 2345, true) // 'https://loremflickr.com/1234/2345/sports?lock=56789'
- *
- * @since 2.0.1
- *
- * @deprecated Use `faker.image.urlLoremFlickr({ category: 'sports' })` if you want an image from LoremFlickr in the correct category, or `faker.image.url()` if you just want any image.
- */
- sports(width?: number, height?: number, randomize?: boolean): string {
- deprecated({
- deprecated: 'faker.image.sports',
- proposed:
- "faker.image.urlLoremFlickr({ category: 'sports' }) or faker.image.url",
- since: '8.0',
- until: '9.0',
- });
- // eslint-disable-next-line deprecation/deprecation
- return this.imageUrl(width, height, 'sports', randomize);
- }
-
- /**
- * Generates a random technics image url.
- *
- * @param width The width of the image. Defaults to `640`.
- * @param height The height of the image. Defaults to `480`.
- * @param randomize Whether to randomize the image or not. Defaults to `false`.
- *
- * @see faker.image.url(): For generating a random image url (has fewer options, uses multiple image providers).
- * @see faker.image.urlLoremFlickr(): For generating a random image url from LoremFlickr.
- *
- * @example
- * faker.image.technics() // 'https://loremflickr.com/640/480/technics'
- * faker.image.technics(1234, 2345) // 'https://loremflickr.com/1234/2345/technics'
- * faker.image.technics(1234, 2345, true) // 'https://loremflickr.com/1234/2345/technics?lock=56789'
- *
- * @since 2.0.1
- *
- * @deprecated Use `faker.image.urlLoremFlickr({ category: 'technics' })` if you want an image from LoremFlickr in the correct category, or `faker.image.url()` if you just want any image.
- */
- technics(width?: number, height?: number, randomize?: boolean): string {
- deprecated({
- deprecated: 'faker.image.technics',
- proposed:
- "faker.image.urlLoremFlickr({ category: 'technics' }) or faker.image.url",
- since: '8.0',
- until: '9.0',
- });
- // eslint-disable-next-line deprecation/deprecation
- return this.imageUrl(width, height, 'technics', randomize);
- }
-
- /**
- * Generates a random transport image url.
- *
- * @param width The width of the image. Defaults to `640`.
- * @param height The height of the image. Defaults to `480`.
- * @param randomize Whether to randomize the image or not. Defaults to `false`.
- *
- * @see faker.image.url(): For generating a random image url (has fewer options, uses multiple image providers).
- * @see faker.image.urlLoremFlickr(): For generating a random image url from LoremFlickr.
- *
- * @example
- * faker.image.transport() // 'https://loremflickr.com/640/480/transport'
- * faker.image.transport(1234, 2345) // 'https://loremflickr.com/1234/2345/transport'
- * faker.image.transport(1234, 2345, true) // 'https://loremflickr.com/1234/2345/transport?lock=56789'
- *
- * @since 2.0.1
- *
- * @deprecated Use `faker.image.urlLoremFlickr({ category: 'transport' })` if you want an image from LoremFlickr in the correct category, or `faker.image.url()` if you just want any image.
- *
- *
- */
- transport(width?: number, height?: number, randomize?: boolean): string {
- deprecated({
- deprecated: 'faker.image.transport',
- proposed:
- "faker.image.urlLoremFlickr({ category: 'transport' }) or faker.image.url",
- since: '8.0',
- until: '9.0',
- });
- // eslint-disable-next-line deprecation/deprecation
- return this.imageUrl(width, height, 'transport', randomize);
- }
}