awesome-phonenumber icon indicating copy to clipboard operation
awesome-phonenumber copied to clipboard

Usage in Deno seems not to be documented in README.md

Open michael-spengler opened this issue 4 years ago • 2 comments

Dear awesome phonenumber team.

I'd like to use this via deno style import.

I could not find anything related in your README.md. As you published it here: https://deno.land/x/[email protected] I guess somehow one can make this work in Deno.

Looking forward to some hints :)

michael-spengler avatar Sep 12 '20 17:09 michael-spengler

i dont think the typings are there for deno. This is what I ended up doing:

//file ./utils/phone.ts
import { createRequire } from "https://deno.land/std/node/module.ts";
const require = createRequire(import.meta.url)
const libphonenumber = require('awesome-phonenumber')
export const { parsePhoneNumber} = libphonenumber

and then install it yarn add awesome-phonenumber

now where ever I need the phone number all I do is

import { parsePhoneNumber } from './utils/phone.ts'

panigrah avatar Oct 16 '22 04:10 panigrah

I used it with Deno (and Supabase) by just importing from esm.sh:

import { parsePhoneNumber } from "https://esm.sh/[email protected]"

then I can just: const pn = parsePhoneNumber( '0707123456', { regionCode: 'SE' } );

monobjorn avatar Feb 21 '23 13:02 monobjorn