libphonenumber-js 1.10.51 → 1.10.53

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -1070,15 +1070,34 @@ getExtPrefix('US') === ' ext. '
1070
1070
  getExtPrefix('GB') === ' x'
1071
1071
  ```
1072
1072
 
1073
- <!--
1074
- ### parsePhoneNumberCharacter(nextCharacter, prevParsedCharacters)
1073
+ ### parseDigits(text: string): string
1074
+
1075
+ Parses digits from string. Can be used for building a phone number extension input component (e.g. [react-phone-number-input](https://gitlab.com/catamphetamine/react-phone-number-input/)).
1076
+
1077
+ ```js
1078
+ parseDigits('x123') === '123'
1079
+ parseDigits('٤٤٢٣') === '4423'
1080
+ ```
1081
+
1082
+ ### parseIncompletePhoneNumber(text: string): string
1083
+
1084
+ Parses phone number characters (`+` and digits). Can be used for building a phone number input component (e.g. [react-phone-number-input](https://gitlab.com/catamphetamine/react-phone-number-input/)).
1085
+
1086
+ ```js
1087
+ parseIncompletePhoneNumber('8 (800) 555') === '8800555'
1088
+ parseIncompletePhoneNumber('+7 800 555') === '+7800555'
1089
+ parseIncompletePhoneNumber('+٤٤٢٣٢٣٢٣٤') === '+442323234'
1090
+ ```
1075
1091
 
1076
- Parses next character while parsing phone number digits (including a `+`) from text: discards everything except `+` and digits, and `+` is only allowed at the start of a phone number.
1092
+ ### parsePhoneNumberCharacter(nextCharacter, prevParsedCharacters, emitEvent?)
1077
1093
 
1078
- For example, is used in [`input-format`](https://gitlab.com/catamphetamine/input-format).
1094
+ Parses next character of an input string while parsing phone number digits (including a `+`) from that string. Basically, it discards everything except `+` and digits, and `+` is only allowed at the start of a phone number.
1095
+
1096
+ This function is a low-level one that is currently only used in [`react-phone-number-input`](https://gitlab.com/catamphetamine/react-phone-number-input) with [`input-format`](https://gitlab.com/catamphetamine/input-format). Frankly speaking, that's the only reason why this function is exported. Other developers should just ignore it and use `parseIncompletePhoneNumber()` instead because it's much simpler.
1079
1097
 
1080
1098
  ```js
1081
- // Suppose a user inputs "+1 (213) 373-42-53".
1099
+ // Suppose a user inputs a "+1 (213) 373-42-53" string
1100
+ // and it starts parsing that string character-by-character.
1082
1101
 
1083
1102
  parsePhoneNumberCharacter('+', undefined) === '+'
1084
1103
  parsePhoneNumberCharacter('1', '+') === '1'
@@ -1099,26 +1118,10 @@ parsePhoneNumberCharacter('-', '+12133734') === undefined
1099
1118
  parsePhoneNumberCharacter('5', '+121337342') === '5'
1100
1119
  parsePhoneNumberCharacter('3', '+1213373425') === '3'
