Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
50 changes: 47 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,13 +6,57 @@ An extended `Map` with Array-like methods and event emission.

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

## Installation
# Installation

## Using NPM Registry

```bash
npm install @danliyev/wishmap
```

## Usage
## Using GitHub Packages Registry

1. Create a [GitHub Personal Access Token](https://github.com/settings/tokens/new) with `read:packages` scope

2. Add to your shell profile (`.bashrc`, `.zshrc`, or `.profile`):

```bash
export GITHUB_TOKEN=your_token_here
```

3. In your project directory, create `.npmrc`:

```
@danliyev:registry=https://npm.pkg.github.com/
//npm.pkg.github.com/:_authToken=${GITHUB_TOKEN}
```

4. Install:

```bash
npm install @danliyev/wishmap
```

### Alternative: npm login

Authenticate once with GitHub Packages:

```bash
npm login --registry=https://npm.pkg.github.com --scope=@danliyev
# Username: your-github-username
# Password: your-personal-access-token (with read:packages scope)
# Email: your-email
```

Then install normally:

```bash
npm install @danliyev/wishmap
```

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.

# Usage

```typescript
import { WishMap } from '@danliyev/wishmap'
Expand Down Expand Up @@ -42,6 +86,6 @@ map.some(v => v > 2) // true
map.reduce((acc, v) => acc + v, 0) // 6
```

## License
# License

This project is licensed under the [MIT License](./LICENSE).
4 changes: 2 additions & 2 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 2 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
{
"name": "@danliyev/wishmap",
"version": "1.0.3",
"version": "1.0.4",
"description": "An extended JavaScript Map with Array-like methods and event emission.",
"main": "dist/index.js",
"types": "dist/index.d.ts",
"scripts": {
"build": "tsup"
},
Expand Down
6 changes: 5 additions & 1 deletion src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,11 @@ import { EventEmitter } from 'node:events'
*/
export class WishMap<K, V> extends Map<K, V> {
/** Event emitter for map mutations */
public events: EventEmitter<WishMapEvents<K, V>> = new EventEmitter()
public readonly events: EventEmitter<WishMapEvents<K, V>> = new EventEmitter()

public on = this.events.on
public once = this.events.once
public off = this.events.off

/**
* Removes the specified element from the map.
Expand Down