Skip to content

Commit

Permalink
perf: inline return promise (#121)
Browse files Browse the repository at this point in the history
  • Loading branch information
samir-byte authored Oct 30, 2024
1 parent 276c0ce commit 17d5dad
Show file tree
Hide file tree
Showing 9 changed files with 14 additions and 14 deletions.
2 changes: 1 addition & 1 deletion frontend/actions/generate-user-stripe.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ export type responseAction = {
const billingUrl = absoluteUrl('/pricing');

async function createStripeSession(priceId, locale, session, params) {
return await stripe.checkout.sessions.create({
return stripe.checkout.sessions.create({
success_url: billingUrl,
cancel_url: billingUrl,
billing_address_collection: 'auto',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ So, I checked the source code of auth.js and found that it uses the jose library
```ts
async function getDerivedEncryptionKey(enc: string, keyMaterial: Parameters<typeof hkdf>[1], salt: Parameters<typeof hkdf>[2]) {
const length = enc === 'A256CBC-HS512' ? 64 : 32;
return await hkdf('sha256', keyMaterial, salt, `Auth.js Generated Encryption Key (${salt})`, length);
return hkdf('sha256', keyMaterial, salt, `Auth.js Generated Encryption Key (${salt})`, length);
}
```

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ const openai = new OpenAI({

async function readImageFile(filePath: string) {
const baseDir = dirname(fileURLToPath(import.meta.url));
return await readFile(join(baseDir, filePath));
return readFile(join(baseDir, filePath));
}

export async function chatImage() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ export const getAuthToken = async () => {
```ts
async function getDerivedEncryptionKey(enc: string, keyMaterial: Parameters<typeof hkdf>[1], salt: Parameters<typeof hkdf>[2]) {
const length = enc === 'A256CBC-HS512' ? 64 : 32;
return await hkdf('sha256', keyMaterial, salt, `Auth.js 生成的加密密钥 (${salt})`, length);
return hkdf('sha256', keyMaterial, salt, `Auth.js 生成的加密密钥 (${salt})`, length);
}
```

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ const openai = new OpenAI({

async function readImageFile(filePath: string) {
const baseDir = dirname(fileURLToPath(import.meta.url));
return await readFile(join(baseDir, filePath));
return readFile(join(baseDir, filePath));
}

export async function chatImage() {
Expand Down
2 changes: 1 addition & 1 deletion frontend/lib/tools/auto.ts
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ export async function autoAnswer(
url: z.string().describe('the url to access'),
}),
execute: async ({ url }) => {
return await accessWebPage(url, onStream);
return accessWebPage(url, onStream);
},
}),
},
Expand Down
2 changes: 1 addition & 1 deletion frontend/lib/tools/hacker-news.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ export async function get_top_stories(limit: number, onStream?: (...args: any[])

export async function get_story(id: number) {
const response = await fetch(`https://hacker-news.firebaseio.com/v0/item/${id}.json`);
return await response.json();
return response.json();
}

export async function get_story_with_comments(id: number) {
Expand Down
2 changes: 1 addition & 1 deletion vector/auth.ts
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ async function getDerivedEncryptionKey(
salt: Parameters<typeof hkdf>[2]
) {
const length = enc === "A256CBC-HS512" ? 64 : 32;
return await hkdf(
return hkdf(
"sha256",
keyMaterial,
salt,
Expand Down
12 changes: 6 additions & 6 deletions vector/db.ts
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ const schema = new Schema([
async function getConnection() {
const bucket = process.env.AWS_BUCKET || "";
if (bucket) {
return await lancedb.connect(bucket, {
return lancedb.connect(bucket, {
storageOptions: {
awsAccessKeyId: process.env.AWS_ACCESS_KEY_ID || "",
s3Express: "true",
Expand All @@ -38,15 +38,15 @@ async function getConnection() {
} else {
// Let open source users could one click deploy
const localDirectory = process.cwd();
return await lancedb.connect(localDirectory);
return lancedb.connect(localDirectory);
}
}

async function getTable(db: any, tableName: string): Promise<lancedb.Table> {
if ((await db.tableNames()).includes(tableName)) {
return await db.openTable(tableName);
return db.openTable(tableName);
} else {
return await db.createEmptyTable(tableName, schema);
return db.createEmptyTable(tableName, schema);
}
}

Expand Down Expand Up @@ -151,12 +151,12 @@ export async function dropTable(tableName: string) {

export async function createEmptyTable(tableName: string) {
const db = await getConnection();
return await db.createEmptyTable(tableName, schema);
return db.createEmptyTable(tableName, schema);
}

export async function reCreateEmptyTable(tableName: string) {
const db = await getConnection();
return await db.createEmptyTable(tableName, schema, { mode: "overwrite" });
return db.createEmptyTable(tableName, schema, { mode: "overwrite" });
}

export async function size(tableName: string) {
Expand Down

0 comments on commit 17d5dad

Please sign in to comment.