Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

p-props

Package Overview
Dependencies
Maintainers
1
Versions
10
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

p-props - npm Package Compare versions

Comparing version 1.1.0 to 1.2.0

14

index.js
'use strict';
const pMap = require('p-map');
const map = input => {
return Promise.all(input.values()).then(values => {
const map = (input, mapper, options) => {
return pMap(input.entries(), entry => mapper(entry[1], entry[0]), options).then(values => {
const ret = new Map();

@@ -17,7 +18,7 @@

const obj = input => {
const obj = (input, mapper, options) => {
// TODO: use `Object.entries()` when targeting Node.js 6
const keys = Object.keys(input);
return Promise.all(keys.map(key => input[key])).then(values => {
return pMap(keys, key => mapper(input[key], key), options).then(values => {
const ret = {};

@@ -40,2 +41,5 @@

module.exports = input => input instanceof Map ? map(input) : obj(input);
module.exports = (input, mapper, options) => {
mapper = mapper || (value => value);
return input instanceof Map ? map(input, mapper, options) : obj(input, mapper, options);
};
{
"name": "p-props",
"version": "1.1.0",
"version": "1.2.0",
"description": "Like `Promise.all()` but for `Map` and `Object`",

@@ -38,2 +38,5 @@ "license": "MIT",

],
"dependencies": {
"p-map": "^1.2.0"
},
"devDependencies": {

@@ -40,0 +43,0 @@ "ava": "*",

@@ -39,5 +39,5 @@ # p-props [![Build Status](https://travis-ci.org/sindresorhus/p-props.svg?branch=master)](https://travis-ci.org/sindresorhus/p-props)

### pProps(input)
### pProps(input, [mapper], [options])
Returns a `Promise` that is fulfilled when all promises in `input` are fulfilled, or rejects if any of the promises reject. The fulfilled value is the same as `input`, but with a fulfilled version of each entry value.
Returns a `Promise` that is fulfilled when all promises in `input` and ones returned from `mapper` are fulfilled, or rejects if any of the promises reject. The fulfilled value is the same as `input`, but with a fulfilled version of each entry value, or the fulfilled value returned from `mapper`, if defined.

@@ -50,3 +50,14 @@ #### input

#### mapper(element, index)
Type: `Function`
Expected to return a `Promise` or value.
#### options
Type: `Object`
See the [`p-map` options](https://github.com/sindresorhus/p-map#options).
## Related

@@ -53,0 +64,0 @@

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc