# totality

> Total from subtotals, automatically updating with mutation observer

Latest version **1.0.3** (published 2021-03-12) · ISC license · 0 weekly downloads

## Install

```sh
npm install totality
pnpm add totality
yarn add totality
bun add totality
```

## 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.3 |
| Published | 2021-03-12 |
| First published | 2020-02-11 |
| Weekly downloads | 0 |
| License | ISC |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 1 |
| Unpacked size | 5.4 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 0 |
| Author | michaelcook.tech |
| Maintainers | entozoon |
| Keywords | total, subtotal, calculation |

## Links

- npm: https://www.npmjs.com/package/totality
- Repository: https://github.com/entozoon/totality
- Homepage: https://github.com/entozoon/totality#readme
- Issues: https://github.com/entozoon/totality/issues
- npm.io page: https://npm.io/package/totality

## Dependencies (1)

- [typescript](https://npm.io/package/typescript.md) ^3.7.5

## Recent versions

- 1.0.3 (latest) — 2021-03-12
- 1.0.2 — 2020-02-11
- 1.0.1 — 2020-02-11
- 1.0.0 — 2020-02-11

## README

# Totality

Total from subtotals, automatically updating in your DOM with mutation observations.

## Installation

```bash
npm i totality
```

## Usage

Create a `[data-totality]` element, which will sum up all the items pointed to by its data attribute, e.g.

```html
<div class="subtotal">£1.99</div>
<div class="subtotal">£2.99</div>
<div class="subtotal">£3.99</div>
<div data-totality=".subtotal"></div>
```

```js
import Totality from "totality";

// Spin up instances for any [data-totality] elements
const totalityElements = document.querySelectorAll("[data-totality]");
if (totalityElements) {
  const totalities = [...totalityElements].map(
    element => new Totality({ element, currency: "£" })
  );
}
```

And it will populate the total with `£8.97`.

## Updating

It observes mutations within the given subtotal elements, so if you've got other scripts wrangling prices, we good.

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