Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/dmitriz/hyperscript-strict
Strict API for Hyperscript Libraries
https://github.com/dmitriz/hyperscript-strict
dom hyperscript virtual-dom
Last synced: 2 months ago
JSON representation
Strict API for Hyperscript Libraries
- Host: GitHub
- URL: https://github.com/dmitriz/hyperscript-strict
- Owner: dmitriz
- License: mit
- Created: 2017-04-23T15:20:55.000Z (over 7 years ago)
- Default Branch: master
- Last Pushed: 2024-05-06T12:27:06.000Z (8 months ago)
- Last Synced: 2024-05-06T23:32:37.607Z (8 months ago)
- Topics: dom, hyperscript, virtual-dom
- Language: JavaScript
- Size: 404 KB
- Stars: 2
- Watchers: 2
- Forks: 0
- Open Issues: 5
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# hyperscript-strict
Strict API for Hyperscript Libraries
## Strict Abstract Node Tree API
As propsed in https://github.com/hyperhype/hyperscript/issues/66#issuecomment-296449960, we implement the API### h( {tag: tag, props: props, children : children} )
that is equivalent to
### h( tag : String, props : Object, children : Array )
## Complete code
Due to the strict nature of the API,
the implementation code for the extension of `h` is very short:```js
var isObject = val => (null != val) && ('object' == typeof val)var extend = h => (obj, ...rest) => isObject(obj)
? h(obj.tag, obj.props, obj.children.map(child => isObject(child)
? extend(h)(child)
: child
))
: h(obj, ...rest)module.exports = extend
```
## Run tests
```sh
git clone https://github.com/dmitriz/hyperscript-strict
yarn
npm test
```