Skip to content

Commit

Permalink
node cookie util
Browse files Browse the repository at this point in the history
  • Loading branch information
tbremer committed Jul 2, 2023
1 parent e60f31f commit 94bf9ff
Show file tree
Hide file tree
Showing 3 changed files with 26 additions and 0 deletions.
11 changes: 11 additions & 0 deletions node/index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
globalThis.useCookie = function useCookie(c) {
return c
.split(";")
.map((c) =>
c
.trim()
.split("=")
.map((i) => i.trim())
)
.reduce((a, c) => ({ ...a, [c[0]]: c[1] }), {});
};
4 changes: 4 additions & 0 deletions node/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
{
"name": "utils",
"main": "index.js"
}
11 changes: 11 additions & 0 deletions node/use-cookie.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
module.exports = function useCookie(c) {
return c
.split(";")
.map((c) =>
c
.trim()
.split("=")
.map((i) => i.trim())
)
.reduce((a, c) => ({ ...a, [c[0]]: c[1] }), {});
};

0 comments on commit 94bf9ff

Please sign in to comment.