UNPKG

islamarchive-sdk

Version:

SDK to interact with islamarchive.cc API

2 lines 849 B
import{URL as g,URLSearchParams as p}from"node:url";var s=async(r={})=>{let t=new g("https://islamarchive.cc/actions.php");if(Object.keys(r).length>0){let n=new p;Object.entries(r).forEach(([i,m])=>{n.append(i,m.toString())}),t.search=n.toString()}return(await fetch(t)).json()},o=async(r,t)=>s({bookid:r,...t&&{id:t},p:"Shamlaa_books",view:"book"}),a=async r=>s({b:r,p:"Shamlaa_treee_book"});var b=async r=>{let t=await o(r);return{firstPageId:Number(t.firstid),id:Number(t.ibook_id),lastPageId:Number(t.lastid),name:t.bk}},u=async(r,t)=>{let e=await o(r,t);return{id:Number(e.id),...e.hno&&{index:Number(e.hno)},text:e[2],title:e.tit}},l=async r=>(await a(r)).map(e=>({id:e.id,link:e.a_attr.GetData,text:e.text,...e.parent&&e.parent!=="#"&&{parent:e.parent}}));export{b as getBook,l as getBookmarks,u as getPage}; //# sourceMappingURL=index.js.map