Skip to content

Instantly share code, notes, and snippets.

@nicholasxjy
Last active January 26, 2021 07:02
Show Gist options
  • Save nicholasxjy/4c4d9a20e23eeba0e61e9c17f921cd54 to your computer and use it in GitHub Desktop.
Save nicholasxjy/4c4d9a20e23eeba0e61e9c17f921cd54 to your computer and use it in GitHub Desktop.
util
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