Last active
January 26, 2021 07:02
-
-
Save nicholasxjy/4c4d9a20e23eeba0e61e9c17f921cd54 to your computer and use it in GitHub Desktop.
util
This file contains 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
const getURLParameters = url => | |
(url.match(/([^?=&]+)(=([^&]*))/g) || []).reduce( | |
(a, v) => ((a[v.slice(0, v.indexOf('='))] = v.slice(v.indexOf('=') + 1)), a), | |
{} | |
); | |
function extractRootDomain(d) { | |
return /^([\d.]+|[a-z-]+)$/.test(d) ? d : d.split('.').slice(-2).join('.') | |
} | |
// compose | |
const prepose = (f, g) => (...args) => f(g(...args)) | |
const compose2 = (...fns) => fns.reduce(prepose) | |
const compose = (...fns) => fns.reduce((f, g) => (...args) => f(g(...args))) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment