Skip to content

Instantly share code, notes, and snippets.

@JerryC8080
Last active March 21, 2016 08:06
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save JerryC8080/945256128cf7b88dc201 to your computer and use it in GitHub Desktop.
Save JerryC8080/945256128cf7b88dc201 to your computer and use it in GitHub Desktop.
使用Chance,随机生成中国电话号码
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