Initial commit

This commit is contained in:
2021-08-26 21:47:42 +02:00
commit fe941c6433
1432 changed files with 161130 additions and 0 deletions

39
node_modules/assert-never/README.md generated vendored Normal file
View File

@ -0,0 +1,39 @@
# Assert Never [![npm version][npm-image]][npm-url]
Helper function for [exhaustive checks][exhaustive-checks] of discriminated
unions in TypeScript.
## Installation
```
npm install --save assert-never
```
## Usage
```ts
import {assertNever} from "assert-never";
type A = {type: 'a'};
type B = {type: 'b'};
type Union = A | B;
function doSomething(arg: Union) {
if (arg.type === 'a') {
return something;
}
if (arg.type === 'b') {
return somethingElse;
}
// TS will error if there are other types in the union
// Will throw an Error when called at runtime. Use `assertNever(arg, true)`
// instead to fail silently.
return assertNever(arg);
}
```
[npm-image]: https://badge.fury.io/js/assert-never.svg
[npm-url]: https://badge.fury.io/js/assert-never
[exhaustive-checks]: https://basarat.gitbooks.io/typescript/docs/types/discriminated-unions.html#exhaustive-checks

27
node_modules/assert-never/index.d.ts generated vendored Normal file
View File

@ -0,0 +1,27 @@
/**
* Helper function for exhaustive checks of discriminated unions.
* https://basarat.gitbooks.io/typescript/docs/types/discriminated-unions.html
*
* @example
*
* type A = {type: 'a'};
* type B = {type: 'b'};
* type Union = A | B;
*
* function doSomething(arg: Union) {
* if (arg.type === 'a') {
* return something;
* }
*
* if (arg.type === 'b') {
* return somethingElse;
* }
*
* // TS will error if there are other types in the union
* // Will throw an Error when called at runtime.
* // Use `assertNever(arg, true)` instead to fail silently.
* return assertNever(arg);
* }
*/
export declare function assertNever(value: never, noThrow?: boolean): never;
export default assertNever;

35
node_modules/assert-never/index.js generated vendored Normal file
View File

@ -0,0 +1,35 @@
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
/**
* Helper function for exhaustive checks of discriminated unions.
* https://basarat.gitbooks.io/typescript/docs/types/discriminated-unions.html
*
* @example
*
* type A = {type: 'a'};
* type B = {type: 'b'};
* type Union = A | B;
*
* function doSomething(arg: Union) {
* if (arg.type === 'a') {
* return something;
* }
*
* if (arg.type === 'b') {
* return somethingElse;
* }
*
* // TS will error if there are other types in the union
* // Will throw an Error when called at runtime.
* // Use `assertNever(arg, true)` instead to fail silently.
* return assertNever(arg);
* }
*/
function assertNever(value, noThrow) {
if (noThrow) {
return value;
}
throw new Error("Unhandled discriminated union member: " + JSON.stringify(value));
}
exports.assertNever = assertNever;
exports.default = assertNever;

36
node_modules/assert-never/index.ts generated vendored Normal file
View File

@ -0,0 +1,36 @@
/**
* Helper function for exhaustive checks of discriminated unions.
* https://basarat.gitbooks.io/typescript/docs/types/discriminated-unions.html
*
* @example
*
* type A = {type: 'a'};
* type B = {type: 'b'};
* type Union = A | B;
*
* function doSomething(arg: Union) {
* if (arg.type === 'a') {
* return something;
* }
*
* if (arg.type === 'b') {
* return somethingElse;
* }
*
* // TS will error if there are other types in the union
* // Will throw an Error when called at runtime.
* // Use `assertNever(arg, true)` instead to fail silently.
* return assertNever(arg);
* }
*/
export function assertNever(value: never, noThrow?: boolean): never {
if (noThrow) {
return value
}
throw new Error(
`Unhandled discriminated union member: ${JSON.stringify(value)}`,
);
}
export default assertNever;

28
node_modules/assert-never/package.json generated vendored Normal file
View File

@ -0,0 +1,28 @@
{
"name": "assert-never",
"version": "1.2.1",
"description": "Helper function for exhaustive checks of discriminated unions in TypeScript",
"main": "index.js",
"typings": "index.d.ts",
"files": [
"index.js",
"index.ts",
"index.d.ts"
],
"scripts": {
"build": "tsc",
"prepublish": "npm run build"
},
"keywords": [
"typescript",
"discriminated unions",
"assert",
"never"
],
"repository": "aikoven/assert-never",
"author": "Daniel Lytkin <dan.lytkin@gmail.com>",
"license": "MIT",
"devDependencies": {
"typescript": "^2.2.1"
}
}