UNPKG

1 kBJavaScriptView Raw
1"use strict";
2Object.defineProperty(exports, "__esModule", { value: true });
3const __1 = require("..");
4const test_1 = require("../test");
5// TODO: After we migrate all usages of this function to specify the optional 'name' parameter, we can change the parameter to be required.
6/**
7Test all the values in the collection against a provided predicate.
8
9@hidden
10@param source Source collection to test.
11@param predicate Predicate to test every item in the source collection against.
12@param name The name to call the collection of values, such as `values` or `keys`. If it is `undefined`, it uses the call stack to infer the label.
13*/
14exports.default = (source, predicate, name) => {
15 try {
16 for (const item of source) {
17 if (name) {
18 test_1.default(item, name, predicate, false);
19 }
20 else {
21 __1.default(item, predicate);
22 }
23 }
24 return true;
25 }
26 catch (error) {
27 return error.message;
28 }
29};