time-to-botec

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

main.js (2438B)


      1 /**
      2 * @license Apache-2.0
      3 *
      4 * Copyright (c) 2020 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 // MODULES //
     22 
     23 var iterMap2 = require( './../../../../iter/tools/map2' );
     24 var log = require( './../../../../base/special/log' );
     25 
     26 
     27 // MAIN //
     28 
     29 /**
     30 * Returns an iterator which iteratively computes the base `b` logarithm.
     31 *
     32 * ## Notes
     33 *
     34 * -   For negative `b` or `x` iterated values, the returned iterator returns `NaN`.
     35 * -   If provided a numeric value as an iterator argument, the value is broadcast as an **infinite** iterator which **always** returns the provided value.
     36 * -   If an iterated value is non-numeric (including `NaN`), the returned iterator returns `NaN`. If non-numeric iterated values are possible, you are advised to provide an iterator which type checks and handles non-numeric values accordingly.
     37 * -   The length of the returned iterator is equal to the length of the shortest provided iterator. In other words, the returned iterator ends once **one** of the provided iterators ends.
     38 * -   If an environment supports `Symbol.iterator` and all provided iterators are iterable, the returned iterator is iterable.
     39 *
     40 * @param {(Iterator|number)} x - input iterator
     41 * @param {(Iterator|number)} b - input iterator
     42 * @throws {TypeError} first argument must be either an iterator protocol-compliant object or a number
     43 * @throws {TypeError} second argument must be either an iterator protocol-compliant object or a number
     44 * @returns {Iterator} iterator
     45 *
     46 * @example
     47 * var uniform = require( '@stdlib/random/iter/uniform' );
     48 *
     49 * var x = uniform( 0.0, 100.0 );
     50 * var y = uniform( 0.0, 10.0 );
     51 *
     52 * var iter = iterLog( x, y );
     53 *
     54 * var r = iter.next().value;
     55 * // returns <number>
     56 *
     57 * r = iter.next().value;
     58 * // returns <number>
     59 *
     60 * r = iter.next().value;
     61 * // returns <number>
     62 *
     63 * // ...
     64 */
     65 function iterLog( x, b ) {
     66 	return iterMap2( x, b, log );
     67 }
     68 
     69 
     70 // EXPORTS //
     71 
     72 module.exports = iterLog;