1101
1120
  ```
1102
- -->
1103
-
1104
- ### parseDigits(text: string): string
1105
-
1106
- Parses digits from string. Can be used for building a phone number extension input component (e.g. [react-phone-number-input](https://gitlab.com/catamphetamine/react-phone-number-input/)).
1107
1121
 
1108
- ```js
1109
- parseDigits('x123') === '123'
1110
- parseDigits('٤٤٢٣') === '4423'
1111
- ```
1122
+ So basically, it's the same as `parseIncompletePhoneNumber()` with the only difference that it operates at a character-by-character level rather than at a string-as-a-whole level.
1112
1123
 
1113
- ### parseIncompletePhoneNumber(text: string): string
1114
-
1115
- Parses phone number characters (`+` and digits). Can be used for building a phone number input component (e.g. [react-phone-number-input](https://gitlab.com/catamphetamine/react-phone-number-input/)).
1116
-
1117
- ```js
1118
- parseIncompletePhoneNumber('8 (800) 555') === '8800555'
1119
- parseIncompletePhoneNumber('+7 800 555') === '+7800555'
1120
- parseIncompletePhoneNumber('+٤٤٢٣٢٣٢٣٤') === '+442323234'
1121
- ```
1124
+ The optional `emitEvent` argument is a function of `(eventName: string)` arguments. It will be called in a situation when the application should stop parsing the input string. Currently, the only situation when that could happen is when it encounters an "out-of-place" `+` character. For example, when parsing a `"+1 (234) + 56-78"` string it would emit an `"end"` event at the second `+` character so that the application would return `"+1234"` rather than `"+12345678"`.
1122
1125
 
1123
1126
  ### formatIncompletePhoneNumber(value: string, defaultCountry?: string | options?: object): string
1124
1127
 
@@ -52,17 +52,32 @@ function parseIncompletePhoneNumber(string) {
52
52
  * [`input-format`](https://gitlab.com/catamphetamine/input-format).
53
53
  * @param {string} character - Yet another character from raw input string.
54
54
  * @param {string?} prevParsedCharacters - Previous parsed characters.
55
- * @param {object} meta - Optional custom use-case-specific metadata.
55
+ * @param {function?} emitEvent - An optional "emit event" function.
56
56
  * @return {string?} The parsed character.
57
57
  */
58
58
 
59
59
 
60
- function parsePhoneNumberCharacter(character, prevParsedCharacters) {
60
+ function parsePhoneNumberCharacter(character, prevParsedCharacters, emitEvent) {
61
61
  // Only allow a leading `+`.
62
62
  if (character === '+') {
63
63
  // If this `+` is not the first parsed character
64
64
  // then discard it.
65
65
  if (prevParsedCharacters) {
66
+ // `emitEvent` argument was added to this `export`ed function on Dec 26th, 2023.
67
+ // Any 3rd-party code that used to `import` and call this function before that
68
+ // won't be passing any `emitEvent` argument.
69
+ //
70
+ // The addition of the `emitEvent` argument was to fix the slightly-weird behavior
71
+ // of parsing an input string when the user inputs something like `"2+7"
72
+ // https://github.com/catamphetamine/react-phone-number-input/issues/437
73
+ //
74
+ // If the parser encounters an unexpected `+` in a string being parsed
75
+ // then it simply discards that out-of-place `+` and any following characters.
76
+ //
77
+ if (typeof emitEvent === 'function') {
78
+ emitEvent('end');
79
+ }
80
+
66
81
  return;
67
82
  }
68
83
 
