MCPcopy Create free account
hub / github.com/aircloud/sync-to-github / base64encode

Function base64encode

apps/chrome-ext/src/utils/githubSync.ts:7–17  ·  view source on GitHub ↗
(str: string)

Source from the content-addressed store, hash-verified

5type CreateOrUpdateResponse = Endpoints[`PUT /repos/{owner}/{repo}/contents/{path}`]['response']
6
7function base64encode(str: string) {
8 if (typeof btoa === 'function') {
9 return btoa(
10 encodeURIComponent(str).replace(/%([0-9A-F]{2})/g, function toSolidBytes(match, p1) {
11 return String.fromCharCode(Number(`0x${p1}`))
12 }),
13 )
14 }
15 if (typeof Buffer !== 'undefined') return Buffer.from(str, 'utf8').toString('base64')
16 throw new Error('Can not find window.btoa or Buffer')
17}
18
19export const githubCreateFile = async (payload: SyncPayload): Promise<CreateOrUpdateResponse> => {
20 const octokit = new Octokit({

Callers 1

githubCreateFileFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected