# dtx-base

> Base Module to simplify IIFE-centric modularization.

Latest version **1.0.0** (published 2017-06-02) · MIT license · 0 weekly downloads

## Install

```sh
npm install dtx-base
pnpm add dtx-base
yarn add dtx-base
bun add dtx-base
```

## Health

**Score 15/100 (F)** — status: abandoned.

Positive: no vulnerabilities.

Warnings: low downloads; no types; no esm support.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 1.0.0 |
| Published | 2017-06-02 |
| First published | 2017-06-02 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 0 |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 0 |
| Author | Thomas Sandberg |
| Maintainers | devtactix |
| Keywords | IIFE, modularization |

## Links

- npm: https://www.npmjs.com/package/dtx-base
- Repository: https://github.com/DevTactix/dtx-base
- Homepage: https://github.com/DevTactix/dtx-base#readme
- Issues: https://github.com/DevTactix/dtx-base/issues
- npm.io page: https://npm.io/package/dtx-base

## Recent versions

- 1.0.0 (latest) — 2017-06-02

## README

# dtx-base
## About
Base module to simplify IIFE-centric modularization.

## Background
Before _ES2015_ and modularization models like _AMD_ and _CommonJS_ dealing with global scope as well as containing functions into some kind of entity, i.e. modularization, was achieved by use of _Immediately-Invoked Function Expressions_ (_IIFE:s_).

The _dtx-base_ simplifies IIFE-centric modularization and creation of namespaces.

## Description
To instantiate a module simply call the _BaseModule_ constructor with first parameter being _the name of the module_ and the optional second parameter being _an already existing namespace object_.

## Implementation
1. Add the file _dtx-base.js_ as a dependency.
2. Now you are ready to implement.

```javascript
/**
 * EXAMPLE 1: Create simple namespace.
 */
// Create namespace.
(function (self) {
    self.hi = hi;

    function hi() {
        console.info("Hi from example 1!");
    }
})(new BaseModule("SimpleRoot"));

// Namespace is now modularized...
// ...and the exposed hi function is able to implement:
SimpleRoot.hi();
```

```javascript
/**
 * EXAMPLE 2: Create namespace with root and child.
 */
// Create root namespace.
var ParentRoot = new BaseModule("ParentRoot");

// Create child namespace.
(function (self) {
    "use strict";

    self.hi = hi;

    function hi() {
        console.info("Hi from example 2!");
    }
})(new BaseModule("Child", ParentRoot));

// Child namespace is now modularized within the context of the ParentRoot namespace.
// Implement the exposed hi function like this:
ParentRoot.Child.hi();
```

## Author
[DevTactix](https://github.com/DevTactix)

---
_Source: https://npm.io/package/dtx-base · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
