overwrite

Transforms own properties of an object using a mapping function.

Signature

overwrite(object, transform)
(Object 'a, ((String, 'a)) => (String, 'b)) => Object 'b

Documentation

Transforms own properties of an object using a mapping function.

This function is a specialised form of mapEntries that overwrites duplicated keys when a collision happens.

Caveats

Because this function takes an object and maps over it, the result of a transformation where keys collide is not defined in ECMAScript 5 and older, as those engines don't define an ordering for key/value pairs in objects. In ECMAScript 2015 properties that were inserted later will win over properties that were inserted earlier.

Properties

Source Code

(object, transform) =>
  mapEntries(object, transform, (result, key, value) => {
    result[key] = value;
    return result;
  })
Stability
stable
Licence
MIT
Module
folktale/core/object/map-entries
Authors
Copyright
(c) 2013-2017 Quildreen Motta, and CONTRIBUTORS
Authors
  • Quildreen Motta
Maintainers
  • Quildreen Motta <queen@robotlolita.me> (http://robotlolita.me/)