@magic/types 0.1.32 → 0.1.33

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
@@ -380,6 +380,11 @@ update dependencies
380
380
 
381
381
  - add is.symbol, is.sym and isSymbol functions
382
382
 
383
- ##### 0.1.33 - unreleased
383
+ ##### 0.1.33
384
+
385
+ - is.instance now typeguards
386
+ - update dependencies
387
+
388
+ ##### 0.1.34 - unreleased
384
389
 
385
390
  ...
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@magic/types",
3
- "version": "0.1.32",
3
+ "version": "0.1.33",
4
4
  "author": "Wizards & Witches",
5
5
  "homepage": "https://github.com/magic/types",
6
6
  "license": "AGPL-3.0",
@@ -46,8 +46,8 @@
46
46
  "@magic-themes/docs": "0.0.15",
47
47
  "@magic/core": "0.0.156",
48
48
  "@magic/format": "0.0.72",
49
- "@magic/test": "0.2.29",
50
- "typescript": "5.9.3"
49
+ "@magic/test": "0.2.30",
50
+ "typescript": "6.0.2"
51
51
  },
52
52
  "keywords": [
53
53
  "magic",
package/src/fns.js CHANGED
@@ -520,9 +520,10 @@ export const isNone = (arr, t) => !isSome(arr, t)
520
520
 
521
521
  /**
522
522
  * Check if a value is an instance of a given constructor
523
+ * @template T
523
524
  * @param {unknown} e - value to check
524
- * @param {new (...args: any[]) => any} t - constructor function
525
- * @returns {boolean} - true if value is an instance of constructor
525
+ * @param {new (...args: any[]) => T} t - constructor function
526
+ * @returns {e is T} - true if value is an instance of constructor
526
527
  */
527
528
  export const isInstanceOf = (e, t) => (!t ? false : e instanceof t)
528
529
 
package/types/fns.d.ts CHANGED
@@ -140,7 +140,7 @@ export function isComparable(a: unknown): a is string | number | boolean
140
140
  export function isEvery<T>(arr: T | T[], t: ((v: T) => boolean) | string): boolean
141
141
  export function isSome<T>(arr: T | T[], t: ((v: T) => boolean) | string): boolean
142
142
  export function isNone<T>(arr: T | T[], t: ((v: T) => boolean) | string): boolean
143
- export function isInstanceOf(e: unknown, t: new (...args: any[]) => any): boolean
143
+ export function isInstanceOf<T>(e: unknown, t: new (...args: any[]) => T): e is T
144
144
  export function isError(e: unknown): e is Error
145
145
  export function isDate(e: unknown): e is Date
146
146
  export function isRegExp(e: unknown): e is RegExp
package/types/index.d.ts CHANGED
@@ -480,9 +480,9 @@ export const is: {
480
480
  all: <T>(arr: T | T[], t: ((v: T) => boolean) | string) => boolean
481
481
  some: <T>(arr: T | T[], t: ((v: T) => boolean) | string) => boolean
482
482
  none: <T>(arr: T | T[], t: ((v: T) => boolean) | string) => boolean
483
- instance: (e: unknown, t: new (...args: any[]) => any) => boolean
484
- instanceof: (e: unknown, t: new (...args: any[]) => any) => boolean
485
- instanceOf: (e: unknown, t: new (...args: any[]) => any) => boolean
483
+ instance: <T>(e: unknown, t: new (...args: any[]) => T) => e is T
484
+ instanceof: <T>(e: unknown, t: new (...args: any[]) => T) => e is T
485
+ instanceOf: <T>(e: unknown, t: new (...args: any[]) => T) => e is T
486
486
  isCase: ((s: unknown, c?: 'up' | 'down') => boolean) & {
487
487
  upper: (s: unknown) => boolean
488
488
  lower: (s: unknown) => boolean
package/types/lib.d.ts CHANGED
@@ -478,9 +478,9 @@ export const is: {
478
478
  all: <T>(arr: T | T[], t: ((v: T) => boolean) | string) => boolean
479
479
  some: <T>(arr: T | T[], t: ((v: T) => boolean) | string) => boolean
480
480
  none: <T>(arr: T | T[], t: ((v: T) => boolean) | string) => boolean
481
- instance: (e: unknown, t: new (...args: any[]) => any) => boolean
482
- instanceof: (e: unknown, t: new (...args: any[]) => any) => boolean
483
- instanceOf: (e: unknown, t: new (...args: any[]) => any) => boolean
481
+ instance: <T>(e: unknown, t: new (...args: any[]) => T) => e is T
482
+ instanceof: <T>(e: unknown, t: new (...args: any[]) => T) => e is T
483
+ instanceOf: <T>(e: unknown, t: new (...args: any[]) => T) => e is T
484
484
  isCase: ((s: unknown, c?: 'up' | 'down') => boolean) & {
485
485
  upper: (s: unknown) => boolean
486
486
  lower: (s: unknown) => boolean