@danliyev/wishmap
    Preparing search index...

    @danliyev/wishmap

    About

    An extended Map with Array-like methods and event emission.

    Links

    API Docs

    Installation

    npm install @danliyev/wishmap
    
    1. Create a GitHub Personal Access Token with read:packages scope

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

    export GITHUB_TOKEN=your_token_here
    
    1. In your project directory, create .npmrc:
    @danliyev:registry=https://npm.pkg.github.com/
    //npm.pkg.github.com/:_authToken=${GITHUB_TOKEN}
    1. Install:
    npm install @danliyev/wishmap
    

    Authenticate once with GitHub Packages:

    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:

    npm install @danliyev/wishmap
    

    See Working with the npm registry for more information.

    Usage

    import { WishMap } from '@danliyev/wishmap'

    const map = new WishMap<string, number>()

    // Listen to events
    map.events.on('set', (key, value) => {
    console.log(`Set ${key} = ${value}`)
    })

    map.events.on('delete', (key, value) => {
    console.log(`Deleted ${key} (was ${value})`)
    })

    // Use like a regular Map
    map.set('a', 1)
    map.set('b', 2)
    map.set('c', 3)

    // Use Array-like methods
    map.filter(v => v > 1) // WishMap { 'b' => 2, 'c' => 3 }
    map.map(v => v * 2) // [2, 4, 6]
    map.find(v => v === 2) // 2
    map.every(v => v > 0) // true
    map.some(v => v > 2) // true
    map.reduce((acc, v) => acc + v, 0) // 6

    License

    This project is licensed under the MIT License.