JSPM

  • ESM via JSPM
  • ES Module Entrypoint
  • Export Map
  • Keywords
  • License
  • Repository URL
  • TypeScript Types
  • README
  • Created
  • Published
  • Downloads 25372
  • Score
    100M100P100Q141400F
  • License MIT

Array-map like function for objects.

Package Exports

  • map-o

This package does not declare an exports field, so the exports above have been automatically detected and optimized by JSPM instead. If any package subpath is missing, it is recommended to post an issue to the original package (map-o) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.

Readme

map-o

Patreon PayPal AMA Version Downloads Get help on Codementor

Array-map like function for objects.

☁️ Installation

$ npm i --save map-o

📋 Example

// Dependencies
const mapObject = require("map-o");

// Modify this object
console.log(mapObject({
    location: "Earth"
  , age: 10
}, (value, name) => {
    if (name === "location") {
        return "Location: " + value;
    }

    if (value === 10) {
        return 42;
    }
}));
// => { location: 'Location: Earth', age: 42 }

var obj = {
    two: 2
  , nine: 9
  , ten: 10
};

// Calculate the squares, but don't override the object
var squares = mapObject(obj, x => x * x, true);
console.log("input:", obj);
// => input: { two: 2, nine: 9, ten: 10 }

console.log("squares:", squares);
// => squares: { two: 4, nine: 81, ten: 100 }

📝 Documentation

mapObject(obj, fn, clone)

Array-map like for objects.

Params

  • Object obj: The input object.
  • Function fn: A function returning the field values.
  • Boolean|Object clone: If true, the input object will be cloned. If clone is an object, it will be used as target object.

Return

  • Object The modified object.

😋 How to contribute

Have an idea? Found a bug? See how to contribute.

💰 Donations

Another way to support the development of my open-source modules is to set up a recurring donation, via Patreon. 🚀

PayPal donations are appreciated too! Each dollar helps.

Thanks! ❤️

💫 Where is this library used?

If you are using this library in one of your projects, add it in this list. ✨

  • compute-size—Helper tool for resizing the things.
  • emoji-name-map—Name to unicode emoji mapping.
  • engine-builder (by jillix)—Engine composition parser.
  • engine-flow-types (by jillix)—Low level library providing Engine flow types.
  • enny (by jillix)—Generate Engine compositions from human-readable inputs.
  • packy—Set default fields in your package.json files.
  • ship-release—Publish new versions on GitHub and npm with ease.

📜 License

MIT © Ionică Bizău