From e2cb7b524057c5195654b3c2c03b7091d07cb336 Mon Sep 17 00:00:00 2001 From: Glenn Dirkx Date: Thu, 6 Apr 2017 11:28:29 +0200 Subject: [PATCH] all arrow functions that weren't one-liners or scope wrappers are now named functions --- addLink.js | 8 ++++---- attachHALObj.js | 2 +- cleanRoutePieces.js | 2 +- getHAL.js | 8 ++++---- parseUrlDocs.js | 2 +- 5 files changed, 11 insertions(+), 11 deletions(-) diff --git a/addLink.js b/addLink.js index 810e111..ffa1474 100755 --- a/addLink.js +++ b/addLink.js @@ -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)) { @@ -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] || {}; diff --git a/attachHALObj.js b/attachHALObj.js index 85b46f7..fcd95ef 100755 --- a/attachHALObj.js +++ b/attachHALObj.js @@ -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; diff --git a/cleanRoutePieces.js b/cleanRoutePieces.js index 225f71f..6b1f98d 100755 --- a/cleanRoutePieces.js +++ b/cleanRoutePieces.js @@ -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("?")); diff --git a/getHAL.js b/getHAL.js index e0a9894..cfd3e3d 100755 --- a/getHAL.js +++ b/getHAL.js @@ -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); @@ -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; @@ -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]; @@ -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; diff --git a/parseUrlDocs.js b/parseUrlDocs.js index f91b95d..a03e891 100755 --- a/parseUrlDocs.js +++ b/parseUrlDocs.js @@ -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++) {