Wondering what’s next for npm?Check out our public roadmap! »

    obj-map

    1.0.1 • Public • Published

    obj-map
    Build Status

    For mapping objects.

    objMap({a: 1, b: 2}, function(k, v) {
        return k == 'b' ? v * 2 : v;
    }); //⇒ {a: 1, b: 4}
     
    objMap.async({a: 1, b: 2}, function(k, v, cb) {
        cb(null, k == 'b' ? v * 2 : v);
    }, console.log); //⇒ {a: 1, b: 4}

    api

    objMap :: ∀ a,b. Object a → (a → b) → Object b

    Takes an object and a transformation function and does what you expect.

    objMap.async :: ∀ a,b. Object a → (a → (Error? → b → ())) → (Error? → Object b → ())

    Takes an object and an asynchronous transformation function and does what you expect.

    licence

    MIT

    Install

    npm i obj-map

    DownloadsWeekly Downloads

    25

    Version

    1.0.1

    License

    MIT

    Last publish

    Collaborators

    • avatar