diff --git a/lib/node_modules/@stdlib/array/base/count-if/README.md b/lib/node_modules/@stdlib/array/base/count-if/README.md new file mode 100644 index 000000000000..368ab4a45690 --- /dev/null +++ b/lib/node_modules/@stdlib/array/base/count-if/README.md @@ -0,0 +1,145 @@ + + +# countIf + +> Count the number of elements in an array that satisfy the provided testing function. + + + +
+ +
+ + + + + +
+ +## Usage + +```javascript +var countIf = require( '@stdlib/array/base/count-if' ); +``` + +#### countIf( x, predicate\[, thisArg] ) + +Counts the number of elements in an array that satisfy the provided testing function. + +```javascript +var x = [ 0, 1, 0, 1, 2 ]; + +function predicate( val ) { + return ( val % 2 === 0 ); +} + +var out = countIf( x, predicate ); +// returns 3 +``` + +If a `predicate` function returns a truthy value, the function counts that value. + +The `predicate` function is provided three arguments: + +- **value**: current array element. +- **index**: current array element index. +- **arr**: input array. + +To set the `predicate` function execution context, provide a `thisArg`. + +```javascript +var x = [ 1, 2, 3, 4 ]; + +var context = { + 'target': 3 +}; + +function predicate( value ) { + return ( value > this.target ); +} + +var out = countIf( x, predicate, context ); +// returns 1 +``` + +
+ + + + + +
+ +
+ + + + + +
+ +## Examples + + + +```javascript +var bernoulli = require( '@stdlib/random/array/bernoulli' ); +var countIf = require( '@stdlib/array/base/count-if' ); + +var x = bernoulli( 100, 0.5, { + 'dtype': 'generic' +}); +console.log( x ); + +function predicate( val ) { + return val === 1; +} +var n = countIf( x, predicate ); +console.log( n ); +``` + +
+ + + + + +
+ +
+ + + + + + + + + + + + + + diff --git a/lib/node_modules/@stdlib/array/base/count-if/benchmark/benchmark.length.js b/lib/node_modules/@stdlib/array/base/count-if/benchmark/benchmark.length.js new file mode 100644 index 000000000000..13a9bc4c09c6 --- /dev/null +++ b/lib/node_modules/@stdlib/array/base/count-if/benchmark/benchmark.length.js @@ -0,0 +1,100 @@ +/** +* @license Apache-2.0 +* +* Copyright (c) 2024 The Stdlib Authors. +* +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +'use strict'; + +// MODULES // + +var bench = require( '@stdlib/bench' ); +var pow = require( '@stdlib/math/base/special/pow' ); +var isNonNegativeInteger = require( '@stdlib/assert/is-nonnegative-integer' ).isPrimitive; +var bernoulli = require( '@stdlib/random/array/bernoulli' ); +var pkg = require( './../package.json' ).name; +var countIf = require( './../lib' ); + + +// FUNCTIONS // + +/** +* Creates a benchmark function. +* +* @private +* @param {PositiveInteger} len - array length +* @returns {Function} benchmark function +*/ +function createBenchmark( len ) { + var x = bernoulli( len, 0.5, { + 'dtype': 'generic' + }); + return benchmark; + + /** + * Benchmark function. + * + * @private + * @param {Benchmark} b - benchmark instance + */ + function benchmark( b ) { + var out; + var i; + + b.tic(); + for ( i = 0; i < b.iterations; i++ ) { + out = countIf( x, function predicate( v ) { + return v === 1; + } ); + if ( typeof out !== 'number' ) { + b.fail( 'should return a number' ); + } + } + b.toc(); + if ( !isNonNegativeInteger( out ) ) { + b.fail( 'should return a nonnegative integer' ); + } + b.pass( 'benchmark finished' ); + b.end(); + } +} + + +// MAIN // + +/** +* Main execution sequence. +* +* @private +*/ +function main() { + var len; + var min; + var max; + var f; + var i; + + min = 1; // 10^min + max = 6; // 10^max + + for ( i = min; i <= max; i++ ) { + len = pow( 10, i ); + + f = createBenchmark( len ); + bench( pkg+':dtype=generic,len='+len, f ); + } +} + +main(); diff --git a/lib/node_modules/@stdlib/array/base/count-if/docs/repl.txt b/lib/node_modules/@stdlib/array/base/count-if/docs/repl.txt new file mode 100644 index 000000000000..457b1181c5f7 --- /dev/null +++ b/lib/node_modules/@stdlib/array/base/count-if/docs/repl.txt @@ -0,0 +1,32 @@ + +{{alias}}( x, predicate[, thisArg] ) + Counts the number of elements in an array that satisfy the provided testing + function. + + Parameters + ---------- + x: ArrayLikeObject + Input array. + + predicate: Function + Testing function. + + thisArg: any (optional) + Execution context. + + Returns + ------- + out: integer + Number of truthy values for which the testing function evaluates to + true. + + Examples + -------- + > var out = {{alias}}( [ 0, 1, 1 ], function predicate( v ) { + ... return v === 1; + ... } ) + 2 + + See Also + -------- + diff --git a/lib/node_modules/@stdlib/array/base/count-if/docs/types/index.d.ts b/lib/node_modules/@stdlib/array/base/count-if/docs/types/index.d.ts new file mode 100644 index 000000000000..719556a52a39 --- /dev/null +++ b/lib/node_modules/@stdlib/array/base/count-if/docs/types/index.d.ts @@ -0,0 +1,90 @@ +/* +* @license Apache-2.0 +* +* Copyright (c) 2024 The Stdlib Authors. +* +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +// TypeScript Version: 4.1 + +/// + +import { Collection, AccessorArrayLike } from '@stdlib/types/array'; + +/** +* Returns a boolean indicating whether an element passes a test. +* +* @returns boolean indicating whether an element passes a test +*/ +type Nullary = ( this: U ) => boolean; + +/** +* Returns a boolean indicating whether an element passes a test. +* +* @param value - current array element +* @returns boolean indicating whether an element passes a test +*/ +type Unary = ( this: U, value: T ) => boolean; + +/** +* Returns a boolean indicating whether an element passes a test. +* +* @param value - current array element +* @param index - current array element index +* @returns boolean indicating whether an element passes a test +*/ +type Binary = ( this: U, value: T, index: number ) => boolean; + +/** +* Returns a boolean indicating whether an element passes a test. +* +* @param value - current array element +* @param index - current array element index +* @param arr - input array +* @returns boolean indicating whether an element passes a test +*/ +type Ternary = ( this: U, value: T, index: number, arr: Collection | AccessorArrayLike ) => boolean; + +/** +* Returns a boolean indicating whether an element passes a test. +* +* @param value - current array element +* @param index - current array element index +* @param arr - input array +* @returns boolean indicating whether an element passes a test +*/ +type Predicate = Nullary | Unary | Binary | Ternary; + +/** +* Counts the number of truthy values in an array. +* +* @param x - input array +* @param predicate - testing function +* @param thisArg - function context +* @returns number of values for which the provided function evaluates to true +* +* @example +* var x = [ 0, 1, 0, 1 ]; +* function predicate( v ) { +* return v > this; +* } +* var n = countIf( x, predicate, 0 ); +* // returns 2 +*/ +declare function countIf( x: Collection | AccessorArrayLike, predicate: Predicate, thisArg?: ThisParameterType> ): number; + + +// EXPORTS // + +export = countIf; diff --git a/lib/node_modules/@stdlib/array/base/count-if/docs/types/test.ts b/lib/node_modules/@stdlib/array/base/count-if/docs/types/test.ts new file mode 100644 index 000000000000..44fb086bdf46 --- /dev/null +++ b/lib/node_modules/@stdlib/array/base/count-if/docs/types/test.ts @@ -0,0 +1,42 @@ +/* +* @license Apache-2.0 +* +* Copyright (c) 2024 The Stdlib Authors. +* +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +import countIf from './index'; + + +// TESTS // + +// The function returns a number... +{ + countIf( [ 1, 2, 3 ], () => { return true } ); // $ExpectType number +} + +// The compiler throws an error if the function is provided an argument which is not a collection or the function is not boolean returning... +{ + countIf( [ 5 ], function() { return 1 } ); // $ExpectError + countIf( true ); // $ExpectError + countIf( false, function() { return false} ); // $ExpectError + countIf( null ); // $ExpectError + countIf( [ {}, {} ], ()=>{} ); // $ExpectError +} + +// The compiler throws an error if the function is provided an unsupported number of arguments... +{ + countIf(); // $ExpectError + countIf( [ 1, 2, 3 ], 2 ); // $ExpectError +} diff --git a/lib/node_modules/@stdlib/array/base/count-if/examples/index.js b/lib/node_modules/@stdlib/array/base/count-if/examples/index.js new file mode 100644 index 000000000000..30d4a733c799 --- /dev/null +++ b/lib/node_modules/@stdlib/array/base/count-if/examples/index.js @@ -0,0 +1,36 @@ +/** +* @license Apache-2.0 +* +* Copyright (c) 2024 The Stdlib Authors. +* +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +'use strict'; + +var bernoulli = require( '@stdlib/random/array/bernoulli' ); +var countIf = require( './../lib' ); + +var x = bernoulli( 100, 0.5, { + 'dtype': 'generic' +}); +console.log( x ); + +var threshold = 0; + +function predicate( val ) { + return val === 1; +} + +var n = countIf( x, predicate, threshold ); +console.log( n ); diff --git a/lib/node_modules/@stdlib/array/base/count-if/lib/index.js b/lib/node_modules/@stdlib/array/base/count-if/lib/index.js new file mode 100644 index 000000000000..af962706c435 --- /dev/null +++ b/lib/node_modules/@stdlib/array/base/count-if/lib/index.js @@ -0,0 +1,46 @@ +/** +* @license Apache-2.0 +* +* Copyright (c) 2024 The Stdlib Authors. +* +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +'use strict'; + +/** +* Count the number of elements in an array that satisfy the provided testing function. +* +* @module @stdlib/array/base/count-if +* +* @example +* var countIf = require( '@stdlib/array/base/count-if' ); +* +* var x = [ 0, 1, 0, 1, 2 ]; +* +* function predicate( value ) { +* return ( value % 2 === 0 ) +* } +* +* var n = countIf( x, predicate ); +* // returns 3 +*/ + +// MODULES // + +var main = require( './main.js' ); + + +// EXPORTS // + +module.exports = main; diff --git a/lib/node_modules/@stdlib/array/base/count-if/lib/main.js b/lib/node_modules/@stdlib/array/base/count-if/lib/main.js new file mode 100644 index 000000000000..898305980626 --- /dev/null +++ b/lib/node_modules/@stdlib/array/base/count-if/lib/main.js @@ -0,0 +1,163 @@ +/** +* @license Apache-2.0 +* +* Copyright (c) 2024 The Stdlib Authors. +* +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +'use strict'; + +// MODULES // + +var isComplexTypedArray = require( '@stdlib/array/base/assert/is-complex-typed-array' ); +var isAccessorArray = require( '@stdlib/array/base/assert/is-accessor-array' ); +var resolveGetter = require( '@stdlib/array/base/resolve-getter' ); +var reinterpret = require( '@stdlib/strided/base/reinterpret-complex' ); + + +// FUNCTIONS // + +/** +* Counts the number of elements in an indexed array that satisfy the provided testing function. +* +* @private +* @param {Collection} x - input array +* @param {Function} predicate - testing function +* @param {*} [thisArg] - function context +* @returns {NonNegativeInteger} number of values for which the provided function evaluates to true +* +* @example +* var x = [ 0, 1, 0, 1 ]; +* function predicate( v ) { +* return v > 0; +* } +* var n = indexed( x, predicate ); +* // returns 2 +*/ +function indexed( x, predicate, thisArg ) { + var n; + var i; + + n = 0; + for ( i = 0; i < x.length; i++ ) { + if ( predicate.call( thisArg, x[ i ], i, x ) ) { + n += 1; + } + } + return n; +} + +/** +* Counts the number of elements in an accessor array that satisfy the provided testing function. +* +* @private +* @param {Collection} x - input array +* @param {Function} predicate - testing function +* @param {*} [thisArg] - function context +* @returns {NonNegativeInteger} number of values for which the provided function evaluates to true +* +* @example +* var toAccessorArray = require( '@stdlib/array/base/to-accessor-array' ); +* +* var x = toAccessorArray( [ 0, 1, 0, 1 ] ); +* function predicate( v ) { +* return v > 0; +* } +* var n = accessors( x, predicate ); +* // returns 2 +*/ +function accessors( x, predicate, thisArg ) { + var get; + var n; + var i; + + get = resolveGetter( x ); + + n = 0; + for ( i = 0; i < x.length; i++ ) { + if ( predicate.call( thisArg, get( x, i ), i, x ) ) { + n += 1; + } + } + return n; +} + +/** +* Counts the number of elements in a complex array that satisfy the provided testing function. +* +* @private +* @param {Collection} x - input array +* @param {Function} predicate - testing function +* @param {*} [thisArg] - function context +* @returns {NonNegativeInteger} number of values for which the provided function evaluates to true +* +* @example +* var Complex128Array = require( '@stdlib/array/complex128' ); +* +* var x = new Complex128Array( [ 1.0, 2.0, 0.0, 0.0, 3.0, 4.0, 0.0, 0.0 ] ); +* function predicate( v ) { +* return v > 0; +* } +* var n = complex( x, predicate ); +* // returns 2 +*/ +function complex( x, predicate, thisArg ) { + var view; + var n; + var i; + + view = reinterpret( x, 0 ); + + n = 0; + for ( i = 0; i < view.length; i += 2 ) { + if ( predicate.call( thisArg, view[ i ], i, view ) || predicate.call( thisArg, view[ i+1 ], i+1, view ) ) { + n += 1; + } + } + return n; +} + + +// MAIN // + +/** +* Counts the number of elements in an array that satisfy the provided testing function. +* +* @param {Collection} x - input array +* @param {Function} predicate - testing array +* @param {*} [thisArg] - function context +* @returns {NonNegativeInteger} number of truthy values +* +* @example +* var x = [ 0, 1, 0, 1, 1 ]; +* function predicate( v ) { +* return v > 0; +* } +* var n = countIf( x, predicate ); +* // returns 3 +*/ +function countIf( x, predicate, thisArg ) { + if ( isAccessorArray( x ) ) { + if ( isComplexTypedArray( x ) ) { + return complex( x, predicate, thisArg ); + } + return accessors( x, predicate, thisArg ); + } + return indexed( x, predicate, thisArg ); +} + + +// EXPORTS // + +module.exports = countIf; diff --git a/lib/node_modules/@stdlib/array/base/count-if/package.json b/lib/node_modules/@stdlib/array/base/count-if/package.json new file mode 100644 index 000000000000..34355f2ab3b7 --- /dev/null +++ b/lib/node_modules/@stdlib/array/base/count-if/package.json @@ -0,0 +1,65 @@ +{ + "name": "@stdlib/array/base/count-if", + "version": "0.0.0", + "description": "Count the number of elements in an array that satisfy the provided testing function.", + "license": "Apache-2.0", + "author": { + "name": "The Stdlib Authors", + "url": "https://github.com/stdlib-js/stdlib/graphs/contributors" + }, + "contributors": [ + { + "name": "The Stdlib Authors", + "url": "https://github.com/stdlib-js/stdlib/graphs/contributors" + } + ], + "main": "./lib", + "directories": { + "benchmark": "./benchmark", + "doc": "./docs", + "example": "./examples", + "lib": "./lib", + "test": "./test" + }, + "types": "./docs/types", + "scripts": {}, + "homepage": "https://github.com/stdlib-js/stdlib", + "repository": { + "type": "git", + "url": "git://github.com/stdlib-js/stdlib.git" + }, + "bugs": { + "url": "https://github.com/stdlib-js/stdlib/issues" + }, + "dependencies": {}, + "devDependencies": {}, + "engines": { + "node": ">=0.10.0", + "npm": ">2.7.0" + }, + "os": [ + "aix", + "darwin", + "freebsd", + "linux", + "macos", + "openbsd", + "sunos", + "win32", + "windows" + ], + "keywords": [ + "stdlib", + "stdtypes", + "types", + "data", + "structure", + "array", + "count", + "sum", + "summation", + "countif", + "total", + "truthy" + ] +} diff --git a/lib/node_modules/@stdlib/array/base/count-if/test/test.js b/lib/node_modules/@stdlib/array/base/count-if/test/test.js new file mode 100644 index 000000000000..86fb05295f8d --- /dev/null +++ b/lib/node_modules/@stdlib/array/base/count-if/test/test.js @@ -0,0 +1,231 @@ +/** +* @license Apache-2.0 +* +* Copyright (c) 2024 The Stdlib Authors. +* +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +'use strict'; + +// MODULES // + +var tape = require( 'tape' ); +var Complex128Array = require( '@stdlib/array/complex128' ); +var Int32Array = require( '@stdlib/array/int32' ); +var toAccessorArray = require( '@stdlib/array/base/to-accessor-array' ); +var countIf = require( './../lib' ); + + +// TESTS // + +tape( 'main export is a function', function test( t ) { + t.ok( true, __filename ); + t.strictEqual( typeof countIf, 'function', 'main export is a function' ); + t.end(); +}); + +tape( 'the function counts the number of truthy values based on a testing function (generic)', function test( t ) { + var expected; + var actual; + var x; + + x = [ 0, 1, 0, 1, 2 ]; + expected = 3; + actual = countIf( x, function predicate( v ) { + return ( v % 2 === 0 ); + }); + + t.strictEqual( actual, expected, 'returns expected value' ); + t.end(); +}); + +tape( 'the function counts the number of truthy values based on a testing function (accessors)', function test( t ) { + var expected; + var actual; + var x; + + x = toAccessorArray([ 0, 1, 0, 1, 2 ]); + expected = 2; + actual = countIf( x, function predicate( v ) { + return v === 1; + }); + + t.strictEqual( actual, expected, 'returns expected value' ); + t.end(); +}); + +tape( 'the function counts the number of truthy values based on a testing function (real typed array)', function test( t ) { + var expected; + var actual; + var x; + + x = new Int32Array([ 0, 1, 0, 1, 2 ]); + expected = 1; + actual = countIf( x, function predicate( v ) { + return v > 1; + }); + + t.strictEqual( actual, expected, 'returns expected value' ); + t.end(); +}); + +tape( 'the function counts the number of truthy values based on a testing function (complex typed array)', function test( t ) { + var expected; + var actual; + var x; + + x = new Complex128Array([ 0.0, 0.0, 1.0, 0.0, 3.0, 4.0, 0.0, 5.0 ]); + expected = 3; + actual = countIf( x, function predicate( v ) { + return v === 0; + }); + + t.strictEqual( actual, expected, 'returns expected value' ); + t.end(); +}); + +tape( 'the function returns zero if provided an array of length `0`', function test( t ) { + var expected; + var actual; + var x; + + expected = 0; + + x = []; + actual = countIf( x, function predicate( v ) { + return v === 1; + }); + t.strictEqual( actual, expected, 'returns expected value' ); + + x = toAccessorArray([]); + actual = countIf( x, function predicate( v ) { + return v === 1; + }); + t.strictEqual( actual, expected, 'returns expected value' ); + + x = new Int32Array([]); + actual = countIf( x, function predicate( v ) { + return v === 1; + }); + t.strictEqual( actual, expected, 'returns expected value' ); + + x = new Complex128Array([]); + actual = countIf( x, function predicate( v ) { + return v === 1; + }); + t.strictEqual( actual, expected, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function returns zero if no truthy values are found', function test( t ) { + var expected; + var actual; + var x; + + expected = 0; + + x = [ 0, 0, 0, 0 ]; + actual = countIf( x, function predicate( v ) { + return v === 1; + }); + t.strictEqual( actual, expected, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function returns the length of the array if all values are truthy', function test( t ) { + var expected; + var actual; + var x; + + x = [ 1, 1, 1, 1 ]; + expected = x.length; + + actual = countIf( x, function predicate( v ) { + return v === 1; + }); + t.strictEqual( actual, expected, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function supports providing a custom execution context', function test( t ) { + var expected; + var context; + var actual; + var x; + + context = { + 'threshold': 2 + }; + x = [ 1, 2, 3, 4, 5 ]; + expected = 3; // Only values greater than 2 + actual = countIf( x, function predicate( v ) { + return v > this.threshold; // eslint-disable-line no-invalid-this + }, context ); + + t.strictEqual( actual, expected, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function counts the number of objects with a custom predicate function using `thisArg`', function test( t ) { + var expected; + var thisArg; + var actual; + var x; + + thisArg = { + 'target': 20 + }; + x = [ + { + 'name': 'John', + 'value': 10 + }, + { + 'name': 'Jane', + 'value': 20 + }, + { + 'name': 'Doe', + 'value': 30 + } + ]; + + // Count the number of objects where the value property matches the target + expected = 1; // One object have its value property equal to 20 + actual = countIf( x, function predicate( v ) { + return v.value === this.target; // eslint-disable-line no-invalid-this + }, thisArg ); + + t.strictEqual( actual, expected, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function returns zero if provided an array with no truthy values (false, null, undefined are treated as non truthy values)', function test( t ) { + var expected; + var actual; + var x; + + expected = 0; + x = [ false, 0, '', null, undefined ]; + actual = countIf( x, function predicate( v ) { + return v; // Returns truthy values + }); + t.strictEqual( actual, expected, 'returns expected value' ); + t.end(); +});