@@ -1 +1 @@
1
- {"version":3,"file":"parseIncompletePhoneNumber.js","names":["parseIncompletePhoneNumber","string","result","split","character","parsePhoneNumberCharacter","prevParsedCharacters","parseDigit"],"sources":["../source/parseIncompletePhoneNumber.js"],"sourcesContent":["import { parseDigit } from './helpers/parseDigits.js'\r\n\r\n/**\r\n * Parses phone number characters from a string.\r\n * Drops all punctuation leaving only digits and the leading `+` sign (if any).\r\n * Also converts wide-ascii and arabic-indic numerals to conventional numerals.\r\n * E.g. in Iraq they don't write `+442323234` but rather `+٤٤٢٣٢٣٢٣٤`.\r\n * @param {string} string\r\n * @return {string}\r\n * @example\r\n * ```js\r\n * // Outputs '8800555'.\r\n * parseIncompletePhoneNumber('8 (800) 555')\r\n * // Outputs '+7800555'.\r\n * parseIncompletePhoneNumber('+7 800 555')\r\n * ```\r\n */\r\nexport default function parseIncompletePhoneNumber(string) {\r\n\tlet result = ''\r\n\t// Using `.split('')` here instead of normal `for ... of`\r\n\t// because the importing application doesn't neccessarily include an ES6 polyfill.\r\n\t// The `.split('')` approach discards \"exotic\" UTF-8 characters\r\n\t// (the ones consisting of four bytes) but digits\r\n\t// (including non-European ones) don't fall into that range\r\n\t// so such \"exotic\" characters would be discarded anyway.\r\n\tfor (const character of string.split('')) {\r\n\t\tresult += parsePhoneNumberCharacter(character, result) || ''\r\n\t}\r\n\treturn result\r\n}\r\n\r\n/**\r\n * Parses next character while parsing phone number digits (including a `+`)\r\n * from text: discards everything except `+` and digits, and `+` is only allowed\r\n * at the start of a phone number.\r\n * For example, is used in `react-phone-number-input` where it uses\r\n * [`input-format`](https://gitlab.com/catamphetamine/input-format).\r\n * @param {string} character - Yet another character from raw input string.\r\n * @param {string?} prevParsedCharacters - Previous parsed characters.\r\n * @param {object} meta - Optional custom use-case-specific metadata.\r\n * @return {string?} The parsed character.\r\n */\r\nexport function parsePhoneNumberCharacter(character, prevParsedCharacters) {\r\n\t// Only allow a leading `+`.\r\n\tif (character === '+') {\r\n\t\t// If this `+` is not the first parsed character\r\n\t\t// then discard it.\r\n\t\tif (prevParsedCharacters) {\r\n\t\t\treturn\r\n\t\t}\r\n\t\treturn '+'\r\n\t}\r\n\t// Allow digits.\r\n\treturn parseDigit(character)\r\n}"],"mappings":";;;;;;;;AAAA;;;;;;;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACe,SAASA,0BAAT,CAAoCC,MAApC,EAA4C;EAC1D,IAAIC,MAAM,GAAG,EAAb,CAD0D,CAE1D;EACA;EACA;EACA;EACA;EACA;;EACA,qDAAwBD,MAAM,CAACE,KAAP,CAAa,EAAb,CAAxB,wCAA0C;IAAA,IAA/BC,SAA+B;IACzCF,MAAM,IAAIG,yBAAyB,CAACD,SAAD,EAAYF,MAAZ,CAAzB,IAAgD,EAA1D;EACA;;EACD,OAAOA,MAAP;AACA;AAED;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;;AACO,SAASG,yBAAT,CAAmCD,SAAnC,EAA8CE,oBAA9C,EAAoE;EAC1E;EACA,IAAIF,SAAS,KAAK,GAAlB,EAAuB;IACtB;IACA;IACA,IAAIE,oBAAJ,EAA0B;MACzB;IACA;;IACD,OAAO,GAAP;EACA,CATyE,CAU1E;;;EACA,OAAO,IAAAC,uBAAA,EAAWH,SAAX,CAAP;AACA"}
1
+ {"version":3,"file":"parseIncompletePhoneNumber.js","names":["parseIncompletePhoneNumber","string","result","split","character","parsePhoneNumberCharacter","prevParsedCharacters","emitEvent","parseDigit"],"sources":["../source/parseIncompletePhoneNumber.js"],"sourcesContent":["import { parseDigit } from './helpers/parseDigits.js'\r\n\r\n/**\r\n * Parses phone number characters from a string.\r\n * Drops all punctuation leaving only digits and the leading `+` sign (if any).\r\n * Also converts wide-ascii and arabic-indic numerals to conventional numerals.\r\n * E.g. in Iraq they don't write `+442323234` but rather `+٤٤٢٣٢٣٢٣٤`.\r\n * @param {string} string\r\n * @return {string}\r\n * @example\r\n * ```js\r\n * // Outputs '8800555'.\r\n * parseIncompletePhoneNumber('8 (800) 555')\r\n * // Outputs '+7800555'.\r\n * parseIncompletePhoneNumber('+7 800 555')\r\n * ```\r\n */\r\nexport default function parseIncompletePhoneNumber(string) {\r\n\tlet result = ''\r\n\t// Using `.split('')` here instead of normal `for ... of`\r\n\t// because the importing application doesn't neccessarily include an ES6 polyfill.\r\n\t// The `.split('')` approach discards \"exotic\" UTF-8 characters\r\n\t// (the ones consisting of four bytes) but digits\r\n\t// (including non-European ones) don't fall into that range\r\n\t// so such \"exotic\" characters would be discarded anyway.\r\n\tfor (const character of string.split('')) {\r\n\t\tresult += parsePhoneNumberCharacter(character, result) || ''\r\n\t}\r\n\treturn result\r\n}\r\n\r\n/**\r\n * Parses next character while parsing phone number digits (including a `+`)\r\n * from text: discards everything except `+` and digits, and `+` is only allowed\r\n * at the start of a phone number.\r\n * For example, is used in `react-phone-number-input` where it uses\r\n * [`input-format`](https://gitlab.com/catamphetamine/input-format).\r\n * @param {string} character - Yet another character from raw input string.\r\n * @param {string?} prevParsedCharacters - Previous parsed characters.\r\n * @param {function?} emitEvent - An optional \"emit event\" function.\r\n * @return {string?} The parsed character.\r\n */\r\nexport function parsePhoneNumberCharacter(character, prevParsedCharacters, emitEvent) {\r\n\t// Only allow a leading `+`.\r\n\tif (character === '+') {\r\n\t\t// If this `+` is not the first parsed character\r\n\t\t// then discard it.\r\n\t\tif (prevParsedCharacters) {\r\n\t\t\t// `emitEvent` argument was added to this `export`ed function on Dec 26th, 2023.\r\n\t\t\t// Any 3rd-party code that used to `import` and call this function before that\r\n\t\t\t// won't be passing any `emitEvent` argument.\r\n\t\t\t//\r\n\t\t\t// The addition of the `emitEvent` argument was to fix the slightly-weird behavior\r\n\t\t\t// of parsing an input string when the user inputs something like `\"2+7\"\r\n\t\t\t// https://github.com/catamphetamine/react-phone-number-input/issues/437\r\n\t\t\t//\r\n\t\t\t// If the parser encounters an unexpected `+` in a string being parsed\r\n\t\t\t// then it simply discards that out-of-place `+` and any following characters.\r\n\t\t\t//\r\n\t\t\tif (typeof emitEvent === 'function') {\r\n\t\t\t\temitEvent('end')\r\n\t\t\t}\r\n\t\t\treturn\r\n\t\t}\r\n\t\treturn '+'\r\n\t}\r\n\t// Allow digits.\r\n\treturn parseDigit(character)\r\n}"],"mappings":";;;;;;;;AAAA;;;;;;;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACe,SAASA,0BAAT,CAAoCC,MAApC,EAA4C;EAC1D,IAAIC,MAAM,GAAG,EAAb,CAD0D,CAE1D;EACA;EACA;EACA;EACA;EACA;;EACA,qDAAwBD,MAAM,CAACE,KAAP,CAAa,EAAb,CAAxB,wCAA0C;IAAA,IAA/BC,SAA+B;IACzCF,MAAM,IAAIG,yBAAyB,CAACD,SAAD,EAAYF,MAAZ,CAAzB,IAAgD,EAA1D;EACA;;EACD,OAAOA,MAAP;AACA;AAED;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;;AACO,SAASG,yBAAT,CAAmCD,SAAnC,EAA8CE,oBAA9C,EAAoEC,SAApE,EAA+E;EACrF;EACA,IAAIH,SAAS,KAAK,GAAlB,EAAuB;IACtB;IACA;IACA,IAAIE,oBAAJ,EAA0B;MACzB;MACA;MACA;MACA;MACA;MACA;MACA;MACA;MACA;MACA;MACA;MACA,IAAI,OAAOC,SAAP,KAAqB,UAAzB,EAAqC;QACpCA,SAAS,CAAC,KAAD,CAAT;MACA;;MACD;IACA;;IACD,OAAO,GAAP;EACA,CAvBoF,CAwBrF;;;EACA,OAAO,IAAAC,uBAAA,EAAWJ,SAAX,CAAP;AACA"}
@@ -32,5 +32,43 @@ describe('parseIncompletePhoneNumber', function () {
32
32
 
33
33
  (0, _parseIncompletePhoneNumber["default"])('+٤٤٢٣٢٣٢٣٤').should.equal('+442323234');
34
34
  });
