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:
parent
0df3ceb439
commit
a69bdba63f
4 changed files with 81 additions and 95 deletions
|
@ -112,14 +112,14 @@ function getSuggestions(tagName) {
|
|||
return actualTag.suggestions || [];
|
||||
}
|
||||
|
||||
module.exports = misc.arrayToObject([
|
||||
getAllCategories,
|
||||
getAllTags,
|
||||
getTagByName,
|
||||
getCategoryByName,
|
||||
getNameToTagMap,
|
||||
getOriginalTagName,
|
||||
refreshExport,
|
||||
getAllImplications,
|
||||
getSuggestions,
|
||||
], func => func.name);
|
||||
module.exports = {
|
||||
getAllCategories: getAllCategories,
|
||||
getAllTags: getAllTags,
|
||||
getTagByName: getTagByName,
|
||||
getCategoryByName: getCategoryByName,
|
||||
getNameToTagMap: getNameToTagMap,
|
||||
getOriginalTagName: getOriginalTagName,
|
||||
refreshExport: refreshExport,
|
||||
getAllImplications: getAllImplications,
|
||||
getSuggestions: getSuggestions,
|
||||
};
|
||||
|
|
|
@ -213,36 +213,22 @@ function arraysDiffer(source1, source2, orderImportant) {
|
|||
source2.filter(value => !source1.includes(value)).length > 0);
|
||||
}
|
||||
|
||||
function arrayToObject(array, keySelector, valueSelector) {
|
||||
if (keySelector === undefined) {
|
||||
keySelector = item => item;
|
||||
}
|
||||
if (valueSelector === undefined) {
|
||||
valueSelector = item => item;
|
||||
}
|
||||
return array.reduce((obj, item) => {
|
||||
obj[keySelector(item)] = valueSelector(item);
|
||||
return obj;
|
||||
}, {});
|
||||
}
|
||||
|
||||
module.exports = arrayToObject([
|
||||
range,
|
||||
formatUrlParameters,
|
||||
parseUrlParameters,
|
||||
parseUrlParametersRoute,
|
||||
formatRelativeTime,
|
||||
formatFileSize,
|
||||
formatMarkdown,
|
||||
formatInlineMarkdown,
|
||||
unindent,
|
||||
enableExitConfirmation,
|
||||
disableExitConfirmation,
|
||||
confirmPageExit,
|
||||
escapeHtml,
|
||||
makeCssName,
|
||||
splitByWhitespace,
|
||||
arraysDiffer,
|
||||
decamelize,
|
||||
arrayToObject,
|
||||
], func => func.name);
|
||||
module.exports = {
|
||||
range: range,
|
||||
formatUrlParameters: formatUrlParameters,
|
||||
parseUrlParameters: parseUrlParameters,
|
||||
parseUrlParametersRoute: parseUrlParametersRoute,
|
||||
formatRelativeTime: formatRelativeTime,
|
||||
formatFileSize: formatFileSize,
|
||||
formatMarkdown: formatMarkdown,
|
||||
formatInlineMarkdown: formatInlineMarkdown,
|
||||
unindent: unindent,
|
||||
enableExitConfirmation: enableExitConfirmation,
|
||||
disableExitConfirmation: disableExitConfirmation,
|
||||
confirmPageExit: confirmPageExit,
|
||||
escapeHtml: escapeHtml,
|
||||
makeCssName: makeCssName,
|
||||
splitByWhitespace: splitByWhitespace,
|
||||
arraysDiffer: arraysDiffer,
|
||||
decamelize: decamelize,
|
||||
};
|
||||
|
|
|
@ -12,6 +12,6 @@ function searchInputNodeFocusHelper(inputNode) {
|
|||
});
|
||||
}
|
||||
|
||||
module.exports = misc.arrayToObject([
|
||||
searchInputNodeFocusHelper,
|
||||
], func => func.name);
|
||||
module.exports = {
|
||||
searchInputNodeFocusHelper: searchInputNodeFocusHelper,
|
||||
};
|
||||
|
|
|
@ -359,31 +359,31 @@ function getTemplate(templatePath) {
|
|||
if (!ctx) {
|
||||
ctx = {};
|
||||
}
|
||||
Object.assign(ctx, misc.arrayToObject([
|
||||
getPostUrl,
|
||||
getPostEditUrl,
|
||||
makeRelativeTime,
|
||||
makeFileSize,
|
||||
makeMarkdown,
|
||||
makeThumbnail,
|
||||
makeRadio,
|
||||
makeCheckbox,
|
||||
makeSelect,
|
||||
makeInput,
|
||||
makeButton,
|
||||
makeTextarea,
|
||||
makeTextInput,
|
||||
makePasswordInput,
|
||||
makeEmailInput,
|
||||
makeColorInput,
|
||||
makePostLink,
|
||||
makeTagLink,
|
||||
makeUserLink,
|
||||
makeFlexboxAlign,
|
||||
makeAccessKey,
|
||||
misc.makeCssName,
|
||||
makeNumericInput,
|
||||
], func => func.name));
|
||||
Object.assign(ctx, {
|
||||
getPostUrl: getPostUrl,
|
||||
getPostEditUrl: getPostEditUrl,
|
||||
makeRelativeTime: makeRelativeTime,
|
||||
makeFileSize: makeFileSize,
|
||||
makeMarkdown: makeMarkdown,
|
||||
makeThumbnail: makeThumbnail,
|
||||
makeRadio: makeRadio,
|
||||
makeCheckbox: makeCheckbox,
|
||||
makeSelect: makeSelect,
|
||||
makeInput: makeInput,
|
||||
makeButton: makeButton,
|
||||
makeTextarea: makeTextarea,
|
||||
makeTextInput: makeTextInput,
|
||||
makePasswordInput: makePasswordInput,
|
||||
makeEmailInput: makeEmailInput,
|
||||
makeColorInput: makeColorInput,
|
||||
makePostLink: makePostLink,
|
||||
makeTagLink: makeTagLink,
|
||||
makeUserLink: makeUserLink,
|
||||
makeFlexboxAlign: makeFlexboxAlign,
|
||||
makeAccessKey: makeAccessKey,
|
||||
makeCssName: misc.makeCssName,
|
||||
makeNumericInput: makeNumericInput,
|
||||
});
|
||||
return htmlToDom(templateFactory(ctx));
|
||||
};
|
||||
}
|
||||
|
@ -493,26 +493,26 @@ document.addEventListener('click', e => {
|
|||
}
|
||||
});
|
||||
|
||||
module.exports = misc.arrayToObject([
|
||||
htmlToDom,
|
||||
getTemplate,
|
||||
emptyContent,
|
||||
replaceContent,
|
||||
enableForm,
|
||||
disableForm,
|
||||
decorateValidator,
|
||||
makeVoidElement,
|
||||
makeNonVoidElement,
|
||||
makeTagLink,
|
||||
makePostLink,
|
||||
makeCheckbox,
|
||||
makeRadio,
|
||||
syncScrollPosition,
|
||||
slideDown,
|
||||
slideUp,
|
||||
monitorNodeRemoval,
|
||||
clearMessages,
|
||||
showError,
|
||||
showSuccess,
|
||||
showInfo,
|
||||
], func => func.name);
|
||||
module.exports = {
|
||||
htmlToDom: htmlToDom,
|
||||
getTemplate: getTemplate,
|
||||
emptyContent: emptyContent,
|
||||
replaceContent: replaceContent,
|
||||
enableForm: enableForm,
|
||||
disableForm: disableForm,
|
||||
decorateValidator: decorateValidator,
|
||||
makeVoidElement: makeVoidElement,
|
||||
makeNonVoidElement: makeNonVoidElement,
|
||||
makeTagLink: makeTagLink,
|
||||
makePostLink: makePostLink,
|
||||
makeCheckbox: makeCheckbox,
|
||||
makeRadio: makeRadio,
|
||||
syncScrollPosition: syncScrollPosition,
|
||||
slideDown: slideDown,
|
||||
slideUp: slideUp,
|
||||
monitorNodeRemoval: monitorNodeRemoval,
|
||||
clearMessages: clearMessages,
|
||||
showError: showError,
|
||||
showSuccess: showSuccess,
|
||||
showInfo: showInfo,
|
||||
};
|
||||
|
|
Loading…
Reference in a new issue