cookie-jar,cookie,index: consistent spacing

errors: fix paramError function
This commit is contained in:
jkhsjdhjs 2019-11-25 23:14:34 +01:00
parent 2271c2e055
commit 425067e759
Signed by: jkhsjdhjs
GPG Key ID: BAC6ADBAB7D576CC
4 changed files with 5 additions and 5 deletions

View File

@ -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) {

View File

@ -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();

View File

@ -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}!`);
};

View File

@ -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 = "";