@vyacheslav97/ct
Advanced tools
Comparing version 1.0.2 to 1.0.3
@@ -6,1 +6,2 @@ export * from './uic'; | ||
export * from './NumberValidators'; | ||
export * from './ErrorWithData'; |
@@ -6,1 +6,2 @@ export * from './uic'; | ||
export * from './NumberValidators'; | ||
export * from './ErrorWithData'; |
@@ -5,1 +5,2 @@ export * from './uic'; | ||
export * from './algorithms'; | ||
export * from './ErrorWithData'; |
@@ -5,1 +5,2 @@ export * from './uic'; | ||
export * from './algorithms'; | ||
export * from './ErrorWithData'; |
{ | ||
"type": "module", | ||
"name": "@vyacheslav97/ct", | ||
"version": "1.0.2", | ||
"version": "1.0.3", | ||
"description": "", | ||
@@ -6,0 +5,0 @@ "keywords": [ |
@@ -9,7 +9,6 @@ # <u>Common tools (ct, also @vyacheslav97/ct)</u> | ||
Current version renewals (1.0.2) (see **Prerequesites** a bit below): | ||
Current version renewals (1.0.3) (see **Prerequesites** a bit below): | ||
- **clear** method for **Graph** and **Tree** template classes (removes all nodes from a graph or node instance) | ||
- Input nodes validation within **Graph** and **Tree** constructors (now they are added via **addNode** method with all its checks) | ||
- **isLeaf** boolean flag (**nodeData** property member) for **Tree** nodes, and related logic of its auto handling during adding and removing nodes (now each newly added node has **isLeaf** === **true**, if node receives some child node, its **isLeaf** then demolished) | ||
- Imports huge bug fix (webpack and the rest became unable to assemble package due to type: module) | ||
- **ErrorWithData** template class | ||
@@ -32,2 +31,3 @@ Next scheduled **major** updates: | ||
- [Mutations history template class](#mutationsHistory) | ||
- [ErrorWithData template class](#ErrorWithDataTemplateClass) | ||
- [Binary search procedure template](#binarySearch) | ||
@@ -463,2 +463,47 @@ - [Duplicates search procedure template](#duplicatesSearch) | ||
<a id="ErrorWithDataTemplateClass"></a> | ||
## ErrorWithData template class | ||
**ErrorWithData** template class can be imported as follows: | ||
```ts | ||
import { | ||
ErrorWithData, | ||
} from '@vyacheslav97/ct'; | ||
``` | ||
This class implements interface: | ||
```ts | ||
export interface ErrorBaseData { | ||
message: string; | ||
} | ||
export interface ErrorWithDataInterface<DataType extends ErrorBaseData> extends Error { | ||
errorData?: DataType; | ||
} | ||
``` | ||
It allows a user to provide an error some extra data of sophisticated shape | ||
Except mentioned above, **ErrorWithData** reproduces built in JS **Error** class behaviour | ||
<u>Usage example</u> | ||
```ts | ||
interface TestErrorData extends ErrorBaseData { | ||
code: number; | ||
} | ||
const errorData: TestErrorData = { message: 'Test error', code: 404 }; | ||
const error = new ErrorWithData<TestErrorData>(errorData); | ||
throw error; | ||
``` | ||
<a id="binarySearch"></a> | ||
@@ -465,0 +510,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
74487
74
1162
708
No