client/build: ditch arrayToObject

UglifyJS seems to have troubles using it, I didn't want to investigate
it too much as it's just a syntactic sugar used in about 4 places so I
just removed it altogether
This commit is contained in:
rr- 2016-09-29 11:16:55 +02:00
parent 0df3ceb439
commit a69bdba63f
4 changed files with 81 additions and 95 deletions

View file

@ -112,14 +112,14 @@ function getSuggestions(tagName) {
return actualTag.suggestions || []; return actualTag.suggestions || [];
} }
module.exports = misc.arrayToObject([ module.exports = {
getAllCategories, getAllCategories: getAllCategories,
getAllTags, getAllTags: getAllTags,
getTagByName, getTagByName: getTagByName,
getCategoryByName, getCategoryByName: getCategoryByName,
getNameToTagMap, getNameToTagMap: getNameToTagMap,
getOriginalTagName, getOriginalTagName: getOriginalTagName,
refreshExport, refreshExport: refreshExport,
getAllImplications, getAllImplications: getAllImplications,
getSuggestions, getSuggestions: getSuggestions,
], func => func.name); };

View file

@ -213,36 +213,22 @@ function arraysDiffer(source1, source2, orderImportant) {
source2.filter(value => !source1.includes(value)).length > 0); source2.filter(value => !source1.includes(value)).length > 0);
} }
function arrayToObject(array, keySelector, valueSelector) { module.exports = {
if (keySelector === undefined) { range: range,
keySelector = item => item; formatUrlParameters: formatUrlParameters,
} parseUrlParameters: parseUrlParameters,
if (valueSelector === undefined) { parseUrlParametersRoute: parseUrlParametersRoute,
valueSelector = item => item; formatRelativeTime: formatRelativeTime,
} formatFileSize: formatFileSize,
return array.reduce((obj, item) => { formatMarkdown: formatMarkdown,
obj[keySelector(item)] = valueSelector(item); formatInlineMarkdown: formatInlineMarkdown,
return obj; unindent: unindent,
}, {}); enableExitConfirmation: enableExitConfirmation,
} disableExitConfirmation: disableExitConfirmation,
confirmPageExit: confirmPageExit,
module.exports = arrayToObject([ escapeHtml: escapeHtml,
range, makeCssName: makeCssName,
formatUrlParameters, splitByWhitespace: splitByWhitespace,
parseUrlParameters, arraysDiffer: arraysDiffer,
parseUrlParametersRoute, decamelize: decamelize,
formatRelativeTime, };
formatFileSize,
formatMarkdown,
formatInlineMarkdown,
unindent,
enableExitConfirmation,
disableExitConfirmation,
confirmPageExit,
escapeHtml,
makeCssName,
splitByWhitespace,
arraysDiffer,
decamelize,
arrayToObject,
], func => func.name);

View file

@ -12,6 +12,6 @@ function searchInputNodeFocusHelper(inputNode) {
}); });
} }
module.exports = misc.arrayToObject([ module.exports = {
searchInputNodeFocusHelper, searchInputNodeFocusHelper: searchInputNodeFocusHelper,
], func => func.name); };

View file

@ -359,31 +359,31 @@ function getTemplate(templatePath) {
if (!ctx) { if (!ctx) {
ctx = {}; ctx = {};
} }
Object.assign(ctx, misc.arrayToObject([ Object.assign(ctx, {
getPostUrl, getPostUrl: getPostUrl,
getPostEditUrl, getPostEditUrl: getPostEditUrl,
makeRelativeTime, makeRelativeTime: makeRelativeTime,
makeFileSize, makeFileSize: makeFileSize,
makeMarkdown, makeMarkdown: makeMarkdown,
makeThumbnail, makeThumbnail: makeThumbnail,
makeRadio, makeRadio: makeRadio,
makeCheckbox, makeCheckbox: makeCheckbox,
makeSelect, makeSelect: makeSelect,
makeInput, makeInput: makeInput,
makeButton, makeButton: makeButton,
makeTextarea, makeTextarea: makeTextarea,
makeTextInput, makeTextInput: makeTextInput,
makePasswordInput, makePasswordInput: makePasswordInput,
makeEmailInput, makeEmailInput: makeEmailInput,
makeColorInput, makeColorInput: makeColorInput,
makePostLink, makePostLink: makePostLink,
makeTagLink, makeTagLink: makeTagLink,
makeUserLink, makeUserLink: makeUserLink,
makeFlexboxAlign, makeFlexboxAlign: makeFlexboxAlign,
makeAccessKey, makeAccessKey: makeAccessKey,
misc.makeCssName, makeCssName: misc.makeCssName,
makeNumericInput, makeNumericInput: makeNumericInput,
], func => func.name)); });
return htmlToDom(templateFactory(ctx)); return htmlToDom(templateFactory(ctx));
}; };
} }
@ -493,26 +493,26 @@ document.addEventListener('click', e => {
} }
}); });
module.exports = misc.arrayToObject([ module.exports = {
htmlToDom, htmlToDom: htmlToDom,
getTemplate, getTemplate: getTemplate,
emptyContent, emptyContent: emptyContent,
replaceContent, replaceContent: replaceContent,
enableForm, enableForm: enableForm,
disableForm, disableForm: disableForm,
decorateValidator, decorateValidator: decorateValidator,
makeVoidElement, makeVoidElement: makeVoidElement,
makeNonVoidElement, makeNonVoidElement: makeNonVoidElement,
makeTagLink, makeTagLink: makeTagLink,
makePostLink, makePostLink: makePostLink,
makeCheckbox, makeCheckbox: makeCheckbox,
makeRadio, makeRadio: makeRadio,
syncScrollPosition, syncScrollPosition: syncScrollPosition,
slideDown, slideDown: slideDown,
slideUp, slideUp: slideUp,
monitorNodeRemoval, monitorNodeRemoval: monitorNodeRemoval,
clearMessages, clearMessages: clearMessages,
showError, showError: showError,
showSuccess, showSuccess: showSuccess,
showInfo, showInfo: showInfo,
], func => func.name); };