Skip to content

Commit 53f4cd5

Browse files
authored
Merge pull request #8 from danliyev/main
feat: add shortcuts WishMap#on, WishMap#once and WishMap#off
2 parents e95b1eb + 7c81445 commit 53f4cd5

File tree

4 files changed

+56
-7
lines changed

4 files changed

+56
-7
lines changed

README.md

Lines changed: 47 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,13 +6,57 @@ An extended `Map` with Array-like methods and event emission.
66

77
[API Docs](https://danliyev.github.io/WishMap)
88

9-
## Installation
9+
# Installation
10+
11+
## Using NPM Registry
1012

1113
```bash
1214
npm install @danliyev/wishmap
1315
```
1416

15-
## Usage
17+
## Using GitHub Packages Registry
18+
19+
1. Create a [GitHub Personal Access Token](https://github.com/settings/tokens/new) with `read:packages` scope
20+
21+
2. Add to your shell profile (`.bashrc`, `.zshrc`, or `.profile`):
22+
23+
```bash
24+
export GITHUB_TOKEN=your_token_here
25+
```
26+
27+
3. In your project directory, create `.npmrc`:
28+
29+
```
30+
@danliyev:registry=https://npm.pkg.github.com/
31+
//npm.pkg.github.com/:_authToken=${GITHUB_TOKEN}
32+
```
33+
34+
4. Install:
35+
36+
```bash
37+
npm install @danliyev/wishmap
38+
```
39+
40+
### Alternative: npm login
41+
42+
Authenticate once with GitHub Packages:
43+
44+
```bash
45+
npm login --registry=https://npm.pkg.github.com --scope=@danliyev
46+
# Username: your-github-username
47+
# Password: your-personal-access-token (with read:packages scope)
48+
# Email: your-email
49+
```
50+
51+
Then install normally:
52+
53+
```bash
54+
npm install @danliyev/wishmap
55+
```
56+
57+
See [Working with the npm registry](https://docs.github.com/en/packages/working-with-a-github-packages-registry/working-with-the-npm-registry) for more information.
58+
59+
# Usage
1660

1761
```typescript
1862
import { WishMap } from '@danliyev/wishmap'
@@ -42,6 +86,6 @@ map.some(v => v > 2) // true
4286
map.reduce((acc, v) => acc + v, 0) // 6
4387
```
4488

45-
## License
89+
# License
4690

4791
This project is licensed under the [MIT License](./LICENSE).

package-lock.json

Lines changed: 2 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,9 @@
11
{
22
"name": "@danliyev/wishmap",
3-
"version": "1.0.3",
3+
"version": "1.0.4",
44
"description": "An extended JavaScript Map with Array-like methods and event emission.",
55
"main": "dist/index.js",
6+
"types": "dist/index.d.ts",
67
"scripts": {
78
"build": "tsup"
89
},

src/index.ts

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,11 @@ import { EventEmitter } from 'node:events'
88
*/
99
export class WishMap<K, V> extends Map<K, V> {
1010
/** Event emitter for map mutations */
11-
public events: EventEmitter<WishMapEvents<K, V>> = new EventEmitter()
11+
public readonly events: EventEmitter<WishMapEvents<K, V>> = new EventEmitter()
12+
13+
public on = this.events.on
14+
public once = this.events.once
15+
public off = this.events.off
1216

1317
/**
1418
* Removes the specified element from the map.

0 commit comments

Comments
 (0)