import each from "lodash/each" ; import { dryadic } from "../index" ; import { Dryad , DryadPlayer } from "dryadic" ; type JSONType = any ; export function makePlayer ( dryad ) { return dryadic ( dryad ) ; } export function expectPlayGraphToEqual ( dryad , expected , ignoreFn ? ) { const p = makePlayer ( dryad ) ; if ( ! p . tree ) { throw new Error ( "p.tree is undefined" ) ; } let g = p . tree . hyperscript ( ) ; if ( ignoreFn ) { g = ignoreFn ( g ) ; if ( expected ) { expected = ignoreFn ( expected ) ; } } if ( expected ) { expect ( g ) . toEqual ( expected ) ; } return g ; } param player param commandName param { Array } childAt return export function getCommand ( player , commandName , childAt = [ ] ) { const cmd = player . _collectCommands ( commandName ) ; let obj = cmd ; each ( childAt , i => { obj = obj . children [ i ] ; } ) ; return obj ; }