1
0
mirror of https://github.com/fluencelabs/wasm-bindgen synced 2025-04-05 11:51:05 +00:00

45 lines
1.1 KiB
JavaScript
Raw Normal View History

const wasm = require('wasm-bindgen-test.js');
const assert = require('assert');
2018-08-21 12:55:09 +01:00
function variadic_sum(...args) {
2018-08-19 13:39:16 +01:00
let answer = 0;
2018-08-21 12:55:09 +01:00
for(var i=0; i<args.length; i++) {
answer += args[i];
2018-08-19 13:39:16 +01:00
}
return answer;
}
2018-08-21 12:55:09 +01:00
exports.variadic_sum_u8 = variadic_sum;
exports.variadic_sum_u16 = variadic_sum;
exports.variadic_sum_u32 = variadic_sum;
exports.variadic_sum_u64 = variadic_sum;
exports.variadic_sum_i8 = variadic_sum;
exports.variadic_sum_i16 = variadic_sum;
exports.variadic_sum_i32 = variadic_sum;
exports.variadic_sum_i64 = variadic_sum;
exports.variadic_sum_f32 = variadic_sum;
exports.variadic_sum_f64 = variadic_sum;
2018-08-21 12:55:09 +01:00
function variadic_sum_opt(...args) {
let answer = 0;
for(var i=0; i<args.length; i++) {
if(args[i] != null) {
answer += args[i];
}
}
return answer;
}
exports.variadic_sum_opt = variadic_sum_opt;
function variadic_concat(...args) {
let answer = "";
for(var i=0; i<args.length; i++) {
answer = `${answer}${args[i]}`;
}
return answer;
}
exports.variadic_concat_str = variadic_concat;
exports.variadic_concat_string = variadic_concat;