From 0d5d50b6890cfd5d4c578894da23dc48334cc517 Mon Sep 17 00:00:00 2001
From: Cuong Tran <103cuong@gmail.com>
Date: Fri, 7 Aug 2020 16:03:58 +0700
Subject: [PATCH] chore: remove for-in (#21)
---
.idea/codeStyles/Project.xml | 42 +++++++++++++++++++
.idea/codeStyles/codeStyleConfig.xml | 5 +++
.idea/hera.iml | 12 ++++++
.idea/inspectionProfiles/Project_Default.xml | 6 +++
.idea/modules.xml | 8 ++++
.idea/vcs.xml | 6 +++
.idea/workspace.xml | 44 ++++++++++++++++++++
package.json | 2 +-
src/index.ts | 16 +++----
9 files changed, 132 insertions(+), 9 deletions(-)
create mode 100644 .idea/codeStyles/Project.xml
create mode 100644 .idea/codeStyles/codeStyleConfig.xml
create mode 100644 .idea/hera.iml
create mode 100644 .idea/inspectionProfiles/Project_Default.xml
create mode 100644 .idea/modules.xml
create mode 100644 .idea/vcs.xml
create mode 100644 .idea/workspace.xml
diff --git a/.idea/codeStyles/Project.xml b/.idea/codeStyles/Project.xml
new file mode 100644
index 0000000..51dedef
--- /dev/null
+++ b/.idea/codeStyles/Project.xml
@@ -0,0 +1,42 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/.idea/codeStyles/codeStyleConfig.xml b/.idea/codeStyles/codeStyleConfig.xml
new file mode 100644
index 0000000..79ee123
--- /dev/null
+++ b/.idea/codeStyles/codeStyleConfig.xml
@@ -0,0 +1,5 @@
+
+
+
+
+
\ No newline at end of file
diff --git a/.idea/hera.iml b/.idea/hera.iml
new file mode 100644
index 0000000..24643cc
--- /dev/null
+++ b/.idea/hera.iml
@@ -0,0 +1,12 @@
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/.idea/inspectionProfiles/Project_Default.xml b/.idea/inspectionProfiles/Project_Default.xml
new file mode 100644
index 0000000..df7825d
--- /dev/null
+++ b/.idea/inspectionProfiles/Project_Default.xml
@@ -0,0 +1,6 @@
+
+
+
+
+
+
\ No newline at end of file
diff --git a/.idea/modules.xml b/.idea/modules.xml
new file mode 100644
index 0000000..907aa31
--- /dev/null
+++ b/.idea/modules.xml
@@ -0,0 +1,8 @@
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/.idea/vcs.xml b/.idea/vcs.xml
new file mode 100644
index 0000000..94a25f7
--- /dev/null
+++ b/.idea/vcs.xml
@@ -0,0 +1,6 @@
+
+
+
+
+
+
\ No newline at end of file
diff --git a/.idea/workspace.xml b/.idea/workspace.xml
new file mode 100644
index 0000000..102c473
--- /dev/null
+++ b/.idea/workspace.xml
@@ -0,0 +1,44 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ 1596790765613
+
+
+ 1596790765613
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/package.json b/package.json
index 4386032..1f2b362 100644
--- a/package.json
+++ b/package.json
@@ -1,6 +1,6 @@
{
"name": "@103cuong/hera-js",
- "version": "0.2.0",
+ "version": "0.2.1",
"description": "👩🏼💻 Simple and lightweight GraphQL client.",
"main": "./lib/index.js",
"types": "./lib/index.d.ts",
diff --git a/src/index.ts b/src/index.ts
index a401928..efc22ca 100644
--- a/src/index.ts
+++ b/src/index.ts
@@ -1,17 +1,17 @@
import axios, { AxiosResponse, AxiosRequestConfig } from 'axios';
function formatVariables(variables: any): any {
- let formatedVariables = JSON.stringify(variables);
- formatedVariables = formatedVariables.replace(/"([^"]+)"\s*:\s*/g, '$1:');
- return formatedVariables;
+ let formattedVariables = JSON.stringify(variables);
+ formattedVariables = formattedVariables.replace(/"([^"]+)"\s*:\s*/g, '$1:');
+ return formattedVariables;
}
function formatQuery(query: string, variables: any): string {
- let formatedQuery = query;
- for (const key in variables) {
+ let formattedQuery = query;
+ Object.keys(variables).forEach((key) => {
const regex = new RegExp(`\\$${key}`, 'g');
- formatedQuery = formatedQuery.replace(regex, formatVariables(variables[key]));
- }
- return formatedQuery;
+ formattedQuery = formattedQuery.replace(regex, formatVariables(variables[key]));
+ });
+ return formattedQuery;
}
interface Option {