I want to implement a structure that can be invoked like in the example below:
require("Promotions").getDisounts().getProductDiscounts().getLength();
I want to implement a structure that can be invoked like in the example below:
require("Promotions").getDisounts().getProductDiscounts().getLength();
 
    
    //Promotions.js
export default {
  getDsounts: () => ({
    getProductDiscounts: () => ({
      getLength: () => 20
    })
  })
}
 
    
    Your question is vague, hence this personal interpretation :
class Collection {
  constructor (items) {
    this.items = items;
  }
  getLength () {
    return this.items.length;
  }
  filter (predicate) {
    return new Collection(
      this.items.filter(predicate)
    );
  }
}
class Product {
  constructor (isDiscount) {
    this.isDiscount = isDiscount;
  }
}
class Products {
  constructor (items) {
    this.items = items;
  }
  getDiscounts () {
    return new ProductDiscounts(
      this.items.filter(p => p.isDiscount)
    );
  }
}
class ProductDiscounts {
  constructor (items) {
    this.items = items;
  }
  getProductDiscounts () {
    return this.items;
  }
}
var products = new Products(new Collection([
  new Product(true),
  new Product(false),
  new Product(true)
]));
console.log(products.getDiscounts().getProductDiscounts().getLength());// promotions.js
var Promotions = function promotions() {
  return {
     getDiscounts: function getDiscounts() {
         return {
             getProductDiscounts: function getProductDiscounts() {
                 return {
                     getLength: function getLength(){
                         return 20;
                     }
                 }
             }
         };            
     }
  };
}
module.exports = Promotions();
// main.js
var promotions = require("./promotions.js");
console.log(promotions.getDiscounts().getProductDiscounts().getLength());
