# map-properties

> array.map equivalent that also works on Objects and Strings

Latest version **0.1.2** (published 2015-10-06) · MIT license · 0 weekly downloads

## Install

```sh
npm install map-properties
pnpm add map-properties
yarn add map-properties
bun add map-properties
```

## Health

**Score 15/100 (F)** — status: abandoned.

Positive: no vulnerabilities.

Warnings: low downloads; no types; no esm support; pre 1.0.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 0.1.2 |
| Published | 2015-10-06 |
| First published | 2015-10-06 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | none |
| Module format | CommonJS |
| Node | >=0.10.0 |
| Dependencies | 1 |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 0 |
| Author | James Talmage |
| Maintainers | jamestalmage |
| Keywords | map, properties, iterator, object, objects, for-each, forEach, iterator |

## Links

- npm: https://www.npmjs.com/package/map-properties
- Repository: https://github.com/jamestalmage/map-properties
- Homepage: https://github.com/jamestalmage/map-properties#readme
- Issues: https://github.com/jamestalmage/map-properties/issues
- npm.io page: https://npm.io/package/map-properties

## Dependencies (1)

- [for-each](https://npm.io/package/for-each.md) ^0.3.2

## Recent versions

- 0.1.2 (latest) — 2015-10-06
- 0.1.1 — 2015-10-06
- 0.1.0 — 2015-10-06
- 0.0.1 — 2015-10-06

## README

# map-properties [![Build Status](https://travis-ci.org/jamestalmage/map-properties.svg?branch=master)](https://travis-ci.org/jamestalmage/map-properties)

> array.map equivalent that also works on Objects and Strings

## Install

```
$ npm install --save map-properties
```

## Usage

```js
var map = require('map-properties');

var mapFn = function(val) {
  return val + val.toUpperCase();
};

map(['a', 'b'], mapFn);
// => ['aA', 'bB']

map({a: 'b', c: 'd'}, mapFn);
// => {a: 'bB', c: 'dD'}

map('ab', mapFn);
// => 'aAbB'
```

## API

### mapProperties(source, mapFn[, context[, destination]])

##### source

*required*

Type: `string|object|array`

The source from which to map properties. 

##### mapFn

*required*

Type: `callback(propertyValue, propertyName, source, destination)`  

A callback that maps the properties to their new values. It is called with the following arguments:

  * `propertyValue` - the value of the property on the source object.
  * `propertyName` - the name (or index) of the property
  * `source` - the source object/array/string from which the properties are being mapped.
  * `destination` - the destination object on to which the properties are being mapped.

##### context

*optional*

If provided, will be the `this` value during execution of `mapFn`.

##### destination

*optional*

Explicitly provide the destination object, otherwise it will be created automatically.

```js
var destination = {};
map(source, mapFn, null, destination);
```
#### returns:

  `destination`

## License

MIT © [James Talmage](http://github.com/jamestalmage)

---
_Source: https://npm.io/package/map-properties · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
