Browser JS utils in ES2015
running in Google Chrome
const seq = n => [...Array(n).keys()];
const S3Regex = /^s3:\/\/([^/]+)\/(.*)$/;
const _parseS3Url = s3url => {
const [protocol, bucket, key] = s3url.match(S3Regex).slice(1);
return [protocol, bucket, key];
};
const parseS3Url = s3Url => s3Url.match(S3Regex).slice(1);
let s3Url = "s3://example.com/foo/bar/buz";
console.log(parseS3Url(s3Url));
javascript:void((() => {
// code comes here
})());
const queryString = url =>
Array.from(url.searchParams.entries())
.reduce(
(obj, [key, value]) => Object.assign(obj, { [key]: value })
, {});
const qs = queryString(new URL(location));
console.log(qs)
document.documentMode && document.documentMode < 11 && alert("Browser below IE11 is unsupported.");
document.documentMode || console.log("No more IE.");