# laz-e

> asynchronously create DOM with a nice syntax.

Latest version **1.2.2** (published 2016-11-30) · MIT license · 0 weekly downloads

## Install

```sh
npm install laz-e
pnpm add laz-e
yarn add laz-e
bun add laz-e
```

## 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.2 |
| Published | 2016-11-30 |
| First published | 2014-10-29 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 1 |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 0 |
| Author | Kory Nunn |
| Maintainers | korynunn |

## Links

- npm: https://www.npmjs.com/package/laz-e
- Repository: https://github.com/KoryNunn/laz-e
- Homepage: https://github.com/KoryNunn/laz-e#readme
- Issues: https://github.com/KoryNunn/laz-e/issues
- npm.io page: https://npm.io/package/laz-e

## Dependencies (1)

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

## Recent versions

- 1.2.2 (latest) — 2016-11-30
- 1.2.1 — 2016-04-14
- 1.2.0 — 2014-12-11
- 1.1.0 — 2014-12-01
- 1.0.1 — 2014-11-27
- 1.0.0 — 2014-10-29

## README

# laz-e

asynchronously create DOM with a nice syntax.

# usage

require:

```javascript
// you must pass in window.document OR an object that implements the same API as document.
var e = require('laz-e')(document);
```

laz-e has the same syntax as [crel](https://www.npmjs.org/package/crel) except that it returns a function, that takes a callback.

also, any objects in the attributes will be JSON.stringified before being assigned as attributes.

```javascript

var dom = e('div',
        e('h1', 'Page heading'),
        e('section', {'class': 'main'}

            'Welcome to my awesome webpage!',

            function(callback){ // An asynchronous 'child'
                setTimeout(function(){
                    e('span')(callback); // return a span after 100ms
                },100);
            }
        )
    );

// Pass a callback to the result to get the element.
dom(function(error, element){
    document.body.appendChild(element);
});

```

Because you pass in document, you can use laz-e in node, using a module such as [dom-lite](https://www.npmjs.org/package/dom-lite):


```javascript

var domLite = require('dom-lite'),
    e = require('laz-e')(domLite.document);

var dom = e('div',
        e('h1', 'Page heading'),
        e('section', {'class': 'main'}
            'Welcome to my awesome webpage!',

            fs.readFile.bind(fs, './foo.txt'), // Load a text file asyncronously.

            fs.readFile.bind(fs, './bar.txt') // Load another text file asyncronously in parallel to the first one.
        )
    );

// Pass a callback to the result to get the element.
dom(function(error, element){
    response.end(element.outerHTML);
});

```

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