aboutsummaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authorShinigami <[email protected]>2022-01-18 12:00:58 +0100
committerGitHub <[email protected]>2022-01-18 12:00:58 +0100
commit8f9fd7be31c7daf00cc4c04c6aca3ca63e6f29a1 (patch)
tree29ce8c1b8249bf98e0286f20c5d68ffbaf5d8937 /lib
parenta973ee1ce64d2b593f64b633e927382280da8f27 (diff)
downloadfaker-8f9fd7be31c7daf00cc4c04c6aca3ca63e6f29a1.tar.xz
faker-8f9fd7be31c7daf00cc4c04c6aca3ca63e6f29a1.zip
chore: migrate image providers to TS (#178)
Diffstat (limited to 'lib')
-rw-r--r--lib/image_providers/lorempicsum.js106
-rw-r--r--lib/image_providers/lorempixel.js241
-rw-r--r--lib/image_providers/unsplash.js137
3 files changed, 0 insertions, 484 deletions
diff --git a/lib/image_providers/lorempicsum.js b/lib/image_providers/lorempicsum.js
deleted file mode 100644
index 65639da7..00000000
--- a/lib/image_providers/lorempicsum.js
+++ /dev/null
@@ -1,106 +0,0 @@
-/**
- *
- * @namespace lorempicsum
- * @memberof faker.image
- */
-var LoremPicsum = function (faker) {
- var self = this;
-
- /**
- * image
- *
- * @param {number} width
- * @param {number} height
- * @param {boolean} grayscale
- * @param {number} blur 1-10
- * @method faker.image.lorempicsum.image
- * @description search image from unsplash
- */
- self.image = function (width, height, grayscale, blur) {
- return self.imageUrl(width, height, grayscale, blur);
- };
- /**
- * imageGrayscaled
- *
- * @param {number} width
- * @param {number} height
- * @param {boolean} grayscale
- * @method faker.image.lorempicsum.imageGrayscaled
- * @description search grayscale image from unsplash
- */
- self.imageGrayscale = function (width, height, grayscale) {
- return self.imageUrl(width, height, grayscale);
- };
- /**
- * imageBlurred
- *
- * @param {number} width
- * @param {number} height
- * @param {number} blur 1-10
- * @method faker.image.lorempicsum.imageBlurred
- * @description search blurred image from unsplash
- */
- self.imageBlurred = function (width, height, blur) {
- return self.imageUrl(width, height, undefined, blur);
- };
- /**
- * imageRandomSeeded
- *
- * @param {number} width
- * @param {number} height
- * @param {boolean} grayscale
- * @param {number} blur 1-10
- * @param {string} seed
- * @method faker.image.lorempicsum.imageRandomSeeded
- * @description search same random image from unsplash, based on a seed
- */
- self.imageRandomSeeded = function (width, height, grayscale, blur, seed) {
- return self.imageUrl(width, height, grayscale, blur, seed);
- };
- /**
- * avatar
- *
- * @method faker.image.lorempicsum.avatar
- */
- self.avatar = function () {
- return faker.internet.avatar();
- };
- /**
- * imageUrl
- *
- * @param {number} width
- * @param {number} height
- * @param {boolean} grayscale
- * @param {number} blur 1-10
- * @param {string} seed
- * @method faker.image.lorempicsum.imageUrl
- */
- self.imageUrl = function (width, height, grayscale, blur, seed) {
- var width = width || 640;
- var height = height || 480;
-
- var url = 'https://picsum.photos';
-
- if (seed) {
- url += '/seed/' + seed;
- }
-
- url += '/' + width + '/' + height;
-
- if (grayscale && blur) {
- return url + '?grayscale' + '&blur=' + blur;
- }
-
- if (grayscale) {
- return url + '?grayscale';
- }
-
- if (blur) {
- return url + '?blur=' + blur;
- }
-
- return url;
- };
-};
-
-module['exports'] = LoremPicsum;
diff --git a/lib/image_providers/lorempixel.js b/lib/image_providers/lorempixel.js
deleted file mode 100644
index 24ad4806..00000000
--- a/lib/image_providers/lorempixel.js
+++ /dev/null
@@ -1,241 +0,0 @@
-/**
- *
- * @namespace lorempixel
- * @memberof faker.image
- */
-var Lorempixel = function (faker) {
- var self = this;
-
- /**
- * image
- *
- * @param {number} width
- * @param {number} height
- * @param {boolean} randomize
- * @method faker.image.lorempixel.image
- */
- self.image = function (width, height, randomize) {
- var categories = [
- 'abstract',
- 'animals',
- 'business',
- 'cats',
- 'city',
- 'food',
- 'nightlife',
- 'fashion',
- 'people',
- 'nature',
- 'sports',
- 'technics',
- 'transport',
- ];
- return self[faker.random.arrayElement(categories)](
- width,
- height,
- randomize
- );
- };
- /**
- * avatar
- *
- * @method faker.image.lorempixel.avatar
- */
- self.avatar = function () {
- return faker.internet.avatar();
- };
- /**
- * imageUrl
- *
- * @param {number} width
- * @param {number} height
- * @param {string} category
- * @param {boolean} randomize
- * @method faker.image.lorempixel.imageUrl
- */
- self.imageUrl = function (width, height, category, randomize) {
- var width = width || 640;
- var height = height || 480;
-
- var url = 'https://lorempixel.com/' + width + '/' + height;
- if (typeof category !== 'undefined') {
- url += '/' + category;
- }
-
- if (randomize) {
- url += '?' + faker.datatype.number();
- }
-
- return url;
- };
- /**
- * abstract
- *
- * @param {number} width
- * @param {number} height
- * @param {boolean} randomize
- * @method faker.image.lorempixel.abstract
- */
- self.abstract = function (width, height, randomize) {
- return faker.image.lorempixel.imageUrl(
- width,
- height,
- 'abstract',
- randomize
- );
- };
- /**
- * animals
- *
- * @param {number} width
- * @param {number} height
- * @param {boolean} randomize
- * @method faker.image.lorempixel.animals
- */
- self.animals = function (width, height, randomize) {
- return faker.image.lorempixel.imageUrl(width, height, 'animals', randomize);
- };
- /**
- * business
- *
- * @param {number} width
- * @param {number} height
- * @param {boolean} randomize
- * @method faker.image.lorempixel.business
- */
- self.business = function (width, height, randomize) {
- return faker.image.lorempixel.imageUrl(
- width,
- height,
- 'business',
- randomize
- );
- };
- /**
- * cats
- *
- * @param {number} width
- * @param {number} height
- * @param {boolean} randomize
- * @method faker.image.lorempixel.cats
- */
- self.cats = function (width, height, randomize) {
- return faker.image.lorempixel.imageUrl(width, height, 'cats', randomize);
- };
- /**
- * city
- *
- * @param {number} width
- * @param {number} height
- * @param {boolean} randomize
- * @method faker.image.lorempixel.city
- */
- self.city = function (width, height, randomize) {
- return faker.image.lorempixel.imageUrl(width, height, 'city', randomize);
- };
- /**
- * food
- *
- * @param {number} width
- * @param {number} height
- * @param {boolean} randomize
- * @method faker.image.lorempixel.food
- */
- self.food = function (width, height, randomize) {
- return faker.image.lorempixel.imageUrl(width, height, 'food', randomize);
- };
- /**
- * nightlife
- *
- * @param {number} width
- * @param {number} height
- * @param {boolean} randomize
- * @method faker.image.lorempixel.nightlife
- */
- self.nightlife = function (width, height, randomize) {
- return faker.image.lorempixel.imageUrl(
- width,
- height,
- 'nightlife',
- randomize
- );
- };
- /**
- * fashion
- *
- * @param {number} width
- * @param {number} height
- * @param {boolean} randomize
- * @method faker.image.lorempixel.fashion
- */
- self.fashion = function (width, height, randomize) {
- return faker.image.lorempixel.imageUrl(width, height, 'fashion', randomize);
- };
- /**
- * people
- *
- * @param {number} width
- * @param {number} height
- * @param {boolean} randomize
- * @method faker.image.lorempixel.people
- */
- self.people = function (width, height, randomize) {
- return faker.image.lorempixel.imageUrl(width, height, 'people', randomize);
- };
- /**
- * nature
- *
- * @param {number} width
- * @param {number} height
- * @param {boolean} randomize
- * @method faker.image.lorempixel.nature
- */
- self.nature = function (width, height, randomize) {
- return faker.image.lorempixel.imageUrl(width, height, 'nature', randomize);
- };
- /**
- * sports
- *
- * @param {number} width
- * @param {number} height
- * @param {boolean} randomize
- * @method faker.image.lorempixel.sports
- */
- self.sports = function (width, height, randomize) {
- return faker.image.lorempixel.imageUrl(width, height, 'sports', randomize);
- };
- /**
- * technics
- *
- * @param {number} width
- * @param {number} height
- * @param {boolean} randomize
- * @method faker.image.lorempixel.technics
- */
- self.technics = function (width, height, randomize) {
- return faker.image.lorempixel.imageUrl(
- width,
- height,
- 'technics',
- randomize
- );
- };
- /**
- * transport
- *
- * @param {number} width
- * @param {number} height
- * @param {boolean} randomize
- * @method faker.image.lorempixel.transport
- */
- self.transport = function (width, height, randomize) {
- return faker.image.lorempixel.imageUrl(
- width,
- height,
- 'transport',
- randomize
- );
- };
-};
-
-module['exports'] = Lorempixel;
diff --git a/lib/image_providers/unsplash.js b/lib/image_providers/unsplash.js
deleted file mode 100644
index e53f270a..00000000
--- a/lib/image_providers/unsplash.js
+++ /dev/null
@@ -1,137 +0,0 @@
-/**
- *
- * @namespace unsplash
- * @memberof faker.image
- */
-var Unsplash = function (faker) {
- var self = this;
- var categories = [
- 'food',
- 'nature',
- 'people',
- 'technology',
- 'objects',
- 'buildings',
- ];
-
- /**
- * image
- *
- * @param {number} width
- * @param {number} height
- * @param {string} keyword
- * @method faker.image.unsplash.image
- * @description search image from unsplash
- */
- self.image = function (width, height, keyword) {
- return self.imageUrl(width, height, undefined, keyword);
- };
- /**
- * avatar
- *
- * @method faker.image.unsplash.avatar
- */
- self.avatar = function () {
- return faker.internet.avatar();
- };
- /**
- * imageUrl
- *
- * @param {number} width
- * @param {number} height
- * @param {string} category
- * @param {string} keyword
- * @method faker.image.unsplash.imageUrl
- */
- self.imageUrl = function (width, height, category, keyword) {
- var width = width || 640;
- var height = height || 480;
-
- var url = 'https://source.unsplash.com';
-
- if (typeof category !== 'undefined') {
- url += '/category/' + category;
- }
-
- url += '/' + width + 'x' + height;
-
- if (typeof keyword !== 'undefined') {
- var keywordFormat = new RegExp(
- '^([A-Za-z0-9].+,[A-Za-z0-9]+)$|^([A-Za-z0-9]+)$'
- );
- if (keywordFormat.test(keyword)) {
- url += '?' + keyword;
- }
- }
-
- return url;
- };
- /**
- * food
- *
- * @param {number} width
- * @param {number} height
- * @param {string} keyword
- * @method faker.image.unsplash.food
- */
- self.food = function (width, height, keyword) {
- return faker.image.unsplash.imageUrl(width, height, 'food', keyword);
- };
- /**
- * people
- *
- * @param {number} width
- * @param {number} height
- * @param {string} keyword
- * @method faker.image.unsplash.people
- */
- self.people = function (width, height, keyword) {
- return faker.image.unsplash.imageUrl(width, height, 'people', keyword);
- };
- /**
- * nature
- *
- * @param {number} width
- * @param {number} height
- * @param {string} keyword
- * @method faker.image.unsplash.nature
- */
- self.nature = function (width, height, keyword) {
- return faker.image.unsplash.imageUrl(width, height, 'nature', keyword);
- };
- /**
- * technology
- *
- * @param {number} width
- * @param {number} height
- * @param {string} keyword
- * @method faker.image.unsplash.technology
- */
- self.technology = function (width, height, keyword) {
- return faker.image.unsplash.imageUrl(width, height, 'technology', keyword);
- };
- /**
- * objects
- *
- * @param {number} width
- * @param {number} height
- * @param {string} keyword
- * @method faker.image.unsplash.objects
- */
- self.objects = function (width, height, keyword) {
- return faker.image.unsplash.imageUrl(width, height, 'objects', keyword);
- };
- /**
- * buildings
- *
- * @param {number} width
- * @param {number} height
- * @param {string} keyword
- * @method faker.image.unsplash.buildings
- */
- self.buildings = function (width, height, keyword) {
- return faker.image.unsplash.imageUrl(width, height, 'buildings', keyword);
- };
-};
-
-module['exports'] = Unsplash;