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/hacker.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'lib/hacker.js') diff --git a/lib/hacker.js b/lib/hacker.js index ca6bfb2d..e67eba8e 100644 --- a/lib/hacker.js +++ b/lib/hacker.js @@ -1,4 +1,4 @@ -var faker = require('../index'); +var faker = require('./index'); var hacker = { -- 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/hacker.js | 47 +++++++++++++++++++++++------------------------ 1 file changed, 23 insertions(+), 24 deletions(-) (limited to 'lib/hacker.js') diff --git a/lib/hacker.js b/lib/hacker.js index e67eba8e..7aba150e 100644 --- a/lib/hacker.js +++ b/lib/hacker.js @@ -1,35 +1,34 @@ -var faker = require('./index'); - -var hacker = { - - abbreviation : function () { +var Hacker = function (faker) { + var self = this; + + self.abbreviation = function () { return faker.random.array_element(faker.definitions.hacker.abbreviation); - }, + }; - adjective : function () { + self.adjective = function () { return faker.random.array_element(faker.definitions.hacker.adjective); - }, + }; - noun : function () { + self.noun = function () { return faker.random.array_element(faker.definitions.hacker.noun); - }, + }; - verb : function () { + self.verb = function () { return faker.random.array_element(faker.definitions.hacker.verb); - }, + }; - ingverb : function () { + self.ingverb = function () { return faker.random.array_element(faker.definitions.hacker.ingverb); - }, + }; - phrase : function () { + self.phrase = function () { var data = { - abbreviation: hacker.abbreviation(), - adjective: hacker.adjective(), - ingverb: hacker.ingverb(), - noun: hacker.noun(), - verb: hacker.verb() + abbreviation: self.abbreviation(), + adjective: self.adjective(), + ingverb: self.ingverb(), + noun: self.noun(), + verb: self.verb() }; var phrase = faker.random.array_element([ "If we {{verb}} the {{noun}}, we can get to the {{abbreviation}} {{noun}} through the {{adjective}} {{abbreviation}} {{noun}}!", @@ -44,9 +43,9 @@ var hacker = { return faker.helpers.mustache(phrase, data); - }, - - + }; + + return self; }; -module.exports = hacker; +module['exports'] = Hacker; \ 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/hacker.js | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) (limited to 'lib/hacker.js') diff --git a/lib/hacker.js b/lib/hacker.js index 7aba150e..463f8331 100644 --- a/lib/hacker.js +++ b/lib/hacker.js @@ -2,23 +2,23 @@ var Hacker = function (faker) { var self = this; self.abbreviation = function () { - return faker.random.array_element(faker.definitions.hacker.abbreviation); + return faker.random.arrayElement(faker.definitions.hacker.abbreviation); }; self.adjective = function () { - return faker.random.array_element(faker.definitions.hacker.adjective); + return faker.random.arrayElement(faker.definitions.hacker.adjective); }; self.noun = function () { - return faker.random.array_element(faker.definitions.hacker.noun); + return faker.random.arrayElement(faker.definitions.hacker.noun); }; self.verb = function () { - return faker.random.array_element(faker.definitions.hacker.verb); + return faker.random.arrayElement(faker.definitions.hacker.verb); }; self.ingverb = function () { - return faker.random.array_element(faker.definitions.hacker.ingverb); + return faker.random.arrayElement(faker.definitions.hacker.ingverb); }; self.phrase = function () { @@ -31,7 +31,7 @@ var Hacker = function (faker) { verb: self.verb() }; - var phrase = faker.random.array_element([ "If we {{verb}} the {{noun}}, we can get to the {{abbreviation}} {{noun}} through the {{adjective}} {{abbreviation}} {{noun}}!", + var phrase = faker.random.arrayElement([ "If we {{verb}} the {{noun}}, we can get to the {{abbreviation}} {{noun}} through the {{adjective}} {{abbreviation}} {{noun}}!", "We need to {{verb}} the {{adjective}} {{abbreviation}} {{noun}}!", "Try to {{verb}} the {{abbreviation}} {{noun}}, maybe it will {{verb}} the {{adjective}} {{noun}}!", "You can't {{verb}} the {{noun}} without {{ingverb}} the {{adjective}} {{abbreviation}} {{noun}}!", -- cgit v1.2.3