extra-utils 5.5.1 → 5.5.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/README.md CHANGED
@@ -192,11 +192,11 @@ removeTrailingBlankLines(
192
192
  ### Enum
193
193
  ```ts
194
194
  function inEnum<T extends Record<string, string | number>>(
195
- val: string | number
195
+ val: unknown
196
196
  , _enum: T
197
197
  ): val is T[keyof T]
198
198
  function notInEnum(
199
- val: string | number
199
+ val: unknown
200
200
  , _enum: Record<string, string | number>
201
201
  ): boolean
202
202
 
@@ -1,2 +1,2 @@
1
- export declare function inEnum<T extends Record<string, string | number>>(val: string | number, _enum: T): val is T[keyof T];
2
- export declare function notInEnum(val: string | number, _enum: Record<string, string | number>): boolean;
1
+ export declare function inEnum<T extends Record<string, string | number>>(val: unknown, _enum: T): val is T[keyof T];
2
+ export declare function notInEnum(val: unknown, _enum: Record<string, string | number>): boolean;
@@ -1 +1 @@
1
- {"version":3,"file":"in-enum.js","sourceRoot":"","sources":["../../src/enum/in-enum.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,kBAAkB,CAAA;AAE7C,MAAM,UAAU,MAAM,CACpB,GAAoB,EACpB,KAAQ;IAER,OAAO,UAAU,CAAC,KAAK,CAAC,CAAC,QAAQ,CAAC,GAAiB,CAAC,CAAA;AACtD,CAAC;AAGD,MAAM,UAAU,SAAS,CACvB,GAAoB,EACpB,KAAsC;IAEtC,OAAO,CAAC,MAAM,CAAC,GAAG,EAAE,KAAK,CAAC,CAAA;AAC5B,CAAC"}
1
+ {"version":3,"file":"in-enum.js","sourceRoot":"","sources":["../../src/enum/in-enum.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,kBAAkB,CAAA;AAE7C,MAAM,UAAU,MAAM,CACpB,GAAY,EACZ,KAAQ;IAER,OAAO,UAAU,CAAC,KAAK,CAAC,CAAC,QAAQ,CAAC,GAAiB,CAAC,CAAA;AACtD,CAAC;AAGD,MAAM,UAAU,SAAS,CACvB,GAAY,EACZ,KAAsC;IAEtC,OAAO,CAAC,MAAM,CAAC,GAAG,EAAE,KAAK,CAAC,CAAA;AAC5B,CAAC"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "extra-utils",
3
- "version": "5.5.1",
3
+ "version": "5.5.2",
4
4
  "description": "Utilities for JavaScript and Typescript",
5
5
  "files": [
6
6
  "src",
@@ -1,7 +1,7 @@
1
1
  import { enumValues } from './enum-values.js'
2
2
 
3
3
  export function inEnum<T extends Record<string, string | number>>(
4
- val: string | number
4
+ val: unknown
5
5
  , _enum: T
6
6
  ): val is T[keyof T] {
7
7
  return enumValues(_enum).includes(val as T[keyof T])
@@ -9,7 +9,7 @@ export function inEnum<T extends Record<string, string | number>>(
9
9
 
10
10
  // 由于TypeScript无法从string | number里精确排除掉枚举类型, 因此返回值为boolean.
11
11
  export function notInEnum(
12
- val: string | number
12
+ val: unknown
13
13
  , _enum: Record<string, string | number>
14
14
  ): boolean {
15
15
  return !inEnum(val, _enum)