Skip to content

Commit 5a11ffb

Browse files
committed
refactor: apply suggestions from code review
--- type: pre_commit_static_analysis_report description: Results of running static analysis checks when committing changes. report: - task: lint_filenames status: passed - task: lint_editorconfig status: passed - task: lint_markdown status: na - task: lint_package_json status: na - task: lint_repl_help status: na - task: lint_javascript_src status: passed - task: lint_javascript_cli status: na - task: lint_javascript_examples status: passed - task: lint_javascript_tests status: passed - task: lint_javascript_benchmarks status: na - task: lint_python status: na - task: lint_r status: na - task: lint_c_src status: na - task: lint_c_examples status: na - task: lint_c_benchmarks status: na - task: lint_c_tests_fixtures status: na - task: lint_shell status: na - task: lint_typescript_declarations status: na - task: lint_typescript_tests status: na - task: lint_license_headers status: passed ---
1 parent 40421e2 commit 5a11ffb

File tree

4 files changed

+832
-575
lines changed

4 files changed

+832
-575
lines changed

lib/node_modules/@stdlib/ndarray/flatten-by/examples/index.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ var ndarray2array = require( '@stdlib/ndarray/to-array' );
2424
var flattenBy = require( './../lib' );
2525

2626
function scale( value ) {
27-
return value * 2.0;
27+
return value * 2.0;
2828
}
2929

3030
var xbuf = discreteUniform( 12, -100, 100, {

lib/node_modules/@stdlib/ndarray/flatten-by/lib/index.js

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -36,8 +36,7 @@
3636
* var x = array( [ [ [ 1.0, 2.0 ] ], [ [ 3.0, 4.0 ] ], [ [ 5.0, 6.0 ] ] ] );
3737
* // return <ndarray>
3838
*
39-
* // Flatten the input ndarray:
40-
* var y = flatten( x, scale );
39+
* var y = flattenBy( x, scale );
4140
* // returns <ndarray>
4241
*
4342
* var arr = ndarray2array( y );

lib/node_modules/@stdlib/ndarray/flatten-by/lib/main.js

Lines changed: 10 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -21,20 +21,8 @@
2121
// MODULES //
2222

2323
var isPlainObject = require( '@stdlib/assert/is-plain-object' );
24-
var hasOwnProp = require( '@stdlib/assert/has-own-property' );
24+
var isFunction = require( '@stdlib/assert/is-function' );
2525
var isndarrayLike = require( '@stdlib/assert/is-ndarray-like' );
26-
var isNonNegativeInteger = require( '@stdlib/assert/is-nonnegative-integer' );
27-
var isOrder = require( '@stdlib/ndarray/base/assert/is-order' );
28-
var getShape = require( '@stdlib/ndarray/shape' );
29-
var getOrder = require( '@stdlib/ndarray/order' );
30-
var getStrides = require( '@stdlib/ndarray/strides' );
31-
var getData = require( '@stdlib/ndarray/base/data-buffer' );
32-
var getDType = require( '@stdlib/ndarray/base/dtype' );
33-
var shape2strides = require( '@stdlib/ndarray/base/shape2strides' );
34-
var strides2order = require( '@stdlib/ndarray/base/strides2order' );
35-
var flattenShape = require( '@stdlib/ndarray/base/flatten-shape' );
36-
var assign = require( '@stdlib/ndarray/base/assign' );
37-
var emptyLike = require( '@stdlib/ndarray/empty-like' );
3826
var map = require( '@stdlib/ndarray/map' );
3927
var flatten = require( '@stdlib/ndarray/flatten' );
4028
var format = require( '@stdlib/string/format' );
@@ -80,35 +68,35 @@ function flattenBy( x, options, fcn, thisArg ) {
8068
var cb;
8169
var y;
8270

83-
if ( !isndarrayLike( x ) ) {
71+
if ( !isndarrayLike( x ) ) {
8472
throw new TypeError( format( 'invalid argument. First argument must be an ndarray-like object. Value: `%s`.', x ) );
8573
}
86-
opts = {};
74+
opts = {};
8775
if ( arguments.length < 3 ) { // Case: flattenBy( x, fcn )
8876
cb = options;
8977
} else if ( arguments.length === 3 ) {
9078
if ( isFunction( options ) ) { // Case: flattenBy( x, fcn, thisArg )
9179
cb = options;
9280
ctx = fcn;
9381
} else { // Case: flattenBy( x, options, fcn )
94-
if ( !isPlainObject( options ) ) {
95-
throw new TypeError( format( 'invalid argument. Options argument must be an object. Value: `%s`.', options ) );
96-
}
82+
if ( !isPlainObject( options ) ) {
83+
throw new TypeError( format( 'invalid argument. Options argument must be an object. Value: `%s`.', options ) );
84+
}
9785
opts = options;
9886
cb = fcn;
9987
}
10088
} else {
101-
if ( !isPlainObject( options ) ) {
102-
throw new TypeError( format( 'invalid argument. Options argument must be an object. Value: `%s`.', options ) );
103-
}
89+
if ( !isPlainObject( options ) ) {
90+
throw new TypeError( format( 'invalid argument. Options argument must be an object. Value: `%s`.', options ) );
91+
}
10492
opts = options;
10593
cb = fcn;
10694
ctx = thisArg;
10795
}
10896
if ( !isFunction( cb ) ) {
10997
throw new TypeError( format( 'invalid argument. Callback argument must be a function. Value: `%s`.', cb ) );
11098
}
111-
y = map( x, cb, ctx );
99+
y = map( x, cb, ctx );
112100
return flatten( y, opts );
113101
}
114102

0 commit comments

Comments
 (0)