Skip to content

Commit 9dc90bc

Browse files
committed
Use base utility
1 parent cc4f221 commit 9dc90bc

File tree

2 files changed

+6
-29
lines changed

2 files changed

+6
-29
lines changed

lib/node_modules/@stdlib/array/logspace/lib/index.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -32,9 +32,9 @@
3232

3333
// MODULES //
3434

35-
var logspace = require( './logspace.js' );
35+
var main = require( './main.js' );
3636

3737

3838
// EXPORTS //
3939

40-
module.exports = logspace;
40+
module.exports = main;

lib/node_modules/@stdlib/array/logspace/lib/logspace.js renamed to lib/node_modules/@stdlib/array/logspace/lib/main.js

Lines changed: 4 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -20,10 +20,10 @@
2020

2121
// MODULES //
2222

23-
var pow = require( '@stdlib/math/base/special/pow' );
2423
var isNumber = require( '@stdlib/assert/is-number' ).isPrimitive;
2524
var isNonNegativeInteger = require( '@stdlib/assert/is-nonnegative-integer' ).isPrimitive;
2625
var isnan = require( '@stdlib/math/base/assert/is-nan' );
26+
var gen = require( '@stdlib/array/base/logspace' );
2727

2828

2929
// MAIN //
@@ -44,11 +44,6 @@ var isnan = require( '@stdlib/math/base/assert/is-nan' );
4444
* // returns [ 1, ~2.5, ~6.31, ~15.85, ~39.81, 100 ]
4545
*/
4646
function logspace( a, b, len ) {
47-
var arr;
48-
var end;
49-
var tmp;
50-
var d;
51-
var i;
5247
if ( !isNumber( a ) || isnan( a ) ) {
5348
throw new TypeError( 'invalid argument. Exponent of start value must be numeric. Value: `' + a + '`.' );
5449
}
@@ -57,28 +52,10 @@ function logspace( a, b, len ) {
5752
}
5853
if ( arguments.length < 3 ) {
5954
len = 10;
60-
} else {
61-
if ( !isNonNegativeInteger( len ) ) {
62-
throw new TypeError( 'invalid argument. Length must be a nonnegative integer. Value: `' + len + '`.' );
63-
}
64-
if ( len === 0 ) {
65-
return [];
66-
}
55+
} else if ( !isNonNegativeInteger( len ) ) {
56+
throw new TypeError( 'invalid argument. Length must be a nonnegative integer. Value: `' + len + '`.' );
6757
}
68-
// Calculate the increment:
69-
end = len - 1;
70-
d = ( b-a ) / end;
71-
72-
// Build the output array...
73-
arr = [];
74-
tmp = a;
75-
arr.push( pow( 10, tmp ) );
76-
for ( i = 1; i < end; i++ ) {
77-
tmp += d;
78-
arr.push( pow( 10, tmp ) );
79-
}
80-
arr.push( pow( 10, b ) );
81-
return arr;
58+
return gen( a, b, len );
8259
}
8360

8461

0 commit comments

Comments
 (0)