Last active
March 21, 2016 08:06
-
-
Save JerryC8080/945256128cf7b88dc201 to your computer and use it in GitHub Desktop.
使用Chance,随机生成中国电话号码
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
let chance = require('chance')(); | |
function generatePhone(nums) { | |
if (!nums){ | |
nums = 1; | |
} | |
return chance.unique(function generatePhone() { | |
let phone = '1'; | |
phone+= chance.string({length: 1, pool: '34578'}); | |
phone+= chance.string({length: 9, pool: '9876543210'}); | |
return phone; | |
}, nums, { country: 'uk', mobile: true }); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment