# confi-helpers

> template helpers for firstandthird/confi

Latest version **1.0.0** (published 2020-11-06) · MIT license · 0 weekly downloads

## Install

```sh
npm install confi-helpers
pnpm add confi-helpers
yarn add confi-helpers
bun add confi-helpers
```

## 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 | 2020-11-06 |
| First published | 2019-05-27 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 1 |
| Unpacked size | 15.5 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 0 |
| Author | First+Third |
| Maintainers | dawnerd, orthagonal1 |
| Keywords | config, settings, env |

## Links

- npm: https://www.npmjs.com/package/confi-helpers
- Repository: https://github.com/firstandthird/confi-helpers
- Issues: https://github.com/firstandthird/confi-helpers/issues
- npm.io page: https://npm.io/package/confi-helpers

## Dependencies (1)

- [ms](https://npm.io/package/ms.md) ^2.1.1

## Alternatives

- [replicas-cli](https://npm.io/package/replicas-cli.md) — 3.0K weekly downloads
- [env-contract](https://npm.io/package/env-contract.md) — 133 weekly downloads
- [@openveo/api](https://npm.io/package/@openveo/api.md) — 61 weekly downloads
- [@ryniaubenpm2/cumque-error-reiciendis](https://npm.io/package/@ryniaubenpm2/cumque-error-reiciendis.md) — 54 weekly downloads
- [ts-global-type-extra](https://npm.io/package/ts-global-type-extra.md) — 11 weekly downloads

## Recent versions

- 1.0.0 (latest) — 2020-11-06
- 0.0.1 — 2019-05-27

## README

<h1 align="center">Confi Helpers</h1>

<p align="center">
  <a href="https://github.com/firstandthird/eslint-config-firstandthird/actions">
    <img src="https://img.shields.io/github/workflow/status/firstandthird/confi-helpers/Test/main?label=Tests&style=for-the-badge" alt="Test Status"/>
  </a>
  <a href="https://github.com/firstandthird/eslint-config-firstandthird/actions">
    <img src="https://img.shields.io/github/workflow/status/firstandthird/confi-helpers/Lint/main?label=Lint&style=for-the-badge" alt="Lint Status"/>
  </a>
</p>

Confi Helpers is not designed to be used directly. It is used by [Confi](https://github.com/firstandthird/confi).

## Helpers:

### `exists(name)`

Checks if a var is set.

  - `name` - name of the variable to check.

Returns: _boolean_


### `getEnv(name, [fallback])`

Gets an environment variable.

  - `name` - the environment variable to grab.
  - `fallback` - a fallback value to use if the environment variable is not set.

Returns: _string_ - Value of environment variable or thrown error if `name` doesn't exist and no fallback provided.


### `getEnvInt(name, [fallback])`

Gets an environment variable.

  - `name` - the environment variable to grab.
  - `fallback` - a fallback value to use if the environment variable is not set.

Returns: _int_ - Value of environment variable, casted to an integer or thrown error if `name` doesn't exist and no fallback provided.

### `getEnvOrFilename(name)`

Reads a file or returns value of an environment variable.

  - `name` - Name of the environment variable.

Returns: _string_ - Contents of a file or value of the environment variable. If variable not found error will be thrown.


### `hasValue(value)`

Checks if a passed variable has a value and isn't null, undefined, or empty.

Note: Arrays and objects are not checked.

  - `value` - Passed variable to check.

Returns: _boolean_


### `readFile(name)`

Checks if a passed variable has a value and isn't null, undefined, or empty.

Note: Arrays and objects are not checked.

  - `name` - Filename

Returns: _string_ File contents.


### `truthy(value, [fallback])`

Checks if a value is truthy.

  - `value` - value to check.
  - `fallback` - defaults to `false`

Returns: _boolean_


### `truthyEnv(name, [fallback])`

Checks if an environment variable is truthy.

  - `value` - name of the environment variable.
  - `fallback` - defaults to `false`

Returns: _boolean_


### `ms(value)`

Converts a value to milliseconds. Uses the [ms](https://www.npmjs.com/package/ms) package.

  - `value` - value to convert.

Returns: _mixed_

---

<a href="https://firstandthird.com"><img src="https://firstandthird.com/_static/ui/images/safari-pinned-tab-62813db097.svg" height="32" width="32" align="right"></a>

_A [First + Third](https://firstandthird.com) Project_

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