1.1.0 • Published 11 months ago

@ali1416/phone2region v1.1.0

Weekly downloads
-
License
Apache-2.0
Repository
github
Last release
11 months ago

Phone Number To Region For JavaScript 手机号码转区域JavaScript版

License Node Support NPM Tag Repo Size

Node CI

简介

本项目迁移自ALI1416/phone2region,构建后phone2region.min.js文件仅3kb

在线示例

数据文件

其他语言项目

依赖导入

网页

https://unpkg.com/@zip.js/zip.js/dist/zip.min.js https://unpkg.com/@ali1416/phone2region@1.1.0/dist/phone2region.min.js

node

npm install @ali1416/phone2region@1.1.0

使用示例

// node test-node.js
const fs = require('fs')
const {Phone2Region} = require('../dist/phone2region.node')

let url = 'https://www.404z.cn/files/phone2region/v2.0.0/data/phone2region.zdb'
let zdbPath = 'D:/phone2region.zdb'

let phone2Region = new Phone2Region()

// runUrl()
runFile()

async function runUrl() {
  await phone2Region.initByUrl(url)
  run()
}

async function runFile() {
  let buffer = fs.readFileSync(zdbPath).buffer
  await phone2Region.init(buffer)
  run()
}

function run() {
  console.log(phone2Region.parse('1875471'))
  console.log(phone2Region.parse('18754710000'))
  console.log(phone2Region.parse7(1875471))
  console.log(phone2Region.parse11(18754710000))
}

更多请见测试

更新日志

点击查看

参考

关于

1.1.0

11 months ago

1.0.0

11 months ago