text: import { isArray, isString } from '@antv/util';
  var INVALID_FIELD_ERR_MSG = 'Invalid field: it must be a string!';
  export function getField(options, defaultField) {
      var field = options.field, fields = options.fields;
      if (isString(field)) {
          return field;
      }
      if (isArray(field)) {
          console.warn(INVALID_FIELD_ERR_MSG);
          return field[0];
      }
      console.warn(INVALID_FIELD_ERR_MSG + " will try to get fields instead.");
      if (isString(fields)) {
          return fields;
      }
      if (isArray(fields) && fields.length) {
          return fields[0];
      }
      if (defaultField) {
          return defaultField;
      }
      throw new TypeError(INVALID_FIELD_ERR_MSG);
  }
  export function getAllNodes(root) {
      var nodes = [];
      if (root && root.each) {
          // d3-hierarchy
          root.each(function (node) {
              nodes.push(node);
          });
      }
      else if (root && root.eachNode) {
          // @antv/hierarchy
          root.eachNode(function (node) {
              nodes.push(node);
          });
      }
      return nodes;
  }
  //# sourceMappingURL=util.js.map