Skip to content

Commit 1dffd31

Browse files
docs(README.md): fix examples, add experimental, update basic concepts.
1 parent 5752d9e commit 1dffd31

1 file changed

Lines changed: 116 additions & 8 deletions

File tree

README.md

Lines changed: 116 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,7 @@ Manages an [`Error`][js-error].
4343
* [Api](#api)
4444
* [`ValidationError`](#validationerror)
4545
* [Interface](#interface)
46+
* [Experimental](#experimental)
4647
* [Git](#git)
4748
* [Commit](#commit)
4849
* [Versioning](#versioning)
@@ -63,13 +64,15 @@ Type guard (constrain)
6364
Guards
6465
> It's a **combination** of both above, **constrains** the type of the parameter in the **code editor**, and checks its provided argument.
6566
66-
Sets
67-
> Sets the existing given value in the `object`.
68-
6967
Defines
70-
> Returns defined value from the method of the `object`.
71-
> Defines the new value in the `object`.
72-
> Both above at the same time.
68+
> Returns defined value from a method of an object.
69+
> Defines new value in an object and returns a defined value.
70+
71+
Gets
72+
> Returns a value from an object.
73+
74+
Sets
75+
> Adds or updates an element with a specified key and a value to an object and returns an object.
7376
7477
<br>
7578

@@ -110,6 +113,18 @@ import {
110113
} from '@angular-package/error';
111114
```
112115

116+
```typescript
117+
/*
118+
* Experimental
119+
*/
120+
import {
121+
// Class.
122+
MessageBuilder,
123+
MessageBuilderTemplate,
124+
MessageFunctionBuilder,
125+
} from '@angular-package/error';
126+
```
127+
113128
<br>
114129

115130
## `ValidationError`
@@ -219,7 +234,7 @@ The **return value** is a message of a `string` type created from the provided `
219234

220235
```typescript
221236
// Example usage.
222-
import { ValidationError } from '@angular-package/core';
237+
import { ValidationError } from '@angular-package/error';
223238

224239
const fix = 'There is no solution to the described problem.';
225240
const problem = 'The problem has no solution.';
@@ -270,7 +285,7 @@ The **return value** is an instance of [`ValidationError`](#validationerror).
270285

271286
```typescript
272287
// Example usage.
273-
import { ValidationError } from '@angular-package/core';
288+
import { ValidationError } from '@angular-package/error';
274289

275290
const fix = 'There is no solution to the described problem.';
276291
const problem = 'The problem has no solution.';
@@ -302,6 +317,98 @@ interface ErrorMessage {
302317

303318
<br>
304319

320+
## Experimental
321+
322+
![experimental]
323+
324+
### Message builder
325+
326+
#### `MessageBuilder`
327+
328+
Message builder for error message of a [`string`][js-string] type.
329+
330+
```typescript
331+
// Example usage of building a function.
332+
import { MessageBuilder } from '@angular-package/error';
333+
334+
/**
335+
* Initialize `MessageBuilder`.
336+
*/
337+
const messageFunctionBuilder = new MessageBuilder('function');
338+
339+
messageFunctionBuilder
340+
.setFunctionName('guardString')
341+
.setParam('value', 'string')
342+
.setReturn('boolean');
343+
344+
// Console returns `guardString(value: string): boolean`
345+
console.log(messageFunctionBuilder.get);
346+
```
347+
348+
```typescript
349+
// Example usage of building a method.
350+
import { MessageBuilder } from '@angular-package/error';
351+
352+
/**
353+
* Initialize `MessageBuilder`.
354+
*/
355+
const messageMethodBuilder = new MessageBuilder('method');
356+
357+
// Build the class method.
358+
messageMethodBuilder
359+
.setMethodName('setPerson')
360+
.setParam('value', 'string')
361+
.setReturn('this');
362+
363+
// Console returns `setPerson(value: string): this`
364+
console.log(messageMethodBuilder.get);
365+
```
366+
367+
```typescript
368+
// Example usage of building a class.
369+
import { MessageBuilder } from '@angular-package/error';
370+
371+
/**
372+
* Initialize `MessageBuilder`.
373+
*/
374+
const messageClassBuilder = new MessageBuilder('class');
375+
376+
// Build the class.
377+
messageClassBuilder
378+
.setClassName('Person.prototype.')
379+
.setMethodName('setPerson')
380+
.setParam('value?', 'object')
381+
.setReturn('object');
382+
383+
// Console returns `Person.prototype.setPerson(value?: object): object`
384+
console.log(messageClassBuilder.get);
385+
```
386+
387+
#### `MessageFunctionBuilder`
388+
389+
Message function builder for error message of a [`string`][js-string] type.
390+
391+
```typescript
392+
// Example usage of building a function.
393+
import { MessageFunctionBuilder } from '@angular-package/error';
394+
395+
/**
396+
* Initialize `MessageFunctionBuilder`.
397+
*/
398+
const messageFunctionBuilder = new MessageFunctionBuilder();
399+
400+
messageFunctionBuilder
401+
.setName('guardString')
402+
.setParam('value', 'string')
403+
.setReturn('boolean')
404+
.build();
405+
406+
// Console returns `guardString(value: string): boolean`
407+
console.log(messageFunctionBuilder.get);
408+
```
409+
410+
<br>
411+
305412
## GIT
306413

307414
### Commit
@@ -345,6 +452,7 @@ MIT © angular-package ([license][error-license])
345452
[skeleton]: https://github.com/angular-package/skeleton
346453

347454
<!-- Update status -->
455+
[experimental]: https://img.shields.io/badge/-experimental-orange
348456
[fix]: https://img.shields.io/badge/-fix-red
349457
[new]: https://img.shields.io/badge/-new-green
350458
[update]: https://img.shields.io/badge/-update-red

0 commit comments

Comments
 (0)