Skip to content

Commit 39bf519

Browse files
committed
Auto-generated commit
1 parent 7f633f2 commit 39bf519

File tree

2 files changed

+4
-28
lines changed

2 files changed

+4
-28
lines changed

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -669,6 +669,7 @@ A total of 63 issues were closed in this release:
669669

670670
<details>
671671

672+
- [`c63f610`](https://github.com/stdlib-js/stdlib/commit/c63f610323ce4a6a44f0d359525274bb174d5c76) - **refactor:** use add-on dispatch utility _(by Athan Reines)_
672673
- [`ece831b`](https://github.com/stdlib-js/stdlib/commit/ece831b187c2e9b9ee3d29b527b39b4005ee9fe8) - **fix:** fallback to `assign` method _(by Athan Reines)_
673674
- [`bac2f1a`](https://github.com/stdlib-js/stdlib/commit/bac2f1af6007402efe470fffaf6a4c37645a3e28) - **docs:** fix comments _(by Athan Reines)_
674675
- [`a657481`](https://github.com/stdlib-js/stdlib/commit/a657481f37f58ef7158aff3363a9ce1819766d7a) - **docs:** add missing 'that' in comment _(by Philipp Burckhardt)_

special/abs/lib/native.js

Lines changed: 3 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -20,17 +20,15 @@
2020

2121
// MODULES //
2222

23-
var isTypedArrayLike = require( '@stdlib/assert/is-typed-array-like' );
24-
var serialize = require( '@stdlib/ndarray/base/serialize-meta-data' );
23+
var dispatch = require( '@stdlib/ndarray/base/unary-addon-dispatch' );
2524
var setProps = require( '@stdlib/ndarray/base/meta-data-props' );
26-
var getData = require( '@stdlib/ndarray/data-buffer' );
2725
var dtypes = require( '@stdlib/ndarray/dtypes' );
2826
var ufunc = require( './../../../tools/unary' );
2927
var addon = require( './../src/addon.node' );
3028
var meta = require( './meta.json' );
3129
var types = require( './types.json' );
3230
var policies = require( './policies.json' );
33-
var js = require( './main.js' );
31+
var fallback = require( './main.js' ).assign;
3432

3533

3634
// VARIABLES //
@@ -39,29 +37,6 @@ var idtypes = dtypes( 'numeric_and_generic' );
3937
var odtypes = dtypes( 'real_and_generic' );
4038

4139

42-
// FUNCTIONS //
43-
44-
/**
45-
* Applies a unary function to an input ndarray and assigns results to an output ndarray.
46-
*
47-
* @private
48-
* @param {ndarray} x - input array
49-
* @param {ndarray} y - output array
50-
* @returns {ndarray} output array
51-
*/
52-
function unary( x, y ) { // FIXME: move to separate package
53-
var xdata = getData( x );
54-
var ydata = getData( y );
55-
56-
// WARNING: we assume that, if we're provided something which has a data buffer resembling a typed array, we're provided a typed ndarray buffer; however, this can lead to potential unintended errors as the native add-on cannot work with non-typed array objects (e.g., generic arrays)...
57-
if ( !( isTypedArrayLike( xdata ) && isTypedArrayLike( ydata ) ) ) {
58-
return js.assign( x, y );
59-
}
60-
addon( xdata, serialize( x ), ydata, serialize( y ) );
61-
return y;
62-
}
63-
64-
6540
// MAIN //
6641

6742
/**
@@ -91,7 +66,7 @@ function unary( x, y ) { // FIXME: move to separate package
9166
* var arr = ndarray2array( y );
9267
* // returns [ [ 1.0, 2.0 ], [ 3.0, 4.0 ] ]
9368
*/
94-
var abs = ufunc( unary, [ idtypes ], odtypes, policies ); // eslint-disable-line vars-on-top
69+
var abs = ufunc( dispatch( addon, fallback ), [ idtypes ], odtypes, policies );
9570
setProps( meta, types, abs );
9671
setProps( meta, types, abs.assign );
9772

0 commit comments

Comments
 (0)