|
21 | 21 | // MODULES //
|
22 | 22 |
|
23 | 23 | 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' ); |
25 | 25 | 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' ); |
38 | 26 | var map = require( '@stdlib/ndarray/map' );
|
39 | 27 | var flatten = require( '@stdlib/ndarray/flatten' );
|
40 | 28 | var format = require( '@stdlib/string/format' );
|
@@ -80,35 +68,35 @@ function flattenBy( x, options, fcn, thisArg ) {
|
80 | 68 | var cb;
|
81 | 69 | var y;
|
82 | 70 |
|
83 |
| - if ( !isndarrayLike( x ) ) { |
| 71 | + if ( !isndarrayLike( x ) ) { |
84 | 72 | throw new TypeError( format( 'invalid argument. First argument must be an ndarray-like object. Value: `%s`.', x ) );
|
85 | 73 | }
|
86 |
| - opts = {}; |
| 74 | + opts = {}; |
87 | 75 | if ( arguments.length < 3 ) { // Case: flattenBy( x, fcn )
|
88 | 76 | cb = options;
|
89 | 77 | } else if ( arguments.length === 3 ) {
|
90 | 78 | if ( isFunction( options ) ) { // Case: flattenBy( x, fcn, thisArg )
|
91 | 79 | cb = options;
|
92 | 80 | ctx = fcn;
|
93 | 81 | } 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 | + } |
97 | 85 | opts = options;
|
98 | 86 | cb = fcn;
|
99 | 87 | }
|
100 | 88 | } 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 | + } |
104 | 92 | opts = options;
|
105 | 93 | cb = fcn;
|
106 | 94 | ctx = thisArg;
|
107 | 95 | }
|
108 | 96 | if ( !isFunction( cb ) ) {
|
109 | 97 | throw new TypeError( format( 'invalid argument. Callback argument must be a function. Value: `%s`.', cb ) );
|
110 | 98 | }
|
111 |
| - y = map( x, cb, ctx ); |
| 99 | + y = map( x, cb, ctx ); |
112 | 100 | return flatten( y, opts );
|
113 | 101 | }
|
114 | 102 |
|
|
0 commit comments