2018-08-19 00:15:29 +03:00
|
|
|
const wasm = require('wasm-bindgen-test.js');
|
|
|
|
const assert = require('assert');
|
|
|
|
|
2018-08-21 14:55:09 +03:00
|
|
|
function variadic_sum(...args) {
|
2018-08-19 15:39:16 +03:00
|
|
|
let answer = 0;
|
2018-08-21 14:55:09 +03:00
|
|
|
for(var i=0; i<args.length; i++) {
|
|
|
|
answer += args[i];
|
2018-08-19 15:39:16 +03:00
|
|
|
}
|
|
|
|
return answer;
|
|
|
|
}
|
|
|
|
|
2018-08-21 14:55:09 +03: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-19 00:15:29 +03:00
|
|
|
|
2018-08-21 14:55:09 +03: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;
|