-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathREADME.hbs
152 lines (103 loc) Β· 4.37 KB
/
README.hbs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
# {{noscope repo.name}}
{{repo.description}}
## π§ Table of contents
- [β¨ Benefits](#-benefits)
- [π Requierments](#-requierments)
- [π Quickstart](#-quickstart)
- [π Documentation](#-documentation)
- [π Troubleshooting](#-troubleshooting)
- [π€ Contributing](#-contributing)
- [π§ͺ Testing](#-testing)
- [βοΈ License](#οΈ-license)
## β¨ Benefits
- [x] More readable than try/catch
- [x] Preserves stack call for debugging
- [x] Exits process (in NodeJS)
## π Requierments
No requierments, just works.
## π Quickstart
### Install
#### NodeJS
Install using the terminal:
```cli
npm install {{repo.name}}
```
Require the module:
```js
const {{noscope repo.name}} = require('{{repo.name}}');
```
<sub>**Note:** In case you're wondering, **@danielcobo/** is just a [namespace scope](https://docs.npmjs.com/about-scopes/) - an NPM feature. Scopes make it easier to name modules and improve [security](https://github.blog/2021-02-12-avoiding-npm-substitution-attacks/).</sub>
#### Browser
Declare it as a global variable named {{noscope repo.name}} by including this script before any script you want to use it in:
```html
<script src="https://cdn.jsdelivr.net/npm/{{repo.name}}@{{major repo.version}}/dist/iife/{{noscope repo.name}}.min.js"></script>
```
Or import it as an [ECMAScript module](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Statements/import):
```js
import * as {{noscope repo.name}} from 'https://cdn.jsdelivr.net/npm/{{repo.name}}@{{major repo.version}}/dist/esm/{{noscope repo.name}}.min.js';
```
Also, feel free to download the file if you prefer not to use [jsdelivr](https://www.jsdelivr.com). In that case just replace the url with the relative file path.
### Example use
```js
const result = await trySomething(param).catch(
err('Everyone fails sometime. Error:')
);
```
For details see documentation below.
## π Documentation
{{#each definition}}
### {{this.name}}{{#if this.isTypedef}} : {{{typecode this.type}}}{{/if}}
{{this.description}}
{{#unless this.isTypedef}}
| Name | Type | Default | Description |
| ---- | ---- | ------- | ----------- |
{{#each this.param}}
| {{#if this.optional}}[{{/if}}{{this.name}}{{#if this.optional}}]{{/if}} | {{{typecode this.type}}} | {{this.default}} | {{this.description}} |
{{/each}}
{{#if this.returns}}
#### Returns
| Type | Description |
| ---- | ----------- |
| {{this.returns.type}} | {{this.returns.description}} |
{{/if}}
{{else}}
| Name | Type | Description |
| ---- | ---- | ----------- |
{{#each this.property}}
| {{this.name}} | {{{typecode this.type}}} | {{this.description}} |
{{/each}}
{{/unless}}
<sub>**Source:** [{{this.source.url}}:{{this.source.line}}]({{nogit ../repo.repository.url}}/blob/master/{{this.source.url}}?plain=1#L{{this.source.line}})</sub>
{{/each}}
## π Troubleshooting
If you run into trouble or have questions just [submit an issue]({{nogit repo.repository.url}}/issues).
## π€ Contributing
### Anyone can contribute
Contributions come in many shapes and sizes. All are welcome.
You can contribute by:
- asking questions
- suggesting features
- sharing this repo with friends
- improving documentation (even fixing typos counts π)
- providing tutorials (if you do, please [let me know](https://twitter.com/danielcobocom), I would love to read them)
- improving tests
- contributing code (new features, performance boosts, code readability improvements..)
### Rules for contributions
**General guidelines:**
- there are no dumb questions
- be polite and respectful to others
- do good
**When coding remember:**
- working > maintainability > performance
- best code is no code
- be descriptive when naming
- keep it [DRY](https://en.wikipedia.org/wiki/Don%27t_repeat_yourself)
- do test
**Contribution licence:**
All contributions are considered to be under same [license](#-license) as this repository.
## π§ͺ Testing
**Testing suite:** [π Jest](https://jestjs.io) | **Test command:** `npm test`
**Mutation testing suite:** [π½ Stryker Mutator](https://stryker-mutator.io) | **Mutation test command:** `npm run mutation`
If you intend to develop further or contribute code, then please ensure to write and use testing. Strive for 100% code coverage and high mutation scores. Mutation score 100 is great, but it's not always neccessary (if there are valid reasons).
## βοΈ License
[MIT License]({{nogit repo.repository.url}}/blob/master/LICENSE.md)