Skip to main content

@module

Syntax​

@module
@module name

Overview​

@module marks a file as a module and optionally gives it a name. All symbols defined in the file are assumed to be members of the module unless they are explicitly marked otherwise.

If you omit the name, JSDoc derives it from the filename.

Examples​

CommonJS module​

/**
* Utilities for working with arrays.
* @module utils/array
*/

/**
* Returns the last element of an array.
* @param {Array} arr
* @returns {*}
*/
exports.last = function (arr) {
return arr[arr.length - 1];
};

ES2015 module​

/**
* @module geometry
*/

/**
* Calculates the area of a circle.
* @param {number} r - Radius.
* @returns {number}
*/
export function circleArea(r) {
return Math.PI * r * r;
}

Referencing a module member​

Use the module: prefix in namepaths:

/** @type {module:utils/array} */

See also​