35
+ it('should work with a new `context` argument in `parsePhoneNumberCharacter()` function (international number)', function () {
36
+ var stopped = false;
37
+
38
+ var emit = function emit(event) {
39
+ switch (event) {
40
+ case 'end':
41
+ stopped = true;
42
+ break;
43
+ }
44
+ };
45
+
46
+ (0, _parseIncompletePhoneNumber.parsePhoneNumberCharacter)('+', undefined, emit).should.equal('+');
47
+ expect(stopped).to.equal(false);
48
+ (0, _parseIncompletePhoneNumber.parsePhoneNumberCharacter)('1', '+', emit).should.equal('1');
49
+ expect(stopped).to.equal(false);
50
+ expect((0, _parseIncompletePhoneNumber.parsePhoneNumberCharacter)('+', '+1', emit)).to.equal(undefined);
51
+ expect(stopped).to.equal(true);
52
+ expect((0, _parseIncompletePhoneNumber.parsePhoneNumberCharacter)('2', '+1', emit)).to.equal('2');
53
+ expect(stopped).to.equal(true);
54
+ });
55
+ it('should work with a new `context` argument in `parsePhoneNumberCharacter()` function (national number)', function () {
56
+ var stopped = false;
57
+
58
+ var emit = function emit(event) {
59
+ switch (event) {
60
+ case 'end':
61
+ stopped = true;
62
+ break;
63
+ }
64
+ };
65
+
66
+ (0, _parseIncompletePhoneNumber.parsePhoneNumberCharacter)('2', undefined, emit).should.equal('2');
67
+ expect(stopped).to.equal(false);
68
+ expect((0, _parseIncompletePhoneNumber.parsePhoneNumberCharacter)('+', '2', emit)).to.equal(undefined);
69
+ expect(stopped).to.equal(true);
70
+ expect((0, _parseIncompletePhoneNumber.parsePhoneNumberCharacter)('1', '2', emit)).to.equal('1');
71
+ expect(stopped).to.equal(true);
72
+ });
35
73
  });
