@aircall/numbers
Advanced tools
Comparing version 0.2.4 to 0.2.5
@@ -6,2 +6,10 @@ # Change Log | ||
## [0.2.5](http://bitbucket.org/aircall/front-end-modules/compare/@aircall/numbers@0.2.4...@aircall/numbers@0.2.5) (2020-04-07) | ||
**Note:** Version bump only for package @aircall/numbers | ||
## [0.2.4](http://bitbucket.org/aircall/front-end-modules/compare/@aircall/numbers@0.2.3...@aircall/numbers@0.2.4) (2020-04-06) | ||
@@ -8,0 +16,0 @@ |
import { Country } from './countries'; | ||
export declare const PHONE_NUMBER_CARACTER_REGEXP: RegExp; | ||
export declare const PHONE_NUMBER_MATCH_REGEXP: RegExp; | ||
export declare const COUNTRIES: Country[]; | ||
@@ -4,0 +5,0 @@ /** @see https://github.com/vtex/country-iso-3-to-2/blob/master/index.js */ |
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.PHONE_NUMBER_CARACTER_REGEXP = /^\+?[\s|\d|(|)|||\-|/]*$/; | ||
exports.PHONE_NUMBER_MATCH_REGEXP = /(\+?[\s|\d|(|).|||\-|/]*)/g; | ||
exports.COUNTRIES = [ | ||
@@ -5,0 +6,0 @@ { |
@@ -1,2 +0,2 @@ | ||
import { PhoneNumber as LibPhonenumberPhoneNumber } from 'libphonenumber-js/max'; | ||
import { PhoneNumber as LibPhonenumberPhoneNumber, NumberFound as LibPhonenumberNumberFound } from 'libphonenumber-js/max'; | ||
import { CountryCode } from './countries'; | ||
@@ -7,2 +7,3 @@ /** | ||
export declare type PhoneNumber = LibPhonenumberPhoneNumber; | ||
export declare type NumberFound = LibPhonenumberNumberFound; | ||
/** | ||
@@ -59,1 +60,10 @@ * Parses strings with phone numbers. | ||
export declare function guessCountryCode(phoneNumber: string, countryCode: CountryCode, defaultCountryCode: CountryCode, isTyping: boolean): CountryCode; | ||
/** | ||
* Parses text for phone numbers | ||
* | ||
* @param text - String to parse | ||
* @param countryCode - Country code to parse the text with (default country) | ||
* | ||
* @returns List of found phone numbers | ||
*/ | ||
export declare function parseText(text: string, countryCode: CountryCode): NumberFound[]; |
@@ -140,2 +140,14 @@ "use strict"; | ||
exports.guessCountryCode = guessCountryCode; | ||
/** | ||
* Parses text for phone numbers | ||
* | ||
* @param text - String to parse | ||
* @param countryCode - Country code to parse the text with (default country) | ||
* | ||
* @returns List of found phone numbers | ||
*/ | ||
function parseText(text, countryCode) { | ||
return max_1.findPhoneNumbersInText(text, countryCode); | ||
} | ||
exports.parseText = parseText; | ||
//# sourceMappingURL=parsing.js.map |
@@ -245,3 +245,18 @@ "use strict"; | ||
}); | ||
describe('parseText', () => { | ||
it('parses the text and returns found numbers', () => { | ||
const text = [ | ||
'The quick brown fox jumps over +33 1 75 00 00 00.', | ||
'Jackdaws love my big +1 415 999 7279 of quartz.', | ||
'Pack my 781.438.3200 with five dozen liquor jugs.' | ||
].join(' '); | ||
const result = parsing_1.parseText(text, 'US'); | ||
expect(result.map(foundNumber => foundNumber.number.number)).toEqual([ | ||
'+33175000000', | ||
'+14159997279', | ||
'+17814383200' | ||
]); | ||
}); | ||
}); | ||
}); | ||
//# sourceMappingURL=parsing.spec.js.map |
{ | ||
"name": "@aircall/numbers", | ||
"version": "0.2.4", | ||
"version": "0.2.5", | ||
"main": "dist/index.js", | ||
@@ -14,3 +14,3 @@ "types": "dist/index.d.ts", | ||
}, | ||
"gitHead": "4d0c82e0a9c84f02df3b66826946e2fc4cbe6bed", | ||
"gitHead": "c9aacc7034b4ae69f927c08dc4d0e0299980e03c", | ||
"dependencies": { | ||
@@ -17,0 +17,0 @@ "libphonenumber-js": "1.7.49" |
import { Country } from './countries'; | ||
export const PHONE_NUMBER_CARACTER_REGEXP = /^\+?[\s|\d|(|)|||\-|/]*$/; | ||
export const PHONE_NUMBER_MATCH_REGEXP = /(\+?[\s|\d|(|).|||\-|/]*)/g; | ||
@@ -5,0 +6,0 @@ export const COUNTRIES: Country[] = [ |
import { ParseError } from 'libphonenumber-js'; | ||
import { CountryCode } from './countries'; | ||
import { getCountryCode, guessCountryCode, parseNumber, parsePartialPhoneNumber } from './parsing'; | ||
import { | ||
getCountryCode, | ||
guessCountryCode, | ||
parseNumber, | ||
parsePartialPhoneNumber, | ||
parseText | ||
} from './parsing'; | ||
@@ -304,2 +310,20 @@ describe('Parsing', () => { | ||
}); | ||
describe('parseText', () => { | ||
it('parses the text and returns found numbers', () => { | ||
const text = [ | ||
'The quick brown fox jumps over +33 1 75 00 00 00.', | ||
'Jackdaws love my big +1 415 999 7279 of quartz.', | ||
'Pack my 781.438.3200 with five dozen liquor jugs.' | ||
].join(' '); | ||
const result = parseText(text, 'US'); | ||
expect(result.map(foundNumber => foundNumber.number.number)).toEqual([ | ||
'+33175000000', | ||
'+14159997279', | ||
'+17814383200' | ||
]); | ||
}); | ||
}); | ||
}); |
import { | ||
AsYouType, | ||
findPhoneNumbersInText, | ||
getCountryCallingCode, | ||
parsePhoneNumber, | ||
PhoneNumber as LibPhonenumberPhoneNumber | ||
PhoneNumber as LibPhonenumberPhoneNumber, | ||
NumberFound as LibPhonenumberNumberFound | ||
} from 'libphonenumber-js/max'; | ||
@@ -17,2 +19,3 @@ | ||
export type PhoneNumber = LibPhonenumberPhoneNumber; | ||
export type NumberFound = LibPhonenumberNumberFound; | ||
@@ -176,1 +179,13 @@ /** | ||
} | ||
/** | ||
* Parses text for phone numbers | ||
* | ||
* @param text - String to parse | ||
* @param countryCode - Country code to parse the text with (default country) | ||
* | ||
* @returns List of found phone numbers | ||
*/ | ||
export function parseText(text: string, countryCode: CountryCode): NumberFound[] { | ||
return findPhoneNumbersInText(text, countryCode); | ||
} |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
508328
4914