Skip to content

Instantly share code, notes, and snippets.

@IgnusG
Created August 18, 2017 08:43
Show Gist options
  • Save IgnusG/a8a7db27e0820d76d8ff36d002202b85 to your computer and use it in GitHub Desktop.
Save IgnusG/a8a7db27e0820d76d8ff36d002202b85 to your computer and use it in GitHub Desktop.
function detectSeparator(input) {
const availableSeparators = [ ';', ',', '|' ];
const separatorCount = availableSeparators.map((separator) => occurrences(input, separator));
return R.transpose([ availableSeparators, separatorCount ])
.reduce((maxSeparator, separator) => {
return separator[1] > maxSeparator[1] ? separator : maxSeparator;
}, [ availableSeparators[0], -1 ])[0];
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment