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

p-one

Package Overview
Dependencies
Maintainers
1
Versions
2
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

p-one

Test whether some promise passes a testing function

  • 1.0.0
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
920
decreased by-31.85%
Maintainers
1
Weekly downloads
 
Created
Source

p-one Build Status

Test whether some promise passes a testing function

Like Array.some for promises.

Install

$ npm install --save p-one

Usage

const pOne = require('p-one');
const getContinent = require('get-continent'); // not a real module

const places = [
	getCapital('Norway').then(info => info.name),
	'Bangkok, Thailand',
	'Berlin, Germany',
	'Tokyo, Japan'
];

const testingFunction = x => getContinent(x).then(x => x === 'europe');

pOne(places, testingFunction).then(result => {
	console.log(result);
	//=> true
});

API

pOne(input, testingFunction, [options])

Returns a Promise that is fulfilled when any promise in input and ones returned from testingFunction are fulfilled, or rejects if any of the promises reject. The fulfilled value is a boolean that is true if any promise passed the test and false otherwise.

input

Type: Iterable<Promise|any>

Iterated over concurrently in the testingFunction function.

testingFunction(element, index)

Type: Function

Expected to return a Promise<boolean> or boolean.

options

Type: Object

concurrency

Type: number
Default: Infinity
Minimum: 1

Number of concurrently pending promises returned by testingFunction.

  • p-every - Test whether all promises passes a testing function
  • p-filter - Filter promises concurrently
  • p-locate - Get the first fulfilled promise that satisfies the provided testing function
  • p-map - Map over promises concurrently
  • More…

License

MIT © Kevin Martensson

Keywords

FAQs

Package last updated on 25 May 2017

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

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