modules/datguivr/index.js
/*
  Verify that all of the items in provided arguments are existing controllers that should be ok to remove.

  Returns false if there are any mismatches, true if believed ok to continue with actual remove()

  If any of the provided args are folders (have isFolder property) this is called recursively.
  This will result in redundant work as each folder will also call it again as it's removed, but this is cheap
  and it means that any error should be caught as early as possible and the whole process aborted.
  */
Verify that all of the items in provided arguments are existing controllers that should be ok to remove.
Returns false if there are any mismatches, true if believed ok to continue with actual remove()

If any of the provided args are folders (have isFolder property) this is called recursively.
This will result in redundant work as each folder will also call it again as it's removed, but this is cheap
and it means that any error should be caught as early as possible and the whole process aborted.
Verify that all of the items in provided arguments are existing controllers that should be ok to remove . Returns false if there are any mismatches true if believed ok to continue with actual remove () If any of the provided args are folders ( have isFolder property ) this is called recursively . This will result in redundant work as each folder will also call it again as it ' s removed but this is cheap and it means that any error should be caught as early as possible and the whole process aborted .
function removeTest( ...args ) {
    for (var i=0; i<args.length; i++) {
      var obj = args[i];
      if (controllers.indexOf(obj) === -1 || !obj.folder.hasChild(obj)) {
        console.log("Can't remove controller " + obj); 
        return false;
      }
      if (obj.isFolder) {
        if (!removeTest( ...obj.guiChildren )) return false;
      }
    }
    return true;
  }
function removeTest ( ... args ) { for ( var i = 0 ; i < args . length ; i ++ ) { var obj = args [ i ] ; if ( controllers . indexOf ( obj ) === - 1 || ! obj . folder . hasChild ( obj ) ) { console . log ( "Can't remove controller " + obj ) ; return false ; } if ( obj . isFolder ) { if ( ! removeTest ( ... obj . guiChildren ) ) return false ; } } return true ; }
Verify that all of the items in provided arguments are existing controllers that should be ok to remove.
Verify that all of the items in provided arguments are existing controllers that should be ok to remove .
//TODO: toString implementations for controllers //not sure the preferred way of reporting problem to user.