|
1 | 1 | /** |
2 | | -* @license Apache-2.0 |
3 | | -* |
4 | | -* Copyright (c) 2020 The Stdlib Authors. |
5 | | -* |
6 | | -* Licensed under the Apache License, Version 2.0 (the "License"); |
7 | | -* you may not use this file except in compliance with the License. |
8 | | -* You may obtain a copy of the License at |
9 | | -* |
10 | | -* http://www.apache.org/licenses/LICENSE-2.0 |
11 | | -* |
12 | | -* Unless required by applicable law or agreed to in writing, software |
13 | | -* distributed under the License is distributed on an "AS IS" BASIS, |
14 | | -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
15 | | -* See the License for the specific language governing permissions and |
16 | | -* limitations under the License. |
17 | | -*/ |
| 2 | + * @license Apache-2.0 |
| 3 | + * |
| 4 | + * Copyright (c) 2020 The Stdlib Authors. |
| 5 | + * |
| 6 | + * Licensed under the Apache License, Version 2.0 (the "License"); |
| 7 | + * you may not use this file except in compliance with the License. |
| 8 | + * You may obtain a copy of the License at |
| 9 | + * |
| 10 | + * http://www.apache.org/licenses/LICENSE-2.0 |
| 11 | + * |
| 12 | + * Unless required by applicable law or agreed to in writing, software |
| 13 | + * distributed under the License is distributed on an "AS IS" BASIS, |
| 14 | + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 15 | + * See the License for the specific language governing permissions and |
| 16 | + * limitations under the License. |
| 17 | + */ |
18 | 18 |
|
19 | | -'use strict'; |
| 19 | +"use strict"; |
20 | 20 |
|
21 | | -var join = require( 'path' ).join; |
22 | | -var tryRequire = require( '@stdlib/utils/try-require' ); |
23 | | -var Float64Array = require( '@stdlib/array/float64' ); |
24 | | -var Float32Array = require( '@stdlib/array/float32' ); |
| 21 | +var Float64Array = require("@stdlib/array/float64"); |
| 22 | +var Float32Array = require("@stdlib/array/float32"); |
25 | 23 |
|
| 24 | +var add; |
26 | 25 | // Try loading the add-on: |
27 | | -var add = tryRequire( join( __dirname, 'addon.node' ) ); |
28 | | - |
| 26 | +try { |
| 27 | + add = require("./addon.node"); |
| 28 | +} catch (err) { |
| 29 | + add = err; |
| 30 | +} |
29 | 31 | /** |
30 | | -* Main execution sequence. |
31 | | -* |
32 | | -* @private |
33 | | -*/ |
| 32 | + * Main execution sequence. |
| 33 | + * |
| 34 | + * @private |
| 35 | + */ |
34 | 36 | function main() { |
35 | 37 | var x; |
36 | 38 | var y; |
37 | 39 | var z; |
38 | 40 |
|
39 | | - x = new Float64Array( [ 0.0, 1.0, 2.0, 3.0, 4.0 ] ); |
40 | | - y = new Float64Array( [ 5.0, 6.0, 7.0, 8.0, 9.0 ] ); |
41 | | - z = new Float64Array( x.length ); |
| 41 | + x = new Float64Array([0.0, 1.0, 2.0, 3.0, 4.0]); |
| 42 | + y = new Float64Array([5.0, 6.0, 7.0, 8.0, 9.0]); |
| 43 | + z = new Float64Array(x.length); |
42 | 44 |
|
43 | | - add( 5, x, 1, y, 1, z, 1 ); |
| 45 | + add(5, x, 1, y, 1, z, 1); |
44 | 46 |
|
45 | | - console.log( '' ); |
46 | | - console.log( 'Float64:' ); |
47 | | - console.log( z ); |
48 | | - console.log( '' ); |
| 47 | + console.log(""); |
| 48 | + console.log("Float64:"); |
| 49 | + console.log(z); |
| 50 | + console.log(""); |
49 | 51 |
|
50 | | - x = new Float32Array( [ 0.0, 1.0, 2.0, 3.0, 4.0 ] ); |
51 | | - y = new Float32Array( [ 5.0, 6.0, 7.0, 8.0, 9.0 ] ); |
52 | | - z = new Float32Array( x.length ); |
| 52 | + x = new Float32Array([0.0, 1.0, 2.0, 3.0, 4.0]); |
| 53 | + y = new Float32Array([5.0, 6.0, 7.0, 8.0, 9.0]); |
| 54 | + z = new Float32Array(x.length); |
53 | 55 |
|
54 | | - add( 5, x, 1, y, 1, z, 1 ); |
| 56 | + add(5, x, 1, y, 1, z, 1); |
55 | 57 |
|
56 | | - console.log( 'Float32:' ); |
57 | | - console.log( z ); |
58 | | - console.log( '' ); |
| 58 | + console.log("Float32:"); |
| 59 | + console.log(z); |
| 60 | + console.log(""); |
59 | 61 | } |
60 | 62 |
|
61 | | -if ( add instanceof Error ) { |
| 63 | +if (add instanceof Error) { |
62 | 64 | // Example compile command: /path/to/stdlib/node_modules/.bin/node-gyp rebuild |
63 | | - console.error( 'Error: please make sure you have compiled the add-on before attempting to run this file. To compile the add-on, resolve the location of the `node-gyp` executable (e.g., `$PWD/.bin/node-gyp` from the root stdlib project directory), navigate to `%s`, and run `%s`.\n\nError: %s\n', __dirname, '/path/to/node-gyp rebuild', add.message ); |
| 65 | + console.error( |
| 66 | + "Error: please make sure you have compiled the add-on before attempting to run this file. To compile the add-on, resolve the location of the `node-gyp` executable (e.g., `$PWD/.bin/node-gyp` from the root stdlib project directory), navigate to `%s`, and run `%s`.\n\nError: %s\n", |
| 67 | + __dirname, |
| 68 | + "/path/to/node-gyp rebuild", |
| 69 | + add.message, |
| 70 | + ); |
64 | 71 | } else { |
65 | 72 | main(); |
66 | 73 | } |
0 commit comments