Following are the key points described later in this article:
var drawTraingle = function() {
console.log("Traingle drawn");
}
var drawCircle = function() {
console.log("Circle drawn");
}
Above code could be saved as draw.js. The file draw.js could be used to represent a module representing functions to draw different shapes. As per this page, module.exports is the object that’s actually returned as the result of a require call.
module.exports = {
drawTraingle: function() {
console.log("Traingle drawn");
},
drawCircle: function() {
console.log("Circle drawn");
}
};
The above code could also be written as following:
var drawTraingle = function() {
console.log("Traingle drawn");
};
var drawCircle = function() {
console.log("Circle drawn");
};
exports.drawTraingle = drawTraingle;
exports.drawCircle = drawCircle;
Following code represents how the above function can be used in other file, say, main.js
var d = require("./draw.js");
d.drawTraingle();
d.drawCircle();
Pay attention to usage of “require” function.
node main.js
It would print following:
Traingle drawn
Circle drawn
When building a Retrieval-Augmented Generation (RAG) application powered by Large Language Models (LLMs), which combine…
Last updated: 25th Jan, 2025 Have you ever wondered how to seamlessly integrate the vast…
Artificial Intelligence (AI) agents have started becoming an integral part of our lives. Imagine asking…
In the ever-evolving landscape of agentic AI workflows and applications, understanding and leveraging design patterns…
In this blog, I aim to provide a comprehensive list of valuable resources for learning…
Have you ever wondered how systems determine whether to grant or deny access, and how…