Last active
June 23, 2022 19:44
-
-
Save rugyoga/7cac7f4147225a72095ca292b5c32313 to your computer and use it in GitHub Desktop.
refactoring exercise
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function pdf_variants(baseUrl) { | |
return { | |
rawUri: baseUrl + '_raw.pdf', | |
rawX1a: baseUrl + '_raw.pdfx', | |
rawNonX1a: baseUrl + '_raw_non_x1a.pdf', | |
proofUri: baseUrl + '.pdf', | |
proofX1a: baseUrl + '.pdfx', | |
proofNonX1a: baseUrl + '_non_x1a.pdf', | |
} | |
} | |
function baseUrl(id) { | |
return '/' + id.substring(id.indexOf('_') + 1) + '/' + id; | |
} | |
function getWhatsRequired(msg) { | |
const ld_flag = function(flag) { return msg.launch_darkly_flags[flag] === 1; } | |
return { | |
id, | |
resource_type: msg.resource_type, | |
receiptHandle: msg.receiptHandle, | |
pdfs: pdf_variants(baseUrl(msg.resource.id)), | |
usePreflight: ld_flag(msg, 'picasso.use_preflight'), | |
strictPreflight: ld_flag(msg, 'picasso.strict_preflight'), | |
}; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
love how much cleaner this is! probably would want to use anonymous functions for performance reasons, but otherwise think it's much more readable
https://dmitripavlutin.com/differences-between-arrow-and-regular-functions/