Skip to content

Commit 2e43753

Browse files
committed
Initial commit
0 parents  commit 2e43753

22 files changed

+2961
-0
lines changed

.config/eslint.config.cjs

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
module.exports = {
2+
root: true,
3+
4+
env: {
5+
browser: true,
6+
node: true,
7+
es2022: true
8+
},
9+
10+
parserOptions: {
11+
sourceType: 'module',
12+
ecmaVersion: 2022
13+
},
14+
15+
extends: ['eslint:recommended', 'plugin:@typescript-eslint/recommended'],
16+
parser: '@typescript-eslint/parser',
17+
plugins: ['@typescript-eslint'],
18+
19+
rules: {
20+
'@typescript-eslint/no-explicit-any': 'off'
21+
},
22+
23+
ignorePatterns: [
24+
'.DS_Store',
25+
'node_modules',
26+
'package*',
27+
'*-lock.*',
28+
'*.log*',
29+
'.cache',
30+
'.env',
31+
'dist'
32+
]
33+
}

.config/prettier.config.cjs

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
module.exports = {
2+
arrowParens: 'avoid',
3+
semi: false,
4+
singleQuote: true,
5+
trailingComma: 'none'
6+
}

.editorconfig

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
# https://editorconfig.org
2+
root = true
3+
4+
[*]
5+
charset = utf-8
6+
end_of_line = lf
7+
indent_size = 2
8+
indent_style = space
9+
insert_final_newline = true
10+
max_line_length = 80
11+
trim_trailing_whitespace = true
12+
13+
[*.md]
14+
max_line_length = 0
15+
trim_trailing_whitespace = false
16+
17+
[COMMIT_EDITMSG]
18+
max_line_length = 0

.gitattributes

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
*.* linguist-language=TypeScript

.github/codeowners

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
* @ivodolenc

.gitignore

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
.DS_Store
2+
node_modules
3+
.private
4+
*.log*
5+
.cache
6+
.env
7+
.npmrc
8+
dist

.prettierignore

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
.DS_Store
2+
node_modules
3+
*-lock.*
4+
*.log*
5+
.cache
6+
.env
7+
dist

.vscode/extensions.json

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
{
2+
"recommendations": [
3+
"dbaeumer.vscode-eslint",
4+
"esbenp.prettier-vscode",
5+
"EditorConfig.EditorConfig"
6+
]
7+
}

.vscode/settings.json

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
{
2+
"editor.defaultFormatter": "esbenp.prettier-vscode",
3+
"editor.formatOnSave": true
4+
}

CHANGELOG.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
# What's New
2+
3+
Check out the latest features and improvements.
4+
5+
#### [Release Notes](https://github.com/hypernym-studio/emitter/releases)

LICENSE.txt

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
MIT License
2+
3+
Copyright (c) Hypernym Studio
4+
5+
Permission is hereby granted, free of charge, to any person obtaining a copy
6+
of this software and associated documentation files (the "Software"), to deal
7+
in the Software without restriction, including without limitation the rights
8+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9+
copies of the Software, and to permit persons to whom the Software is
10+
furnished to do so, subject to the following conditions:
11+
12+
The above copyright notice and this permission notice shall be included in all
13+
copies or substantial portions of the Software.
14+
15+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21+
SOFTWARE.

README.md

Lines changed: 79 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,79 @@
1+
# Emitter
2+
3+
A super simple and lightweight event emitter.
4+
5+
## Features
6+
7+
- TypeScript friendly
8+
- Supports CJS & ESM
9+
- Zero dependencies
10+
- Ultra lightweight
11+
12+
## Installation
13+
14+
```sh
15+
npm i @hypernym/emitter
16+
```
17+
18+
## Usage
19+
20+
### JS
21+
22+
```js
23+
import { createEmitter } from '@hypernym/emitter'
24+
25+
const emitter = createEmitter()
26+
27+
emitter.on('event-id', e => console.log(e.x, e.y))
28+
29+
emitter.emit('event-id', { x: 0, y: 0 })
30+
```
31+
32+
### TS
33+
34+
```ts
35+
import { createEmitter, Emitter } from '@hypernym/emitter'
36+
37+
type Events = {
38+
'event-id': { x: number; y: number }
39+
// ...
40+
}
41+
42+
const emitter: Emitter<Events> = createEmitter<Events>()
43+
44+
emitter.on('event-id', e => console.log(e.x, e.y))
45+
46+
emitter.emit('event-id', { x: 0, y: 0 })
47+
```
48+
49+
## API
50+
51+
### .on()
52+
53+
```ts
54+
emitter.on(id: string, callback: (event: any) => void)
55+
```
56+
57+
### .emit()
58+
59+
```ts
60+
emitter.emit(id: string, event: any)
61+
```
62+
63+
### .clear()
64+
65+
```ts
66+
emitter.events.clear()
67+
```
68+
69+
## Community
70+
71+
Feel free to use the official [discussions](https://github.com/hypernym-studio/emitter/discussions) for any additional questions.
72+
73+
## License
74+
75+
Developed in 🇭🇷 Croatia
76+
77+
Released under the [MIT](LICENSE.txt) license.
78+
79+
© Hypernym Studio

0 commit comments

Comments
 (0)