From eaf5c65cfae0a6636555884c18e6c955fae7887e Mon Sep 17 00:00:00 2001 From: Marak Date: Tue, 7 Jul 2015 16:22:50 -0700 Subject: [refactor] [dist] Allow for node to require individual locales ( to avoid the default behavior of requiring all locale data. #125 #167 --- lib/image.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'lib/image.js') diff --git a/lib/image.js b/lib/image.js index aa983139..3f87ab7d 100644 --- a/lib/image.js +++ b/lib/image.js @@ -1,4 +1,4 @@ -var faker = require('../index'); +var faker = require('./index'); var image = { image: function () { -- cgit v1.2.3 From e25e1ebc349c426c6b2598dc907eae497ef67160 Mon Sep 17 00:00:00 2001 From: Marak Date: Wed, 8 Jul 2015 14:34:39 -0700 Subject: [refactor] [major] Adds incremental browser builds. Switch to using prototype for internal API. Previous usage of `module.parent` is not acceptable. Locale information is now passed into Faker constructor. Closes #125 --- lib/image.js | 75 ++++++++++++++++++++++++++++++------------------------------ 1 file changed, 38 insertions(+), 37 deletions(-) (limited to 'lib/image.js') diff --git a/lib/image.js b/lib/image.js index 3f87ab7d..e791ffea 100644 --- a/lib/image.js +++ b/lib/image.js @@ -1,14 +1,15 @@ -var faker = require('./index'); +var Image = function (faker) { -var image = { - image: function () { + var self = this; + + self.image = function () { var categories = ["abstract", "animals", "business", "cats", "city", "food", "nightlife", "fashion", "people", "nature", "sports", "technics", "transport"]; - return image[faker.random.array_element(categories)](); - }, - avatar: function () { + return self[faker.random.array_element(categories)](); + }; + self.avatar = function () { return faker.internet.avatar(); - }, - imageUrl: function (width, height, category) { + }; + self.imageUrl = function (width, height, category) { var width = width || 640; var height = height || 480; @@ -17,46 +18,46 @@ var image = { url += '/' + category; } return url; - }, - abstract: function (width, height) { + }; + self.abstract = function (width, height) { return faker.image.imageUrl(width, height, 'abstract'); - }, - animals: function (width, height) { + }; + self.animals = function (width, height) { return faker.image.imageUrl(width, height, 'animals'); - }, - business: function (width, height) { + }; + self.business = function (width, height) { return faker.image.imageUrl(width, height, 'business'); - }, - cats: function (width, height) { + }; + self.cats = function (width, height) { return faker.image.imageUrl(width, height, 'cats'); - }, - city: function (width, height) { + }; + self.city = function (width, height) { return faker.image.imageUrl(width, height, 'city'); - }, - food: function (width, height) { + }; + self.food = function (width, height) { return faker.image.imageUrl(width, height, 'food'); - }, - nightlife: function (width, height) { + }; + self.nightlife = function (width, height) { return faker.image.imageUrl(width, height, 'nightlife'); - }, - fashion: function (width, height) { + }; + self.fashion = function (width, height) { return faker.image.imageUrl(width, height, 'fashion'); - }, - people: function (width, height) { + }; + self.people = function (width, height) { return faker.image.imageUrl(width, height, 'people'); - }, - nature: function (width, height) { + }; + self.nature = function (width, height) { return faker.image.imageUrl(width, height, 'nature'); - }, - sports: function (width, height) { + }; + self.sports = function (width, height) { return faker.image.imageUrl(width, height, 'sports'); - }, - technics: function (width, height) { + }; + self.technics = function (width, height) { return faker.image.imageUrl(width, height, 'technics'); - }, - transport: function (width, height) { + }; + self.transport = function (width, height) { return faker.image.imageUrl(width, height, 'transport'); - } -}; + } +} -module.exports = image; +module["exports"] = Image; \ No newline at end of file -- cgit v1.2.3 From 4c1b454b8e3c8d87f2569a2ce0d7730dc31ee821 Mon Sep 17 00:00:00 2001 From: Marak Date: Wed, 8 Jul 2015 23:56:22 -0700 Subject: [api] [refactor] Rename `array_element` and `object_element` to camelCase. Set default max random number to 99999. Added default arguments to some methods. --- lib/image.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'lib/image.js') diff --git a/lib/image.js b/lib/image.js index e791ffea..01f7f5cb 100644 --- a/lib/image.js +++ b/lib/image.js @@ -4,7 +4,7 @@ var Image = function (faker) { self.image = function () { var categories = ["abstract", "animals", "business", "cats", "city", "food", "nightlife", "fashion", "people", "nature", "sports", "technics", "transport"]; - return self[faker.random.array_element(categories)](); + return self[faker.random.arrayElement(categories)](); }; self.avatar = function () { return faker.internet.avatar(); -- cgit v1.2.3