Encapsulation in functional program

I need good example encapsulation with module but without using classes. In pure functional style.

Hello,
Here’s a simple example of encapsulation using modules in a pure functional style:

javascript

// Define the module
const CounterModule = (() => {
  let count = 0;
  
  const getCount = () => count;
  const increment = () => count += 1;
  const reset = () => count = 0;

  return {
    getCount,
    increment,
    reset
  };
})();

// Usage
CounterModule.increment();
console.log(CounterModule.getCount()); // 1
CounterModule.reset();
console.log(CounterModule.getCount()); // 0

This example encapsulates the count variable within the module, providing controlled access through functions. new york dmv

Best Regards,
Thomas Brown