diff --git a/index.js b/index.js index 5770fdf..90ac99f 100644 --- a/index.js +++ b/index.js @@ -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 } diff --git a/lib/cookie.js b/lib/cookie.js index 9961225..e6c84a9 100644 --- a/lib/cookie.js +++ b/lib/cookie.js @@ -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 '' } diff --git a/package.json b/package.json index debfb0f..d51ff2f 100644 --- a/package.json +++ b/package.json @@ -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" },