cafe-utility 4.7.2 → 4.7.3

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.
Files changed (3) hide show
  1. package/index.d.ts +1 -1
  2. package/index.js +3 -2
  3. package/package.json +1 -1
package/index.d.ts CHANGED
@@ -58,7 +58,7 @@ declare function isString(value: any): value is string;
58
58
  declare function isNumber(value: any): value is number;
59
59
  declare function isDate(value: any): value is Date;
60
60
  declare function isBlank(value: any): boolean;
61
- declare function isId(value: any): value is number;
61
+ declare function isId(value: any): value is number | string;
62
62
  declare function randomLetterString(length: number): string;
63
63
  declare function randomAlphanumericString(length: number): string;
64
64
  declare function randomRichAsciiString(length: number): string;
package/index.js CHANGED
@@ -382,7 +382,8 @@ function isBlank(value) {
382
382
  }
383
383
 
384
384
  function isId(value) {
385
- return Number.isInteger(value) && value >= 1
385
+ const numeric = typeof value === 'string' ? parseInt(value, 10) : value
386
+ return Number.isInteger(numeric) && numeric >= 1
386
387
  }
387
388
 
388
389
  const alphabet = 'abcdefghijklmnopqrstuvwxyz'
@@ -462,7 +463,7 @@ function asId(value) {
462
463
  if (!isId(value)) {
463
464
  throw new TypeError('Expected id, got: ' + value)
464
465
  }
465
- return value
466
+ return typeof value === 'string' ? parseInt(value, 10) : value
466
467
  }
467
468
 
468
469
  function represent(value) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "cafe-utility",
3
- "version": "4.7.2",
3
+ "version": "4.7.3",
4
4
  "description": "",
5
5
  "main": "index.js",
6
6
  "exports": {