libphonenumber-js 1.11.1 → 1.11.2

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "libphonenumber-js",
3
- "version": "1.11.1",
3
+ "version": "1.11.2",
4
4
  "description": "A simpler (and smaller) rewrite of Google Android's libphonenumber library in javascript",
5
5
  "main": "index.cjs",
6
6
  "module": "index.js",
@@ -260,6 +260,6 @@ describe('format', () => {
260
260
  it('should use the default IDD prefix when formatting a phone number', () => {
261
261
  // Testing preferred international prefixes with ~ are supported.
262
262
  // ("~" designates waiting on a line until proceeding with the input).
263
- formatNumber('+390236618300', 'IDD', { fromCountry: 'UZ' }).should.equal('8~10 39 02 3661 8300')
263
+ formatNumber('+390236618300', 'IDD', { fromCountry: 'BY' }).should.equal('8~10 39 02 3661 8300')
264
264
  })
265
265
  })
@@ -235,6 +235,6 @@ describe('format', () => {
235
235
  it('should use the default IDD prefix when formatting a phone number', () => {
236
236
  // Testing preferred international prefixes with ~ are supported.
237
237
  // ("~" designates waiting on a line until proceeding with the input).
238
- formatNumber('+390236618300', 'IDD', { fromCountry: 'UZ' }).should.equal('8~10 39 02 3661 8300')
238
+ formatNumber('+390236618300', 'IDD', { fromCountry: 'BY' }).should.equal('8~10 39 02 3661 8300')
239
239
  })
240
240
  })
package/types.d.cts CHANGED
@@ -70,21 +70,16 @@ export type NumberType = undefined | 'PREMIUM_RATE' | 'TOLL_FREE' | 'SHARED_COST
70
70
  // Shows an error:
71
71
  // Type 'E164Number' is not assignable to type 'CarrierCode'.
72
72
  //
73
- // The `__tag` property is declared optional in order to allow passing a `string`
74
- // in place of a `Tagged` argument to functions that receive such arguments.
75
- // There currently are no such functions in this package, but in case there were any,
76
- // in their arguments they'd accept both a `string` and the `Tagged` type of the argument.
73
+ // Originally, the `__tag` property was declared optional in order to allow passing
74
+ // a generic `string` in place of a `Tagged` type argument to functions that receive such arguments:
75
+ // that would allow ingesting generic `string` values from an outside source such as a database.
76
+ // Without that, those externally-obtained `string` values would have to be forcefully converted
77
+ // to the `Tagged` type via TypeScript `as` operator which is an anti-pattern.
77
78
  //
78
- // The `__tag` property could also be declared non-optional but what issue would it solve?
79
- // It would disallow assigning a `string` to an `E164Number` variable, but what would be the props of such approach?
80
- // For example, the following code wouldn't compile:
81
- //
82
- // const number: E164Number = "some random text"
83
- //
84
- // But in that case, how would one initialize an `E164Number` variable with a value received from outside?
85
- // For example, a program reads an `E.164` number from a database in the form of a `string`.
86
- // How would it cast it to an `E164Number`? Using `as` keyword?
87
- // In that case it wouldn't really make any difference from allowing it to assign a `string` to a `E164Number` variable directly.
79
+ // Later, it has been decided to make the `__tag` property non-optional and instead
80
+ // declare the arguments of those functions as `string | Tagged` rather than just `Tagged`:
81
+ // that would still allow ingesting generic `string` values from an outside source
82
+ // and would also make the `Tagged` type more "type safe".
88
83
  //
89
84
  type Tagged<A, T> = A & { __tag: T };
90
85
 
package/types.d.ts CHANGED
@@ -70,21 +70,16 @@ export type NumberType = undefined | 'PREMIUM_RATE' | 'TOLL_FREE' | 'SHARED_COST
70
70
  // Shows an error:
71
71
  // Type 'E164Number' is not assignable to type 'CarrierCode'.
72
72
  //
73
- // The `__tag` property is declared optional in order to allow passing a `string`
74
- // in place of a `Tagged` argument to functions that receive such arguments.
75
- // There currently are no such functions in this package, but in case there were any,
76
- // in their arguments they'd accept both a `string` and the `Tagged` type of the argument.
73
+ // Originally, the `__tag` property was declared optional in order to allow passing
74
+ // a generic `string` in place of a `Tagged` type argument to functions that receive such arguments:
75
+ // that would allow ingesting generic `string` values from an outside source such as a database.
76
+ // Without that, those externally-obtained `string` values would have to be forcefully converted
77
+ // to the `Tagged` type via TypeScript `as` operator which is an anti-pattern.
77
78
  //
78
- // The `__tag` property could also be declared non-optional but what issue would it solve?
79
- // It would disallow assigning a `string` to an `E164Number` variable, but what would be the props of such approach?
80
- // For example, the following code wouldn't compile:
81
- //
82
- // const number: E164Number = "some random text"
83
- //
84
- // But in that case, how would one initialize an `E164Number` variable with a value received from outside?
85
- // For example, a program reads an `E.164` number from a database in the form of a `string`.
86
- // How would it cast it to an `E164Number`? Using `as` keyword?
87
- // In that case it wouldn't really make any difference from allowing it to assign a `string` to a `E164Number` variable directly.
79
+ // Later, it has been decided to make the `__tag` property non-optional and instead
80
+ // declare the arguments of those functions as `string | Tagged` rather than just `Tagged`:
81
+ // that would still allow ingesting generic `string` values from an outside source
82
+ // and would also make the `Tagged` type more "type safe".
88
83
  //
89
84
  type Tagged<A, T> = A & { __tag: T };
90
85