Skip to content

Commit

Permalink
all arrow functions that weren't one-liners or scope wrappers are now…
Browse files Browse the repository at this point in the history
… named functions
  • Loading branch information
Juravenator committed Apr 6, 2017
1 parent bcf6ca2 commit e2cb7b5
Show file tree
Hide file tree
Showing 5 changed files with 11 additions and 11 deletions.
8 changes: 4 additions & 4 deletions addLink.js
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
var parseUrlDocs = require('./parseUrlDocs.js');
var cache = {};

module.exports = (server, options) => {
module.exports = function addLinkInit(server, options) {
var attachHALObj = require('./attachHALObj.js')(options);

var findLink = (method, urlWithoutQuery) => {
function findLink(method, urlWithoutQuery) {
for (var i = 0; i < server.router.routes[method].length; i++) {
var route = server.router.routes[method][i];
if (route.path.exec(urlWithoutQuery)) {
Expand All @@ -28,10 +28,10 @@ module.exports = (server, options) => {
}
}

return (halContainer, response) => {
return function addLinkFactory(halContainer, response) {

// this function is given to the developer
return (method, url, customName) => {
return function addLink(method, url, customName) {
method = method.toUpperCase();
var urlWithoutQuery = url.indexOf("?") == -1 ? url : url.substring(0, url.indexOf("?"));
cache[method] = cache[method] || {};
Expand Down
2 changes: 1 addition & 1 deletion attachHALObj.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
module.exports = options => (halObj, container) => {
module.exports = options => function attachHALObj(halObj, container) {
if (options.makeObjects) {
// _links is an object
var name = halObj.rel;
Expand Down
2 changes: 1 addition & 1 deletion cleanRoutePieces.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
// removes the last element from a given array if it is an empty string or a query parameter
// used to make /api/call/ and /api/call equivalent
module.exports = array => {
module.exports = function cleanRoutePieces(array) {
var lastItem = array[array.length-1];
if (lastItem.indexOf("?") > -1) {
array[array.length-1] = lastItem.substring(0, lastItem.indexOf("?"));
Expand Down
8 changes: 4 additions & 4 deletions getHAL.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ var parseUrlDocs = require('./parseUrlDocs.js');
var cleanRoutePieces = require('./cleanRoutePieces.js');
var urlMatches = require('./urlMatches.js');

module.exports = (server, options) => (url) => {
module.exports = (server, options) => function getHAL(url) {
var routes = server.router.routes;
var routeChains = server.routes;
var attachHALObj = require('./attachHALObj.js')(options);
Expand Down Expand Up @@ -81,7 +81,7 @@ module.exports = (server, options) => (url) => {
// the smallest match is the 'self' match
// only the path pieces from 0 - self.length need to be evaluated for variables
var stringMatches = matches.filter( match => !match.isRegex);
var smallestPiecesLength = stringMatches.reduce( (result, match) => {
var smallestPiecesLength = stringMatches.reduce( function smallestPiecesReducer(result, match) {
match.realPathPieces = cleanRoutePieces(match.route.spec.path.split("/"));
var l = match.realPathPieces.length;
return l < result ? l : result;
Expand All @@ -91,7 +91,7 @@ module.exports = (server, options) => (url) => {
* Now filter using the previously made list *
* Any match with a variable on a place that should be static is a false positive *
*********************************************************************************/
matches = matches.filter( match => {
matches = matches.filter( function matchFilter(match) {
if (!match.isRegex) {
for (var i = 0; i < smallestPiecesLength; i++) {
var piece = match.realPathPieces[i];
Expand All @@ -107,7 +107,7 @@ module.exports = (server, options) => (url) => {
/***************************************
* Render json-HAL entry for each match *
***************************************/
matches.forEach( match => {
matches.forEach( function matchLoop(match) {
var halObj = {}

var name;
Expand Down
2 changes: 1 addition & 1 deletion parseUrlDocs.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
var comments = require('parse-comments');

module.exports = ({chain, halObj, name}) => {
module.exports = function parseUrlDocs({chain, halObj, name}) {
// check each of the functions in the url chain for HAL documentation
for (var z = 0; z < chain.length; z++) {

Expand Down

0 comments on commit e2cb7b5

Please sign in to comment.