Skip to content

Commit 4ef53d6

Browse files
Moving functions to lib file
1 parent 775f1eb commit 4ef53d6

File tree

2 files changed

+19
-19
lines changed

2 files changed

+19
-19
lines changed

src/fetch_request.js

Lines changed: 1 addition & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import { FetchResponse } from './fetch_response'
22
import { RequestInterceptor } from './request_interceptor'
3-
import { getCookie } from './lib/cookie'
3+
import { getCookie, compact, metaContent } from './lib/utils'
44

55
export class FetchRequest {
66
constructor (method, url, options = {}) {
@@ -102,21 +102,3 @@ export class FetchRequest {
102102
return this.options.headers || {}
103103
}
104104
}
105-
106-
function compact (object) {
107-
const result = {}
108-
109-
for (const key in object) {
110-
const value = object[key]
111-
if (value !== undefined) {
112-
result[key] = value
113-
}
114-
}
115-
116-
return result
117-
}
118-
119-
function metaContent (name) {
120-
const element = document.head.querySelector(`meta[name="${name}"]`)
121-
return element && element.content
122-
}

src/lib/cookie.js renamed to src/lib/utils.js

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,3 +11,21 @@ export function getCookie (name) {
1111
}
1212
}
1313
}
14+
15+
export function compact (object) {
16+
const result = {}
17+
18+
for (const key in object) {
19+
const value = object[key]
20+
if (value !== undefined) {
21+
result[key] = value
22+
}
23+
}
24+
25+
return result
26+
}
27+
28+
export function metaContent (name) {
29+
const element = document.head.querySelector(`meta[name="${name}"]`)
30+
return element && element.content
31+
}

0 commit comments

Comments
 (0)