0.1.1 • Published 1 year ago
@stdlib/utils-every-in-by v0.1.1
everyInBy
Test whether all properties (own and inherited) of an object pass a test implemented by a predicate function.
Installation
npm install @stdlib/utils-every-in-byUsage
var everyInBy = require( '@stdlib/utils-every-in-by' );everyInBy( object, predicate[, thisArg ] )
Tests whether all properties (own and inherited) of an object pass a test implemented by a predicate function.
var o;
var bool;
function isPositive( v ) {
return ( v > 0 );
}
o = {
'a': 1,
'b': 2,
'c': 3
};
bool = everyInBy( o, isPositive );
// returns trueIf provided an empty object, the function returns true.
function isPositive(v) {
return ( v > 0 );
}
var bool = everyInBy( {}, isPositive );
// returns trueExamples
var randu = require( '@stdlib/random-base-randu' );
var everyInBy = require( '@stdlib/utils-every-in-by' );
var bool;
var o;
var i;
function isPositive(v) {
return ( v > 0 );
}
o = {};
for ( i = 0; i < 100; i++ ) {
o[ i ] = ( randu() < 0.95 );
}
bool = everyInBy( o, isPositive );
// returns <boolean>Notice
This package is part of stdlib, a standard library for JavaScript and Node.js, with an emphasis on numerical and scientific computing. The library provides a collection of robust, high performance libraries for mathematics, statistics, streams, utilities, and more.
For more information on the project, filing bug reports and feature requests, and guidance on how to develop stdlib, see the main project repository.
Community
License
See LICENSE.
Copyright
Copyright © 2016-2024. The Stdlib Authors.