UNPKG

qforce

Version:

Commands to help with salesforce development.

135 lines (134 loc) 4.29 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.random = void 0; const nameData_1 = require("./nameData"); const streetData_1 = require("./streetData"); const cityData_1 = require("./cityData"); const statesData_1 = require("./statesData"); const wordData_1 = require("./wordData"); const randomatic = require('randomatic'); let random = { find: function find(names) { return names[~~(Math.random() * names.length)].split(' ').map(this.capitalize).join(' '); }, capitalize: function capitalize(name) { if (name.length < 2) return name.toUpperCase(); return name.charAt(0).toUpperCase() + name.slice(1).toLowerCase(); }, getString: function getString(pattern = 'a', length = ~~(Math.random() * 9) + 3) { return randomatic(pattern, length); }, getDate: function getDate(min = -365 * 21, max = -365 * 65) { let count = ~~(Math.random() * max) + min; let now = Date.now(); let result = new Date(now + count * 24 * 60 * 60 * 1000); return result.toJSON(); }, get date() { return this.getDate(); }, get lastWeek() { return this.getDate(-1, -8); }, get lastMonth() { return this.getDate(-1, -31); }, get lastYear() { return this.getDate(-1, -366); }, get nextWeek() { return this.getDate(1, 8); }, get nextMonth() { return this.getDate(1, 31); }, get nextYear() { return this.getDate(1, 366); }, get useRealWords() { if (this._useRealWords) return this._useRealWords; else return false; }, set useRealWords(value) { this._useRealWords = value; }, get language() { if (this._language) return this._language; else return null; }, set language(value) { this._language = value; }, get string() { //let count = ~~(Math.random() * 15) + 1 return this.getString(); }, get word() { if (this.language == 'spanish') { return wordData_1.spanishWords[~~(Math.random() * wordData_1.spanishWords.length)]; } else if (this.language == 'polish') { return wordData_1.polishWords[~~(Math.random() * wordData_1.polishWords.length)]; } else if (this.language == 'english') { return wordData_1.englishWords[~~(Math.random() * wordData_1.englishWords.length)]; } else if (this.language == 'urdu') { return wordData_1.urduWords[~~(Math.random() * wordData_1.urduWords.length)]; } else { return wordData_1.loremIpsum[~~(Math.random() * wordData_1.loremIpsum.length)]; } }, get sentence() { let sentence = this.capitalize(this.word); let count = ~~(Math.random() * 5) + 3; for (let i = 0; i < count; i++) { sentence += ' ' + this.word; } return sentence + '. '; }, get paragraph() { let para = this.sentence; let count = ~~(Math.random() * 5) + 3; for (let i = 0; i < count; i++) { para += this.sentence; } return para; }, get firstName() { return this.find(nameData_1.firstNames); }, get lastName() { return this.find(nameData_1.lastNames); }, get street() { return this.find(streetData_1.streetNames); }, get city() { return this.find(cityData_1.cityNames); }, get state() { return this.find(statesData_1.stateNames).toUpperCase(); }, get person() { let p = {}; p.firstName = this.firstName; p.lastName = this.lastName; p.birthdate = this.date; p.ssn = `${randomatic('000')}-${randomatic('00')}-${randomatic('0000')}`; p.phone = `(${randomatic('000')}) ${randomatic('000')}-${randomatic('0000')}`; p.email = `${p.firstName.toLowerCase()}.${p.lastName.toLowerCase()}@${randomatic('a', 8)}.com`; p.street = randomatic('0', 4) + ' ' + this.street; p.city = this.city; p.state = this.state; p.zip = randomatic('0', 5); return p; } }; exports.random = random;