Skip to content

Latest commit

 

History

History
 
 

Folders and files

NameName
Last commit message
Last commit date

parent directory

..
 
 
 
 
 
 
 
 
 
 
 
 
 
 

README.md

everyInBy

Test whether all properties (own and inherited) of an object pass a test implemented by a predicate function.

Usage

var everyInBy = require( '@stdlib/object/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 true

If provided an empty object, the function returns true.

function isPositive( v ) {
    return ( v > 0 );
}

var bool = everyInBy( {}, isPositive );
// returns true

Examples

var randu = require( '@stdlib/random/base/randu' );
var everyInBy = require( '@stdlib/object/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>

See Also

  • @stdlib/object/none-in-by: test whether every property in an object fails a test implemented by a predicate function.
  • @stdlib/object/some-in-by: test whether an object contains at least n properties (own and inherited) which pass a test implemented by a predicate function.
  • @stdlib/object/every-own-by: test whether all own properties of an object pass a test implemented by a predicate function.