mirror of
https://github.com/swc-project/swc.git
synced 2024-12-30 00:52:29 +03:00
bbaf619f63
swc_bundler: - [x] Fix wrapped esms. (denoland/deno#9307) - [x] Make test secure.
50 lines
1.5 KiB
TypeScript
50 lines
1.5 KiB
TypeScript
// Loaded from https://deno.land/x/ramda@v0.27.2/source/whereAny.js
|
|
|
|
|
|
import _curry2 from './internal/_curry2.js';
|
|
import _has from './internal/_has.js';
|
|
|
|
|
|
/**
|
|
* Takes a spec object and a test object; each of the spec's own properties must be a predicate function.
|
|
* Each predicate is applied to the value of the corresponding property of the
|
|
* test object. `whereAny` returns true if at least one of the predicates return true,
|
|
* false otherwise.
|
|
*
|
|
* `whereAny` is well suited to declaratively expressing constraints for other
|
|
* functions such as [`filter`](#filter) and [`find`](#find).
|
|
*
|
|
* @func
|
|
* @memberOf R
|
|
* @category Object
|
|
* @sig {String: (* -> Boolean)} -> {String: *} -> Boolean
|
|
* @param {Object} spec
|
|
* @param {Object} testObj
|
|
* @return {Boolean}
|
|
* @see R.propSatisfies, R.where
|
|
* @example
|
|
*
|
|
* // pred :: Object -> Boolean
|
|
* const pred = R.whereAny({
|
|
* a: R.equals('foo'),
|
|
* b: R.complement(R.equals('xxx')),
|
|
* x: R.gt(R.__, 10),
|
|
* y: R.lt(R.__, 20)
|
|
* });
|
|
*
|
|
* pred({a: 'foo', b: 'xxx', x: 8, y: 34}); //=> true
|
|
* pred({a: 'xxx', b: 'xxx', x: 9, y: 21}); //=> false
|
|
* pred({a: 'bar', b: 'xxx', x: 10, y: 20}); //=> false
|
|
* pred({a: 'foo', b: 'bar', x: 10, y: 20}); //=> true
|
|
* pred({a: 'foo', b: 'xxx', x: 11, y: 20}); //=> true
|
|
*/
|
|
var whereAny = _curry2(function whereAny(spec, testObj) {
|
|
for (var prop in spec) {
|
|
if (_has(prop, spec) && spec[prop](testObj[prop])) {
|
|
return true;
|
|
}
|
|
}
|
|
return false;
|
|
});
|
|
export default whereAny;
|