Skip to content

Commit e81185b

Browse files
committed
refactor: rely on ndarray/to-fancy for implementation logic
1 parent 629ce7b commit e81185b

File tree

14 files changed

+4
-1020
lines changed

14 files changed

+4
-1020
lines changed

lib/node_modules/@stdlib/ndarray/fancy/lib/error_message.js

Lines changed: 0 additions & 42 deletions
This file was deleted.

lib/node_modules/@stdlib/ndarray/fancy/lib/get.js

Lines changed: 0 additions & 62 deletions
This file was deleted.

lib/node_modules/@stdlib/ndarray/fancy/lib/get_slice.js

Lines changed: 0 additions & 57 deletions
This file was deleted.

lib/node_modules/@stdlib/ndarray/fancy/lib/get_value.js

Lines changed: 0 additions & 65 deletions
This file was deleted.

lib/node_modules/@stdlib/ndarray/fancy/lib/has_property.js

Lines changed: 0 additions & 52 deletions
This file was deleted.

lib/node_modules/@stdlib/ndarray/fancy/lib/main.js

Lines changed: 4 additions & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -25,22 +25,7 @@
2525
var setReadOnly = require( '@stdlib/utils/define-nonenumerable-read-only-property' );
2626
var parent = require( '@stdlib/ndarray/ctor' ); // eslint-disable-line stdlib/no-redeclare
2727
var inherit = require( '@stdlib/utils/inherit' );
28-
var Proxy = require( '@stdlib/proxy/ctor' );
29-
var prop2slice0d = require( './prop2slice.0d.js' );
30-
var prop2slice1d = require( './prop2slice.1d.js' );
31-
var prop2slicend = require( './prop2slice.nd.js' );
32-
var get = require( './get.js' );
33-
var set = require( './set.js' );
34-
35-
36-
// VARIABLES //
37-
38-
var get0d = get( prop2slice0d );
39-
var set0d = set( prop2slice0d );
40-
var get1d = get( prop2slice1d );
41-
var set1d = set( prop2slice1d );
42-
var getnd = get( prop2slicend );
43-
var setnd = set( prop2slicend );
28+
var ndarray2fancy = require( '@stdlib/ndarray/to-fancy' );
4429

4530

4631
// MAIN //
@@ -85,11 +70,7 @@ var setnd = set( prop2slicend );
8570
* // returns <FancyArray>
8671
*/
8772
function FancyArray( dtype, buffer, shape, strides, offset, order, options ) {
88-
var handlers;
89-
var nargs;
90-
var ndims;
91-
92-
nargs = arguments.length;
73+
var nargs = arguments.length;
9374
if ( !( this instanceof FancyArray ) ) {
9475
if ( nargs < 7 ) {
9576
return new FancyArray( dtype, buffer, shape, strides, offset, order );
@@ -99,24 +80,8 @@ function FancyArray( dtype, buffer, shape, strides, offset, order, options ) {
9980
// Call the parent constructor:
10081
parent.call( this, dtype, buffer, shape, strides, offset, order, ( nargs < 7 ) ? {} : options );
10182

102-
if ( Proxy ) { // NOTE: cannot use `@stdlib/assert/has-proxy-support` here, as that API uses code evaluation and might violate CSPs
103-
ndims = shape.length;
104-
handlers = {};
105-
if ( ndims === 0 ) {
106-
handlers.get = get0d;
107-
handlers.set = set0d;
108-
} else if ( ndims === 1 ) {
109-
handlers.get = get1d;
110-
handlers.set = set1d;
111-
} else {
112-
handlers.get = getnd;
113-
handlers.set = setnd;
114-
}
115-
return new Proxy( this, handlers );
116-
}
117-
// TODO: replace with `@stdlib/console/warn` (or equivalent once available)
118-
console.warn( 'WARNING: Proxy objects are not supported in the current environment. Some `FancyArray` functionality may not be available.' ); // eslint-disable-line no-console
119-
return this;
83+
// Proxy the current instance:
84+
return ndarray2fancy( this );
12085
}
12186

12287
// Inherit from the parent constructor:

0 commit comments

Comments
 (0)