36
74
  //# sourceMappingURL=parseIncompletePhoneNumber.test.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"parseIncompletePhoneNumber.test.js","names":["describe","it","parsePhoneNumberCharacter","should","equal","expect","to","be","undefined","parseIncompletePhoneNumber"],"sources":["../source/parseIncompletePhoneNumber.test.js"],"sourcesContent":["import parseIncompletePhoneNumber, { parsePhoneNumberCharacter } from './parseIncompletePhoneNumber.js'\r\n\r\ndescribe('parseIncompletePhoneNumber', () => {\r\n\tit('should parse phone number character', () => {\r\n\t\t// Accepts leading `+`.\r\n\t\tparsePhoneNumberCharacter('+').should.equal('+')\r\n\r\n\t\t// Doesn't accept non-leading `+`.\r\n\t\texpect(parsePhoneNumberCharacter('+', '+')).to.be.undefined\r\n\r\n\t\t// Parses digits.\r\n\t\tparsePhoneNumberCharacter('1').should.equal('1')\r\n\r\n\t\t// Parses non-European digits.\r\n\t\tparsePhoneNumberCharacter('٤').should.equal('4')\r\n\r\n\t\t// Dismisses other characters.\r\n\t\texpect(parsePhoneNumberCharacter('-')).to.be.undefined\r\n\t})\r\n\r\n\tit('should parse incomplete phone number', () => {\r\n\t\tparseIncompletePhoneNumber('').should.equal('')\r\n\r\n\t\t// Doesn't accept non-leading `+`.\r\n\t\tparseIncompletePhoneNumber('++').should.equal('+')\r\n\r\n\t\t// Accepts leading `+`.\r\n\t\tparseIncompletePhoneNumber('+7 800 555').should.equal('+7800555')\r\n\r\n\t\t// Parses digits.\r\n\t\tparseIncompletePhoneNumber('8 (800) 555').should.equal('8800555')\r\n\r\n\t\t// Parses non-European digits.\r\n\t\tparseIncompletePhoneNumber('+٤٤٢٣٢٣٢٣٤').should.equal('+442323234')\r\n\t})\r\n})"],"mappings":";;;;AAAA;;;;;;AAEAA,QAAQ,CAAC,4BAAD,EAA+B,YAAM;EAC5CC,EAAE,CAAC,qCAAD,EAAwC,YAAM;IAC/C;IACA,IAAAC,qDAAA,EAA0B,GAA1B,EAA+BC,MAA/B,CAAsCC,KAAtC,CAA4C,GAA5C,EAF+C,CAI/C;;IACAC,MAAM,CAAC,IAAAH,qDAAA,EAA0B,GAA1B,EAA+B,GAA/B,CAAD,CAAN,CAA4CI,EAA5C,CAA+CC,EAA/C,CAAkDC,SAAlD,CAL+C,CAO/C;;IACA,IAAAN,qDAAA,EAA0B,GAA1B,EAA+BC,MAA/B,CAAsCC,KAAtC,CAA4C,GAA5C,EAR+C,CAU/C;;IACA,IAAAF,qDAAA,EAA0B,GAA1B,EAA+BC,MAA/B,CAAsCC,KAAtC,CAA4C,GAA5C,EAX+C,CAa/C;;IACAC,MAAM,CAAC,IAAAH,qDAAA,EAA0B,GAA1B,CAAD,CAAN,CAAuCI,EAAvC,CAA0CC,EAA1C,CAA6CC,SAA7C;EACA,CAfC,CAAF;EAiBAP,EAAE,CAAC,sCAAD,EAAyC,YAAM;IAChD,IAAAQ,sCAAA,EAA2B,EAA3B,EAA+BN,MAA/B,CAAsCC,KAAtC,CAA4C,EAA5C,EADgD,CAGhD;;IACA,IAAAK,sCAAA,EAA2B,IAA3B,EAAiCN,MAAjC,CAAwCC,KAAxC,CAA8C,GAA9C,EAJgD,CAMhD;;IACA,IAAAK,sCAAA,EAA2B,YAA3B,EAAyCN,MAAzC,CAAgDC,KAAhD,CAAsD,UAAtD,EAPgD,CAShD;;IACA,IAAAK,sCAAA,EAA2B,aAA3B,EAA0CN,MAA1C,CAAiDC,KAAjD,CAAuD,SAAvD,EAVgD,CAYhD;;IACA,IAAAK,sCAAA,EAA2B,YAA3B,EAAyCN,MAAzC,CAAgDC,KAAhD,CAAsD,YAAtD;EACA,CAdC,CAAF;AAeA,CAjCO,CAAR"}
