async_filter: Keep or drop elements using an asyncronous predicate function

View source: R/filter.R

async_filterR Documentation

Keep or drop elements using an asyncronous predicate function

Description

async_filter keep the elements for which .p is true. (Tested via isTRUE(). async_reject is the opposite, it drops them.

Usage

async_filter(.x, .p, ...)

async_reject(.x, .p, ...)

Arguments

.x

A list or atomic vector.

.p

An asynchronous predicate function.

...

Additional arguments to the predicate function.

Value

A deferred value for the result.

See Also

Other async iterators: async_detect(), async_every(), async_map()

Examples


## Filter out non-working URLs
afun <- async(function(urls) {
  test_url <- async_sequence(
     http_head, function(x) identical(x$status_code, 200L))
  async_filter(urls, test_url)
})
urls <- c("https://eu.httpbin.org/get",
          "https://eu.httpbin.org/status/404")
synchronise(afun(urls))


gaborcsardi/async documentation built on Nov. 20, 2024, 4:51 p.m.