# register-toml

> Register a require hook for .toml files

Latest version **1.0.0** (published 2018-07-17) · MIT license · 0 weekly downloads

## Install

```sh
npm install register-toml
pnpm add register-toml
yarn add register-toml
bun add register-toml
```

## 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 | 2018-07-17 |
| First published | 2018-07-17 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 3 |
| Unpacked size | 3.9 KB |
| Known vulnerabilities | 0 (+2 in 1 direct dependencies) |
| Install scripts | no |
| Author | Vojtech Stepancik |
| Maintainers | vojtechstep |
| Keywords | register, require, toml |

## Links

- npm: https://www.npmjs.com/package/register-toml
- Repository: https://github.com/VojtechStep/register-toml
- npm.io page: https://npm.io/package/register-toml

## Dependencies (3)

- [toml](https://npm.io/package/toml.md) ^2.3.3
- [pirates](https://npm.io/package/pirates.md) ^4.0.0
- [tosource](https://npm.io/package/tosource.md) ^1.0.0

## Recent versions

- 1.0.0 (latest) — 2018-07-17

## README

# register-toml

Adds a register hook to `require()` or `import` .toml files. Not meant for production, in which case it's preferred to include the .toml in the deployed bundle, for example with [this Rollup.js plugin](https://github.com/VojtechStep/rollup-plugin-toml).

```toml
# config.toml

[config]
api = { hostname = "localhost", port = 3000 }

[probe]
[[probe.nodes]]
id = "api"

[[probe.nodes.replicas]]
address = "localhost:3001"

[[probe.nodes.replicas]]
address = "localhost:3002"

[[probe.nodes]]
id = "web"

[[probe.nodes.replicas]]
address = "localhost:4000"

[[probe.nodes.replicas]]
address = "localhost:4001"
```

```js
// index.js
require('register-toml');
// Default import
import configuration from './config.toml';

console.log(Object.keys(configuration)); // [ 'config', 'probe' ]

// Named import
import { config, probe } from './config.toml';

console.log(probe.nodes[1].replicas.length); // 2
```
# Installation

`yarn add -D register-toml`  
or  
`npm install --save-dev register-toml`

# Usage

```js
require('register-ts')
```

Or for `require()`ing .toml in the REPL:
```bash
node -r register-toml
```

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