time-to-botec

Benchmark sampling in different programming languages
Log | Files | Refs | README

index.js (1931B)


      1 /**
      2 * @license Apache-2.0
      3 *
      4 * Copyright (c) 2018 The Stdlib Authors.
      5 *
      6 * Licensed under the Apache License, Version 2.0 (the "License");
      7 * you may not use this file except in compliance with the License.
      8 * You may obtain a copy of the License at
      9 *
     10 *    http://www.apache.org/licenses/LICENSE-2.0
     11 *
     12 * Unless required by applicable law or agreed to in writing, software
     13 * distributed under the License is distributed on an "AS IS" BASIS,
     14 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
     15 * See the License for the specific language governing permissions and
     16 * limitations under the License.
     17 */
     18 
     19 'use strict';
     20 
     21 /**
     22 * Test whether a collection contains at least `n` elements which pass a test implemented by a predicate function, iterating from right to left.
     23 *
     24 * @module @stdlib/utils/async/some-by-right
     25 *
     26 * @example
     27 * var readFile = require( '@stdlib/fs/read-file' );
     28 * var someByRightAsync = require( '@stdlib/utils/async/some-by-right' );
     29 *
     30 * var files = [
     31 *     './beep.js',
     32 *     './boop.js'
     33 * ];
     34 *
     35 * function done( error, bool ) {
     36 *     if ( error ) {
     37 *         throw error;
     38 *     }
     39 *     if ( bool ) {
     40 *         console.log( 'Successfully read some files.' );
     41 *     } else {
     42 *         console.log( 'Unable to read some files.' );
     43 *     }
     44 * }
     45 *
     46 * function predicate( file, next ) {
     47 *     var opts = {
     48 *         'encoding': 'utf8'
     49 *     };
     50 *     readFile( file, opts, onFile );
     51 *
     52 *     function onFile( error ) {
     53 *         if ( error ) {
     54 *             return next( null, false );
     55 *         }
     56 *         next( null, true );
     57 *     }
     58 * }
     59 *
     60 * someByRightAsync( files, 2, predicate, done );
     61 */
     62 
     63 // MODULES //
     64 
     65 var setReadOnly = require( './../../../define-nonenumerable-read-only-property' );
     66 var someByRightAsync = require( './some_by_right.js' );
     67 var factory = require( './factory.js' );
     68 
     69 
     70 // MAIN //
     71 
     72 setReadOnly( someByRightAsync, 'factory', factory );
     73 
     74 
     75 // EXPORTS //
     76 
     77 module.exports = someByRightAsync;