ts-pattern
Advanced tools
Comparing version 3.1.3 to 3.2.1-next.0
import type { Pattern, AnonymousSelectPattern, NamedSelectPattern, GuardPattern, NotPattern, GuardFunction } from './types/Pattern'; | ||
import type { Match } from './types/Match'; | ||
import { __ } from './PatternType'; | ||
import { AnyConstructor } from './types/helpers'; | ||
export declare const when: <a, b extends a = never>(predicate: GuardFunction<a, b>) => GuardPattern<a, b>; | ||
@@ -8,2 +9,3 @@ export declare const not: <a>(pattern: Pattern<a>) => NotPattern<a>; | ||
export declare function select<k extends string>(key: k): NamedSelectPattern<k>; | ||
export declare function instanceOf<T extends AnyConstructor>(classConstructor: T): GuardPattern<unknown, InstanceType<T>>; | ||
/** | ||
@@ -10,0 +12,0 @@ * # Pattern matching |
@@ -24,3 +24,3 @@ "use strict"; | ||
exports.__esModule = true; | ||
exports.match = exports.__ = exports.select = exports.not = exports.when = void 0; | ||
exports.match = exports.__ = exports.instanceOf = exports.select = exports.not = exports.when = void 0; | ||
var PatternType_1 = require("./PatternType"); | ||
@@ -49,2 +49,6 @@ exports.__ = PatternType_1.__; | ||
exports.select = select; | ||
function instanceOf(classConstructor) { | ||
return exports.when(function (val) { return val instanceof classConstructor; }); | ||
} | ||
exports.instanceOf = instanceOf; | ||
/** | ||
@@ -51,0 +55,0 @@ * #### match |
@@ -50,2 +50,3 @@ export declare type ValueOf<a> = a extends any[] ? a[number] : a[keyof a]; | ||
export declare type Union<a, b> = [b] extends [a] ? a : [a] extends [b] ? b : a | b; | ||
export declare type AnyConstructor = new (...args: any[]) => any; | ||
export {}; |
{ | ||
"name": "ts-pattern", | ||
"version": "3.1.3", | ||
"version": "3.2.1-next.0", | ||
"description": "Typescript pattern matching library", | ||
@@ -5,0 +5,0 @@ "main": "lib/index.js", |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
No v1
QualityPackage is not semver >=1. This means it is not stable and does not support ^ ranges.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
71697
855
1