You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
TS7016: Could not find a declaration file for module 'parse-link-header'. '/home/daniel/pro/aic/front/node_modules/parse-link-header/index.js' implicitly has an 'any' type. Try `npm i --save-dev @types/parse-link-header` if it exists or add a new declaration (.d.ts) file containing `declare module 'parse-link-header';`
The text was updated successfully, but these errors were encountered:
there is typescript implementation without any dependencies that works in browsers
constPARSE_LINK_HEADER_MAXLEN=2000;constPARSE_LINK_HEADER_THROW_ON_MAXLEN_EXCEEDED=false;interfaceLink{rel: string;url: string;[key: string]: string}functionhasRel(x: Link|undefined): x is Link{returnx!==undefined&&x.rel!==undefined;}functionintoRels(acc: Record<string,Link>,x: Link): Record<string,Link>{functionsplitRel(rel: string): void{acc[rel]={...x, rel};}x.rel.split(/\s+/).forEach(splitRel);returnacc;}exportfunctionparseSingleLink(linkHeader: string): Link|undefined{constlinkRegex=/<([^>]+)>(?:\s*;\s*(.+))?/i;constmatches=linkHeader.match(linkRegex);if(!matches)returnundefined;consturl=newURL(matches[1]);constparams=matches[2]?.split(';').map(param=>param.trim().split('=')).reduce((acc: Record<string,string>,[key,value])=>{if(value&&value.startsWith('"')&&value.endsWith('"')){value=value.slice(1,-1);}acc[key]=value;returnacc;},{})??{};return{rel: "",
...Object.fromEntries(url.searchParams),
...params,url: url.href,};}functioncheckHeader(linkHeader: string|null): boolean{if(!linkHeader)returnfalse;if(linkHeader.length>PARSE_LINK_HEADER_MAXLEN){if(PARSE_LINK_HEADER_THROW_ON_MAXLEN_EXCEEDED){thrownewError('Input string too long, it should be under '+PARSE_LINK_HEADER_MAXLEN+' characters.');}else{returnfalse;}}returntrue;}exportfunctionparseLinkHeader(linkHeader: string|null): Record<string,Link>|null{if(!linkHeader||!checkHeader(linkHeader))returnnull;returnlinkHeader.split(/,\s*/).map(e=>{console.log(e);returne}).map(parseSingleLink).filter(Boolean).filter(hasRel).reduce(intoRels,{});}
i have problem with https://www.npmjs.com/package/@types/parse-link-header
The text was updated successfully, but these errors were encountered: