Transpiled ES5 code to ES6/ES7

This commit is contained in:
Liyas Thomas
2020-06-11 19:55:40 +05:30
parent 9bc0ae975a
commit 0644a8c9fb
16 changed files with 108 additions and 123 deletions

View File

@@ -1,9 +1,9 @@
// Docs on event and context https://www.netlify.com/docs/functions/#the-handler-method
exports.handler = async (event, context) => {
switch (event.httpMethod) {
export async function handler({ httpMethod, queryStringParameters }, context) {
switch (httpMethod) {
case "GET":
try {
const name = event.queryStringParameters.name || "World"
const name = queryStringParameters.name || "World"
return {
statusCode: 200,
headers: {

View File

@@ -105,7 +105,7 @@ export const fb = {
author: fb.currentUser.uid,
author_name: fb.currentUser.displayName,
author_image: fb.currentUser.photoURL,
collection: collection,
collection,
}
usersCollection
.doc(fb.currentUser.uid)
@@ -120,7 +120,7 @@ export const fb = {
author: fb.currentUser.uid,
author_name: fb.currentUser.displayName,
author_image: fb.currentUser.photoURL,
environment: environment,
environment,
}
usersCollection
.doc(fb.currentUser.uid)

View File

@@ -120,10 +120,10 @@ function expect(str) {
if (kind === "EOF") {
found = "[end of file]"
} else if (end - start > 1) {
found = "`" + string.slice(start, end) + "`"
found = `\`${string.slice(start, end)}\``
} else {
const match = string.slice(start).match(/^.+?\b/)
found = "`" + (match ? match[0] : string[start]) + "`"
found = `\`${match ? match[0] : string[start]}\``
}
throw syntaxError(`Expected ${str} but found ${found}.`)

View File

@@ -1,17 +1,15 @@
export function hasPathParams(params) {
return params.some((p) => p.type === "path")
return params.some(({ type }) => type === "path")
}
export function addPathParamsToVariables(params, variables) {
params
.filter(({ key }) => !!key)
.filter(({ type }) => type === "path")
.forEach(p => variables[p.key] = p.value)
return variables;
params
.filter(({ key }) => !!key)
.filter(({ type }) => type === "path")
.forEach(({ key, value }) => (variables[key] = value))
return variables
}
export function getQueryParams(params) {
return params
.filter(({ key }) => !!key)
.filter(({ type }) => type != "path")
}
return params.filter(({ key }) => !!key).filter(({ type }) => type != "path")
}

View File

@@ -9,16 +9,16 @@ export function defineGQLLanguageMode(ace) {
const TextHighlightRules = aceRequire("ace/mode/text_highlight_rules").TextHighlightRules
const GQLQueryTextHighlightRules = function () {
var keywords =
const keywords =
"type|interface|union|enum|schema|input|implements|extends|scalar|fragment|query|mutation|subscription"
var dataTypes = "Int|Float|String|ID|Boolean"
const dataTypes = "Int|Float|String|ID|Boolean"
var literalValues = "true|false|null"
const literalValues = "true|false|null"
var escapeRe = /\\(?:u[\da-fA-f]{4}|.)/
const escapeRe = /\\(?:u[\da-fA-f]{4}|.)/
var keywordMapper = this.createKeywordMapper(
const keywordMapper = this.createKeywordMapper(
{
keyword: keywords,
"storage.type": dataTypes,
@@ -48,7 +48,7 @@ export function defineGQLLanguageMode(ace) {
},
{
token: "string", // character
regex: "'(?:" + escapeRe + "|.)?'",
regex: `'(?:${escapeRe}|.)?'`,
},
{
token: "string.start",

View File

@@ -1,13 +1,13 @@
export function parseUrlAndPath(value) {
let result = {}
try {
let url = new URL(value)
result.url = url.origin
result.path = url.pathname
} catch (error) {
let uriRegex = value.match(/^((http[s]?:\/\/)?(<<[^\/]+>>)?[^\/]*|)(\/?.*)$/)
result.url = uriRegex[1]
result.path = uriRegex[4]
}
return result;
}
let result = {}
try {
let url = new URL(value)
result.url = url.origin
result.path = url.pathname
} catch (error) {
let uriRegex = value.match(/^((http[s]?:\/\/)?(<<[^\/]+>>)?[^\/]*|)(\/?.*)$/)
result.url = uriRegex[1]
result.path = uriRegex[4]
}
return result
}