@unveil/vk 0.4.0 → 0.5.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.d.mts +1 -0
- package/dist/index.mjs +1 -1
- package/package.json +1 -1
package/dist/index.d.mts
CHANGED
package/dist/index.mjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import{identify as e}from"@unveil/identity";var t=class extends Error{status;url;constructor(e,t,n){super(e),this.name=`GitHubError`,this.status=t,this.url=n}};async function n(e){try{let t=await e.json();if(t?.message)return t.message}catch{}return`${e.status} ${e.statusText}`}async function r(e,r){let i=`https://api.github.com${e}`,a={Accept:`application/vnd.github+json`,"X-GitHub-Api-Version":`2022-11-28`,"User-Agent":`unveil-vk`};r&&(a.Authorization=`Bearer ${r}`);let o=await fetch(i,{headers:a});if(!o.ok)throw new t(await n(o),o.status,i);return await o.json()}async function i(t,n){let i=n?.token,a=encodeURIComponent(t),o=await r(`/users/${a}`,i),s=Array.from({length:3},(e,t)=>r(`/users/${a}/events/public?per_page=100&page=${t+1}`,i)),c=(await Promise.all(s)).flat();return{analysis:e({user:o,events:c}),events:n?.showEvents?c:[],eventsCount:c.length}}export{t as GitHubError,i as analyze};
|
|
1
|
+
import{identify as e}from"@unveil/identity";var t=class extends Error{status;url;constructor(e,t,n){super(e),this.name=`GitHubError`,this.status=t,this.url=n}};async function n(e){try{let t=await e.json();if(t?.message)return t.message}catch{}return`${e.status} ${e.statusText}`}async function r(e,r){let i=`https://api.github.com${e}`,a={Accept:`application/vnd.github+json`,"X-GitHub-Api-Version":`2022-11-28`,"User-Agent":`unveil-vk`};r&&(a.Authorization=`Bearer ${r}`);let o=await fetch(i,{headers:a});if(!o.ok)throw new t(await n(o),o.status,i);return await o.json()}async function i(t,n){let i=n?.token,a=encodeURIComponent(t),o=await r(`/users/${a}`,i),s=Array.from({length:3},(e,t)=>r(`/users/${a}/events/public?per_page=100&page=${t+1}`,i)),c=(await Promise.all(s)).flat();return{analysis:e({user:o,events:c}),userId:o.id,events:n?.showEvents?c:[],eventsCount:c.length}}export{t as GitHubError,i as analyze};
|