Skip to content

Instantly share code, notes, and snippets.

@Sc4ramouche
Last active March 15, 2018 11:40
Show Gist options
  • Save Sc4ramouche/431f4732e907145451cdadee8c2e4797 to your computer and use it in GitHub Desktop.
Save Sc4ramouche/431f4732e907145451cdadee8c2e4797 to your computer and use it in GitHub Desktop.
/*
Welcome fellow learners!
We are going to tackle JSdoc today.
1. Initialize your working directory
npm init -y
2. Install JSdoc locally
npm i --save-dev jsdoc
3. Create JavaScript file
touch test.js
*/
/**
* Returns all but the last element of provided array
*
* @since 0.1.0
* @param {Array} array - The array to process
* @returns {Array} - Returns the slice of the array
* @example
*
* _.initial([1, 2, 3]);
* // => [1, 2]
*/
function initial(array) {
var length = array == null ? 0 : array.length;
return length ? array.slice(0, -1) : [];
}
/*
Lets create documentation:
./node_modules/.bin/jsdoc test.js
*/
/*
# We are learning new tools!
Why? Because we are:
* awesome
* inquisitive
* going to change the world
*/
// ./node_modules/.bin/jsdoc test.js README.md
/**
* @license Lodash <https://lodash.com/>
* @namespace Lodash
*/
const lodash = (function () {
/**
* @memberof Lodash
* @access private
*/
const meaningOfLife = 42;
/**
* @memberof Lodash
* @access public
*/
const lodash = function() {
// ...
}
/**
* Returns all but the last element of provided array
*
* @memberof Lodash
* @since 0.1.0
* @param {Array} array - The array to process
* @returns {Array} - Returns the slice of the array
* @example
*
* _.initial([1, 2, 3]);
* // => [1, 2]
*/
lodash.initial = function initial(array) {
var length = array == null ? 0 : array.length;
return length ? array.slice(0, -1) : [];
}
return lodash;
})();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment