ts-pattern
Advanced tools
Comparing version 2.0.1-next.0 to 2.0.1-next.1
import type { Pattern, SelectPattern, GuardPattern, NotPattern, GuardFunction } from './types/Pattern'; | ||
import type { Match, ExhaustiveMatch } from './types/Match'; | ||
import type { EmptyMatch } from './types/Match'; | ||
import { __ } from './PatternType'; | ||
import { DistributeUnions } from './types/DistributeUnions'; | ||
export declare const when: <a, b extends a = a>(predicate: GuardFunction<a, b>) => GuardPattern<a, b>; | ||
@@ -17,9 +16,2 @@ export declare const not: <a>(pattern: Pattern<a>) => NotPattern<a>; | ||
*/ | ||
export declare const match: <a, b = "@match/unset">(value: a) => Match<a, b>; | ||
/** | ||
* ### exhaustiveMatch | ||
* creates an exhaustive match expression checking | ||
* that **all cases are handled**. `when` predicates | ||
* aren't supported on exhaustive matches. | ||
**/ | ||
export declare const exhaustiveMatch: <a, b = "@match/unset">(value: a) => ExhaustiveMatch<DistributeUnions<a>, b>; | ||
export declare const match: <a, b = "@match/unset">(value: a) => EmptyMatch<a, b>; |
@@ -23,3 +23,3 @@ "use strict"; | ||
exports.__esModule = true; | ||
exports.exhaustiveMatch = exports.match = exports.__ = exports.select = exports.not = exports.when = void 0; | ||
exports.match = exports.__ = exports.select = exports.not = exports.when = void 0; | ||
var PatternType_1 = require("./PatternType"); | ||
@@ -52,10 +52,2 @@ exports.__ = PatternType_1.__; | ||
/** | ||
* ### exhaustiveMatch | ||
* creates an exhaustive match expression checking | ||
* that **all cases are handled**. `when` predicates | ||
* aren't supported on exhaustive matches. | ||
**/ | ||
var exhaustiveMatch = function (value) { return builder(value, []); }; | ||
exports.exhaustiveMatch = exhaustiveMatch; | ||
/** | ||
* ### builder | ||
@@ -121,2 +113,11 @@ * This is the implementation of our pattern matching, using the | ||
return entry.handler(value, entry.select(value)); | ||
}, | ||
/** | ||
* ### exhaustive | ||
* creates an exhaustive match expression checking | ||
* that **all cases are handled**. `when` predicates | ||
* aren't supported on exhaustive matches. | ||
**/ | ||
exhaustive: function () { | ||
return builder(value, patterns); | ||
} | ||
@@ -123,0 +124,0 @@ }); }; |
import type { Pattern, GuardValue, ExhaustivePattern } from './Pattern'; | ||
import type { ExtractPreciseValue } from './ExtractPreciseValue'; | ||
import type { InvertPattern } from './InvertPattern'; | ||
import type { DistributeUnions } from './DistributeUnions'; | ||
import type { UnionToIntersection } from './helpers'; | ||
@@ -44,2 +45,11 @@ import type { FindSelected } from './FindSelected'; | ||
}; | ||
export declare type EmptyMatch<i, o> = Match<i, o> & { | ||
/** | ||
* ### exhaustive | ||
* creates an exhaustive match expression checking | ||
* that **all cases are handled**. `when` predicates | ||
* aren't supported on exhaustive matches. | ||
**/ | ||
exhaustive: () => ExhaustiveMatch<DistributeUnions<i>, o>; | ||
}; | ||
declare type NonExhaustivePattern<i> = { | ||
@@ -46,0 +56,0 @@ __nonExhaustive: never; |
{ | ||
"name": "ts-pattern", | ||
"version": "2.0.1-next.0", | ||
"version": "2.0.1-next.1", | ||
"description": "Typescript pattern matching library", | ||
@@ -5,0 +5,0 @@ "main": "lib/index.js", |
@@ -52,3 +52,3 @@ <h1 align="center">ts-pattern</h1> | ||
Via npm: | ||
Via npm | ||
@@ -55,0 +55,0 @@ ``` |
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
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
665
53716