# display-anything

> Display anything in DOM

Latest version **1.2.0** (published 2024-01-24) · MIT license · 0 weekly downloads

## Install

```sh
npm install display-anything
pnpm add display-anything
yarn add display-anything
bun add display-anything
```

## 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.2.0 |
| Published | 2024-01-24 |
| First published | 2024-01-21 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 0 |
| Unpacked size | 12.2 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 0 |
| Author | Pavel Grabovets / Hermann Rolfes |
| Maintainers | kungfooman |
| Keywords | json, dom, display, object, visualisation |

## Links

- npm: https://www.npmjs.com/package/display-anything
- Repository: https://github.com/kungfooman/DisplayAnything.js
- Homepage: https://github.com/kungfooman/DisplayAnything.js#readme
- Issues: https://github.com/kungfooman/DisplayAnything.js/issues
- npm.io page: https://npm.io/package/display-anything

## Alternatives

- [@mapbox/jsonlint-lines-primitives](https://npm.io/package/@mapbox/jsonlint-lines-primitives.md) — 5.3M weekly downloads
- [reftools](https://npm.io/package/reftools.md) — 3.5M weekly downloads
- [@hey-api/openapi-ts](https://npm.io/package/@hey-api/openapi-ts.md) — 3.5M weekly downloads
- [@mapbox/geojson-rewind](https://npm.io/package/@mapbox/geojson-rewind.md) — 2.4M weekly downloads
- [turbo-stream](https://npm.io/package/turbo-stream.md) — 1.7M weekly downloads

## Recent versions

- 1.2.0 (latest) — 2024-01-24
- 1.1.1 — 2024-01-24
- 1.1.0 — 2024-01-24
- 1.0.1 — 2024-01-22
- 1.0.0 — 2024-01-21

## README

# DisplayAnything.js

Work in 

This is a javascript library for displaying anything in a DOM. [link to demo](http://pgrabovets.github.io/json-view/)

### Installation
```javascript
  npm install display-anything;
```

### How to use
include jsonview.js from dist directory in your html page
```html
 <script src="jsonview.js"></script>
```
or you can use import
```javascript
  import jsonview from '@pgrabovets/json-view';
```

get json data and render tree into DOM
```javascript
// get json data
const data = '{"name": "json-view","version": "1.0.0"}';

// create json tree object
const tree = jsonview.create(data);

// render tree into dom element
jsonview.render(tree, document.querySelector('.tree'));

// you can render json data without creating tree
const tree = jsonview.renderJSON(data, document.querySelector('.tree'));
```

control methods
```javascript
// expand tree
jsonview.expand(tree);

// collapse tree
jsonview.collapse(tree);

// traverse tree object
jsonview.traverse(tree, function(node) {
  console.log(node);
});

// function toggles between show or hide
jsonview.toggleNode(tree);

// destory and unmount json tree from the dom
jsonview.destroy(tree);
```

# Example

https://github.com/kungfooman/DisplayAnything.js/blob/main/demo/demo.js

# Development

```sh
# Package doesn't require a build step, ESM ftw!
cd /var/www/html
git clone https://github.com/kungfooman/DisplayAnything.js
open http://127.0.0.1/DisplayAnything.js
```

As link: http://127.0.0.1/DisplayAnything.js

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