repo_name string | dataset string | owner string | lang string | func_name string | code string | docstring string | url string | sha string |
|---|---|---|---|---|---|---|---|---|
devdb-vscode | github_2023 | damms005 | typescript | Runner.runPhp | private static async runPhp(code: string): Promise<string> {
code = code.replace(/\"/g, "\\\"");
// code = code.replace(/(?:\r\n|\r|\n)/g, ' ');
// Escape special characters for Unix-like systems
if (['linux', 'openbsd', 'sunos', 'darwin'].some(platform => os.platform().includes(platfor... | /**
* Run simple PHP code
*/ | https://github.com/damms005/devdb-vscode/blob/8efde0f9fc7b5c9932326da68db16936f442c328/src/services/laravel/code-runner/runner.ts#L111-L135 | 8efde0f9fc7b5c9932326da68db16936f442c328 |
devdb-vscode | github_2023 | damms005 | typescript | Runner.getProjectPath | private static getProjectPath(path: string, escape: boolean = false): string {
const basePath = vscode.workspace.workspaceFolders?.[0]?.uri.fsPath || '';
const fullPath = `${basePath}/${path}`;
return escape ? fullPath.replace(/\\/g, '\\\\') : fullPath;
} | /**
* Get the Laravel project path
*/ | https://github.com/damms005/devdb-vscode/blob/8efde0f9fc7b5c9932326da68db16936f442c328/src/services/laravel/code-runner/runner.ts#L140-L144 | 8efde0f9fc7b5c9932326da68db16936f442c328 |
devdb-vscode | github_2023 | damms005 | typescript | Runner.cleanOutcome | public static cleanOutcome(outcome: string): string {
return outcome
.replace(this.DEVDB_ERROR_OUTPUT_START, '')
.replace(this.DEVDB_OUTPUT_START, '')
.replace(this.DEVDB_OUTPUT_END, '');
} | /**
* Removes boundary texts like, ___DEVDB_ERROR_OUTPUT_START___, etc from the output
*/ | https://github.com/damms005/devdb-vscode/blob/8efde0f9fc7b5c9932326da68db16936f442c328/src/services/laravel/code-runner/runner.ts#L149-L154 | 8efde0f9fc7b5c9932326da68db16936f442c328 |
chatdev | github_2023 | 10cl | typescript | randomIP | function randomIP() {
return `13.${random(104, 107)}.${random(0, 255)}.${random(0, 255)}`
} | // https://github.com/acheong08/EdgeGPT/blob/master/src/EdgeGPT.py#L32 | https://github.com/10cl/chatdev/blob/a0b8bdc69d9aeb0728ae2d1a2692f6ae19b58e3b/src/app/bots/bing/api.ts#L8-L10 | a0b8bdc69d9aeb0728ae2d1a2692f6ae19b58e3b |
chatdev | github_2023 | 10cl | typescript | ChatGPTClient.fixAuthState | async fixAuthState() {
if (this.requester === proxyFetchRequester) {
await proxyFetchRequester.refreshProxyTab()
} else {
await proxyFetchRequester.getProxyTab()
this.switchRequester(proxyFetchRequester)
}
} | // Switch to proxy mode, or refresh the proxy tab | https://github.com/10cl/chatdev/blob/a0b8bdc69d9aeb0728ae2d1a2692f6ae19b58e3b/src/app/bots/chatgpt-webapp/client.ts#L97-L104 | a0b8bdc69d9aeb0728ae2d1a2692f6ae19b58e3b |
chatdev | github_2023 | 10cl | typescript | ChatTimeWeightedVectorStoreRetriever.constructor | constructor(fields: TimeWeightedVectorStoreRetrieverFields) {
super(fields);
this.vectorStore = fields.vectorStore;
this.searchKwargs = fields.searchKwargs ?? 100;
this.memoryStream = fields.memoryStream ?? [];
this.decayRate = fields.decayRate ?? 0.01;
this.k = fields.k ?? 4;
this.otherScor... | /**
* Constructor to initialize the required fields
* @param fields - The fields required for initializing the TimeWeightedVectorStoreRetriever
*/ | https://github.com/10cl/chatdev/blob/a0b8bdc69d9aeb0728ae2d1a2692f6ae19b58e3b/src/embedding/chat_time_weighted.ts#L98-L107 | a0b8bdc69d9aeb0728ae2d1a2692f6ae19b58e3b |
chatdev | github_2023 | 10cl | typescript | ChatTimeWeightedVectorStoreRetriever.getMemoryStream | getMemoryStream(): DocumentInterface[] {
return this.memoryStream;
} | /**
* Get the memory stream of documents.
* @returns The memory stream of documents.
*/ | https://github.com/10cl/chatdev/blob/a0b8bdc69d9aeb0728ae2d1a2692f6ae19b58e3b/src/embedding/chat_time_weighted.ts#L113-L115 | a0b8bdc69d9aeb0728ae2d1a2692f6ae19b58e3b |
chatdev | github_2023 | 10cl | typescript | ChatTimeWeightedVectorStoreRetriever.setMemoryStream | setMemoryStream(memoryStream: DocumentInterface[]) {
this.memoryStream = memoryStream;
} | /**
* Set the memory stream of documents.
* @param memoryStream The new memory stream of documents.
*/ | https://github.com/10cl/chatdev/blob/a0b8bdc69d9aeb0728ae2d1a2692f6ae19b58e3b/src/embedding/chat_time_weighted.ts#L121-L123 | a0b8bdc69d9aeb0728ae2d1a2692f6ae19b58e3b |
chatdev | github_2023 | 10cl | typescript | ChatTimeWeightedVectorStoreRetriever._getRelevantDocuments | async _getRelevantDocuments(
query: string,
runManager?: CallbackManagerForRetrieverRun
): Promise<DocumentInterface[]> {
const now = Math.floor(Date.now() / 1000);
const memoryDocsAndScores = this.getMemoryDocsAndScores();
const salientDocsAndScores = await this.getSalientDocuments(
query,... | /**
* Get relevant documents based on time-weighted relevance
* @param query - The query to search for
* @returns The relevant documents
*/ | https://github.com/10cl/chatdev/blob/a0b8bdc69d9aeb0728ae2d1a2692f6ae19b58e3b/src/embedding/chat_time_weighted.ts#L130-L144 | a0b8bdc69d9aeb0728ae2d1a2692f6ae19b58e3b |
chatdev | github_2023 | 10cl | typescript | ChatTimeWeightedVectorStoreRetriever.addDocuments | async addDocuments(docs: DocumentInterface[]): Promise<void> {
const now = Math.floor(Date.now() / 1000);
const savedDocs = this.prepareDocuments(docs, now);
this.memoryStream.push(...savedDocs);
await this.vectorStore.addDocuments(savedDocs);
} | /**
* NOTE: When adding documents to a vector store, use addDocuments
* via retriever instead of directly to the vector store.
* This is because it is necessary to process the document
* in prepareDocuments.
*
* @param docs - The documents to add to vector store in the retriever
*/ | https://github.com/10cl/chatdev/blob/a0b8bdc69d9aeb0728ae2d1a2692f6ae19b58e3b/src/embedding/chat_time_weighted.ts#L154-L160 | a0b8bdc69d9aeb0728ae2d1a2692f6ae19b58e3b |
chatdev | github_2023 | 10cl | typescript | ChatTimeWeightedVectorStoreRetriever.getMemoryDocsAndScores | private getMemoryDocsAndScores(): Record<
number,
{ doc: DocumentInterface; score: number }
> {
const memoryDocsAndScores: Record<
number,
{ doc: DocumentInterface; score: number }
> = {};
for (const doc of this.memoryStream.slice(-this.k)) {
const bufferIdx = doc.metadata[BUFFER... | /**
* Get memory documents and their scores
* @returns An object containing memory documents and their scores
*/ | https://github.com/10cl/chatdev/blob/a0b8bdc69d9aeb0728ae2d1a2692f6ae19b58e3b/src/embedding/chat_time_weighted.ts#L215-L236 | a0b8bdc69d9aeb0728ae2d1a2692f6ae19b58e3b |
chatdev | github_2023 | 10cl | typescript | ChatTimeWeightedVectorStoreRetriever.getSalientDocuments | private async getSalientDocuments(
query: string,
runManager?: CallbackManagerForRetrieverRun
): Promise<Record<number, { doc: DocumentInterface; score: number }>> {
const docAndScores: [DocumentInterface, number][] =
await this.vectorStore.similaritySearchWithScore(
query,
this.sear... | /**
* Get salient documents and their scores based on the query
* @param query - The query to search for
* @returns An object containing salient documents and their scores
*/ | https://github.com/10cl/chatdev/blob/a0b8bdc69d9aeb0728ae2d1a2692f6ae19b58e3b/src/embedding/chat_time_weighted.ts#L243-L267 | a0b8bdc69d9aeb0728ae2d1a2692f6ae19b58e3b |
chatdev | github_2023 | 10cl | typescript | ChatTimeWeightedVectorStoreRetriever.computeResults | private computeResults(
docsAndScores: Record<number, { doc: DocumentInterface; score: number }>,
now: number
): DocumentInterface[] {
const recordedDocs = Object.values(docsAndScores)
.map(({ doc, score }) => ({
doc,
score: this.getCombinedScore(doc, score, now),
}))
.so... | /**
* Compute the final result set of documents based on the combined scores
* @param docsAndScores - An object containing documents and their scores
* @param now - The current timestamp
* @returns The final set of documents
*/ | https://github.com/10cl/chatdev/blob/a0b8bdc69d9aeb0728ae2d1a2692f6ae19b58e3b/src/embedding/chat_time_weighted.ts#L275-L296 | a0b8bdc69d9aeb0728ae2d1a2692f6ae19b58e3b |
chatdev | github_2023 | 10cl | typescript | ChatTimeWeightedVectorStoreRetriever.prepareDocuments | private prepareDocuments(
docs: DocumentInterface[],
now: number
): DocumentInterface[] {
return docs.map((doc, i) => ({
...doc,
metadata: {
...doc.metadata,
[LAST_ACCESSED_AT_KEY]: doc.metadata[LAST_ACCESSED_AT_KEY] ?? now,
created_at: doc.metadata.created_at ?? now,
... | /**
* Prepare documents with necessary metadata before saving
* @param docs - The documents to prepare
* @param now - The current timestamp
* @returns The prepared documents
*/ | https://github.com/10cl/chatdev/blob/a0b8bdc69d9aeb0728ae2d1a2692f6ae19b58e3b/src/embedding/chat_time_weighted.ts#L304-L317 | a0b8bdc69d9aeb0728ae2d1a2692f6ae19b58e3b |
chatdev | github_2023 | 10cl | typescript | ChatTimeWeightedVectorStoreRetriever.getCombinedScore | private getCombinedScore(
doc: DocumentInterface,
vectorRelevance: number | null,
nowMsec: number
): number {
const hoursPassed = this.getHoursPassed(
nowMsec,
doc.metadata[LAST_ACCESSED_AT_KEY]
);
let score = (1.0 - this.decayRate) ** hoursPassed;
for (const key of this.otherS... | /**
* Calculate the combined score based on vector relevance and other factors
* @param doc - The document to calculate the score for
* @param vectorRelevance - The relevance score from the vector store
* @param nowMsec - The current timestamp in milliseconds
* @returns The combined score for the documen... | https://github.com/10cl/chatdev/blob/a0b8bdc69d9aeb0728ae2d1a2692f6ae19b58e3b/src/embedding/chat_time_weighted.ts#L326-L343 | a0b8bdc69d9aeb0728ae2d1a2692f6ae19b58e3b |
chatdev | github_2023 | 10cl | typescript | ChatTimeWeightedVectorStoreRetriever.getHoursPassed | private getHoursPassed(time: number, refTime: number): number {
return (time - refTime) / 3600;
} | /**
* Calculate the hours passed between two time points
* @param time - The current time in seconds
* @param refTime - The reference time in seconds
* @returns The number of hours passed between the two time points
*/ | https://github.com/10cl/chatdev/blob/a0b8bdc69d9aeb0728ae2d1a2692f6ae19b58e3b/src/embedding/chat_time_weighted.ts#L351-L353 | a0b8bdc69d9aeb0728ae2d1a2692f6ae19b58e3b |
TechStack | github_2023 | Get-Tech-Stack | typescript | Background.onMessageFromExtension | init = () => {
console.log("[===== Loaded Background Scripts =====]");
//When extension installed
runtime.onInstalled.addListener(this.onInstalled);
//Add message listener in Browser.
runtime.onMessage.addListener(this.onMessage);
//Add Update listener for tab
tabs.onUpdated.addListener(t... | /**
* When changes tabs
*
* @param {*} tabId
* @param {*} changeInfo
* @param {*} tab
*/ | https://github.com/Get-Tech-Stack/TechStack/blob/d1698f0ca5751e7760874e5fa1895ae623889b38/src/background/index.ts | d1698f0ca5751e7760874e5fa1895ae623889b38 |
TechStack | github_2023 | Get-Tech-Stack | typescript | get_options | const get_options = (key: string): boolean => {
storage.get([key]);
return true;
}; | // WIP | https://github.com/Get-Tech-Stack/TechStack/blob/d1698f0ca5751e7760874e5fa1895ae623889b38/src/utils/get_option.ts#L4-L7 | d1698f0ca5751e7760874e5fa1895ae623889b38 |
AugmentOS | github_2023 | AugmentOS-Community | typescript | getInitialSession | const getInitialSession = async () => {
const {
data: { session },
} = await supabase.auth.getSession();
setSession(session);
setUser(session?.user ?? null);
setLoading(false);
}; | // 1. Check for an active session on mount | https://github.com/AugmentOS-Community/AugmentOS/blob/d985e676a0b760fd8e211138645900a7c1b69414/augmentos_manager/src/AuthContext.tsx#L23-L31 | d985e676a0b760fd8e211138645900a7c1b69414 |
AugmentOS | github_2023 | AugmentOS-Community | typescript | BluetoothService.handleBondedPeripheral | handleBondedPeripheral(data: any) {
console.log('Bonding successful with:', data);
// Alert.alert('Bonded', `Successfully bonded with ${data.peripheral}`);
// GlobalEventEmitter.emit('SHOW_BANNER', { message: `Successfully bonded with ${data.peripheral}`, type: 'success' })
} | // Handle bonded peripherals | https://github.com/AugmentOS-Community/AugmentOS/blob/d985e676a0b760fd8e211138645900a7c1b69414/augmentos_manager/src/BluetoothService.tsx#L299-L303 | d985e676a0b760fd8e211138645900a7c1b69414 |
AugmentOS | github_2023 | AugmentOS-Community | typescript | BluetoothService.handleCharacteristicUpdate | handleCharacteristicUpdate(data: any) {
if (
data.peripheral === this.connectedDevice?.id &&
data.characteristic === this.CHARACTERISTIC_UUID
) {
const deviceId = data.peripheral;
const value = data.value; // This is an array of bytes (number[])
// Convert value array to Uint8Arra... | //Updated handleCharacteristicUpdate function | https://github.com/AugmentOS-Community/AugmentOS/blob/d985e676a0b760fd8e211138645900a7c1b69414/augmentos_manager/src/BluetoothService.tsx#L496-L557 | d985e676a0b760fd8e211138645900a7c1b69414 |
AugmentOS | github_2023 | AugmentOS-Community | typescript | BluetoothService.concatenateUint8Arrays | concatenateUint8Arrays(chunks: Uint8Array[]): Uint8Array {
let totalLength = chunks.reduce((acc, curr) => acc + curr.length, 0);
let result = new Uint8Array(totalLength);
let offset = 0;
for (let chunk of chunks) {
result.set(chunk, offset);
offset += chunk.length;
}
return result;
... | // Helper function to concatenate Uint8Array chunks | https://github.com/AugmentOS-Community/AugmentOS/blob/d985e676a0b760fd8e211138645900a7c1b69414/augmentos_manager/src/BluetoothService.tsx#L560-L569 | d985e676a0b760fd8e211138645900a7c1b69414 |
AugmentOS | github_2023 | AugmentOS-Community | typescript | BluetoothService.sendHeartbeat | async sendHeartbeat() {
console.log('Send Connection Check');
await this.sendDataToAugmentOs({ command: 'ping' });
await this.validateResponseFromCore();
} | /* AugmentOS Comms Methods (call these to do things) */ | https://github.com/AugmentOS-Community/AugmentOS/blob/d985e676a0b760fd8e211138645900a7c1b69414/augmentos_manager/src/BluetoothService.tsx#L815-L819 | d985e676a0b760fd8e211138645900a7c1b69414 |
AugmentOS | github_2023 | AugmentOS-Community | typescript | BluetoothService.sendUninstallApp | async sendUninstallApp(packageName: string) {
return await this.sendDataToAugmentOs({
command: 'uninstall_app',
params: {
target: packageName
}
})
} | // } | https://github.com/AugmentOS-Community/AugmentOS/blob/d985e676a0b760fd8e211138645900a7c1b69414/augmentos_manager/src/BluetoothService.tsx#L1022-L1029 | d985e676a0b760fd8e211138645900a7c1b69414 |
AugmentOS | github_2023 | AugmentOS-Community | typescript | handleInfoResult | const handleInfoResult = ({ appInfo }: { appInfo: any }) => {
// console.log("GOT SOME APP INFO YO");
// console.log(JSON.stringify(appInfo));
setAppInfo(appInfo);
// Initialize settings state with current values
const initialState: { [key: string]: any } = {};
appInfo.settings.forE... | // Define the event handler | https://github.com/AugmentOS-Community/AugmentOS/blob/d985e676a0b760fd8e211138645900a7c1b69414/augmentos_manager/src/screens/AppSettings.tsx#L40-L53 | d985e676a0b760fd8e211138645900a7c1b69414 |
Next-Nav | github_2023 | oslabs-beta | typescript | sendUpdatedDirectory | async function sendUpdatedDirectory(
webview: vscode.WebviewPanel,
dirName: string
): Promise<void> {
try {
// Call treeMaker with only one folder name
const result = await treeMaker(dirName);
const sendString = JSON.stringify(result);
//console.log(sendString);
webview.webview.postMessage({ c... | //get the directory to send to the React | https://github.com/oslabs-beta/Next-Nav/blob/f48dedc5eb4d8eb3f73aa9c79fe31231a1d8562a/src/extension.ts#L10-L25 | f48dedc5eb4d8eb3f73aa9c79fe31231a1d8562a |
Next-Nav | github_2023 | oslabs-beta | typescript | isSubdirectory | function isSubdirectory(parent: string, child: string) {
const parentPath = path.resolve(parent).toLowerCase();
const childPath = path.resolve(child).toLowerCase();
console.log('p: ' + parentPath);
console.log('c: ' + childPath);
return parentPath.startsWith(childPath);
} | //Checks that child directory is within parent directory | https://github.com/oslabs-beta/Next-Nav/blob/f48dedc5eb4d8eb3f73aa9c79fe31231a1d8562a/src/functions.ts#L6-L12 | f48dedc5eb4d8eb3f73aa9c79fe31231a1d8562a |
Next-Nav | github_2023 | oslabs-beta | typescript | listFiles | async function listFiles(dir: string, parent: number): Promise<void> {
const entities = await fsPromises.readdir(dir, { withFileTypes: true });
for (const entity of entities) {
const fullPath = path.join(dir, entity.name);
if (entity.isDirectory()) {
const directoryData: Directory = {
... | // Recursive function to list files and populate structure | https://github.com/oslabs-beta/Next-Nav/blob/f48dedc5eb4d8eb3f73aa9c79fe31231a1d8562a/src/makeTree.ts#L89-L116 | f48dedc5eb4d8eb3f73aa9c79fe31231a1d8562a |
Next-Nav | github_2023 | oslabs-beta | typescript | handleSubmitDir | const handleSubmitDir = () => {
onPathChange(rootPath);
console.log(vscode);
console.log('Creating new root with', path);
console.log('path', pathStack);
vscode.postMessage({
command: 'submitDir',
folderName: path,
showError: false,
});
}; | //function that creates a new view using this node as the root node when we go into a subtree | https://github.com/oslabs-beta/Next-Nav/blob/f48dedc5eb4d8eb3f73aa9c79fe31231a1d8562a/webview-react-app/src/components/Node.tsx#L76-L86 | f48dedc5eb4d8eb3f73aa9c79fe31231a1d8562a |
Next-Nav | github_2023 | oslabs-beta | typescript | getIcon | const getIcon = (fileString: string): [IconType, string] => {
// store of file extensions and their respective icons and icon background color
const iconStore: { [index: string]: [IconType, string] } = {
default: [PiFileCodeFill, 'white'],
html: [SiHtml5,'#e34c26'],
css: [SiCss3, '#264de4'],
... | // selects an icon to use based on a file name | https://github.com/oslabs-beta/Next-Nav/blob/f48dedc5eb4d8eb3f73aa9c79fe31231a1d8562a/webview-react-app/src/components/Node.tsx#L101-L128 | f48dedc5eb4d8eb3f73aa9c79fe31231a1d8562a |
Next-Nav | github_2023 | oslabs-beta | typescript | handlePostMessage | const handlePostMessage: (
filePath: string,
command: string,
setterFunc?: (string: string) => any
) => void = (filePath, command, setterFunc) => {
vscode.postMessage({
command: command,
filePath: filePath,
});
if (setterFunc) {
setterFunc("");
}
... | //function that sends messages to the extension/backend | https://github.com/oslabs-beta/Next-Nav/blob/f48dedc5eb4d8eb3f73aa9c79fe31231a1d8562a/webview-react-app/src/components/TreeContainer.tsx#L210-L222 | f48dedc5eb4d8eb3f73aa9c79fe31231a1d8562a |
anirohi | github_2023 | noelrohi | typescript | getUserByUsername | async function getUserByUsername(username: string) {
const data = await db.query.users.findFirst({
where: eq(users.name, username),
});
if (!data) notFound();
return data;
} | // export async function generateStaticParams(): Promise< | https://github.com/noelrohi/anirohi/blob/967bcd1955d17bde9a7de3f1894d552d679bc7ce/src/app/u/[name]/page.tsx#L29-L35 | 967bcd1955d17bde9a7de3f1894d552d679bc7ce |
p256-verifier | github_2023 | daimo-eth | typescript | main | async function main() {
const vectors = [];
while (vectors.length < 1000) {
const p256 = { name: "ECDSA", namedCurve: "P-256", hash: "SHA-256" };
const key = await crypto.subtle.generateKey(p256, true, ["sign", "verify"]);
const pubKeyDer = await crypto.subtle.exportKey("spki", key.publicKey);
cons... | // Generate random signatures for benchmarking gas usage. | https://github.com/daimo-eth/p256-verifier/blob/607d3ec8377a3f59d65eca60d87dee8485d2ebcc/test-vectors/generate_random_valid.ts#L6-L48 | 607d3ec8377a3f59d65eca60d87dee8485d2ebcc |
p256-verifier | github_2023 | daimo-eth | typescript | main | async function main() {
const sourceObj: { v: ScureVector[] } = await fetch(scureVectorsURL).then(
(res) => res.json()
);
const vectors = sourceObj.v.filter(
(v: ScureVector) => v.fn_name === "base64url"
);
// Write to JSON
const filepath = "./vectors_scure_base64url.jsonl";
console.log(`Writing ... | // Fetch scure's test vectors and filter out base64url | https://github.com/daimo-eth/p256-verifier/blob/607d3ec8377a3f59d65eca60d87dee8485d2ebcc/test-vectors/generate_scure_base64url.ts#L15-L34 | 607d3ec8377a3f59d65eca60d87dee8485d2ebcc |
p256-verifier | github_2023 | daimo-eth | typescript | main | async function main() {
// Download latest Wycheproof vectors
const vectors = [];
for (const url of sourceURLs) {
console.log(`Downloading ${url}`);
const sourceObj = await fetch(url).then((res) => res.json());
const friendlyName = url.replace(wycheproofURL, `wycheproof`);
const vecs = await extra... | // Collect secp256r1 signature test vectors, deduplicate, and output as a single | https://github.com/daimo-eth/p256-verifier/blob/607d3ec8377a3f59d65eca60d87dee8485d2ebcc/test-vectors/generate_wycheproof.ts#L15-L44 | 607d3ec8377a3f59d65eca60d87dee8485d2ebcc |
p256-verifier | github_2023 | daimo-eth | typescript | tryParseASN | function tryParseASN(sig: string): [string, string] {
let r, rLen, s, sLen, totalLen;
let rem = consume(sig, "30"); // SEQUENCE
[totalLen, rem] = read(rem, 2); // length, verified at the end
assert(parseInt(totalLen, 16) === sig.length / 2 - 2, "wrong total length");
rem = consume(rem, "02"); // INTEGER
[r... | // Parse r,s from an ASN.1-encoded signature | https://github.com/daimo-eth/p256-verifier/blob/607d3ec8377a3f59d65eca60d87dee8485d2ebcc/test-vectors/generate_wycheproof.ts#L111-L131 | 607d3ec8377a3f59d65eca60d87dee8485d2ebcc |
p256-verifier | github_2023 | daimo-eth | typescript | tryParseP1363 | function tryParseP1363(sig: string): [string, string] {
assert(sig.length === 128, `exp 128 chars, found ${sig.length}`);
const r = sig.substring(0, 64);
const s = sig.substring(64);
return [r, s];
} | // Parse r,s from an P1363-encoded signature | https://github.com/daimo-eth/p256-verifier/blob/607d3ec8377a3f59d65eca60d87dee8485d2ebcc/test-vectors/generate_wycheproof.ts#L134-L139 | 607d3ec8377a3f59d65eca60d87dee8485d2ebcc |
p256-verifier | github_2023 | daimo-eth | typescript | main | async function main() {
const wycheproofVectorsJSONL = fs.readFileSync(
"vectors_wycheproof.jsonl",
"utf8"
);
const randomVectorsJSONL = fs.readFileSync(
"vectors_random_valid.jsonl",
"utf8"
);
const wycheproofVectors = wycheproofVectorsJSONL
.split("\n")
.map((line) => JSON.parse(lin... | // Validate generated vectors using the known-good SubtleCrypto P256 verifier and @noble/curves. | https://github.com/daimo-eth/p256-verifier/blob/607d3ec8377a3f59d65eca60d87dee8485d2ebcc/test-vectors/test.ts#L18-L81 | 607d3ec8377a3f59d65eca60d87dee8485d2ebcc |
friendmex | github_2023 | Anish-Agnihotri | typescript | collectEthPrice | async function collectEthPrice() {
const { data } = await axios.get("/api/eth");
setEth(data);
} | // Load eth price | https://github.com/Anish-Agnihotri/friendmex/blob/0e7e89ca8a00abf6bd77498a17c94007ecd1eef0/frontend/state/global.ts#L35-L38 | 0e7e89ca8a00abf6bd77498a17c94007ecd1eef0 |
friendmex | github_2023 | Anish-Agnihotri | typescript | addFavorite | const addFavorite = (user: StateUser) => {
const newFavorites = { ...favorites, [user.address]: user };
setFavorites({ ...newFavorites });
localStorage.setItem("friendmex_favorites", JSON.stringify(newFavorites));
}; | /**
* Track favorite user
* @param {StateUser} user
*/ | https://github.com/Anish-Agnihotri/friendmex/blob/0e7e89ca8a00abf6bd77498a17c94007ecd1eef0/frontend/state/global.ts#L56-L60 | 0e7e89ca8a00abf6bd77498a17c94007ecd1eef0 |
friendmex | github_2023 | Anish-Agnihotri | typescript | removeFavorite | const removeFavorite = (user: StateUser) => {
const { [user.address]: _, ...rest } = favorites;
setFavorites({ ...rest });
localStorage.setItem("friendmex_favorites", JSON.stringify(rest));
}; | /**
* Remove favorite user
* @param {StateUser} user
*/ | https://github.com/Anish-Agnihotri/friendmex/blob/0e7e89ca8a00abf6bd77498a17c94007ecd1eef0/frontend/state/global.ts#L66-L70 | 0e7e89ca8a00abf6bd77498a17c94007ecd1eef0 |
friendmex | github_2023 | Anish-Agnihotri | typescript | toggleFavorite | const toggleFavorite = (user: StateUser) =>
user.address in favorites ? removeFavorite(user) : addFavorite(user); | /**
* Toggles favorite user
* @param {StateUser} user
*/ | https://github.com/Anish-Agnihotri/friendmex/blob/0e7e89ca8a00abf6bd77498a17c94007ecd1eef0/frontend/state/global.ts#L76-L77 | 0e7e89ca8a00abf6bd77498a17c94007ecd1eef0 |
friendmex | github_2023 | Anish-Agnihotri | typescript | execute | async function execute(): Promise<void> {
await collectData();
setLastChecked(0);
} | /**
* Collection execution function
*/ | https://github.com/Anish-Agnihotri/friendmex/blob/0e7e89ca8a00abf6bd77498a17c94007ecd1eef0/frontend/utils/usePollData.ts#L49-L52 | 0e7e89ca8a00abf6bd77498a17c94007ecd1eef0 |
friendmex | github_2023 | Anish-Agnihotri | typescript | execute | async function execute(): Promise<void> {
// Collect env vars
const RPC_URL: string | undefined = process.env.RPC_URL;
const REDIS_URL: string = process.env.REDIS_URL ?? "redis://127.0.0.1:6379";
// Ensure env vars exist
if (!RPC_URL) throw new Error("Missing env vars");
// Create new keeper
const keepe... | /**
* Indexer execution lifecycle
*/ | https://github.com/Anish-Agnihotri/friendmex/blob/0e7e89ca8a00abf6bd77498a17c94007ecd1eef0/indexer/src/index.ts#L8-L32 | 0e7e89ca8a00abf6bd77498a17c94007ecd1eef0 |
friendmex | github_2023 | Anish-Agnihotri | typescript | Keeper.constructor | constructor(rpc_url: string, redis_url: string) {
this.db = new PrismaClient();
this.redis = new Redis(redis_url);
this.rpc = axios.create({
baseURL: rpc_url,
});
} | /**
* Create new Keeper
* @param {string} rpc_url Base RPC
* @param {string} redis_url Cache URL
*/ | https://github.com/Anish-Agnihotri/friendmex/blob/0e7e89ca8a00abf6bd77498a17c94007ecd1eef0/indexer/src/keeper.ts#L31-L37 | 0e7e89ca8a00abf6bd77498a17c94007ecd1eef0 |
friendmex | github_2023 | Anish-Agnihotri | typescript | Keeper.getChainBlock | async getChainBlock(): Promise<number> {
try {
// Send request
const { data } = await this.rpc.post("/", {
id: 0,
jsonrpc: "2.0",
method: "eth_blockNumber",
params: [],
});
// Parse hex to number
return Number(data.result);
} catch {
logger.er... | /**
* Get chain head number
* @returns {Promise<number>} block number
*/ | https://github.com/Anish-Agnihotri/friendmex/blob/0e7e89ca8a00abf6bd77498a17c94007ecd1eef0/indexer/src/keeper.ts#L43-L59 | 0e7e89ca8a00abf6bd77498a17c94007ecd1eef0 |
friendmex | github_2023 | Anish-Agnihotri | typescript | Keeper.getSyncedBlock | async getSyncedBlock(): Promise<number> {
// If latest synced block exists locally, return
if (this.latestSyncedBlock) return this.latestSyncedBlock;
// Else, get value from cache
const value: string | null = await this.redis.get("synced_block");
// If value exists
return value
? // Retur... | /**
* Get latest synced block from cache
* @returns {Promise<number>} block number
*/ | https://github.com/Anish-Agnihotri/friendmex/blob/0e7e89ca8a00abf6bd77498a17c94007ecd1eef0/indexer/src/keeper.ts#L65-L77 | 0e7e89ca8a00abf6bd77498a17c94007ecd1eef0 |
friendmex | github_2023 | Anish-Agnihotri | typescript | Keeper.loadUsersAndSupplies | async loadUsersAndSupplies(): Promise<void> {
// Collect all users from database
const users: { address: string; supply: number }[] =
await this.db.user.findMany({
select: {
address: true,
supply: true,
},
});
for (const user of users) {
// Assign to li... | /**
* Loads user addresses and token supplies from backend
*/ | https://github.com/Anish-Agnihotri/friendmex/blob/0e7e89ca8a00abf6bd77498a17c94007ecd1eef0/indexer/src/keeper.ts#L82-L100 | 0e7e89ca8a00abf6bd77498a17c94007ecd1eef0 |
friendmex | github_2023 | Anish-Agnihotri | typescript | Keeper.getTradeCost | getTradeCost(subject: string, amount: number, buy: boolean): number {
// If subject supply is not tracked locally
if (!this.supply.hasOwnProperty(subject)) {
// Update to 0
this.supply[subject] = 0;
}
if (buy) {
// Return price to buy tokens
const cost = getPrice(this.supply[sub... | /**
* Calculates trade cost based on bonding curve
* @param {string} subject address
* @param {number} amount to buy or sell
* @param {boolean} buy is a buy tx or a sell tx
* @returns {number} cost
*/ | https://github.com/Anish-Agnihotri/friendmex/blob/0e7e89ca8a00abf6bd77498a17c94007ecd1eef0/indexer/src/keeper.ts#L109-L127 | 0e7e89ca8a00abf6bd77498a17c94007ecd1eef0 |
friendmex | github_2023 | Anish-Agnihotri | typescript | Keeper.chunkTxCall | async chunkTxCall(batch: RPCMethod[]) {
let txData: {
result: {
transactionHash: string;
status: "0x0" | "0x1";
};
}[] = [];
// Execute batch data request in chunks of 950
for (const chunk of [...chunks(batch, 950)]) {
// Execute request for batch tx data
const {... | /**
* Chunks batch data request processing to avoid 1K request limit
* @param {RPCMethod[]} batch to execute
*/ | https://github.com/Anish-Agnihotri/friendmex/blob/0e7e89ca8a00abf6bd77498a17c94007ecd1eef0/indexer/src/keeper.ts#L133-L161 | 0e7e89ca8a00abf6bd77498a17c94007ecd1eef0 |
friendmex | github_2023 | Anish-Agnihotri | typescript | Keeper.syncTradeRange | async syncTradeRange(startBlock: number, endBlock: number): Promise<void> {
// Create block + transaction collection requests
const numBlocks: number = endBlock - startBlock;
logger.info(`Collecting ${numBlocks} blocks: ${startBlock} -> ${endBlock}`);
// Create batch requests array
const batchBlock... | /**
* Syncs trades between a certain range of blocks
* @param {number} startBlock beginning index
* @param {number} endBlock ending index
*/ | https://github.com/Anish-Agnihotri/friendmex/blob/0e7e89ca8a00abf6bd77498a17c94007ecd1eef0/indexer/src/keeper.ts#L168-L374 | 0e7e89ca8a00abf6bd77498a17c94007ecd1eef0 |
friendmex | github_2023 | Anish-Agnihotri | typescript | sleep | const sleep = (ms: number) => new Promise((r) => setTimeout(r, ms)); | /**
* Sleep for period of time
* @param {number} ms milliseconds to sleep
* @returns {Promise} resolves when sleep period finished
*/ | https://github.com/Anish-Agnihotri/friendmex/blob/0e7e89ca8a00abf6bd77498a17c94007ecd1eef0/indexer/src/profile.ts#L11-L11 | 0e7e89ca8a00abf6bd77498a17c94007ecd1eef0 |
friendmex | github_2023 | Anish-Agnihotri | typescript | Profile.constructor | constructor() {
// Setup db
this.db = new PrismaClient();
// Setup api client
this.client = axios.create({
baseURL: constants.API,
});
} | /**
* Create profile manager
*/ | https://github.com/Anish-Agnihotri/friendmex/blob/0e7e89ca8a00abf6bd77498a17c94007ecd1eef0/indexer/src/profile.ts#L24-L31 | 0e7e89ca8a00abf6bd77498a17c94007ecd1eef0 |
friendmex | github_2023 | Anish-Agnihotri | typescript | Profile.syncUser | async syncUser(address: string) {
try {
// Collect user details
const {
data,
}: {
data:
| { message: string }
| { twitterUsername: string; twitterPfpUrl: string };
} = await this.client.get(`/users/${address}`);
// Check for no message
if ("m... | /**
* Syncs users metadata
* @param address
*/ | https://github.com/Anish-Agnihotri/friendmex/blob/0e7e89ca8a00abf6bd77498a17c94007ecd1eef0/indexer/src/profile.ts#L37-L87 | 0e7e89ca8a00abf6bd77498a17c94007ecd1eef0 |
friendmex | github_2023 | Anish-Agnihotri | typescript | Profile.syncProfiles | async syncProfiles() {
// Collect all users that have not been checked (250 at a time)
const users: { address: string }[] = await this.db.user.findMany({
orderBy: {
// Get highest supply users first
supply: "desc",
},
select: {
address: true,
},
where: {
... | /**
* Syncs profile metadata to database
*/ | https://github.com/Anish-Agnihotri/friendmex/blob/0e7e89ca8a00abf6bd77498a17c94007ecd1eef0/indexer/src/profile.ts#L92-L115 | 0e7e89ca8a00abf6bd77498a17c94007ecd1eef0 |
friendmex | github_2023 | Anish-Agnihotri | typescript | Stats.constructor | constructor(redis_url: string) {
// Setup db
this.db = new PrismaClient();
// Setup redis
this.redis = new Redis(redis_url);
} | /**
* Create new Stats
* @param {string} redis_url Cache URL
*/ | https://github.com/Anish-Agnihotri/friendmex/blob/0e7e89ca8a00abf6bd77498a17c94007ecd1eef0/indexer/src/stats.ts#L17-L22 | 0e7e89ca8a00abf6bd77498a17c94007ecd1eef0 |
friendmex | github_2023 | Anish-Agnihotri | typescript | Stats.updateNewestUsers | async updateNewestUsers(): Promise<void> {
const users: User[] = await this.db.user.findMany({
orderBy: {
createdAt: "desc",
},
take: 50,
});
// Augment data with cost
const augmented = users.map((user) => ({
...user,
cost: getPrice(user.supply, 1),
}));
a... | /**
* Tracks newest 50 users
*/ | https://github.com/Anish-Agnihotri/friendmex/blob/0e7e89ca8a00abf6bd77498a17c94007ecd1eef0/indexer/src/stats.ts#L27-L42 | 0e7e89ca8a00abf6bd77498a17c94007ecd1eef0 |
friendmex | github_2023 | Anish-Agnihotri | typescript | Stats.udpateRecentTrades | async udpateRecentTrades(): Promise<void> {
const txs = await this.db.trade.findMany({
orderBy: {
timestamp: "desc",
},
include: {
fromUser: {
select: {
twitterUsername: true,
twitterPfpUrl: true,
},
},
subjectUser: {
... | /**
* Tracks latest 100 trades
*/ | https://github.com/Anish-Agnihotri/friendmex/blob/0e7e89ca8a00abf6bd77498a17c94007ecd1eef0/indexer/src/stats.ts#L47-L70 | 0e7e89ca8a00abf6bd77498a17c94007ecd1eef0 |
friendmex | github_2023 | Anish-Agnihotri | typescript | Stats.sync15s | async sync15s(): Promise<void> {
await Promise.all([
this.updateNewestUsers(),
this.udpateRecentTrades(),
this.tokenLeaderboard(),
]);
// Recollect in 15s
logger.info("Stats: Collected quarter-minute stats");
setTimeout(() => this.sync15s(), 1000 * 15);
} | /**
* Stats synced at a 15s frequency
*/ | https://github.com/Anish-Agnihotri/friendmex/blob/0e7e89ca8a00abf6bd77498a17c94007ecd1eef0/indexer/src/stats.ts#L146-L156 | 0e7e89ca8a00abf6bd77498a17c94007ecd1eef0 |
solv | github_2023 | EpicsDAO | typescript | getPreferredDisks | function getPreferredDisks(): GetPreferredDisksResult {
const commandOutput = execSync('lsblk -l -b -o NAME,SIZE,MOUNTPOINT', {
encoding: 'utf8',
})
const lines = commandOutput.split('\n').slice(1) // skip the header line
const disks: DiskInfo[] = []
// Collecting all disk names to identify which ones h... | // This method can be improved later - Prioritize the NVMe disks over SATA disks | https://github.com/EpicsDAO/solv/blob/47de96b6725b8be575b388f900f43abc05fef523/packages/solv/src/cli/check/mt/getLargestDisk.ts#L20-L93 | 47de96b6725b8be575b388f900f43abc05fef523 |
solv | github_2023 | EpicsDAO | typescript | installAgave | const installAgave = (version: string) => {
spawnSync(
`sh -c "$(curl -sSfL https://release.anza.xyz/v${version}/install)"`,
{
shell: true,
stdio: 'inherit',
},
)
} | // Agave Install e.g. installAgave('0.1.0') | https://github.com/EpicsDAO/solv/blob/47de96b6725b8be575b388f900f43abc05fef523/packages/solv/src/cli/install/installAgave.ts#L4-L12 | 47de96b6725b8be575b388f900f43abc05fef523 |
solv | github_2023 | EpicsDAO | typescript | installSolana | const installSolana = (version: string) => {
spawnSync(
`sh -c "$(curl -sSfL https://release.solana.com/v${version}/install)"`,
{
shell: true,
stdio: 'inherit',
},
)
} | // Agave Install e.g. installAgave('0.1.0') | https://github.com/EpicsDAO/solv/blob/47de96b6725b8be575b388f900f43abc05fef523/packages/solv/src/cli/install/installSolana.ts#L4-L12 | 47de96b6725b8be575b388f900f43abc05fef523 |
solv | github_2023 | EpicsDAO | typescript | initialConfigSetup | const initialConfigSetup = async () => {
try {
// Setup solv config
let validatorType: ValidatorType = ValidatorType.NONE
let rpcType: RpcType = RpcType.AGAVE
let commission = DEFAULT_CONFIG.COMMISSION
let isDummy = false
const answer = await inquirer.prompt<SolvInitialConfig>([
{
... | // Setup initial config in solv4.config.json | https://github.com/EpicsDAO/solv/blob/47de96b6725b8be575b388f900f43abc05fef523/packages/solv/src/cli/setup/question/initialConfigSetup.ts#L24-L128 | 47de96b6725b8be575b388f900f43abc05fef523 |
solv | github_2023 | EpicsDAO | typescript | autoUpdate | const autoUpdate = async (config: DefaultConfigType) => {
const isMainnet = config.NETWORK === Network.MAINNET
const { mainnetValidatorKey, testnetValidatorKey } = getAllKeyPaths()
const validatorKey = isMainnet ? mainnetValidatorKey : testnetValidatorKey
const solanaVersion = getSolanaVersion()
// Notify the... | // NODE_RESTART_REQUIRED_MAINNET/TESTNET is a boolean | https://github.com/EpicsDAO/solv/blob/47de96b6725b8be575b388f900f43abc05fef523/packages/solv/src/cli/update/autoUpdate/index.ts#L22-L77 | 47de96b6725b8be575b388f900f43abc05fef523 |
movies | github_2023 | oktay | typescript | sanitizeParams | const sanitizeParams = (params?: Record<string, string | undefined>) => {
return Object.fromEntries(
Object.entries(params ?? {}).filter(([, value]) => value !== undefined)
)
} | /**
* Sanitizes the given parameters by removing entries with undefined values.
* This ensures that only valid parameters are included in the API request.
*
* @param {Record<string, string | undefined>} params - The parameters to be sanitized.
* @returns {Record<string, string>} A new parameters object with undefi... | https://github.com/oktay/movies/blob/56e0581305db8ee2b9876a79e770cc9230dae787/tmdb/api/api.ts#L17-L21 | 56e0581305db8ee2b9876a79e770cc9230dae787 |
movies | github_2023 | oktay | typescript | createSearchParams | const createSearchParams = (params: Record<string, string | undefined>) => {
const sanitizedParams = sanitizeParams(params)
const mergedParams: Record<string, string> = {
...apiConfig.defaultParams,
...sanitizedParams,
} as Record<string, string>
return new URLSearchParams(mergedParams).toString()
} | /**
* Creates a URL search params string from the given parameters.
* Merges default parameters from the API configuration with the provided parameters.
* Undefined parameters are filtered out.
*
* @param {Record<string, string | undefined>} params - The parameters to include in the search string.
* @returns {str... | https://github.com/oktay/movies/blob/56e0581305db8ee2b9876a79e770cc9230dae787/tmdb/api/api.ts#L31-L39 | 56e0581305db8ee2b9876a79e770cc9230dae787 |
movies | github_2023 | oktay | typescript | createHeaders | const createHeaders = (init?: RequestInit): Headers => {
const headers = init?.headers ?? {}
const mergedHeaders = { ...apiConfig.defaultHeaders, ...headers }
return new Headers(mergedHeaders)
} | /**
* Creates a Headers instance for the fetch request.
* Merges default headers from the API configuration with any headers provided in the init object.
*
* @param {RequestInit} [init] - Optional initial settings for the fetch request, including headers.
* @returns {Headers} The Headers instance for the fetch req... | https://github.com/oktay/movies/blob/56e0581305db8ee2b9876a79e770cc9230dae787/tmdb/api/api.ts#L48-L52 | 56e0581305db8ee2b9876a79e770cc9230dae787 |
movies | github_2023 | oktay | typescript | fetcher | const fetcher: Fetcher = async ({ endpoint, params }, init) => {
const sanitizedParams = sanitizeParams(params)
const _params = createSearchParams(sanitizedParams)
const _headers = createHeaders(init)
const _init = {
...init,
next: { revalidate: 600, ...init?.next },
headers: _headers,
}
const... | /**
* Fetches data from the specified endpoint using the provided parameters and initialization options.
* Sanitizes parameters to remove any undefined values, constructs the full URL with parameters,
* and performs the fetch request with custom headers.
* Throws an error if the response is not ok.
*
* @template ... | https://github.com/oktay/movies/blob/56e0581305db8ee2b9876a79e770cc9230dae787/tmdb/api/api.ts#L65-L86 | 56e0581305db8ee2b9876a79e770cc9230dae787 |
movies | github_2023 | oktay | typescript | details | const details = ({ id }: CollectionRequestParams) =>
api.fetcher<DetailedCollection>({
endpoint: `collection/${id}`,
}) | /**
* Fetches detailed information about a specific collection from the TMDB API.
*
* @param {CollectionRequestParams} params - The parameters for the collection request, including the collection ID.
* @returns {Promise<DetailedCollection>} A promise that resolves to the detailed information about the collection.
... | https://github.com/oktay/movies/blob/56e0581305db8ee2b9876a79e770cc9230dae787/tmdb/api/collection/index.ts#L13-L16 | 56e0581305db8ee2b9876a79e770cc9230dae787 |
movies | github_2023 | oktay | typescript | movie | const movie = (args: DiscoverMovieRequestParams) =>
api.fetcher<ListResponse<Movie>>({
endpoint: "discover/movie",
params: args as Record<string, string>,
}) | /**
* Fetches a list of movies based on the provided request parameters.
*
* @param args - The request parameters for discovering movies.
* @returns A Promise that resolves to a ListResponse containing the discovered movies.
*/ | https://github.com/oktay/movies/blob/56e0581305db8ee2b9876a79e770cc9230dae787/tmdb/api/discover/index.ts#L15-L19 | 56e0581305db8ee2b9876a79e770cc9230dae787 |
movies | github_2023 | oktay | typescript | tv | const tv = (args: DiscoverTvRequestParams) =>
api.fetcher<ListResponse<TvShow>>({
endpoint: "discover/tv",
params: args as Record<string, string>,
}) | /**
* Fetches a list of tv shows based on the provided request parameters.
*
* @param args - The request parameters for discovering movies.
* @returns A Promise that resolves to a ListResponse containing the discovered movies.
*/ | https://github.com/oktay/movies/blob/56e0581305db8ee2b9876a79e770cc9230dae787/tmdb/api/discover/index.ts#L27-L31 | 56e0581305db8ee2b9876a79e770cc9230dae787 |
movies | github_2023 | oktay | typescript | movie | const movie = () =>
api.fetcher<GenreResponse>({
endpoint: "genre/movie/list",
}) | /**
* Fetches the list of movie genres from the TMDB API.
* @returns A promise that resolves to the genre response.
*/ | https://github.com/oktay/movies/blob/56e0581305db8ee2b9876a79e770cc9230dae787/tmdb/api/genres/index.ts#L8-L11 | 56e0581305db8ee2b9876a79e770cc9230dae787 |
movies | github_2023 | oktay | typescript | tv | const tv = () =>
api.fetcher<GenreResponse>({
endpoint: "genre/tv/list",
}) | /**
* Fetches the list of tv show genres from the TMDB API.
* @returns A promise that resolves to the genre response.
*/ | https://github.com/oktay/movies/blob/56e0581305db8ee2b9876a79e770cc9230dae787/tmdb/api/genres/index.ts#L17-L20 | 56e0581305db8ee2b9876a79e770cc9230dae787 |
movies | github_2023 | oktay | typescript | list | const list = ({ list, page, region }: MovieListRequestParams) =>
api.fetcher<ListResponse<Movie>>({
endpoint: `movie/${list}`,
params: {
page,
region,
},
}) | /**
* Fetches a list of movies based on the specified criteria.
*
* @param {MovieListRequestParams} params - The parameters for the movie list request, including list type, page, and region.
* @returns {Promise<ListResponse<Movie>>} A promise that resolves to the list of movies.
* @see https://developer.themoviedb... | https://github.com/oktay/movies/blob/56e0581305db8ee2b9876a79e770cc9230dae787/tmdb/api/movie/index.ts#L35-L42 | 56e0581305db8ee2b9876a79e770cc9230dae787 |
movies | github_2023 | oktay | typescript | detail | const detail = <T>({ id, append }: MovieDetailsRequestParams) =>
api.fetcher<MovieDetails & T>({
endpoint: `movie/${id}`,
params: {
append_to_response: append,
},
}) | /**
* Fetches detailed information about a specific movie.
*
* @param {MovieDetailsRequestParams} params - The parameters for the movie details request, including the movie ID and any additional data to append.
* @returns {Promise<MovieDetails>} A promise that resolves to the detailed information about the movie.
... | https://github.com/oktay/movies/blob/56e0581305db8ee2b9876a79e770cc9230dae787/tmdb/api/movie/index.ts#L51-L57 | 56e0581305db8ee2b9876a79e770cc9230dae787 |
movies | github_2023 | oktay | typescript | credits | const credits = ({ id }: MovieCreditsRequestParams) =>
api.fetcher<Credits>({
endpoint: `movie/${id}/credits`,
}) | /**
* Fetches the credits (cast and crew) for a specific movie.
*
* @param {MovieCreditsRequestParams} params - The parameters for the movie credits request, including the movie ID.
* @returns {Promise<Credits>} A promise that resolves to the credits for the movie.
* @see https://developer.themoviedb.org/reference... | https://github.com/oktay/movies/blob/56e0581305db8ee2b9876a79e770cc9230dae787/tmdb/api/movie/index.ts#L66-L69 | 56e0581305db8ee2b9876a79e770cc9230dae787 |
movies | github_2023 | oktay | typescript | recommendations | const recommendations = ({ id, page }: MovieRecommendationsRequestParams) =>
api.fetcher<ListResponse<Movie>>({
endpoint: `movie/${id}/recommendations`,
params: {
page,
},
}) | /**
* Fetches recommendations for a specific movie.
*
* @param {MovieRecommendationsRequestParams} params - The parameters for the movie recommendations request, including the movie ID and page number.
* @returns {Promise<ListResponse<Movie>>} A promise that resolves to a list of recommended movies.
* @see https:/... | https://github.com/oktay/movies/blob/56e0581305db8ee2b9876a79e770cc9230dae787/tmdb/api/movie/index.ts#L78-L84 | 56e0581305db8ee2b9876a79e770cc9230dae787 |
movies | github_2023 | oktay | typescript | similar | const similar = ({ id, page }: MovieSimilarRequestParams) =>
api.fetcher<ListResponse<Movie>>({
endpoint: `movie/${id}/similar`,
params: {
page,
},
}) | /**
* Fetches movies similar to a specific movie.
*
* @param {MovieSimilarRequestParams} params - The parameters for the movie similar request, including the movie ID and page number.
* @returns {Promise<ListResponse<Movie>>} A promise that resolves to a list of similar movies.
* @see https://developer.themoviedb.... | https://github.com/oktay/movies/blob/56e0581305db8ee2b9876a79e770cc9230dae787/tmdb/api/movie/index.ts#L93-L99 | 56e0581305db8ee2b9876a79e770cc9230dae787 |
movies | github_2023 | oktay | typescript | images | const images = ({ id, langs }: MovieImagesRequestParams) =>
api.fetcher<GetImagesResponse>({
endpoint: `movie/${id}/images`,
params: {
include_image_language: langs,
},
}) | /**
* Fetches images for a specific movie.
*
* @param {MovieImagesRequestParams} params - The parameters for the movie images request, including the movie ID and languages for the images.
* @returns {Promise<GetImagesResponse>} A promise that resolves to the images of the movie.
* @see https://developer.themoviedb... | https://github.com/oktay/movies/blob/56e0581305db8ee2b9876a79e770cc9230dae787/tmdb/api/movie/index.ts#L108-L114 | 56e0581305db8ee2b9876a79e770cc9230dae787 |
movies | github_2023 | oktay | typescript | videos | const videos = ({ id }: MovieVideosRequestParams) =>
api.fetcher<GetVideosResponse>({
endpoint: `movie/${id}/videos`,
}) | /**
* Fetches videos for a specific movie.
*
* @param {MovieVideosRequestParams} params - The parameters for the movie videos request, including the movie ID.
* @returns {Promise<GetVideosResponse>} A promise that resolves to the videos of the movie.
* @see https://developer.themoviedb.org/reference/movie-videos
... | https://github.com/oktay/movies/blob/56e0581305db8ee2b9876a79e770cc9230dae787/tmdb/api/movie/index.ts#L123-L126 | 56e0581305db8ee2b9876a79e770cc9230dae787 |
movies | github_2023 | oktay | typescript | reviews | const reviews = ({ id, page }: MovieReviewsRequestParams) =>
api.fetcher<ListResponse<Review>>({
endpoint: `movie/${id}/reviews`,
params: {
page,
},
}) | /**
* Fetches reviews for a specific movie.
*
* @param {MovieReviewsRequestParams} params - The parameters for the movie reviews request, including the movie ID and page number.
* @returns {Promise<ListResponse<Review>>} A promise that resolves to a list of reviews for the movie.
* @see https://developer.themovied... | https://github.com/oktay/movies/blob/56e0581305db8ee2b9876a79e770cc9230dae787/tmdb/api/movie/index.ts#L135-L141 | 56e0581305db8ee2b9876a79e770cc9230dae787 |
movies | github_2023 | oktay | typescript | providers | const providers = ({ id, region }: MovieProvidersRequestParams) =>
api.fetcher<WatchProviders>({
endpoint: `movie/${id}/watch/providers`,
params: {
watch_region: region,
},
}) | /**
* Fetches providers for a specific movie.
*
* @param {MovieProvidersRequestParams} params - The parameters for the movie reviews request, including the movie ID and page number.
* @returns {Promise<WatchProviders>} A promise that resolves to a list of reviews for the movie.
* @see https://developer.themoviedb.... | https://github.com/oktay/movies/blob/56e0581305db8ee2b9876a79e770cc9230dae787/tmdb/api/movie/index.ts#L150-L156 | 56e0581305db8ee2b9876a79e770cc9230dae787 |
movies | github_2023 | oktay | typescript | list | const list = async ({ list, page }: PersonListRequestParams) =>
api.fetcher<ListResponse<Person>>({
endpoint: `person/${list}`,
params: {
page,
},
}) | /**
* Fetches a list of movies based on the specified criteria.
*
* @param {PersonListRequestParams} params - The parameters for the movie list request, including list type, page, and region.
* @returns {Promise<ListResponse<Person>>} A promise that resolves to the list of movies.
* @see https://developer.themovie... | https://github.com/oktay/movies/blob/56e0581305db8ee2b9876a79e770cc9230dae787/tmdb/api/person/index.ts#L14-L20 | 56e0581305db8ee2b9876a79e770cc9230dae787 |
movies | github_2023 | oktay | typescript | detail | const detail = async <T>({ id, append }: PersonDetailsRequestParams) =>
api.fetcher<PersonDetails & T>({
endpoint: `person/${id}`,
params: {
append_to_response: append,
},
}) | /**
* Fetches details for a person by ID.
* @param id - Person ID.
* @param append - Additional information to append to the response.
* @returns A promise resolving to the person details.
* @see https://developers.themoviedb.org/3/reference/person-details
*/ | https://github.com/oktay/movies/blob/56e0581305db8ee2b9876a79e770cc9230dae787/tmdb/api/person/index.ts#L29-L35 | 56e0581305db8ee2b9876a79e770cc9230dae787 |
movies | github_2023 | oktay | typescript | combinedCredits | const combinedCredits = async ({ id }: PersonDetailsRequestParams) =>
api.fetcher<CombinedCreditsResponse>({
endpoint: `person/${id}/combined_credits`,
}) | /**
* Fetches combined credits for a person by ID.
* @param id - Person ID.
* @returns A promise resolving to the combined credits for the person.
* @see https://developers.themoviedb.org/3/reference/person-combined-credits
*/ | https://github.com/oktay/movies/blob/56e0581305db8ee2b9876a79e770cc9230dae787/tmdb/api/person/index.ts#L43-L46 | 56e0581305db8ee2b9876a79e770cc9230dae787 |
movies | github_2023 | oktay | typescript | multi | const multi = async ({
query,
adult = false,
page = "1",
}: SearchRequestParams) =>
api.fetcher<
ListResponse<MovieWithMediaType | TvShowWithMediaType | PersonWithMediaType>
>({
endpoint: "/search/multi",
params: {
query,
page,
include_adult: String(adult),
},
}) | /**
* Fetches a list of movies, TV shows, and people based on the specified search query.
*
* @param {SearchRequestParams} params - The parameters for the search request, including the search query, adult content filter, and page number.
* @returns {Promise<ListResponse<MovieWithMediaType | TvShowWithMediaType | Pe... | https://github.com/oktay/movies/blob/56e0581305db8ee2b9876a79e770cc9230dae787/tmdb/api/search/index.ts#L18-L32 | 56e0581305db8ee2b9876a79e770cc9230dae787 |
movies | github_2023 | oktay | typescript | movie | const movie = ({ time, page = "1" }: TrendingRequestParams) =>
api.fetcher<ListResponse<MovieWithMediaType>>({
endpoint: `trending/movie/${time}`,
params: {
page,
},
}) | /**
* Fetches a list of trending movies, TV shows, or people based on the specified criteria.
*
* @param {TrendingRequestParams} params - The parameters for the trending request, including the time window and page number.
* @returns {Promise<ListResponse<MovieWithMediaType | TvShowWithMediaType | PersonWithMediaTyp... | https://github.com/oktay/movies/blob/56e0581305db8ee2b9876a79e770cc9230dae787/tmdb/api/trending/index.ts#L18-L24 | 56e0581305db8ee2b9876a79e770cc9230dae787 |
movies | github_2023 | oktay | typescript | tv | const tv = ({ time, page = "1" }: TrendingRequestParams) =>
api.fetcher<ListResponse<TvShowWithMediaType>>({
endpoint: `trending/tv/${time}`,
params: {
page,
},
}) | /**
* Fetches a list of trending TV shows based on the specified criteria.
*
* @param {TrendingRequestParams} params - The parameters for the trending request, including the time window and page number.
* @returns {Promise<ListResponse<TvShowWithMediaType>>} A promise that resolves to the list of trending TV shows.... | https://github.com/oktay/movies/blob/56e0581305db8ee2b9876a79e770cc9230dae787/tmdb/api/trending/index.ts#L33-L39 | 56e0581305db8ee2b9876a79e770cc9230dae787 |
movies | github_2023 | oktay | typescript | people | const people = ({ time, page = "1" }: TrendingRequestParams) =>
api.fetcher<ListResponse<PersonWithMediaType>>({
endpoint: `trending/person/${time}`,
params: {
page,
},
}) | /**
* Fetches a list of trending people based on the specified criteria.
*
* @param {TrendingRequestParams} params - The parameters for the trending request, including the time window and page number.
* @returns {Promise<ListResponse<PersonWithMediaType>>} A promise that resolves to the list of trending people.
* ... | https://github.com/oktay/movies/blob/56e0581305db8ee2b9876a79e770cc9230dae787/tmdb/api/trending/index.ts#L48-L54 | 56e0581305db8ee2b9876a79e770cc9230dae787 |
movies | github_2023 | oktay | typescript | details | const details = <T>({ id, season, append }: TvSeasonsDetailsRequestParams) =>
api.fetcher<SeasonDetails & T>({
endpoint: `tv/${id}/season/${season}`,
params: {
append_to_response: append,
},
}) | /**
* Fetches detailed information about a specific TV season.
*
* @param {TvSeasonsDetailsRequestParams} params - The parameters for the TV season details request, including the TV series ID and the season number.
* @returns {Promise<SeasonDetails>} A promise that resolves to the detailed information about the TV ... | https://github.com/oktay/movies/blob/56e0581305db8ee2b9876a79e770cc9230dae787/tmdb/api/tv-seasons/index.ts#L13-L19 | 56e0581305db8ee2b9876a79e770cc9230dae787 |
movies | github_2023 | oktay | typescript | list | const list = ({ list, page = "1", region, timezone }: TvListRequestParams) =>
api.fetcher<ListResponse<TvShow>>({
endpoint: `tv/${list}`,
params: {
page,
region,
timezone,
},
}) | /**
* Fetches a list of TV shows based on the specified criteria.
*
* @param {TvListRequestParams} params - The parameters for the TV list request, including list type, page, and region.
* @returns {Promise<ListResponse<TvShow>>} A promise that resolves to the list of TV shows.
* @see https://developer.themoviedb.... | https://github.com/oktay/movies/blob/56e0581305db8ee2b9876a79e770cc9230dae787/tmdb/api/tv/index.ts#L35-L43 | 56e0581305db8ee2b9876a79e770cc9230dae787 |
movies | github_2023 | oktay | typescript | detail | const detail = <T>({ id, append }: TvDetailsRequestParams) =>
api.fetcher<TvShowDetails & T>({
endpoint: `tv/${id}`,
params: {
append_to_response: append,
},
}) | /**
* Fetches detailed information about a specific TV series.
*
* @param {TvDetailsRequestParams} params - The parameters for the TV details request, including the TV series ID and any additional data to append.
* @returns {Promise<TvShowDetails>} A promise that resolves to the detailed information about the TV se... | https://github.com/oktay/movies/blob/56e0581305db8ee2b9876a79e770cc9230dae787/tmdb/api/tv/index.ts#L52-L58 | 56e0581305db8ee2b9876a79e770cc9230dae787 |
movies | github_2023 | oktay | typescript | credits | const credits = ({ id }: TvCreditsRequestParams) =>
api.fetcher<Credits>({
endpoint: `tv/${id}/credits`,
}) | /**
* Fetches the credits (cast and crew) for a specific TV series.
*
* @param {TvCreditsRequestParams} params - The parameters for the TV credits request, including the TV series ID.
* @returns {Promise<Credits>} A promise that resolves to the credits for the TV series.
* @see https://developer.themoviedb.org/ref... | https://github.com/oktay/movies/blob/56e0581305db8ee2b9876a79e770cc9230dae787/tmdb/api/tv/index.ts#L67-L70 | 56e0581305db8ee2b9876a79e770cc9230dae787 |
movies | github_2023 | oktay | typescript | recommendations | const recommendations = ({ id, page }: TvRecommendationsRequestParams) =>
api.fetcher<ListResponse<TvShow>>({
endpoint: `tv/${id}/recommendations`,
params: {
page,
},
}) | /**
* Fetches recommendations for a specific TV series.
*
* @param {TvRecommendationsRequestParams} params - The parameters for the TV recommendations request, including the TV series ID and page number.
* @returns {Promise<ListResponse<TvShow>>} A promise that resolves to a list of recommended TV shows.
* @see ht... | https://github.com/oktay/movies/blob/56e0581305db8ee2b9876a79e770cc9230dae787/tmdb/api/tv/index.ts#L79-L85 | 56e0581305db8ee2b9876a79e770cc9230dae787 |
movies | github_2023 | oktay | typescript | similar | const similar = ({ id, page }: TvSimilarRequestParams) =>
api.fetcher<ListResponse<TvShow>>({
endpoint: `tv/${id}/similar`,
params: {
page,
},
}) | /**
* Fetches TV shows similar to a specific TV series.
*
* @param {TvSimilarRequestParams} params - The parameters for the TV similar request, including the TV series ID and page number.
* @returns {Promise<ListResponse<TvShow>>} A promise that resolves to a list of similar TV shows.
* @see https://developer.them... | https://github.com/oktay/movies/blob/56e0581305db8ee2b9876a79e770cc9230dae787/tmdb/api/tv/index.ts#L94-L100 | 56e0581305db8ee2b9876a79e770cc9230dae787 |
movies | github_2023 | oktay | typescript | images | const images = ({ id, langs }: TvImagesRequestParams) =>
api.fetcher<GetImagesResponse>({
endpoint: `tv/${id}/images`,
params: {
include_image_language: langs,
},
}) | /**
* Fetches images for a specific TV series.
*
* @param {TvImagesRequestParams} params - The parameters for the TV images request, including the TV series ID and languages for the images.
* @returns {Promise<GetImagesResponse>} A promise that resolves to the images of the TV series.
* @see https://developer.them... | https://github.com/oktay/movies/blob/56e0581305db8ee2b9876a79e770cc9230dae787/tmdb/api/tv/index.ts#L109-L115 | 56e0581305db8ee2b9876a79e770cc9230dae787 |
movies | github_2023 | oktay | typescript | videos | const videos = ({ id }: TvVideosRequestParams) =>
api.fetcher<GetVideosResponse>({
endpoint: `tv/${id}/videos`,
}) | /**
* Fetches videos related to a specific TV series.
*
* @param {TvVideosRequestParams} params - The parameters for the TV videos request, including the TV series ID.
* @returns {Promise<GetVideosResponse>} A promise that resolves to the videos of the TV series.
* @see https://developer.themoviedb.org/reference/t... | https://github.com/oktay/movies/blob/56e0581305db8ee2b9876a79e770cc9230dae787/tmdb/api/tv/index.ts#L124-L127 | 56e0581305db8ee2b9876a79e770cc9230dae787 |
movies | github_2023 | oktay | typescript | reviews | const reviews = ({ id, page }: TvReviewsRequestParams) =>
api.fetcher<ListResponse<Review>>({
endpoint: `tv/${id}/reviews`,
params: {
page,
},
}) | /**
* Fetches reviews for a specific TV series.
*
* @param {TvReviewsRequestParams} params - The parameters for the TV reviews request, including the TV series ID and page number.
* @returns {Promise<ListResponse<Review>>} A promise that resolves to the reviews of the TV series.
* @see https://developer.themoviedb... | https://github.com/oktay/movies/blob/56e0581305db8ee2b9876a79e770cc9230dae787/tmdb/api/tv/index.ts#L136-L142 | 56e0581305db8ee2b9876a79e770cc9230dae787 |
movies | github_2023 | oktay | typescript | providers | const providers = ({ id, region }: TvProvidersRequestParams) =>
api.fetcher<WatchProviders>({
endpoint: `tv/${id}/watch/providers`,
params: {
watch_region: region,
},
}) | /**
* Fetches providers for a specific TV Series.
*
* @param {TvProvidersRequestParams} params - The parameters for the movie reviews request, including the movie ID and page number.
* @returns {Promise<WatchProviders>} A promise that resolves to a list of reviews for the movie.
* @see https://developer.themoviedb... | https://github.com/oktay/movies/blob/56e0581305db8ee2b9876a79e770cc9230dae787/tmdb/api/tv/index.ts#L151-L157 | 56e0581305db8ee2b9876a79e770cc9230dae787 |
movies | github_2023 | oktay | typescript | regions | const regions = () =>
api.fetcher<GetAvailableRegionsResponse>({
endpoint: `watch/providers/regions`,
}) | /**
* Fetches the available regions for watch providers.
*
* @returns {Promise<GetAvailableRegionsResponse>} A promise that resolves to a list of reviews for the movie.
* @see https://developer.themoviedb.org/reference/watch-providers-available-regions
*/ | https://github.com/oktay/movies/blob/56e0581305db8ee2b9876a79e770cc9230dae787/tmdb/api/watch-providers/index.ts#L11-L14 | 56e0581305db8ee2b9876a79e770cc9230dae787 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.