Skip to content

dmitriz/hyperscript-strict

Repository files navigation

hyperscript-strict

Strict API for Hyperscript Libraries

Strict Abstract Node Tree API

As propsed in hyperhype/hyperscript#66 (comment), 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:

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

git clone https://github.com/dmitriz/hyperscript-strict
yarn
npm test

About

Strict API for Hyperscript Libraries

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published