First upload version 0.0.1
This commit is contained in:
21
node_modules/node-llama-cpp/dist/cli/utils/resolveHeaderFlag.js
generated
vendored
Normal file
21
node_modules/node-llama-cpp/dist/cli/utils/resolveHeaderFlag.js
generated
vendored
Normal file
@@ -0,0 +1,21 @@
|
||||
export function resolveHeaderFlag(header) {
|
||||
if (typeof header === "string")
|
||||
header = [header];
|
||||
if (header == null || header.length === 0)
|
||||
return {};
|
||||
const res = {};
|
||||
for (const headerItem of header) {
|
||||
const colonIndex = headerItem.indexOf(":");
|
||||
if (colonIndex < 0)
|
||||
throw new Error(`Invalid header item: ${headerItem}`);
|
||||
const key = headerItem.slice(0, colonIndex).trim();
|
||||
if (Object.hasOwn(res, key))
|
||||
throw new Error(`Duplicate header key: ${key}`);
|
||||
let value = headerItem.slice(colonIndex + 1);
|
||||
if (value.startsWith(" "))
|
||||
value = value.slice(1);
|
||||
res[key] = value;
|
||||
}
|
||||
return res;
|
||||
}
|
||||
//# sourceMappingURL=resolveHeaderFlag.js.map
|
||||
Reference in New Issue
Block a user