重构2.0

v2
yutent 2023-10-30 18:45:06 +08:00
parent 0af0ebc5fc
commit e32ca8c726
3 changed files with 18 additions and 8 deletions

View File

@ -8,8 +8,14 @@ import STATUS_TEXT from './lib/http-code.js'
import { serialize } from './lib/cookie.js'
export default class Response {
rendered = false
constructor(req, res) {
this.origin = { req, res }
this.#req = req
this.#res = res
this.rendered = !!res.rendered
}

View File

@ -3,16 +3,16 @@
* @date 2020/09/20 15:08:50
*/
var KEY_REGEXP = /^[\u0009\u0020-\u007e\u0080-\u00ff]+$/
// var SPLIT_REGEXP = /; */
var encode = encodeURIComponent
// var decode = decodeURIComponent
const KEY_REGEXP = /^[\u0009\u0020-\u007e\u0080-\u00ff]+$/
// const SPLIT_REGEXP = /; */
const encode = encodeURIComponent
// const decode = decodeURIComponent
/**
* [serialize 序列化对象]
*/
export function serialize(key, val, opts) {
var pairs = []
let pairs = []
if (!KEY_REGEXP.test(key)) {
return ''
}

View File

@ -1,11 +1,15 @@
{
"name": "@gm5/response",
"version": "1.3.1",
"version": "2.0.0",
"type": "module",
"description": "对Http的response进一步封装, 提供常用的API",
"main": "index.js",
"author": "yutent",
"keywords": ["fivejs", "response", "http"],
"keywords": [
"fivejs",
"response",
"http"
],
"dependencies": {
"iofs": "^1.5.0"
},