Ecosyste.ms: Awesome

An open API service indexing awesome lists of open source software.

Awesome Lists | Featured Topics | Projects

https://github.com/kvnneff/deku-component-is-node

Determine if an object is a valid Deku node
https://github.com/kvnneff/deku-component-is-node

Last synced: 25 days ago
JSON representation

Determine if an object is a valid Deku node

Awesome Lists containing this project

README

        

# deku-component-is-node [![Build Status](https://travis-ci.org/kvnneff/deku-component-is-node.svg?branch=master)](https://travis-ci.org/kvnneff/deku-component-is-node)

Determine if an object is a valid [Deku](https://github.com/dekujs/deku) node. Useful for testing.

## Example

```js
import isNode from 'deku-component-is-node'
import element from 'virtual-element'
import Mock from 'component-mock'

const Component = {
render: function () {
element('div', [
element('span', 'Hello World!')
])
}
}

const mock = Mock(component)
const node = mock.render()

isNode(node) //=> returns `true`
isNode(node, 'div') //=> returns `true`
isNode(node, 'span') //=> returns `false`
```

## API

### isNode(node, [type])

Returns `true` if `node` is a valid Deku node. If `type` is specified,
it will ensure that type is strictly equal. (whether that is a `Component`
or a `String` element name)

## License
MIT