Skip to content

Commit 6dbff24

Browse files
feat: added wasm implementation for dapxsum
1 parent 18ad933 commit 6dbff24

File tree

2 files changed

+96
-0
lines changed

2 files changed

+96
-0
lines changed
Lines changed: 63 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,63 @@
1+
#!/usr/bin/env node
2+
3+
/**
4+
* @license Apache-2.0
5+
*
6+
* Copyright (c) 2024 The Stdlib Authors.
7+
*
8+
* Licensed under the Apache License, Version 2.0 (the "License");
9+
* you may not use this file except in compliance with the License.
10+
* You may obtain a copy of the License at
11+
*
12+
* http://www.apache.org/licenses/LICENSE-2.0
13+
*
14+
* Unless required by applicable law or agreed to in writing, software
15+
* distributed under the License is distributed on an "AS IS" BASIS,
16+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
17+
* See the License for the specific language governing permissions and
18+
* limitations under the License.
19+
*/
20+
21+
'use strict';
22+
23+
// MODULES //
24+
25+
var resolve = require( 'path' ).resolve;
26+
var readFile = require( '@stdlib/fs/read-file' ).sync;
27+
var writeFile = require( '@stdlib/fs/write-file' ).sync;
28+
var replace = require( '@stdlib/string/replace' );
29+
30+
31+
// VARIABLES //
32+
33+
var wpath = resolve( __dirname, '..', 'src', 'main.wasm' );
34+
var tpath = resolve( __dirname, 'template.txt' );
35+
var opath = resolve( __dirname, '..', 'lib', 'binary.browser.js' );
36+
37+
var opts = {
38+
'encoding': 'utf8'
39+
};
40+
41+
var PLACEHOLDER = '{{WASM_BASE64}}';
42+
43+
44+
// MAIN //
45+
46+
/**
47+
* Main execution sequence.
48+
*
49+
* @private
50+
*/
51+
function main() {
52+
var wasm;
53+
var tmpl;
54+
55+
wasm = readFile( wpath );
56+
tmpl = readFile( tpath, opts );
57+
58+
tmpl = replace( tmpl, PLACEHOLDER, wasm.toString( 'base64' ) );
59+
60+
writeFile( opath, tmpl, opts );
61+
}
62+
63+
main();
Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
/**
2+
* @license Apache-2.0
3+
*
4+
* Copyright (c) 2024 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+
19+
'use strict';
20+
21+
// MODULES //
22+
23+
var base64ToUint8Array = require( '@stdlib/string/base/base64-to-uint8array' );
24+
25+
26+
// MAIN //
27+
28+
var wasm = base64ToUint8Array( '{{WASM_BASE64}}' );
29+
30+
31+
// EXPORTS //
32+
33+
module.exports = wasm;

0 commit comments

Comments
 (0)