[phone] Add allowLandLine parameter from 2.4.0 (#39439)

This commit is contained in:
Tim Brown 2019-11-04 14:25:49 -05:00 committed by Nathan Shively-Sanders
parent f7f7463517
commit 092408150b
2 changed files with 6 additions and 3 deletions

View File

@ -1,7 +1,7 @@
// Type definitions for phone 1.0.8
// Type definitions for phone 2.4.0
// Project: https://github.com/aftership/phone
// Definitions by: Hagai Cohen <https://github.com/DxCx>
// Definitions by: Hagai Cohen <https://github.com/DxCx>, Tim Brown <https://github.com/brimtown>
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
declare function phone(phoneNumber: string, countryCode?: string): Array<string>;
declare function phone(phoneNumber: string, countryCode?: string, allowLandLine?: boolean): Array<string>;
export = phone;

View File

@ -4,6 +4,9 @@ phone('+852 6569-8900'); // return ['+85265698900', 'HKG']
phone('(817) 569-8900'); // return ['+18175698900, 'USA']
phone('(817) 569-8900', ''); // return ['+18175698900, 'USA']
phone('(817) 569-8900', 'USA'); // return ['+18175698900', 'USA']
phone('(555) 569-8900', 'USA'); // return [], as it is not a valid USA mobile phone number
phone('(555) 569-8900', 'USA', false); // return [], as it is not a valid USA mobile phone number
phone('(555) 569-8900', 'USA', true); // return ['+15555698900', 'USA'], as we passed `true` to `allowLandLine`
phone('(817) 569-8900', 'HKG'); // return []
phone('+1(817) 569-8900', 'HKG'); // return [], as it is not a valid HKG mobile phone number
phone('+1(817) 569-8900', ''); // return ['+18175698900', 'USA']