Skip to content

Commit

Permalink
version 0.1.5
Browse files Browse the repository at this point in the history
  • Loading branch information
TomaszPilch committed Jan 12, 2021
1 parent 47a83b8 commit f49a218
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 6 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ import { cookie } from 'devx-js-utilities'
```
function | specification
---|---
createCookie | (name: string, value: string, minutes: number, secure?: boolean, samesite?: 'strict' \ 'lax') => void
createCookie | (name: string, value: string, minutes?: number, secure?: boolean, samesite?: 'strict' \ 'lax') => void
readCookie | (name: string) => null / string

### Random
Expand Down
12 changes: 8 additions & 4 deletions lib/cookie.js
Original file line number Diff line number Diff line change
@@ -1,9 +1,13 @@
// @flow
export const createCookie = (name: string, value: string, minutes: number, secure?: boolean, samesite?: 'strict' | 'lax'): void => {
export const createCookie = (name: string, value: string, minutes?: number, secure?: boolean, samesite?: 'strict' | 'lax'): void => {
let params = ['path=/']
if (minutes) {
const date = new Date()
date.setTime(date.getTime() + (minutes * 60 * 1000));
if (typeof minutes === 'number') {
let date = new Date()
if (minutes <= 0) {
date = new Date(null)
} else {
date.setTime(date.getTime() + (minutes * 60 * 1000))
}
params.push(`expires=${date.toUTCString()}`)
}
if (secure) {
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "devx-js-utilities",
"version": "0.1.4",
"version": "0.1.5",
"main": "dist/index.js",
"scripts": {
"build": "babel lib --out-dir dist",
Expand Down

0 comments on commit f49a218

Please sign in to comment.