Files
new-phone-who-dis/resources/server/utils/getRandomPhoneNumber.ts
T
2021-04-18 15:38:50 -04:00

14 lines
467 B
TypeScript

import { config } from '../server';
export function getRandomPhoneNumber() {
if (!config.general.useDashNumber) {
return Math.floor(Math.random() * 10000000).toString(); // 10000000 creates a number with 7 characters.
}
return Math.floor(Math.random() * 10000000)
.toString()
.replace(/(\d{3})(\d{4})/, '$1-$2');
// The numbers inside {} in replace() can be changed to how many digits you want on each side of the dash.
// Example: 123-4567
}