Narcoleptic Pony Machine

    deepmap

    0.2.1 • Public • Published

    deepmap

    Maps with multiple keys per value

    Supports the following Map methods:

    • clear
    • delete
    • has
    • get
    • set

    All other Map methods & properties, including well-known symbols and coercion logic, are not catered for at present.

    Signature for all methods is the same as for Map, except that in place of a key, it instead accepts an array of keys.

    map[ method ]( key, value? )

    ...DeepMaps instead provide:

    map[ method ]( [ ...keys ], value? )

    Ergo:

    const sums = new DeepMap()
     
    sums.set( [ 1, 2 ], 3 )
     
    sums.has( 1 )           // false
     
    sums.has( [ 1 ] )       // false
     
    sums.has( [ 1, 2 ] )    // true
     
    sums.get( [ 1, 2 ] )    // 3
     
    sums.delete( [ 1, 2 ] ) // true
     
    sums.has( [ 1, 2 ] )    // false

    Install

    npm i deepmap

    DownloadsWeekly Downloads

    1

    Version

    0.2.1

    License

    MIT

    Last publish

    Collaborators

    • barneycarroll