Skip to content

Commit 62b0fa6

Browse files
Adding utils file
1 parent affb372 commit 62b0fa6

File tree

2 files changed

+17
-17
lines changed

2 files changed

+17
-17
lines changed

src/fetch_request.js

Lines changed: 1 addition & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import { FetchResponse } from './fetch_response'
2-
import { getCookie } from './lib/cookie'
2+
import { getCookie, compact, metaContent } from './lib/utils'
33

44
export class FetchRequest {
55
constructor (method, url, options = {}) {
@@ -86,19 +86,3 @@ export class FetchRequest {
8686
return this.options.headers || {}
8787
}
8888
}
89-
90-
function compact (object) {
91-
const result = {}
92-
for (const key in object) {
93-
const value = object[key]
94-
if (value !== undefined) {
95-
result[key] = value
96-
}
97-
}
98-
return result
99-
}
100-
101-
function metaContent (name) {
102-
const element = document.head.querySelector(`meta[name="${name}"]`)
103-
return element && element.content
104-
}

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

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

0 commit comments

Comments
 (0)