# uwire

> A way to create persistent fragments

Latest version **1.1.0** (published 2020-08-24) · ISC license · 0 weekly downloads

## Install

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

## Health

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

Positive: esm support; no vulnerabilities.

Warnings: low downloads; no types.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 1.1.0 |
| Published | 2020-08-24 |
| First published | 2020-03-12 |
| Weekly downloads | 0 |
| License | ISC |
| TypeScript types | none |
| Module format | ESM + CommonJS |
| Dependencies | 1 |
| Unpacked size | 8.1 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| Author | Andrea Giammarchi |
| Maintainers | webreflection |
| Keywords | udomdiff, wire, persistent, fragment |

## Links

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

## Dependencies (1)

- [uarray](https://npm.io/package/uarray.md) ^1.0.0

## Alternatives

- [@mdxeditor/editor](https://npm.io/package/@mdxeditor/editor.md) — 962.4K weekly downloads
- [mmdb-lib](https://npm.io/package/mmdb-lib.md) — 680.9K weekly downloads
- [playcanvas](https://npm.io/package/playcanvas.md) — 36.2K weekly downloads
- [@glw907/cairn-cms](https://npm.io/package/@glw907/cairn-cms.md) — 967 weekly downloads
- [markdown-to-confluence](https://npm.io/package/markdown-to-confluence.md) — 103 weekly downloads

## Recent versions

- 1.1.0 (latest) — 2020-08-24
- 1.0.1 — 2020-03-12
- 1.0.0 — 2020-03-12

## README

# <em>µ</em>wire

[![Build Status](https://travis-ci.com/WebReflection/uwire.svg?branch=master)](https://travis-ci.com/WebReflection/uwire) [![Coverage Status](https://coveralls.io/repos/github/WebReflection/uwire/badge.svg?branch=master)](https://coveralls.io/github/WebReflection/uwire?branch=master)

A way to create persistent "_wired_" fragments that can be moved around when diffed through _[µdomdiff](https://github.com/WebReflection/udomdiff#readme)_.

```js
import {diffable, persistent} from 'uwire';

const wire = persistent(fragment);
diffable(wire, 1);  // repopulate all nodes, if gone, returns the fragment
diffable(wire, 0);  // return the initial fragment firstChild
diffable(wire, -0); // return the initial fragment lastChild
diffable(wire, -1); // remove all nodes and return the firstChild
```

If the fragment has only one child node, the `diffable` will always return that child node instead, making it a no-op.

### Why it this called _wire_?

It's like attaching, via strings (_wires_), the behavior of a _fragment_ that cannot be used to obtain the same result.

A _wire_ is not really a fragment per se, but it carries with it all it's needed to reuse, move, remove, re-append, such fragment.

```
      ┌--------▶[fragment]
◀---[wire]        |
        ├--------▶├ firstChild
        |         ├ ...
        └--------▶└ lastChild
```

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