@johntalton/http-util 3.0.0 → 3.0.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/package.json +1 -1
- package/src/conditional.js +25 -0
package/package.json
CHANGED
package/src/conditional.js
CHANGED
|
@@ -79,6 +79,31 @@ export function isQuoted(etag) {
|
|
|
79
79
|
return true
|
|
80
80
|
}
|
|
81
81
|
|
|
82
|
+
export class ETag {
|
|
83
|
+
/**
|
|
84
|
+
* @param {string} etag
|
|
85
|
+
* @returns {WeakEtagItem}
|
|
86
|
+
*/
|
|
87
|
+
static weak(etag) {
|
|
88
|
+
if(!isValidEtag(etag)) { throw new Error('invalid etag format') }
|
|
89
|
+
return { any: false, weak: true, etag }
|
|
90
|
+
}
|
|
91
|
+
|
|
92
|
+
/**
|
|
93
|
+
* @param {string} etag
|
|
94
|
+
* @returns {NotWeakEtagItem}
|
|
95
|
+
*/
|
|
96
|
+
static strong(etag) {
|
|
97
|
+
if(!isValidEtag(etag)) { throw new Error('invalid etag format') }
|
|
98
|
+
return { any: false, weak: false, etag }
|
|
99
|
+
}
|
|
100
|
+
|
|
101
|
+
/**
|
|
102
|
+
* @returns {AnyEtagItem}
|
|
103
|
+
*/
|
|
104
|
+
static any() { return ANY_ETAG_ITEM }
|
|
105
|
+
}
|
|
106
|
+
|
|
82
107
|
export class Conditional {
|
|
83
108
|
/**
|
|
84
109
|
* @param {EtagItem|undefined} etagItem
|