diff --git a/README.md b/README.md index 146cc1d..9c324a8 100644 --- a/README.md +++ b/README.md @@ -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' @@ -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). diff --git a/package-lock.json b/package-lock.json index cc9dab3..9138066 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,12 +1,12 @@ { "name": "wishmap", - "version": "1.0.3", + "version": "1.0.4", "lockfileVersion": 3, "requires": true, "packages": { "": { "name": "wishmap", - "version": "1.0.3", + "version": "1.0.4", "license": "MIT", "devDependencies": { "@types/node": "^25.0.10", diff --git a/package.json b/package.json index d3e6bc5..9824f53 100644 --- a/package.json +++ b/package.json @@ -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" }, diff --git a/src/index.ts b/src/index.ts index 25265f8..c938f14 100644 --- a/src/index.ts +++ b/src/index.ts @@ -8,7 +8,11 @@ import { EventEmitter } from 'node:events' */ export class WishMap extends Map { /** Event emitter for map mutations */ - public events: EventEmitter> = new EventEmitter() + public readonly events: EventEmitter> = new EventEmitter() + + public on = this.events.on + public once = this.events.once + public off = this.events.off /** * Removes the specified element from the map.