Hi,
I try to create CommonJS from Kotlin and tried the factorial example from here: https://kotlinlang.org/docs/tutorials/create-library-js.html
That gives me a module that I can import using:
module.exports = function (Kotlin) {
'use strict';
var _ = Kotlin.defineRootPackage(null, /** @lends _ */ {
org: Kotlin.definePackage(null, /** @lends _.org */ {
sample: Kotlin.definePackage(null, /** @lends _.org.sample */ {
factorial_za3lpa$: function (n) {
return n === 0 ? Kotlin.Long.ONE : Kotlin.Long.fromInt(n).multiply(_.org.sample.factorial_za3lpa$(n - 1));
}
})
})
});
Kotlin.defineModule('my.module', _);
return _;
}(require('kotlin'));
Why is the function called factorial_za3lpa
instead of plain factorial
?