# rely-on

> Returns selected DOM elements and throws an error if they are null.

Latest version **3.1.0-types.beta.2** (published 2017-11-22) · ISC license · 0 weekly downloads

## Install

```sh
npm install rely-on
pnpm add rely-on
yarn add rely-on
bun add rely-on
```

## Health

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

Positive: has types; no vulnerabilities; high quality score.

Warnings: low downloads; no esm support.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 3.1.0-types.beta.2 |
| Published | 2017-11-22 |
| First published | 2017-06-14 |
| Weekly downloads | 0 |
| License | ISC |
| TypeScript types | bundled |
| Module format | CommonJS |
| Dependencies | 0 |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 1 |
| Author | Daniel Arthur Gallagher |
| Maintainers | danarthurgallagher |
| Keywords | front-end, typescript, flow |

## Links

- npm: https://www.npmjs.com/package/rely-on
- Repository: https://github.com/DanArthurGallagher/rely-on
- Homepage: https://github.com/DanArthurGallagher/rely-on#readme
- Issues: https://github.com/DanArthurGallagher/rely-on/issues
- npm.io page: https://npm.io/package/rely-on

## Alternatives

- [@openai/codex-sdk](https://npm.io/package/@openai/codex-sdk.md) — 731.4K weekly downloads
- [babel-plugin-transform-react-jsx](https://npm.io/package/babel-plugin-transform-react-jsx.md) — 565.0K weekly downloads
- [babel-helper-remove-or-void](https://npm.io/package/babel-helper-remove-or-void.md) — 508.5K weekly downloads
- [@pnpm/store-controller-types](https://npm.io/package/@pnpm/store-controller-types.md) — 186.9K weekly downloads
- [react-native-signature-canvas](https://npm.io/package/react-native-signature-canvas.md) — 155.6K weekly downloads

## Recent versions

- 3.1.0-types.beta.2 (latest) — 2017-11-22
- 3.1.0-types.beta.1 — 2017-11-22
- 3.0.1 — 2017-06-15
- 3.0.0 — 2017-06-15
- 2.1.0 — 2017-06-15
- 2.0.1 — 2017-06-15
- 2.0.0 — 2017-06-14
- 1.0.1 — 2017-06-14
- 1.0.0 — 2017-06-14

## README

# Summary

HTML applications often require an identified element to be present and select the element with the assumption that it is present.

Type-annotation tools like TypeScript and Flow will let you know that this isn't strictly the case: if an element isn't present, then `null` will be returned from `document.getElementById`.

Refining the type of the result can be done in an `if (element !== null)...else` but this must be done every time in order to eliminate the possibility of `null`.

This package allows code to rely on a `Node` being present
- It refines a `Node | null | undefined` node into a `Node` to satisfy the type checker.
- It returns the `Node` passed so methods can chain as usual.
- It throws a TypeError with a customizable message if passed `null | undefined` so missing elements are caught at the point of selection.
- It throws a TypeError if the argument passed is not a `Node`.

## Example
    const element = relyOn(document.getElementById('identifier'));

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