expresso
  • Get Started
    • 👋Welcome!
    • ⚡Quick Start
  • Expresso Library
    • 📖Introduction
    • ⚛️expresso-core
      • Currency
      • Random String
      • Formatter
      • File
      • Phone
    • ⚓expresso-hooks
      • Multer
      • Token
      • OTP
    • 🚀expresso-provider
      • FCM
      • SMTP
      • Redis
      • Storage
    • 🔗expresso-query
      • TypeORM
      • Sequelize
Powered by GitBook
On this page
  • Format Phone with international format
  • Format phone for Whatsapp
  • Format hide phone number
  1. Expresso Library
  2. expresso-core

Phone

format phonenumber with international phone & whatsapp

Using commonjs

const { Phonenumber } = require('expresso-core')

Using ES6

import { Phonenumber } from 'expresso-core'

Format Phone with international format

const phone = new Phonenumber({ country: 'ID' })

const myPhone = '081234567890'
const newPhone = phone.format(myPhone)

console.log(newPhone)

// output
+6281234567890

Format phone for Whatsapp

const phone = new Phonenumber({ country: 'ID' })

const myPhone = '081234567890'
const newPhone = phone.formatWhatsapp(myPhone)

console.log(newPhone)

// output
[email protected]

Format hide phone number

const phone = new Phonenumber({ country: 'ID' })

const myPhone = '081234567890'
const newPhone = phone.hidePhone(myPhone)

console.log(newPhone)

// output
+6281234***890
PreviousFileNextexpresso-hooks

Last updated 1 year ago

⚛️