Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
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
- Host: GitHub
- URL: https://github.com/kvnneff/deku-component-is-node
- Owner: kvnneff
- License: mit
- Created: 2015-11-26T00:32:57.000Z (almost 9 years ago)
- Default Branch: master
- Last Pushed: 2015-11-26T03:20:53.000Z (almost 9 years ago)
- Last Synced: 2024-09-18T16:42:27.127Z (about 2 months ago)
- Language: JavaScript
- Size: 4.88 KB
- Stars: 1
- Watchers: 3
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: Readme.md
- Changelog: History.md
- License: LICENSE
Awesome Lists containing this project
- awesome-deku - deku-component-is-node - Determine if an object is a valid Deku node. (Testing)
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