From c93ed72eb8fe568fc55cd1b0434f51a9e38118f4 Mon Sep 17 00:00:00 2001 From: josher19 Date: Fri, 21 Aug 2020 12:14:24 -0700 Subject: [PATCH 01/10] Update address.js casual.zip works without needing to do `casual.zip()` --- src/providers/address.js | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/src/providers/address.js b/src/providers/address.js index dddf29c..c385177 100644 --- a/src/providers/address.js +++ b/src/providers/address.js @@ -50,7 +50,7 @@ var provider = { return this.populate_one_of(this.city_formats); }, - zip: function(digits) { + zip: function(digits=this.random_element(this.zip_formats)) { if (digits === 5) { return this.numerify(this.zip_formats[0]); } else if (digits === 9) { @@ -59,6 +59,14 @@ var provider = { return this.numerify(this.random_element(this.zip_formats)); } }, + + zip5: function() { + return this.numerify(this.zip_formats[0]); + }, + + zip9: function() { + return this.numerify(this.zip_formats[1]); + }, street_suffix: function() { return this.random_element(this.street_suffixes); From 7210c38f62096f7e9771de6f99bcd8ceb6f1b369 Mon Sep 17 00:00:00 2001 From: josher19 Date: Fri, 21 Aug 2020 12:19:49 -0700 Subject: [PATCH 02/10] Update README.md Add zip5 and zip9 examples --- README.md | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index 7ea8ffb..546d042 100644 --- a/README.md +++ b/README.md @@ -41,7 +41,9 @@ Casual uses javascript properties for common generators so you don't need to use casual.country // 'United Kingdom' casual.city // 'New Ortiz chester' -casual.zip(digits = {5, 9}) // '26995-7979' (if no digits specified then random selection between ZIP and ZIP+4) +casual.zip(digits = {5, 9}) // '26995-7979' or '26995' (if no digits specified then random selection between ZIP and ZIP+4) +casual.zip5 // '26995' +casual.zip9 // '26995-7979' casual.street // 'Jadyn Islands' casual.address // '6390 Tremblay Pines Suite 784' casual.address1 // '8417 Veda Circles' From 98fce522e56f8c5c70f808f4aa39368954ce7895 Mon Sep 17 00:00:00 2001 From: josher19 Date: Fri, 21 Aug 2020 12:20:54 -0700 Subject: [PATCH 03/10] Update package.json Minor version bump --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index a4b5037..ce8be5d 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "casual", - "version": "1.6.2", + "version": "1.7.0", "description": "Fake data generator", "main": "src/casual.js", "scripts": { From 3a995519682f64cf8c423e1b4f083d22417dc5e1 Mon Sep 17 00:00:00 2001 From: josher19 Date: Fri, 21 Aug 2020 16:27:26 -0700 Subject: [PATCH 04/10] Update README.md Use zip_short and zip_long instead --- README.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index 546d042..45372d1 100644 --- a/README.md +++ b/README.md @@ -42,8 +42,8 @@ Casual uses javascript properties for common generators so you don't need to use casual.country // 'United Kingdom' casual.city // 'New Ortiz chester' casual.zip(digits = {5, 9}) // '26995-7979' or '26995' (if no digits specified then random selection between ZIP and ZIP+4) -casual.zip5 // '26995' -casual.zip9 // '26995-7979' +casual.zip_short // '26995' +casual.zip_long // '26995-7979' casual.street // 'Jadyn Islands' casual.address // '6390 Tremblay Pines Suite 784' casual.address1 // '8417 Veda Circles' From c50bb406418b6886423c78f5a56c1b4c3d54a81f Mon Sep 17 00:00:00 2001 From: josher19 Date: Fri, 21 Aug 2020 16:28:53 -0700 Subject: [PATCH 05/10] Update address.js Use zip_short and zip_long instead. --- src/providers/address.js | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/providers/address.js b/src/providers/address.js index c385177..d5a8eba 100644 --- a/src/providers/address.js +++ b/src/providers/address.js @@ -60,12 +60,12 @@ var provider = { } }, - zip5: function() { + zip_short: function() { return this.numerify(this.zip_formats[0]); }, - zip9: function() { - return this.numerify(this.zip_formats[1]); + zip_long: function() { + return this.numerify(this.zip_formats[this.zip_formats.length - 1]); }, street_suffix: function() { From 3cee5ac04eacbba7a900a4ae1165f13fb331b607 Mon Sep 17 00:00:00 2001 From: josher19 Date: Fri, 21 Aug 2020 16:30:58 -0700 Subject: [PATCH 06/10] Update tests zip should not be a function --- test/casual.js | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/test/casual.js b/test/casual.js index cf73fcb..886deae 100644 --- a/test/casual.js +++ b/test/casual.js @@ -344,6 +344,11 @@ describe('API', function() { it('Should have getter function at _{name}', function() { providers.forEach(check_getters); }); + + it('zip should not be a function', function() { + const type = typeof casual.zip; + type.should.not.eql('function'); + }); it('Should return only funtions interface', function() { var functions = casual.functions(); From 6914cc1078369f314c7e19ba44691f04f7fd27f0 Mon Sep 17 00:00:00 2001 From: josher19 Date: Fri, 21 Aug 2020 16:33:55 -0700 Subject: [PATCH 07/10] Update index.d.ts Type defs --- index.d.ts | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/index.d.ts b/index.d.ts index b556860..587ce95 100644 --- a/index.d.ts +++ b/index.d.ts @@ -181,7 +181,9 @@ declare namespace Casual { // EMBEDDED GENERATORS country: string; // 'United Kingdom' city: string; // 'New Ortiz chester' - zip(digits: Object): string; // '26995-7979' (if no digits specified then random selection between ZIP and ZIP+4) + zip(digits?: number): string; // '26995-7979' (if no digits specified then random selection between ZIP and ZIP+4) + zip_short: string; // '26995' + zip_long: string // '26995-7979' street: string; // 'Jadyn Islands' address: string; // '6390 Tremblay Pines Suite 784' address1: string; // '8417 Veda Circles' From 05ef5b0b1a5dab42f070c6431e55d7df3153a4e3 Mon Sep 17 00:00:00 2001 From: josher19 Date: Fri, 21 Aug 2020 16:35:42 -0700 Subject: [PATCH 08/10] Update address.js --- src/providers/ar_SY/address.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/providers/ar_SY/address.js b/src/providers/ar_SY/address.js index 21ee936..ea9c0f9 100644 --- a/src/providers/ar_SY/address.js +++ b/src/providers/ar_SY/address.js @@ -35,7 +35,7 @@ var provider = { return this.random_element(this.cities); }, - zip: function(digits) { + zip: function(digits=0) { if (digits === 5) { return this.numerify(this.zip_formats[0]); } else if (digits === 9) { From 0d679d6e5b3a0a964de39e3dbfb4e68a88f65538 Mon Sep 17 00:00:00 2001 From: josher19 Date: Fri, 21 Aug 2020 16:36:13 -0700 Subject: [PATCH 09/10] Update address.js --- src/providers/ja_JP/address.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/providers/ja_JP/address.js b/src/providers/ja_JP/address.js index 9e4e3f3..92b89bc 100644 --- a/src/providers/ja_JP/address.js +++ b/src/providers/ja_JP/address.js @@ -52,7 +52,7 @@ var provider = { return this.populate_one_of(this.city_formats); }, - zip: function(digits) { + zip: function(digits=0) { if (digits === 5) { return this.numerify(this.zip_formats[0]); } else if (digits === 9) { From 3568db83b369b0954b4c647d8fb07bbb7bdab922 Mon Sep 17 00:00:00 2001 From: josher19 Date: Fri, 21 Aug 2020 16:36:50 -0700 Subject: [PATCH 10/10] Update address.js --- src/providers/address.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/providers/address.js b/src/providers/address.js index d5a8eba..01f5075 100644 --- a/src/providers/address.js +++ b/src/providers/address.js @@ -50,7 +50,7 @@ var provider = { return this.populate_one_of(this.city_formats); }, - zip: function(digits=this.random_element(this.zip_formats)) { + zip: function(digits=0) { if (digits === 5) { return this.numerify(this.zip_formats[0]); } else if (digits === 9) {