(hash, data, encoding)
| 147 | * @returns {void} |
| 148 | */ |
| 149 | const update = (hash, data, encoding) => { |
| 150 | if (encoding === "base64url" && !isBase64URLSupported) { |
| 151 | const base64String = /** @type {string} */ (data) |
| 152 | .replace(/-/g, "+") |
| 153 | .replace(/_/g, "/"); |
| 154 | const buf = Buffer.from(base64String, "base64"); |
| 155 | hash.update(buf); |
| 156 | return; |
| 157 | } else if ( |
| 158 | typeof data === "string" && |
| 159 | encoding && |
| 160 | typeof ENCODE_TABLE[/** @type {Base} */ (encoding.slice(4))] !== "undefined" |
| 161 | ) { |
| 162 | const buf = decode(data, /** @type {Base} */ (encoding.slice(4))); |
| 163 | hash.update(buf); |
| 164 | return; |
| 165 | } |
| 166 | |
| 167 | if (encoding) { |
| 168 | hash.update(/** @type {string} */ (data), encoding); |
| 169 | } else { |
| 170 | hash.update(data); |
| 171 | } |
| 172 | }; |
| 173 | |
| 174 | /** |
| 175 | * Returns digest. |
no test coverage detected