Skip to content

Commit

Permalink
Auto-generated commit
Browse files Browse the repository at this point in the history
  • Loading branch information
stdlib-bot committed Jan 14, 2024
1 parent 50188e2 commit 957c6c1
Showing 1 changed file with 7 additions and 12 deletions.
19 changes: 7 additions & 12 deletions base/every-by/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -77,27 +77,22 @@ The `predicate` function is provided three arguments:
To set the `predicate` function execution context, provide a `thisArg`.

```javascript
function sum( value ) {
if ( value < 0 ) {
return false;
}
this.sum += value;
function predicate( value ) {
this.count += 1;
return true;
return ( value > 0 );
}

var x = [ 1, 2, 3, 4 ];
var x = [ 1, 2, -3, 4 ];

var context = {
'sum': 0,
'count': 0
};

var bool = everyBy( x, sum, context );
// returns true
var bool = everyBy( x, predicate, context );
// returns false

var mean = context.sum / context.count;
// returns 2.5
var cnt = context.count;
// returns 3
```

</section>
Expand Down

0 comments on commit 957c6c1

Please sign in to comment.