Skip to main content

modules_snippets_js

To use a module, use the custom import syntax in the process (or other module) where you want to utilize it.

const { myFunc } = yepcode.import("your-module");
tip

Modules also support versioning, and if you want to import one specific module version, just add a second parameter to the import sentence:

const { myFunc } = yepcode.import("your-module", "v1.0");

You can have as many modules as needed, and they work like any CommonJS module, exporting the functions you want to use from process source code.

For example, a JavaScript module exporting a function to say hello:

module.exports = () => console.log("Hello world!");

To use this library from a YepCode process named say_hello, the code would be:

const sayHello = yepcode.import("say_hello");

sayHello();

A module can also export several functions:

const sayHelloToMike = () => console.log("Hello Mike!");
const sayHelloToDavid = () => console.log("Hello David!");

module.exports = { sayHelloToMike, sayHelloToDavid };

To use these functions, read them from the returned object:

const sayHelloModule = yepcode.import("say_hello");

sayHelloModule.sayHelloToMike();
sayHelloModule.sayHelloToDavid();