0.0.7 • Published 2 years ago
@plotdb/httputil v0.0.7
httputil
utility functions for commonly used http and browser context related functions, including:
cookie(key,value,opt)- getter / setter of cookie.- if
valueis omitted, return the cookie corresponding tokey. - return undefined if
keyis not found in cookie. - option: either a string for expiration date, or an object with cookie options such as:
expiresmax-afgepath
- if
qs(key)- get value forkeyin querystring- return key-value pair hash if key is omitted.
- return composed query string if
keyis a hash for key-value pairs. - return undefined if
keyis not found in query string.
datefmt(date, opt)- date object formatter.- return a date string in
YY/MM/DD hh:mm:ssformat. - parameters:
date: either a number (epoch) or a Date object. Usenew Date()if omitted.opt: an option object with following fields:time: show time if true. Default true if omitted.invalid: placeholder text when the given date is invalid.undefinedwill be used if omitted.
- return a date string in
License
MIT