Skip to content

Commit

Permalink
Split street into number and name properties RandomAPI#112
Browse files Browse the repository at this point in the history
  • Loading branch information
keitharm committed Sep 28, 2019
1 parent 2aca690 commit ffe1cd5
Show file tree
Hide file tree
Showing 4 changed files with 4 additions and 11 deletions.
5 changes: 4 additions & 1 deletion api/1.3/api.js
Original file line number Diff line number Diff line change
Expand Up @@ -152,7 +152,10 @@ class Generator {

let timezone = JSON.parse(randomItem(this.datasets.common.timezones));
this.include('location', {
street: range(1, 9999) + ' ' + randomItem(this.datasets[nat].street),
street: {
number: range(1, 9999),
name: randomItem(this.datasets[nat].street)
},
city: randomItem(this.datasets[nat].cities),
state: randomItem(this.datasets[nat].states),
country: this.fullNatName(nat),
Expand Down
4 changes: 0 additions & 4 deletions api/1.3/data/AU/inject.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,5 @@ module.exports = (inc, contents) => {
include(inc, contents, 'picture', pic);
include(inc, contents, 'location', () => {
contents.location.postcode = range(200, 9999); // Override common postcode with AU range

// Override common postcode with AU range
const oldStreet = contents.location.street;
contents.location.street = contents.location.street.replace(/(\d+)/, range(1,9999));
});
};
4 changes: 0 additions & 4 deletions api/1.3/data/DE/inject.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,5 @@ module.exports = (inc, contents) => {
name: '',
value: null
});
include(inc, contents, 'location', () => {
const oldStreet = contents.location.street.replace(/(\d+) /, '');
contents.location.street = oldStreet + ' ' + range(1, 200);
});
include(inc, contents, 'picture', pic);
};
2 changes: 0 additions & 2 deletions api/1.3/data/NO/inject.js
Original file line number Diff line number Diff line change
Expand Up @@ -62,8 +62,6 @@ module.exports = (inc, contents, datasets) => {
});

include(inc, contents, 'location', () => {
const oldStreet = contents.location.street.replace(/(\d+) /, '');
contents.location.street = oldStreet + ' ' + range(1, 9998);
contents.location.postcode = randomItem(datasets['NO'].post_codes);
});
include(inc, contents, 'picture', pic);
Expand Down

0 comments on commit ffe1cd5

Please sign in to comment.