JSFiddle - React, Tailwind, and code Playground
by Nalin Sajwan
JavaScript
var _definitions = {
"name": [
"first_name",
"last_name",
"prefix",
"suffix",
"title",
"male_first_name",
"female_first_name",
"male_middle_name",
"female_middle_name",
"male_last_name",
"female_last_name"
],
"address": [
"city_prefix",
"city_suffix",
"street_suffix",
"county",
"country",
"country_code",
"state",
"state_abbr",
"street_prefix",
"postcode"
],
"company": [
"adjective",
"noun",
"descriptor",
"bs_adjective",
"bs_noun",
"bs_verb",
"suffix"
],
"lorem": ["words"],
"hacker": [
"abbreviation", "adjective", "noun", "verb", "ingverb"
],
"phone_number": ["formats"],
"finance": [
"account_type", "transaction_type", "currency", "iban"
],
"internet": [
"avatar_uri", "domain_suffix", "free_email", "example_email", "password"
],
"commerce": [
"color", "department", "product_name", "price", "categories"
],
"database": [
"collation", "column", "engine", "type"
],
"system": ["mimeTypes"],
"date": [
"month", "weekday"
],
"title": "",
"separator": ""
};
var path = [];
// Create a Getter for all definitions.foo.bar properties
Object.keys(_definitions).forEach(function (d) {
if (typeof _definitions[d] === "undefined") {
_definitions[d] = {};
}
if (typeof _definitions[d] === "string") {
path.push(`${d}`)
return;
}
_definitions[d].forEach(function (p) {
path.push(`${d} > ${p}`)
});
});
console.log("path ==> ", JSON.stringify(path, null, 4))