@beenotung/tslib
Version:
utils library in Typescript
155 lines (154 loc) • 5.09 kB
TypeScript
/** ********************************
* Combined for multiple countries *
***********************************/
export declare function is_mobile_phone(tel: number | string): boolean;
/**
* check if the tel is mobile phone number in:
* - HK (Hong Kong)
* - SG (Singapore)
* - AU (Australia)
* - CN (China Mainland)
* - MO (Macau)
*
* @returns the full tel number with country code, or empty string if not valid
*/
export declare function to_full_mobile_phone(tel: string | number): string;
/**
* format the mobile phone number with pattern if valid:
* - HK: +852 xxxx yyyy
* - SG: +65 xxxx yyyy
* - AU: +61 4xx xxx xxx
* - CN: +86 1nn xxxx xxxx
* - MO: +853 xxxx yyyy
*/
export declare function format_mobile_phone(tel: string | number): string;
/** ******************************
* Hong Kong mobile phone number *
*********************************/
/**
* 4, 7, 8 heading are allowed since 2018
* news: https://skypost.ulifestyle.com.hk/article/2006268/
* */
export declare function is_hk_mobile_phone_prefix(tel: string): boolean;
/**
* with/without +852 prefix
* */
export declare function is_hk_mobile_phone(tel: number | string): boolean;
/**
* very forgiving
*
* @return +852xxxxyyyy if valid
* empty string if not valid
* */
export declare function to_full_hk_mobile_phone(tel: string | number): string;
/**
* @returns +852 xxxx yyyy if valid
*/
export declare function format_hk_mobile_phone(tel: string | number): string;
/** ******************************
* Singapore mobile phone number *
*********************************/
/**
* starts with 8, 9
* reference: https://en.wikipedia.org/wiki/Telephone_numbers_in_Singapore
*/
export declare function is_sg_mobile_phone_prefix(tel: string): boolean;
/**
* with/without +65 prefix
*/
export declare function is_sg_mobile_phone(tel: number | string): boolean;
/**
* very forgiving
*
* @returns +65xxxxyyyy if valid
* empty string if not valid
*/
export declare function to_full_sg_mobile_phone(tel: string | number): string;
/**
* @returns +65 xxxx yyyy if valid
*/
export declare function format_sg_mobile_phone(tel: string | number): string;
/** ******************************
* Australia mobile phone number *
*********************************/
export declare function is_au_mobile_phone_prefix(tel: string): boolean;
/**
* with/without +61 prefix
*/
export declare function is_au_mobile_phone(tel: number | string): boolean;
/**
* landline number example:
* excluding area code: xxxx xxxx
* including area code: (07) xxxx xxxx
* including country and area code: +61 7 xxxx xxxx
* the area code can be 2-digit, being "0x", or 1 digit, being "1"
*
* mobile number example:
* country code: +61
* mobile prefix: e.g. starting with 4 (area and operator code)
* local number: 8 digits
*
* Within Australia, mobile phone numbers begin with 04– the Australian national trunk code 0,
* plus the mobile indicator 4 – followed by eight digits.
*
* This is generally written as 04XX XXX XXX within Australia,
* or as +61 4XX XXX XXX for an international audience.
*
* reference: https://en.wikipedia.org/wiki/Telephone_numbers_in_Australia
*/
export declare function to_full_au_mobile_phone(tel: string | number): string;
export declare function format_au_mobile_phone(tel: string | number): string;
/** **************************
* China mobile phone number *
*****************************/
/**
* starts with 1, second digit is 3,4, 5, 6, 7, 8
* reference: https://en.wikipedia.org/wiki/Telephone_numbers_in_China
*/
export declare function is_cn_mobile_phone_prefix(tel: string): boolean;
/**
* with/without +86 prefix
*/
export declare function is_cn_mobile_phone(tel: number | string): boolean;
/**
* @returns +86xxxxxxxxxx if valid
* empty string if not valid
*
* should be 1xx-XXXX-XXXX (except for 140–144, which are 13-digit IoT numbers)
* in which the first three digits (13x to 19x) designate the mobile phone service provider.
*/
export declare function to_full_cn_mobile_phone(tel: string | number): string;
/**
* @returns +86 1nn xxxx xxxx if valid
*/
export declare function format_cn_mobile_phone(tel: string | number): string;
/** ******************************
* Macau mobile phone number *
*********************************/
/**
* starts with 6
* news: https://en.wikipedia.org/wiki/Telephone_numbers_in_Macau
* */
export declare function is_mo_mobile_phone_prefix(tel: string): boolean;
/**
* with/without +853 prefix
* */
export declare function is_mo_mobile_phone(tel: number | string): boolean;
/**
* very forgiving
*
* @return +853xxxxyyyy if valid
* empty string if not valid
* */
export declare function to_full_mo_mobile_phone(tel: string | number): string;
/**
* @returns +853 xxxx yyyy if valid
*/
export declare function format_mo_mobile_phone(tel: string | number): string;
/** *****************
* helper functions *
********************/
/**
* helper function to format tel with pattern
*/
export declare function format_tel_with_pattern(tel: string, pattern: string): string;