cookie-jar,cookie,index: consistent spacing
errors: fix paramError function
This commit is contained in:
parent
2271c2e055
commit
425067e759
|
@ -1,7 +1,7 @@
|
|||
import { promises as fs } from "fs";
|
||||
import {promises as fs} from "fs";
|
||||
import url from "url";
|
||||
import Cookie from "./cookie.mjs";
|
||||
import { paramError, CookieParseError } from "./errors.mjs";
|
||||
import {paramError, CookieParseError} from "./errors.mjs";
|
||||
|
||||
export default class CookieJar {
|
||||
constructor(file, flags = "rw", cookies) {
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
import url from "url";
|
||||
import { paramError, CookieParseError } from "./errors.mjs";
|
||||
import {paramError, CookieParseError} from "./errors.mjs";
|
||||
|
||||
const validateHostname = (cookieHostname, requestHostname, subdomains) => {
|
||||
cookieHostname = cookieHostname.toLowerCase();
|
||||
|
|
|
@ -6,7 +6,7 @@ export class CookieParseError extends Error {
|
|||
};
|
||||
|
||||
export function paramError(position, paramName, functionName, validTypes) {
|
||||
validTypes = [validTypes].flatMap(t => "\"" + t + "\"");
|
||||
validTypes = [validTypes].flat().map(t => "\"" + t + "\"");
|
||||
validTypes = validTypes.slice(0, -1).join(", ") + (validTypes.length > 1 ? " or " : "") + validTypes.slice(-1);
|
||||
return new TypeError(`${position} parameter "${paramName}" passed to "${functionName}" is not of type ${validTypes}!`);
|
||||
};
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
import _fetch from "node-fetch";
|
||||
import CookieJar from "./cookie-jar.mjs";
|
||||
import Cookie from "./cookie.mjs";
|
||||
import { paramError, CookieParseError } from "./errors.mjs"
|
||||
import {paramError, CookieParseError} from "./errors.mjs"
|
||||
|
||||
async function fetch(cookieJars, url, options) {
|
||||
let cookies = "";
|
||||
|
|
Loading…
Reference in New Issue
Block a user