1
+ {"version":3,"file":"parseIncompletePhoneNumber.test.js","names":["describe","it","parsePhoneNumberCharacter","should","equal","expect","to","be","undefined","parseIncompletePhoneNumber","stopped","emit","event"],"sources":["../source/parseIncompletePhoneNumber.test.js"],"sourcesContent":["import parseIncompletePhoneNumber, { parsePhoneNumberCharacter } from './parseIncompletePhoneNumber.js'\r\n\r\ndescribe('parseIncompletePhoneNumber', () => {\r\n\tit('should parse phone number character', () => {\r\n\t\t// Accepts leading `+`.\r\n\t\tparsePhoneNumberCharacter('+').should.equal('+')\r\n\r\n\t\t// Doesn't accept non-leading `+`.\r\n\t\texpect(parsePhoneNumberCharacter('+', '+')).to.be.undefined\r\n\r\n\t\t// Parses digits.\r\n\t\tparsePhoneNumberCharacter('1').should.equal('1')\r\n\r\n\t\t// Parses non-European digits.\r\n\t\tparsePhoneNumberCharacter('٤').should.equal('4')\r\n\r\n\t\t// Dismisses other characters.\r\n\t\texpect(parsePhoneNumberCharacter('-')).to.be.undefined\r\n\t})\r\n\r\n\tit('should parse incomplete phone number', () => {\r\n\t\tparseIncompletePhoneNumber('').should.equal('')\r\n\r\n\t\t// Doesn't accept non-leading `+`.\r\n\t\tparseIncompletePhoneNumber('++').should.equal('+')\r\n\r\n\t\t// Accepts leading `+`.\r\n\t\tparseIncompletePhoneNumber('+7 800 555').should.equal('+7800555')\r\n\r\n\t\t// Parses digits.\r\n\t\tparseIncompletePhoneNumber('8 (800) 555').should.equal('8800555')\r\n\r\n\t\t// Parses non-European digits.\r\n\t\tparseIncompletePhoneNumber('+٤٤٢٣٢٣٢٣٤').should.equal('+442323234')\r\n\t})\r\n\r\n\tit('should work with a new `context` argument in `parsePhoneNumberCharacter()` function (international number)', () => {\r\n\t\tlet stopped = false\r\n\r\n\t\tconst emit = (event) => {\r\n\t\t\tswitch (event) {\r\n\t\t\t\tcase 'end':\r\n\t\t\t\t\tstopped = true\r\n\t\t\t\t\tbreak\r\n\t\t\t}\r\n\t\t}\r\n\r\n\t\tparsePhoneNumberCharacter('+', undefined, emit).should.equal('+')\r\n\t\texpect(stopped).to.equal(false)\r\n\r\n\t\tparsePhoneNumberCharacter('1', '+', emit).should.equal('1')\r\n\t\texpect(stopped).to.equal(false)\r\n\r\n\t\texpect(parsePhoneNumberCharacter('+', '+1', emit)).to.equal(undefined)\r\n\t\texpect(stopped).to.equal(true)\r\n\r\n\t\texpect(parsePhoneNumberCharacter('2', '+1', emit)).to.equal('2')\r\n\t\texpect(stopped).to.equal(true)\r\n\t})\r\n\r\n\tit('should work with a new `context` argument in `parsePhoneNumberCharacter()` function (national number)', () => {\r\n\t\tlet stopped = false\r\n\r\n\t\tconst emit = (event) => {\r\n\t\t\tswitch (event) {\r\n\t\t\t\tcase 'end':\r\n\t\t\t\t\tstopped = true\r\n\t\t\t\t\tbreak\r\n\t\t\t}\r\n\t\t}\r\n\r\n\t\tparsePhoneNumberCharacter('2', undefined, emit).should.equal('2')\r\n\t\texpect(stopped).to.equal(false)\r\n\r\n\t\texpect(parsePhoneNumberCharacter('+', '2', emit)).to.equal(undefined)\r\n\t\texpect(stopped).to.equal(true)\r\n\r\n\t\texpect(parsePhoneNumberCharacter('1', '2', emit)).to.equal('1')\r\n\t\texpect(stopped).to.equal(true)\r\n\t})\r\n})"],"mappings":";;;;AAAA;;;;;;AAEAA,QAAQ,CAAC,4BAAD,EAA+B,YAAM;EAC5CC,EAAE,CAAC,qCAAD,EAAwC,YAAM;IAC/C;IACA,IAAAC,qDAAA,EAA0B,GAA1B,EAA+BC,MAA/B,CAAsCC,KAAtC,CAA4C,GAA5C,EAF+C,CAI/C;;IACAC,MAAM,CAA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