Skip to content

Cumulatively test whether at least `n` array elements in a provided array are truthy.

License

Notifications You must be signed in to change notification settings

stdlib-js/array-base-cusome

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

43 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

About stdlib...

We believe in a future in which the web is a preferred environment for numerical computation. To help realize this future, we've built stdlib. stdlib is a standard library, with an emphasis on numerical and scientific computation, written in JavaScript (and C) for execution in browsers and in Node.js.

The library is fully decomposable, being architected in such a way that you can swap out and mix and match APIs and functionality to cater to your exact preferences and use cases.

When you use stdlib, you can be absolutely certain that you are using the most thorough, rigorous, well-written, studied, documented, tested, measured, and high-quality code out there.

To join us in bringing numerical computing to the web, get started by checking us out on GitHub, and please consider financially supporting stdlib. We greatly appreciate your continued support!

cusome

NPM version Build Status Coverage Status

Cumulatively test whether at least n array elements in a provided array are truthy.

Usage

import cusome from 'https://cdn.jsdelivr.net/gh/stdlib-js/array-base-cusome@deno/mod.js';

You can also import the following named exports from the package:

import { assign } from 'https://cdn.jsdelivr.net/gh/stdlib-js/array-base-cusome@deno/mod.js';

cusome( x, n )

Cumulatively tests whether at least n array elements in a provided array are truthy.

var x = [ false, false, false, true, true ];

var y = cusome( x, 2 );
// returns [ false, false, false, false, true ];

cusome.assign( x, n, y, stride, offset )

Cumulatively tests whether at least n array elements in a provided array are truthy and assigns results to a provided output array.

var x = [ false, false, false, true, true ];
var y = [ false, null, false, null, false, null, false, null, false, null ];

var out = cusome.assign( x, 2, y, 2, 0 );
// returns [ false, null, false, null, false, null, false, null, true, null ]

var bool = ( out === y );
// returns true

The function supports the following parameters:

  • x: input array.
  • n: number of elements.
  • out: output array.
  • stride: output array stride.
  • offset: output array offset.

Examples

import bernoulli from 'https://cdn.jsdelivr.net/gh/stdlib-js/random-array-bernoulli@deno/mod.js';
import cusome from 'https://cdn.jsdelivr.net/gh/stdlib-js/array-base-cusome@deno/mod.js';

// Create an array of random values:
var x = bernoulli( 10, 0.3 );
console.log( x );

// Cumulatively test whether at least two array elements are truthy:
var out = cusome( x, 2 );
console.log( out );

Notice

This package is part of stdlib, a standard library 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

Chat


License

See LICENSE.

Copyright

Copyright © 2016-2025. The Stdlib Authors.

Releases

No releases published

Packages

No packages published