code: function calculateFunction() {
    var args = mlutil.asArray.apply(null, arguments);
    if (args.length < 1) {
      throw new Error('calculate function without module name');
    }
  
    var moduleName = args[0];
  
    var rootname = mlutil.rootname(moduleName);
    if (rootname === null) {
      throw new Error('library must have an extension of .xqy');
    }
  
    return {
        'start-facet': {
          apply: 'start-facet',
          ns:    'http://marklogic.com/query/custom/'+rootname,
          at:    '/ext/marklogic/query/custom/'+moduleName
        },
        'finish-facet': {
          apply: 'finish-facet',
          ns:    'http://marklogic.com/query/custom/'+rootname,
          at:    '/ext/marklogic/query/custom/'+moduleName
        }
    };
  }
docs: The specification for a custom constraint facet generation module
  as returned by {@link queryBuilder#calculateFunction} to pass
  to the {@link queryBuilder#facet} function.
  @typedef {object} queryBuilder.CalculateFunction
  @since 1.0
   
  Specifies a module that generates a custom facet as an argument to the
  {@link queryBuilder#facet} function.
  The library must be installed as /ext/marklogic/query/custom/MODULE_NAME.xqy,
  must have the http://marklogic.com/query/custom/MODULE_NAME namespace, and
  must define the start-facet() and finish-facet() functions. The same module
  can implement a parse() function for a custom parser specified with the
  {@link queryBuilder#parseFunction} helper.
  @method
  @since 1.0
  @memberof queryBuilder#
  @param {string} moduleName - the name of the module with the functions
  @returns {queryBuilder.CalculateFunction} the specification for a custom facet
  module for the {@link queryBuilder#facet} function.