Modules
Private members
Symbols for semi-privacy were replaced with JavaScript private properties [1] in E-mc 0.12.
0.11.0
const kConfig = Symbol('config');
class Host {
private readonly [kConfig]: Readonly<HostInitConfig>;
constructor(config: HostInitConfig) {
if (config.username) {
HOST_USERNAME.set(this, config.username);
}
this[kConfig] = Object.freeze({ ...config });
}
}
0.12.0
class Host {
readonly #config: Readonly<HostInitConfig>;
constructor(config: HostInitConfig) {
if (config.username) {
const cipher = HOST.CIPHER;
this.#username = cipher ? decryptUTF8(cipher.algorithm, cipher.key, cipher.iv, config.username) || '' : config.username;
}
this.#config = Object.freeze({ ...config });
}
}
The username property in particular requires pre-encryption [2] using the encryptUTF8 method exported from the Types package.
ESM imports
The default convention for all packages was removed in E-mc 0.9. It is auto-generated by the TSC compiler and is not necessary for out-of-source tree usage.
0.8.0
import Module from "@e-mc/module"; // OK
const Module = require("@e-mc/module"); // OK
let Module;
import("@e-mc/module").then(res => Module = res.default); // OK
import("@e-mc/module").then(res => Module = res); // OK
Module.default.isPath("/path/file"); // OK
Module.isPath("/path/file"); // OK
0.9.0
import Module from "@e-mc/module"; // OK
const Module = require("@e-mc/module"); // OK
let Module;
import("@e-mc/module").then(res => Module = res.default); // FAIL
import("@e-mc/module").then(res => Module = res); // OK
Module.default.isPath("/path/file"); // FAIL
Module.isPath("/path/file"); // OK
Besides static methods there is an additional utility library within these modules: