Uploading the main structure
هذا الالتزام موجود في:
21
node_modules/assert-never/LICENSE
مولّد
مباع
Normal file
21
node_modules/assert-never/LICENSE
مولّد
مباع
Normal file
@@ -0,0 +1,21 @@
|
||||
MIT License
|
||||
|
||||
Copyright (C) 2017-2024 Daniel Lytkin
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
of this software and associated documentation files (the "Software"), to deal
|
||||
in the Software without restriction, including without limitation the rights
|
||||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
copies of the Software, and to permit persons to whom the Software is
|
||||
furnished to do so, subject to the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be included in
|
||||
all copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||
THE SOFTWARE.
|
39
node_modules/assert-never/README.md
مولّد
مباع
Normal file
39
node_modules/assert-never/README.md
مولّد
مباع
Normal 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.gitbook.io/typescript/type-system/discriminated-unions#exhaustive-checks
|
4
node_modules/assert-never/index.d.ts
مولّد
مباع
Normal file
4
node_modules/assert-never/index.d.ts
مولّد
مباع
Normal file
@@ -0,0 +1,4 @@
|
||||
export declare function assertNever(value: never, errorMessage?: string): never;
|
||||
export declare function assertNever(value: never, getErrorMessage?: (value: unknown) => string): never;
|
||||
export declare function assertNever(value: never, noThrow?: boolean): never;
|
||||
export default assertNever;
|
41
node_modules/assert-never/index.js
مولّد
مباع
Normal file
41
node_modules/assert-never/index.js
مولّد
مباع
Normal file
@@ -0,0 +1,41 @@
|
||||
"use strict";
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
exports.assertNever = assertNever;
|
||||
/**
|
||||
* 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, errorMessageOrNoThrow) {
|
||||
if (typeof errorMessageOrNoThrow === 'string') {
|
||||
throw new Error(errorMessageOrNoThrow);
|
||||
}
|
||||
if (typeof errorMessageOrNoThrow === 'function') {
|
||||
throw new Error(errorMessageOrNoThrow(value));
|
||||
}
|
||||
if (errorMessageOrNoThrow) {
|
||||
return value;
|
||||
}
|
||||
throw new Error("Unhandled discriminated union member: ".concat(JSON.stringify(value)));
|
||||
}
|
||||
exports.default = assertNever;
|
48
node_modules/assert-never/index.ts
مولّد
مباع
Normal file
48
node_modules/assert-never/index.ts
مولّد
مباع
Normal file
@@ -0,0 +1,48 @@
|
||||
export function assertNever(value: never, errorMessage?: string): never
|
||||
export function assertNever(value: never, getErrorMessage?: (value: unknown) => string): never
|
||||
export function assertNever(value: never, noThrow?: boolean): never
|
||||
|
||||
/**
|
||||
* 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, errorMessageOrNoThrow?: string | ((value: unknown) => string) | boolean): never {
|
||||
if (typeof errorMessageOrNoThrow === 'string') {
|
||||
throw new Error(errorMessageOrNoThrow)
|
||||
}
|
||||
|
||||
if (typeof errorMessageOrNoThrow === 'function') {
|
||||
throw new Error(errorMessageOrNoThrow(value))
|
||||
}
|
||||
|
||||
if (errorMessageOrNoThrow) {
|
||||
return value
|
||||
}
|
||||
|
||||
throw new Error(
|
||||
`Unhandled discriminated union member: ${JSON.stringify(value)}`,
|
||||
);
|
||||
}
|
||||
|
||||
export default assertNever;
|
36
node_modules/assert-never/package.json
مولّد
مباع
Normal file
36
node_modules/assert-never/package.json
مولّد
مباع
Normal file
@@ -0,0 +1,36 @@
|
||||
{
|
||||
"name": "assert-never",
|
||||
"version": "1.4.0",
|
||||
"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 && npm test",
|
||||
"test": "jest"
|
||||
},
|
||||
"keywords": [
|
||||
"typescript",
|
||||
"discriminated unions",
|
||||
"assert",
|
||||
"never"
|
||||
],
|
||||
"repository": "aikoven/assert-never",
|
||||
"author": "Daniel Lytkin <dan.lytkin@gmail.com>",
|
||||
"license": "MIT",
|
||||
"devDependencies": {
|
||||
"@babel/core": "^7.24.7",
|
||||
"@babel/preset-env": "^7.24.7",
|
||||
"@babel/preset-typescript": "^7.24.7",
|
||||
"@types/jest": "^29.5.12",
|
||||
"babel-jest": "^29.7.0",
|
||||
"jest": "^29.7.0",
|
||||
"type-assertions": "^1.1.0",
|
||||
"typescript": "^5.5.3"
|
||||
}
|
||||
}
|
المرجع في مشكلة جديدة
حظر مستخدم