repo_name string | dataset string | owner string | lang string | func_name string | code string | docstring string | url string | sha string |
|---|---|---|---|---|---|---|---|---|
turbo | github_2023 | unfoldadmin | typescript | UsersService.usersMeUpdate | public usersMeUpdate(
requestBody: UserCurrent
): CancelablePromise<UserCurrent> {
return this.httpRequest.request({
method: 'PUT',
url: '/api/users/me/',
body: requestBody,
mediaType: 'application/json'
})
} | /**
* @param requestBody
* @returns UserCurrent
* @throws ApiError
*/ | https://github.com/unfoldadmin/turbo/blob/6f4ecf55bf67fbc6d9d42840ea50f71fe513a639/frontend/packages/types/api/services/UsersService.ts#L73-L82 | 6f4ecf55bf67fbc6d9d42840ea50f71fe513a639 |
turbo | github_2023 | unfoldadmin | typescript | UsersService.usersMePartialUpdate | public usersMePartialUpdate(
requestBody?: PatchedUserCurrent
): CancelablePromise<UserCurrent> {
return this.httpRequest.request({
method: 'PATCH',
url: '/api/users/me/',
body: requestBody,
mediaType: 'application/json'
})
} | /**
* @param requestBody
* @returns UserCurrent
* @throws ApiError
*/ | https://github.com/unfoldadmin/turbo/blob/6f4ecf55bf67fbc6d9d42840ea50f71fe513a639/frontend/packages/types/api/services/UsersService.ts#L89-L98 | 6f4ecf55bf67fbc6d9d42840ea50f71fe513a639 |
block-development-examples | github_2023 | WordPress | typescript | getTagsFromURL | const getTagsFromURL = () => {
const params = new URLSearchParams(window.location.search);
const tags = params.get("tags");
return tags ? tags.split(",") : [];
}; | // Helper function to get tags from URL | https://github.com/WordPress/block-development-examples/blob/687ede8bd13c8d622a94029c1ffd68fa4979a34e/_app/src/App.tsx#L22-L26 | 687ede8bd13c8d622a94029c1ffd68fa4979a34e |
block-development-examples | github_2023 | WordPress | typescript | updateURLWithTags | const updateURLWithTags = (tags: string[]) => {
const params = new URLSearchParams(window.location.search);
if (tags.length > 0) {
params.set("tags", tags.join(","));
} else {
params.delete("tags");
}
// Update URL without reloading the page
window.history.pushState(
{},
"",
`${window.... | // Helper function to update URL with tags | https://github.com/WordPress/block-development-examples/blob/687ede8bd13c8d622a94029c1ffd68fa4979a34e/_app/src/App.tsx#L29-L46 | 687ede8bd13c8d622a94029c1ffd68fa4979a34e |
block-development-examples | github_2023 | WordPress | typescript | generateTablesBase | function generateTablesBase( readmePath: string, targetSlug?: string ): void {
info( `📝 Updating ${ readmePath }...` );
validatePath( readmePath );
const examples = readJsonFile< Example[] >( EXAMPLES_DATA_PATH );
const tags = readJsonFile< Tag[] >( TAGS_DATA_PATH );
validateRequiredData( examples, 'No examples... | // Base function without error handling | https://github.com/WordPress/block-development-examples/blob/687ede8bd13c8d622a94029c1ffd68fa4979a34e/_bin/src/services/tableMarkdown.ts#L19-L45 | 687ede8bd13c8d622a94029c1ffd68fa4979a34e |
payload-enchants | github_2023 | r1tsuu | typescript | Layout | const Layout: React.FC<{ children: React.ReactNode }> = ({ children }) => {
return (
<html>
<body>
<main>{children}</main>
</body>
</html>
);
}; | /* Our app sits here to not cause any conflicts with payload's root layout */ | https://github.com/r1tsuu/payload-enchants/blob/7cd7c95f6158ef61d61be3a602104b1de0612e4e/test/src/app/(app)/layout.tsx#L6-L14 | 7cd7c95f6158ef61d61be3a602104b1de0612e4e |
booking-microservices-expressjs | github_2023 | meysamhadeli | typescript | authenticateMiddleware | function authenticateMiddleware(security: TsoaRoute.Security[] = []) {
return async function runAuthenticationMiddleware(request: any, response: any, next: any) {
// WARNING: This file was auto-generated with tsoa. Please do not modify it. Re-run tsoa to re-generate this file: https://github.com/lukeautry/tso... | // WARNING: This file was auto-generated with tsoa. Please do not modify it. Re-run tsoa to re-generate this file: https://github.com/lukeautry/tsoa | https://github.com/meysamhadeli/booking-microservices-expressjs/blob/631bfdfb92d732d0d2b9e83f8476a5858f129829/src/booking/src/routes/routes.ts#L113-L182 | 631bfdfb92d732d0d2b9e83f8476a5858f129829 |
booking-microservices-expressjs | github_2023 | meysamhadeli | typescript | authenticateMiddleware | function authenticateMiddleware(security: TsoaRoute.Security[] = []) {
return async function runAuthenticationMiddleware(request: any, response: any, next: any) {
// WARNING: This file was auto-generated with tsoa. Please do not modify it. Re-run tsoa to re-generate this file: https://github.com/lukeautry/tso... | // WARNING: This file was auto-generated with tsoa. Please do not modify it. Re-run tsoa to re-generate this file: https://github.com/lukeautry/tsoa | https://github.com/meysamhadeli/booking-microservices-expressjs/blob/631bfdfb92d732d0d2b9e83f8476a5858f129829/src/flight/src/routes/routes.ts#L562-L631 | 631bfdfb92d732d0d2b9e83f8476a5858f129829 |
booking-microservices-expressjs | github_2023 | meysamhadeli | typescript | authenticateMiddleware | function authenticateMiddleware(security: TsoaRoute.Security[] = []) {
return async function runAuthenticationMiddleware(request: any, response: any, next: any) {
// WARNING: This file was auto-generated with tsoa. Please do not modify it. Re-run tsoa to re-generate this file: https://github.com/lukeautry/tso... | // WARNING: This file was auto-generated with tsoa. Please do not modify it. Re-run tsoa to re-generate this file: https://github.com/lukeautry/tsoa | https://github.com/meysamhadeli/booking-microservices-expressjs/blob/631bfdfb92d732d0d2b9e83f8476a5858f129829/src/identity/src/routes/routes.ts#L463-L532 | 631bfdfb92d732d0d2b9e83f8476a5858f129829 |
booking-microservices-expressjs | github_2023 | meysamhadeli | typescript | Passenger.constructor | constructor(partial?: Partial<Passenger>) {
Object.assign(this, partial);
this.createdAt = partial?.createdAt ?? new Date();
} | // You can use 'Date | null' to allow null values | https://github.com/meysamhadeli/booking-microservices-expressjs/blob/631bfdfb92d732d0d2b9e83f8476a5858f129829/src/passenger/src/passenger/entities/passenger.entity.ts#L31-L34 | 631bfdfb92d732d0d2b9e83f8476a5858f129829 |
booking-microservices-expressjs | github_2023 | meysamhadeli | typescript | authenticateMiddleware | function authenticateMiddleware(security: TsoaRoute.Security[] = []) {
return async function runAuthenticationMiddleware(request: any, response: any, next: any) {
// WARNING: This file was auto-generated with tsoa. Please do not modify it. Re-run tsoa to re-generate this file: https://github.com/lukeautry/tso... | // WARNING: This file was auto-generated with tsoa. Please do not modify it. Re-run tsoa to re-generate this file: https://github.com/lukeautry/tsoa | https://github.com/meysamhadeli/booking-microservices-expressjs/blob/631bfdfb92d732d0d2b9e83f8476a5858f129829/src/passenger/src/routes/routes.ts#L156-L225 | 631bfdfb92d732d0d2b9e83f8476a5858f129829 |
bibata | github_2023 | ful1e5 | typescript | prismaClientSingleton | const prismaClientSingleton = () => {
return new PrismaClient();
}; | // https://www.prisma.io/docs/guides/other/troubleshooting-orm/help-articles/nextjs-prisma-client-dev-practices | https://github.com/ful1e5/bibata/blob/9ab69b7e56b63e28cdcda08e0d4b96d483c32e37/src/services/prisma.ts#L4-L6 | 9ab69b7e56b63e28cdcda08e0d4b96d483c32e37 |
bibata | github_2023 | ful1e5 | typescript | hashObject | const hashObject = (body: BodyInit): string => {
const jsonString = JSON.stringify(body);
const hash = crypto.createHash('md5').update(jsonString).digest('hex');
return hash;
}; | // eslint-disable-next-line no-undef | https://github.com/ful1e5/bibata/blob/9ab69b7e56b63e28cdcda08e0d4b96d483c32e37/src/utils/fetchX.ts#L10-L14 | 9ab69b7e56b63e28cdcda08e0d4b96d483c32e37 |
launcher | github_2023 | openmultiplayer | typescript | runner | async function runner() {
// const favsStr = localStorage.getItem("favorites-and-recentlyjoined-storage");
// const genericStr = localStorage.getItem("generic-state-storage");
// const settingsStr = localStorage.getItem("settings-storage");
// const themeStr = localStorage.getItem("theme-storage");
// if (fa... | // import { useGenericPersistentState } from "./states/genericStates"; | https://github.com/openmultiplayer/launcher/blob/d14481d9796fa38b339d867b27cb6cb3e8eac321/src/main.tsx#L10-L55 | d14481d9796fa38b339d867b27cb6cb3e8eac321 |
bepass-worker | github_2023 | bepass-org | typescript | handleTCPOutBound | async function handleTCPOutBound(remoteSocket, destinationNetwork, addressRemote, portRemote, rawClientData, webSocket, log) {
async function connectAndWrite(address, port, rawHeaderEnabled) {
address = address.replace("[", "").replace("]", ""); // Simplify address manipulation
const mmd = `${destinationNetwo... | // Utilize async/await for clarity and error handling | https://github.com/bepass-org/bepass-worker/blob/7965a3a2641af240b25fdbd6acc7e0095b64cc64/src/worker.ts#L183-L225 | 7965a3a2641af240b25fdbd6acc7e0095b64cc64 |
block-explorer | github_2023 | matter-labs | typescript | Batch.toJSON | toJSON() {
return {
...this,
size: this.size,
status: this.status,
};
} | // Include getters so the fields are included in responses | https://github.com/matter-labs/block-explorer/blob/2f896cc702abc5b2b0a603f4bf822d07a918548c/packages/api/src/batch/batch.entity.ts#L42-L48 | 2f896cc702abc5b2b0a603f4bf822d07a918548c |
block-explorer | github_2023 | matter-labs | typescript | handler | const handler = () => {}; | // eslint-disable-next-line @typescript-eslint/no-empty-function | https://github.com/matter-labs/block-explorer/blob/2f896cc702abc5b2b0a603f4bf822d07a918548c/packages/data-fetcher/src/blockchain/blockchain.service.spec.ts#L1784-L1784 | 2f896cc702abc5b2b0a603f4bf822d07a918548c |
block-explorer | github_2023 | matter-labs | typescript | TransferService.formatFeeAndRefundDeposits | private formatFeeAndRefundDeposits(transfers: Transfer[], transactionDetails?: types.TransactionDetails) {
if (!transactionDetails?.isL1Originated) {
return;
}
const ethDeposits = transfers.filter(
(t) => t.type === TransferType.Deposit && t.tokenAddress === BASE_TOKEN_ADDRESS
);
const f... | // Identifies and formats fee and refund deposits for ETH and ERC20 deposits | https://github.com/matter-labs/block-explorer/blob/2f896cc702abc5b2b0a603f4bf822d07a918548c/packages/data-fetcher/src/transfer/transfer.service.ts#L87-L115 | 2f896cc702abc5b2b0a603f4bf822d07a918548c |
block-explorer | github_2023 | matter-labs | typescript | handler | const handler = () => {}; | // eslint-disable-next-line @typescript-eslint/no-empty-function | https://github.com/matter-labs/block-explorer/blob/2f896cc702abc5b2b0a603f4bf822d07a918548c/packages/worker/src/blockchain/blockchain.service.spec.ts#L1187-L1187 | 2f896cc702abc5b2b0a603f4bf822d07a918548c |
block-explorer | github_2023 | matter-labs | typescript | ProcessContractDeployedLogs1679923273990.down | public async down(): Promise<void> {} | // eslint-disable-next-line @typescript-eslint/no-empty-function | https://github.com/matter-labs/block-explorer/blob/2f896cc702abc5b2b0a603f4bf822d07a918548c/packages/worker/src/migrations/1679923273990-ProcessContractDeployedLogs.ts#L61-L61 | 2f896cc702abc5b2b0a603f4bf822d07a918548c |
block-explorer | github_2023 | matter-labs | typescript | MigrateExistingBalancesToNewTable1680615242024.down | public async down(): Promise<void> {} | // eslint-disable-next-line @typescript-eslint/no-empty-function | https://github.com/matter-labs/block-explorer/blob/2f896cc702abc5b2b0a603f4bf822d07a918548c/packages/worker/src/migrations/1680615242024-MigrateExistingBalancesToNewTable.ts#L26-L26 | 2f896cc702abc5b2b0a603f4bf822d07a918548c |
block-explorer | github_2023 | matter-labs | typescript | DeleteOldBalances1682512427377.down | public async down(): Promise<void> {} | // eslint-disable-next-line @typescript-eslint/no-empty-function | https://github.com/matter-labs/block-explorer/blob/2f896cc702abc5b2b0a603f4bf822d07a918548c/packages/worker/src/migrations/1682512427377-DeleteOldBalances.ts#L10-L10 | 2f896cc702abc5b2b0a603f4bf822d07a918548c |
block-explorer | github_2023 | matter-labs | typescript | PopulateL1AddressForBridgedTokens1683119965214.down | public async down(): Promise<void> {} | // eslint-disable-next-line @typescript-eslint/no-empty-function | https://github.com/matter-labs/block-explorer/blob/2f896cc702abc5b2b0a603f4bf822d07a918548c/packages/worker/src/migrations/1683119965214-PopulateL1AddressForBridgedTokens.ts#L18-L18 | 2f896cc702abc5b2b0a603f4bf822d07a918548c |
block-explorer | github_2023 | matter-labs | typescript | MigrateOldETHBalancesToNewAddress1685422448610.down | public async down(): Promise<void> {} | // eslint-disable-next-line @typescript-eslint/no-empty-function | https://github.com/matter-labs/block-explorer/blob/2f896cc702abc5b2b0a603f4bf822d07a918548c/packages/worker/src/migrations/1685422448610-MigrateOldETHBalancesToNewAddress.ts#L19-L19 | 2f896cc702abc5b2b0a603f4bf822d07a918548c |
block-explorer | github_2023 | matter-labs | typescript | RemoveBalancesWithZeroValue1687975773306.down | public async down(): Promise<void> {} | // eslint-disable-next-line @typescript-eslint/no-empty-function | https://github.com/matter-labs/block-explorer/blob/2f896cc702abc5b2b0a603f4bf822d07a918548c/packages/worker/src/migrations/1687975773306-RemoveBalancesWithZeroValue.ts#L11-L11 | 2f896cc702abc5b2b0a603f4bf822d07a918548c |
block-explorer | github_2023 | matter-labs | typescript | SetTransferTypeForEmptyBlockTransfers1699955766418.down | public async down(): Promise<void> {} | // eslint-disable-next-line @typescript-eslint/no-empty-function | https://github.com/matter-labs/block-explorer/blob/2f896cc702abc5b2b0a603f4bf822d07a918548c/packages/worker/src/migrations/1699955766418-SetTransferTypeForEmptyBlockTransfers.ts#L21-L21 | 2f896cc702abc5b2b0a603f4bf822d07a918548c |
obsidian-day-planner-og | github_2023 | ebullient | typescript | Logger.logDebug | logDebug(message: string, ...optionalParams: any[]): void {
if (!this.settings || this.settings.debug) {
console.debug("(DP)", message, ...optionalParams);
}
} | // biome-ignore lint/suspicious/noExplicitAny: <explanation> | https://github.com/ebullient/obsidian-day-planner-og/blob/60b0e4e3182dd0a9d92a7eecf043e7607c079df0/src/logger.ts#L20-L24 | 60b0e4e3182dd0a9d92a7eecf043e7607c079df0 |
obsidian-day-planner-og | github_2023 | ebullient | typescript | Logger.logInfo | logInfo(message: string, ...optionalParams: any[]): void {
console.info("(DP)", message, ...optionalParams);
} | // biome-ignore lint/suspicious/noExplicitAny: <explanation> | https://github.com/ebullient/obsidian-day-planner-og/blob/60b0e4e3182dd0a9d92a7eecf043e7607c079df0/src/logger.ts#L28-L30 | 60b0e4e3182dd0a9d92a7eecf043e7607c079df0 |
obsidian-day-planner-og | github_2023 | ebullient | typescript | Logger.logError | logError(message: string, ...optionalParams: any[]): void {
console.error("(DP)", message, ...optionalParams);
} | // biome-ignore lint/suspicious/noExplicitAny: <explanation> | https://github.com/ebullient/obsidian-day-planner-og/blob/60b0e4e3182dd0a9d92a7eecf043e7607c079df0/src/logger.ts#L34-L36 | 60b0e4e3182dd0a9d92a7eecf043e7607c079df0 |
obsidian-day-planner-og | github_2023 | ebullient | typescript | DayPlanner.resolvePath | resolvePath(link: string): string {
const path = this.file.todayPlannerFilePath();
const file = this.app.metadataCache.getFirstLinkpathDest(link, path);
return file.path;
} | // Static method to return the current file | https://github.com/ebullient/obsidian-day-planner-og/blob/60b0e4e3182dd0a9d92a7eecf043e7607c079df0/src/main.ts#L383-L387 | 60b0e4e3182dd0a9d92a7eecf043e7607c079df0 |
obsidian-day-planner-og | github_2023 | ebullient | typescript | PlannerMarkdown.processDayPlanner | async processDayPlanner(iAmWriter: boolean): Promise<PlanSummaryData> {
try {
await this.file.prepareFile();
const filePath = this.file.todayPlannerFilePath();
const summary = new PlanSummaryData([], iAmWriter);
const now = new Date();
// Read and upd... | // Combine parse and update in a single function (lock file once.) | https://github.com/ebullient/obsidian-day-planner-og/blob/60b0e4e3182dd0a9d92a7eecf043e7607c079df0/src/planner-md.ts#L50-L71 | 60b0e4e3182dd0a9d92a7eecf043e7607c079df0 |
obsidian-day-planner-og | github_2023 | ebullient | typescript | MockDate | function MockDate(mockOverride?: Date | number) {
return new _Date(mockOverride || expected)
} | // If any Date or number is passed to the constructor | https://github.com/ebullient/obsidian-day-planner-og/blob/60b0e4e3182dd0a9d92a7eecf043e7607c079df0/tests/mocks/date.ts#L11-L13 | 60b0e4e3182dd0a9d92a7eecf043e7607c079df0 |
papillon-v6 | github_2023 | PapillonApp | typescript | IndexDataInstance.waitInit | private async waitInit(): Promise<boolean> {
if (this.initialized) return true;
if (!this.initializing) {
if (this.service === 'skolengo' && !this.skolengoInstance) {
await this.init('skolengo');
}
else if (this.service === 'pronote' && !this.pronoteInstance) {
await this.init... | /**
* Internal function that waits for the initialization
* of the service to be finished so we can use it.
*/ | https://github.com/PapillonApp/papillon-v6/blob/0550b47d75382b563c5ad782bf276263df74df76/fetch/index.ts#L58-L80 | 0550b47d75382b563c5ad782bf276263df74df76 |
papillon-v6 | github_2023 | PapillonApp | typescript | IndexDataInstance.getHomeworks | public async getHomeworks (force = false): Promise<PapillonHomework[]> {
await this.waitInit();
if (this.service === 'skolengo') {
// TODO
// return this.skolengoInstance.getHomeworks(day, force, day2) || [];
}
else if (this.service === 'pronote') {
return pronoteHomeworkHandler(f... | /**
* Get all the homeworks from first day to end of the year.
*/ | https://github.com/PapillonApp/papillon-v6/blob/0550b47d75382b563c5ad782bf276263df74df76/fetch/index.ts#L170-L182 | 0550b47d75382b563c5ad782bf276263df74df76 |
papillon-v6 | github_2023 | PapillonApp | typescript | IndexDataInstance.changeNewsState | public async changeNewsState (localID: string, forceState: boolean = true): Promise<boolean> {
await this.waitInit();
if (this.service === 'skolengo') {
// TODO
}
else if (this.service === 'pronote') {
return pronoteNewsStateHandler(localID, forceState, this.pronoteInstance);
}
retu... | /**
* Change the `read` state of a news.
* Applies to information and surveys.
*
* @returns `true` when operation is successful.
*/ | https://github.com/PapillonApp/papillon-v6/blob/0550b47d75382b563c5ad782bf276263df74df76/fetch/index.ts#L217-L227 | 0550b47d75382b563c5ad782bf276263df74df76 |
papillon-v6 | github_2023 | PapillonApp | typescript | IndexDataInstance.getTimetable | public async getTimetable (day: Date, force = false, day2?: Date): Promise<PapillonLesson[]> {
await this.waitInit();
// JS dates are starting from Sunday, we do `+1` to be on Monday;
let mondayIndex = day.getDate() - day.getDay() + 1;
let sundayIndex = mondayIndex + 6;
if(day2) {
mondayInde... | /**
* Get a list of user's lessons for a week.
* The week is calculated from the given day.
* A week goes from the Monday to the Sunday.
*
* If the user is offline and/or the cache fails, an
* empty list is returned.
*/ | https://github.com/PapillonApp/papillon-v6/blob/0550b47d75382b563c5ad782bf276263df74df76/fetch/index.ts#L247-L279 | 0550b47d75382b563c5ad782bf276263df74df76 |
papillon-v6 | github_2023 | PapillonApp | typescript | IndexDataInstance.getUser | public async getUser (force = false): Promise<PapillonUser> {
await this.waitInit();
let user: PapillonUser | undefined | null;
if (this.service === 'skolengo') {
// TODO: Implement typings for skolengo.
// user = await this.skolengoInstance.getUser(force);
}
else if (this.service === '... | /**
* Retrieves information about the user and also
* about the school and periods.
*/ | https://github.com/PapillonApp/papillon-v6/blob/0550b47d75382b563c5ad782bf276263df74df76/fetch/index.ts#L285-L304 | 0550b47d75382b563c5ad782bf276263df74df76 |
papillon-v6 | github_2023 | PapillonApp | typescript | IndexDataInstance.getConversations | public async getConversations (): Promise<PapillonDiscussion[]> {
await this.waitInit();
if (this.service === 'pronote') {
return pronoteDiscussionsHandler(this.pronoteInstance);
}
return [];
} | /**
* Get every conversation registered.
* Also get the recipients of each conversation and read all the messages.
*/ | https://github.com/PapillonApp/papillon-v6/blob/0550b47d75382b563c5ad782bf276263df74df76/fetch/index.ts#L325-L333 | 0550b47d75382b563c5ad782bf276263df74df76 |
papillon-v6 | github_2023 | PapillonApp | typescript | IndexDataInstance.replyToConversation | async replyToConversation (localDiscussionID: string, messageContent: string): Promise<PapillonDiscussionMessage[] | null> {
await this.waitInit();
if (this.service === 'pronote') {
return pronoteDiscussionReplyHandler(localDiscussionID, messageContent, this.pronoteInstance);
}
return null;
} | /**
* Reply to a conversation and returns the
* whole conversation with updated messages.
*/ | https://github.com/PapillonApp/papillon-v6/blob/0550b47d75382b563c5ad782bf276263df74df76/fetch/index.ts#L339-L347 | 0550b47d75382b563c5ad782bf276263df74df76 |
papillon-v6 | github_2023 | PapillonApp | typescript | IndexDataInstance.createDiscussion | async createDiscussion (subject: string, content: string, recipients: PapillonRecipient[]): Promise<void> {
await this.waitInit();
if (this.service === 'pronote') {
await pronoteDiscussionsCreationHandler(subject, content, recipients, this.pronoteInstance);
}
} | /**
* Create a discussion with the given `subject` and `content` as first message.
* If possible, add `recipients` to the discussion.
*/ | https://github.com/PapillonApp/papillon-v6/blob/0550b47d75382b563c5ad782bf276263df74df76/fetch/index.ts#L353-L359 | 0550b47d75382b563c5ad782bf276263df74df76 |
papillon-v6 | github_2023 | PapillonApp | typescript | IndexDataInstance.getRecipients | public async getRecipients (localDiscussionID: string): Promise<string[]> {
await this.waitInit();
if (this.service === 'pronote') {
return pronoteDiscussionsRecipientsHandler(localDiscussionID, this.pronoteInstance);
}
return [];
} | /**
* Get the recipients attached to a discussion
* using the local ID of it.
*/ | https://github.com/PapillonApp/papillon-v6/blob/0550b47d75382b563c5ad782bf276263df74df76/fetch/index.ts#L365-L373 | 0550b47d75382b563c5ad782bf276263df74df76 |
papillon-v6 | github_2023 | PapillonApp | typescript | IndexDataInstance.getCreationRecipients | public async getCreationRecipients (): Promise<PapillonRecipient[]> {
await this.waitInit();
if (this.service === 'pronote') {
return pronoteDiscussionsCreationRecipientsHandler(this.pronoteInstance);
}
return [];
} | /**
* Get the recipients that can be added to a new discussion.
*/ | https://github.com/PapillonApp/papillon-v6/blob/0550b47d75382b563c5ad782bf276263df74df76/fetch/index.ts#L378-L386 | 0550b47d75382b563c5ad782bf276263df74df76 |
papillon-v6 | github_2023 | PapillonApp | typescript | IndexDataInstance.getED_Documents | public async getED_Documents (force = false): Promise<studentDocsResData | null> {
await this.waitInit();
if (this.service === 'ecoledirecte') {
return EDDocumentsHandler(this.ecoledirecteInstance, force);
}
throw new Error('Method only works for EcoleDirecte');
} | /**
* ONLY FOR ECOLEDIRECTE
*
* Get the documents
*/ | https://github.com/PapillonApp/papillon-v6/blob/0550b47d75382b563c5ad782bf276263df74df76/fetch/index.ts#L410-L417 | 0550b47d75382b563c5ad782bf276263df74df76 |
papillon-v6 | github_2023 | PapillonApp | typescript | runUserMiddleware | const runUserMiddleware = async (user: PapillonUser): Promise<PapillonUser> => {
const customProfilePictureB64 = await AsyncStorage.getItem('custom_profile_picture');
if (customProfilePictureB64) {
user.profile_picture = customProfilePictureB64;
}
const customName = await AsyncStorage.getItem('custom_name'... | /**
* Middleware mainly here to add the custom
* profile picture and custom name from settings.
*/ | https://github.com/PapillonApp/papillon-v6/blob/0550b47d75382b563c5ad782bf276263df74df76/fetch/index.ts#L438-L450 | 0550b47d75382b563c5ad782bf276263df74df76 |
papillon-v6 | github_2023 | PapillonApp | typescript | getGradeState | const getGradeState = (gradeValue: number | PronoteApiGradeType): PapillonGradeValue => {
if (typeof gradeValue === 'number') {
return {
significant: false,
value: gradeValue,
type: 'number' as PronoteApiGradeType
};
}
return {
significant: true,
type: gradeValue,
};
}; | /**
* Get the state of a grade in an integer form.
*
* @param gradeValue - Value of the grade.
*/ | https://github.com/PapillonApp/papillon-v6/blob/0550b47d75382b563c5ad782bf276263df74df76/fetch/PronoteData/grades.ts#L12-L25 | 0550b47d75382b563c5ad782bf276263df74df76 |
papillon-v6 | github_2023 | PapillonApp | typescript | hashCode | function hashCode(str: string): number {
let hash = 5;
for (let i = 0; i < str.length; i++) {
const char = str.charCodeAt(i) + 1;
hash = (hash << 5) - hash + char;
}
return hash;
} | // Fonction pour générer une valeur de hachage à partir du nom du cours | https://github.com/PapillonApp/papillon-v6/blob/0550b47d75382b563c5ad782bf276263df74df76/utils/ColorCoursName.ts#L75-L82 | 0550b47d75382b563c5ad782bf276263df74df76 |
papillon-v6 | github_2023 | PapillonApp | typescript | mapChildrenWithKeys | const mapChildrenWithKeys = (children: ReactNode) => {
const count = Children.count(children);
return Children.map(children, (child, index) => {
// remove null/undefined children
if (!isValidElement(child)) {
return null;
}
// Check if this is the last child and add last={true} prop if it is... | /**
* Maps the given children with keys with the
* following format : "child-(index)".
*
* A `last` attribute is also given in the
* last children of the list.
*/ | https://github.com/PapillonApp/papillon-v6/blob/0550b47d75382b563c5ad782bf276263df74df76/utils/mapChildrenWithKeys.ts#L10-L24 | 0550b47d75382b563c5ad782bf276263df74df76 |
papillon-v6 | github_2023 | PapillonApp | typescript | onBackPress | const onBackPress = () => {
if (createNewSubjectModalOpen) {
createNewSubjectModal.current?.dismiss();
return true; // TS complains if handler doesn't return a boolean
} else {
navigation.goBack()
return true;
}
}; | // addEventListener and removeEventListener must refer to the same function | https://github.com/PapillonApp/papillon-v6/blob/0550b47d75382b563c5ad782bf276263df74df76/views/Devoirs/CreateHomeworkScreen.android.tsx#L69-L77 | 0550b47d75382b563c5ad782bf276263df74df76 |
papillon-v6 | github_2023 | PapillonApp | typescript | fetchInstances | const fetchInstances = async () => {
try {
setInstancesLoading(true);
const instances = await findPronoteInstances(defaultPawnoteFetcher, { longitude, latitude });
if (instances.length === 0) {
setInstances(null);
console.log('[LocateEtabList] Aucune instance trouvée')... | // Utilisation correcte des noms de variables | https://github.com/PapillonApp/papillon-v6/blob/0550b47d75382b563c5ad782bf276263df74df76/views/NewAuthStack/Pronote/LocateEtabList.tsx#L74-L91 | 0550b47d75382b563c5ad782bf276263df74df76 |
firefox-webserial | github_2023 | kuba2k2 | typescript | MessageHandler.getNativeParams | async getNativeParams() {
return await getNativeParamsFromBackground()
} | /**
* Get native app state & parameters.
*
* ACCESS:
* - Page Script (via Content Script)
* - Popup Script
*/ | https://github.com/kuba2k2/firefox-webserial/blob/c18aec90c7352e6591891df05886a7340b6dce9f/src/background.ts#L26-L28 | c18aec90c7352e6591891df05886a7340b6dce9f |
firefox-webserial | github_2023 | kuba2k2 | typescript | MessageHandler.getPorts | async getPorts({ origin }: BackgroundRequest) {
const originAuth = await readOriginAuth(origin)
if (Object.keys(originAuth).length == 0) return []
const ports = await listPortsNative()
const authPorts = ports.filter((port) => port.id in originAuth)
for (const port of authPorts) {
port.isPaired = true
... | /**
* List authorized ports.
*
* ACCESS:
* - Page Script (via Content Script)
*/ | https://github.com/kuba2k2/firefox-webserial/blob/c18aec90c7352e6591891df05886a7340b6dce9f/src/background.ts#L36-L48 | c18aec90c7352e6591891df05886a7340b6dce9f |
firefox-webserial | github_2023 | kuba2k2 | typescript | MessageHandler.requestPort | async requestPort({ origin, options }: BackgroundRequest) {
const port = await choosePort(origin, options)
await writeOriginAuth(origin, port)
port.isPaired = true
port.authKey = await getPortAuthKey(port)
return port
} | /**
* Request authorization for a single port.
*
* ACCESS:
* - Page Script (via Content Script)
*/ | https://github.com/kuba2k2/firefox-webserial/blob/c18aec90c7352e6591891df05886a7340b6dce9f/src/background.ts#L56-L63 | c18aec90c7352e6591891df05886a7340b6dce9f |
firefox-webserial | github_2023 | kuba2k2 | typescript | MessageHandler.listAvailablePorts | async listAvailablePorts({ origin, options }: BackgroundRequest) {
const originAuth = await readOriginAuth(origin)
const ports = await listPortsNative()
for (const port of ports) {
port.isPaired = port.id in originAuth
}
return ports
} | /**
* List all available ports.
*
* ACCESS:
* - Popup Script
*/ | https://github.com/kuba2k2/firefox-webserial/blob/c18aec90c7352e6591891df05886a7340b6dce9f/src/background.ts#L71-L78 | c18aec90c7352e6591891df05886a7340b6dce9f |
firefox-webserial | github_2023 | kuba2k2 | typescript | MessageHandler.clearAuthKeyCache | async clearAuthKeyCache() {
clearPortAuthKeyCache()
} | /**
* Clear local port authKey cache.
*
* ACCESS:
* - Background Script (via sendNative())
*/ | https://github.com/kuba2k2/firefox-webserial/blob/c18aec90c7352e6591891df05886a7340b6dce9f/src/background.ts#L86-L88 | c18aec90c7352e6591891df05886a7340b6dce9f |
firefox-webserial | github_2023 | kuba2k2 | typescript | MessageHandler.extendPromise | async extendPromise({ id, timeoutMs }: BackgroundRequest) {
extendPromiseFromBackground(id, timeoutMs)
} | /**
* ACCESS:
* - Popup Script
*/ | https://github.com/kuba2k2/firefox-webserial/blob/c18aec90c7352e6591891df05886a7340b6dce9f/src/background.ts#L94-L96 | c18aec90c7352e6591891df05886a7340b6dce9f |
decky-XRGaming | github_2023 | wheaney | typescript | refreshDriverState | async function refreshDriverState() {
try {
setDriverState(await retrieveDriverState());
} catch (e) {
setError((e as Error).message);
}
setTimeout(() => {
refreshDriverState().catch((err) => setError(err));
}, 1000);
} | // have this function call itself every second to keep the UI up to date | https://github.com/wheaney/decky-XRGaming/blob/6f92d733025bf4b982e159d9a83d86b6642ea8fe/src/index.tsx#L226-L236 | 6f92d733025bf4b982e159d9a83d86b6642ea8fe |
sec-insights | github_2023 | run-llama | typescript | getDocDeDupeKey | const getDocDeDupeKey = (doc: SecDocument) => `${doc.ticker}-${doc.year}-${doc.quarter || ''}`; | // de-dupe hotfix | https://github.com/run-llama/sec-insights/blob/ec0d6d63cf14d26543b14e33a2538fba86985ab6/frontend/src/api/utils/documents.tsx#L35-L35 | ec0d6d63cf14d26543b14e33a2538fba86985ab6 |
sec-insights | github_2023 | run-llama | typescript | renderSVG | const renderSVG = () => {
// If we've scrolled past all SVGs, keep showing the last one
if (scrollPosition >= svgs.length) {
return svgs[svgs.length - 1];
}
// Otherwise, show the SVG for the current scroll position
return svgs[scrollPosition];
}; | // Function to render SVGs | https://github.com/run-llama/sec-insights/blob/ec0d6d63cf14d26543b14e33a2538fba86985ab6/frontend/src/components/landing-page/AnimateSvg.tsx#L36-L44 | ec0d6d63cf14d26543b14e33a2538fba86985ab6 |
jsx-email | github_2023 | shellscape | typescript | importInlinePlugin | const importInlinePlugin = async () => {
try {
// Note: tshy up to bullshit again with compile errors where there are none
// @ts-ignore
const { plugin } = (await import('@jsx-email/plugin-inline')) as unknown as PluginImport;
return plugin;
} catch (error) {
handleImportError(error, '@jsx-email... | // Note: We have to be verbose here so that bundlers pick up on the imports. | https://github.com/shellscape/jsx-email/blob/f2779a052f86f21b1a4ed946c9f123744bf0f660/packages/jsx-email/src/config.ts#L96-L107 | f2779a052f86f21b1a4ed946c9f123744bf0f660 |
jsx-email | github_2023 | shellscape | typescript | contextFunction | const contextFunction = (props: ProviderProps<TValue>): ReactNode => props.children; | // Create the base function that will be enhanced with properties | https://github.com/shellscape/jsx-email/blob/f2779a052f86f21b1a4ed946c9f123744bf0f660/packages/jsx-email/src/renderer/compat/context.ts#L38-L38 | f2779a052f86f21b1a4ed946c9f123744bf0f660 |
jsx-email | github_2023 | shellscape | typescript | importPlugins | const importPlugins = async () => {
const rehypeMinifyAttributeWhitespace = await import('rehype-minify-attribute-whitespace');
const rehypeMinifyCssStyle = await import('rehype-minify-css-style');
const rehypeMinifyEnumeratedAttribute = await import('rehype-minify-enumerated-attribute');
const rehypeMinifyMedi... | // Note: rehype is all ESM-only, so for CJS compat we're dynamically importing | https://github.com/shellscape/jsx-email/blob/f2779a052f86f21b1a4ed946c9f123744bf0f660/packages/plugin-minify/src/index.ts#L8-L50 | f2779a052f86f21b1a4ed946c9f123744bf0f660 |
react-magic-motion | github_2023 | Etesam913 | typescript | handleForbiddenComponent | function handleForbiddenComponent(
node: React.ReactPortal | React.ReactElement<unknown>
): null | React.ReactPortal | React.ReactElement<unknown> {
if (typeof node.type === "function") {
if (node.key !== null && forbiddenComponentKeys.has(String(node.key))) {
return node;
}
return null;
}
ret... | /**
When a component is encontered that is forbidden (should not be animated)
this function will return the regular un-animated component.
*/ | https://github.com/Etesam913/react-magic-motion/blob/796ae52f4b613ad4ab64e6e9eee3c4e5134933c3/packages/react-magic-motion/utils/magic-animation.ts#L60-L70 | 796ae52f4b613ad4ab64e6e9eee3c4e5134933c3 |
kitforstartups | github_2023 | okupter | typescript | generateEmailVerificationToken | const generateEmailVerificationToken = async (userId: string | undefined) => {
if (!userId) {
throw new Error('Invalid user ID');
}
const storedUserTokens = await drizzleClient
.select()
.from(emailVerification)
.where(eq(emailVerification.userId, userId));
if (storedUserTokens.length > 0) {
const reusa... | // 2 hours | https://github.com/okupter/kitforstartups/blob/ee5fa9842c3b7f8ed1b253b92844693d4e469b70/starter/src/lib/drizzle/mysql/models/tokens.ts#L9-L40 | ee5fa9842c3b7f8ed1b253b92844693d4e469b70 |
kitforstartups | github_2023 | okupter | typescript | generateEmailVerificationToken | const generateEmailVerificationToken = async (userId: string | undefined) => {
if (!userId) {
throw new Error('Invalid user ID');
}
const storedUserTokens = await drizzleClient
.select()
.from(emailVerification)
.where(eq(emailVerification.userId, userId));
if (storedUserTokens.length > 0) {
const reusa... | // 2 hours | https://github.com/okupter/kitforstartups/blob/ee5fa9842c3b7f8ed1b253b92844693d4e469b70/starter/src/lib/drizzle/postgres/models/tokens.ts#L9-L40 | ee5fa9842c3b7f8ed1b253b92844693d4e469b70 |
kitforstartups | github_2023 | okupter | typescript | generateEmailVerificationToken | const generateEmailVerificationToken = async (userId: string | undefined) => {
if (!userId) {
throw new Error('Invalid user ID');
}
const storedUserTokens = await drizzleClient
.select()
.from(emailVerification)
.where(eq(emailVerification.userId, userId));
if (storedUserTokens.length > 0) {
const reusa... | // 2 hours | https://github.com/okupter/kitforstartups/blob/ee5fa9842c3b7f8ed1b253b92844693d4e469b70/starter/src/lib/drizzle/turso/models/tokens.ts#L9-L40 | ee5fa9842c3b7f8ed1b253b92844693d4e469b70 |
brisa | github_2023 | brisa-build | typescript | sync | const sync = (event?: StorageEvent) => {
if (event && event.key !== key) return;
const storageValue = window[storage].getItem(key);
if (storageValue != null) ctx.store.set(key, JSON.parse(storageValue));
}; | // Sync from storage to store | https://github.com/brisa-build/brisa/blob/92fb8fe4766c6e2cd026adf1d07be0ccad1f64b9/packages/brisa/src/__fixtures__/web-components/_integrations2.tsx#L14-L18 | 92fb8fe4766c6e2cd026adf1d07be0ccad1f64b9 |
brisa | github_2023 | brisa-build | typescript | nanoseconds | function nanoseconds() {
return Number(process.hrtime.bigint());
} | // Similar than Bun.nanoseconds, but also working with Node.js / Deno | https://github.com/brisa-build/brisa/blob/92fb8fe4766c6e2cd026adf1d07be0ccad1f64b9/packages/brisa/src/cli/dev-live-reload.tsx#L15-L17 | 92fb8fe4766c6e2cd026adf1d07be0ccad1f64b9 |
brisa | github_2023 | brisa-build | typescript | handleRequest | async function handleRequest(
req: RequestContext,
{ assetPath }: { assetPath: string | null },
) {
const initiator = getInitiator(req);
const { route, isReservedPathname } = pagesRouter.match(req);
const isApi = initiator === Initiator.API_REQUEST;
const api = isApi ? rootRouter.match(req) : ... | /////////////////////////////////////////////////////// | https://github.com/brisa-build/brisa/blob/92fb8fe4766c6e2cd026adf1d07be0ccad1f64b9/packages/brisa/src/cli/serve/serve-options.tsx#L245-L307 | 92fb8fe4766c6e2cd026adf1d07be0ccad1f64b9 |
brisa | github_2023 | brisa-build | typescript | get_raw_body | function get_raw_body(req: http.IncomingMessage) {
const h = req.headers;
if (!h['content-type']) {
return null;
}
const content_length = Number(h['content-length']);
// check if no request body
if (
(req.httpVersionMajor === 1 &&
isNaN(content_length) &&
h['transfer-encoding'] == nul... | /*
Credits to the SvelteKit team
https://github.com/sveltejs/kit/blob/8d1ba04825a540324bc003e85f36559a594aadc2/packages/kit/src/exports/node/index.js
*/ | https://github.com/brisa-build/brisa/blob/92fb8fe4766c6e2cd026adf1d07be0ccad1f64b9/packages/brisa/src/cli/serve/node-serve/handler.ts#L33-L92 | 92fb8fe4766c6e2cd026adf1d07be0ccad1f64b9 |
brisa | github_2023 | brisa-build | typescript | deleteLast | const deleteLast = () =>
(
[
...(magicList?.shadowRoot?.querySelectorAll(
'button',
) as NodeListOf<HTMLButtonElement>),
].at(-2) as HTMLButtonElement
).click(); | // Deleting the last item | https://github.com/brisa-build/brisa/blob/92fb8fe4766c6e2cd026adf1d07be0ccad1f64b9/packages/brisa/src/utils/brisa-element/index.test.ts#L1465-L1472 | 92fb8fe4766c6e2cd026adf1d07be0ccad1f64b9 |
brisa | github_2023 | brisa-build | typescript | Component | const Component = ({}, { test }: WebContext) => {
return ['div', {}, test];
}; | // @ts-ignore | https://github.com/brisa-build/brisa/blob/92fb8fe4766c6e2cd026adf1d07be0ccad1f64b9/packages/brisa/src/utils/brisa-element/index.test.ts#L4158-L4160 | 92fb8fe4766c6e2cd026adf1d07be0ccad1f64b9 |
brisa | github_2023 | brisa-build | typescript | deleteLast | const deleteLast = () =>
(
[
...(magicList?.shadowRoot?.querySelectorAll(
'button',
) as NodeListOf<HTMLButtonElement>),
].at(-2) as HTMLButtonElement
).click(); | // Deleting the last item | https://github.com/brisa-build/brisa/blob/92fb8fe4766c6e2cd026adf1d07be0ccad1f64b9/packages/brisa/src/utils/client-build-plugin/integration.test.tsx#L1531-L1538 | 92fb8fe4766c6e2cd026adf1d07be0ccad1f64b9 |
brisa | github_2023 | brisa-build | typescript | detectReturnStatementInside | function detectReturnStatementInside(item: ESTree.Statement): boolean {
let hasReturnStatement = false;
JSON.stringify(item, (key, value) => {
// Ignore analyzing inside these types
if (TYPES_TO_AVOID_ANALYZE_RETURN.has(value?.type)) {
return null;
}
// If there is a return sta... | // Function to analyze if the conditional statement has a return statement and register it | https://github.com/brisa-build/brisa/blob/92fb8fe4766c6e2cd026adf1d07be0ccad1f64b9/packages/brisa/src/utils/client-build-plugin/merge-early-returns-in-one/index.ts#L60-L79 | 92fb8fe4766c6e2cd026adf1d07be0ccad1f64b9 |
brisa | github_2023 | brisa-build | typescript | traverseA2B | function traverseA2B(this: any, key: string, node: any) {
if (
node?.type === 'VariableDeclaration' &&
node?.declarations[0]?.id?.type === 'ObjectPattern' &&
webContextDetails.identifier === node?.declarations[0]?.init?.name
) {
setWebContextProperties(node?.declarations[0]?.id?.properti... | // The first traverse is needed to get the effect identifier, the cleanup | https://github.com/brisa-build/brisa/blob/92fb8fe4766c6e2cd026adf1d07be0ccad1f64b9/packages/brisa/src/utils/client-build-plugin/optimize-effects/index.ts#L99-L141 | 92fb8fe4766c6e2cd026adf1d07be0ccad1f64b9 |
brisa | github_2023 | brisa-build | typescript | traverseAgainA2B | function traverseAgainA2B(this: any, key: string, node: any) {
if (
DECLARATION_NODE_TYPES.has(node?.type) &&
node?.id?.name === getEffectIdentifier()
) {
return JSON.parse(
JSON.stringify(node, (k, v) => {
if (v?.constructor === Object)
v.effectDeps = [getRNameFr... | // This second traverse, once we have the effect identifier, is needed to | https://github.com/brisa-build/brisa/blob/92fb8fe4766c6e2cd026adf1d07be0ccad1f64b9/packages/brisa/src/utils/client-build-plugin/optimize-effects/index.ts#L146-L161 | 92fb8fe4766c6e2cd026adf1d07be0ccad1f64b9 |
brisa | github_2023 | brisa-build | typescript | traverseB2A | function traverseB2A(this: any, key: string, node: any) {
if (
DECLARATION_NODE_TYPES.has(node?.type) &&
node?.id?.name === getEffectIdentifier()
) {
return transformInnerEffect(node, this);
}
if (
node?.callee?.property?.name &&
node?.callee?.object?.name !== webContextDe... | // This third traverse is needed to: | https://github.com/brisa-build/brisa/blob/92fb8fe4766c6e2cd026adf1d07be0ccad1f64b9/packages/brisa/src/utils/client-build-plugin/optimize-effects/index.ts#L167-L187 | 92fb8fe4766c6e2cd026adf1d07be0ccad1f64b9 |
brisa | github_2023 | brisa-build | typescript | transformInnerEffect | function transformInnerEffect(effect: EffectNode, parent: EffectNode) {
const effectIdentifier = (effect as any)?.id?.name;
const takenName = getRNameFromIdentifier(effectIdentifier);
if (takenName) {
effect.effectDeps = [takenName];
assignRNameToNode(effect, { takenName, parent });
}
... | // This function is called to each sub-effect function to wrap it with | https://github.com/brisa-build/brisa/blob/92fb8fe4766c6e2cd026adf1d07be0ccad1f64b9/packages/brisa/src/utils/client-build-plugin/optimize-effects/index.ts#L193-L262 | 92fb8fe4766c6e2cd026adf1d07be0ccad1f64b9 |
brisa | github_2023 | brisa-build | typescript | setWebContextProperties | function setWebContextProperties(properties: Properties) {
let setted = false;
for (const property of properties) {
const { key, value, type } = property;
if (type === 'RestElement') {
webContextDetails.identifier = (property as any).argument.name;
setted = true;
continue;
... | // This function is called to set the effect name, cleanup name and identifier | https://github.com/brisa-build/brisa/blob/92fb8fe4766c6e2cd026adf1d07be0ccad1f64b9/packages/brisa/src/utils/client-build-plugin/optimize-effects/index.ts#L270-L294 | 92fb8fe4766c6e2cd026adf1d07be0ccad1f64b9 |
brisa | github_2023 | brisa-build | typescript | propagateEffectDeps | function propagateEffectDeps(node: EffectNode, parent: EffectNode) {
if (typeof node !== 'object' || node === null || node.effectDeps) return;
if (Array.isArray(node)) {
for (const item of node) propagateEffectDeps(item, parent);
return;
}
if (!Array.isArray(parent) && parent.effectDeps) {
node.ef... | /**
* Add effect dependencies array to the node or array node items to propagate it.
*
* @param {any} value - The object or array of objects to which to add effect dependencies.
* @param {any} parent - The parent object containing the effect dependencies.
*
* @example
* propagateEffectDeps(value, parent);
*/ | https://github.com/brisa-build/brisa/blob/92fb8fe4766c6e2cd026adf1d07be0ccad1f64b9/packages/brisa/src/utils/client-build-plugin/optimize-effects/index.ts#L306-L318 | 92fb8fe4766c6e2cd026adf1d07be0ccad1f64b9 |
brisa | github_2023 | brisa-build | typescript | wrapEffectWithDependencies | function wrapEffectWithDependencies(
effect: EffectNode,
parent: EffectNode,
async = false,
) {
const deps = parent.effectDeps ?? [];
let newEffectNode: EffectNode = effect;
for (const depName of deps) {
const innerFn = (newEffectNode.arguments?.[0] ??
newEffectNode) as EffectNode;
if (depNa... | /**
* Wraps an effect function with its dependencies.
*
* @param {any} effect - The effect function or object to be wrapped.
* @param {any} parent - The parent object containing information about dependencies.
* @returns {any} The modified effect function or object with dependencies wrapped.
*
* @example
* cons... | https://github.com/brisa-build/brisa/blob/92fb8fe4766c6e2cd026adf1d07be0ccad1f64b9/packages/brisa/src/utils/client-build-plugin/optimize-effects/index.ts#L330-L359 | 92fb8fe4766c6e2cd026adf1d07be0ccad1f64b9 |
brisa | github_2023 | brisa-build | typescript | getRNameGenerator | function getRNameGenerator(allVariableNames: Set<string>) {
const registeredRNames = new Set<string>();
let count = 0;
return () => {
let defaultName = `r${count ? count : ''}`;
// Update the name if it's already taken adding a '$' at the end
while (
registeredRNames.has(defaultName) ||
... | /**
* Generates a function that creates unique names for 'r' variables.
* It checks if the name is already used by a variable declared in the component
* or in the component's scope. If the name is taken, it appends '$' to the end of the name.
*
* @param {Set<string>} allVariableNames - Set of all variable names d... | https://github.com/brisa-build/brisa/blob/92fb8fe4766c6e2cd026adf1d07be0ccad1f64b9/packages/brisa/src/utils/client-build-plugin/optimize-effects/index.ts#L375-L395 | 92fb8fe4766c6e2cd026adf1d07be0ccad1f64b9 |
brisa | github_2023 | brisa-build | typescript | getSubEffectManager | function getSubEffectManager(allVariableNames: Set<string>) {
const generateUniqueRName = getRNameGenerator(allVariableNames);
const identifierRName = new Map<string, string>();
let effectIdentifier: string | undefined;
return {
getRNameFromIdentifier: (identifier: string) =>
identifierRName.get(iden... | /**
* Provides a manager for handling sub-effects within the optimizeEffects function.
*
* This manager handles the registration of sub-effects with the 'r' function and
* manages the assignment of unique 'r' variable names.
*
* @param {Set<string>} allVariableNames - Set of all variable names already declared
*... | https://github.com/brisa-build/brisa/blob/92fb8fe4766c6e2cd026adf1d07be0ccad1f64b9/packages/brisa/src/utils/client-build-plugin/optimize-effects/index.ts#L416-L451 | 92fb8fe4766c6e2cd026adf1d07be0ccad1f64b9 |
brisa | github_2023 | brisa-build | typescript | createReactiveEvent | function createReactiveEvent(eventCallee: ESTree.Expression) {
return {
type: 'ArrowFunctionExpression',
expression: true,
params: [
{
type: 'Identifier',
name: 'e',
},
],
body: {
type: 'CallExpression',
callee: eventCallee,
arguments: [
{
... | /**
* Evaluate signals on event time and not only during render time.
*
* Transform:
* <button onClick={someEvent(signal.value)} />
*
* to:
* <button onClick={e => someEvent(signal.value)(e)} />
*/ | https://github.com/brisa-build/brisa/blob/92fb8fe4766c6e2cd026adf1d07be0ccad1f64b9/packages/brisa/src/utils/client-build-plugin/transform-to-reactive-arrays/index.ts#L250-L271 | 92fb8fe4766c6e2cd026adf1d07be0ccad1f64b9 |
brisa | github_2023 | brisa-build | typescript | getImports | async function getImports(
entries: [string, string][],
integrationsPath?: string | null,
) {
const imports = entries.map(([name, path]) =>
path[0] === '{'
? `require("${normalizePath(path)}");`
: `import ${snakeToCamelCase(name)} from "${path.replaceAll(sep, '/')}";`,
);
if (integrationsPath... | /**
* Generates import statements for Web Components and optional integrations.
* Also determines if web context plugins are present in the integration module.
*/ | https://github.com/brisa-build/brisa/blob/92fb8fe4766c6e2cd026adf1d07be0ccad1f64b9/packages/brisa/src/utils/client-build/generate-entrypoint-code/index.ts#L69-L89 | 92fb8fe4766c6e2cd026adf1d07be0ccad1f64b9 |
brisa | github_2023 | brisa-build | typescript | getWebComponentSelectors | function getWebComponentSelectors(
entries: [string, string][],
{
useContextProvider,
isDevelopment,
}: { useContextProvider: boolean; isDevelopment: boolean },
) {
const customElementKeys = entries
.filter(([_, path]) => path[0] !== '{')
.map(([key]) => key);
if (useContextProvider) {
cu... | /**
* Generates the list of Web Component selectors to define.
* Includes internal components like context provider and error dialog.
*/ | https://github.com/brisa-build/brisa/blob/92fb8fe4766c6e2cd026adf1d07be0ccad1f64b9/packages/brisa/src/utils/client-build/generate-entrypoint-code/index.ts#L95-L114 | 92fb8fe4766c6e2cd026adf1d07be0ccad1f64b9 |
brisa | github_2023 | brisa-build | typescript | defineElements | function defineElements(selectors: string[]): string {
const defineElementCode =
'const defineElement = (name, component) => name && !customElements.get(name) && customElements.define(name, component);';
const definitions = selectors
.map((key) => `defineElement("${key}", ${snakeToCamelCase(key)});`)
.j... | /**
* Generates the JavaScript code to define all Web Components.
* Uses the `defineElement` function to register each Web Component
* only if it is not already defined in the custom elements registry.
*/ | https://github.com/brisa-build/brisa/blob/92fb8fe4766c6e2cd026adf1d07be0ccad1f64b9/packages/brisa/src/utils/client-build/generate-entrypoint-code/index.ts#L121-L129 | 92fb8fe4766c6e2cd026adf1d07be0ccad1f64b9 |
brisa | github_2023 | brisa-build | typescript | injectDevelopmentCode | async function injectDevelopmentCode(): Promise<string> {
return (await injectBrisaDialogErrorCode()).replace(
'__FILTER_DEV_RUNTIME_ERRORS__',
getFilterDevRuntimeErrors(),
);
} | /**
* Injects development-only debugging tools like the brisa-error-dialog.
* This code is only included when running in development mode.
*/ | https://github.com/brisa-build/brisa/blob/92fb8fe4766c6e2cd026adf1d07be0ccad1f64b9/packages/brisa/src/utils/client-build/generate-entrypoint-code/index.ts#L135-L140 | 92fb8fe4766c6e2cd026adf1d07be0ccad1f64b9 |
brisa | github_2023 | brisa-build | typescript | createTempFileSync | function createTempFileSync(content: string, extension = 'tsx') {
const fileName = `${Bun.hash(content)}.${extension}`;
const filePath = path.join(TEMP_DIR, fileName);
return { filePath, content };
} | // Utility to create a unique file with Bun.hash | https://github.com/brisa-build/brisa/blob/92fb8fe4766c6e2cd026adf1d07be0ccad1f64b9/packages/brisa/src/utils/client-build/pre-entrypoint-analysis/index.test.ts#L16-L20 | 92fb8fe4766c6e2cd026adf1d07be0ccad1f64b9 |
brisa | github_2023 | brisa-build | typescript | writeTempFiles | async function writeTempFiles(
files: Array<{ filePath: string; content: string }>,
) {
await Promise.all(
files.map(({ filePath, content }) => writeFile(filePath, content, 'utf-8')),
);
} | // Write files concurrently to disk | https://github.com/brisa-build/brisa/blob/92fb8fe4766c6e2cd026adf1d07be0ccad1f64b9/packages/brisa/src/utils/client-build/pre-entrypoint-analysis/index.test.ts#L23-L29 | 92fb8fe4766c6e2cd026adf1d07be0ccad1f64b9 |
brisa | github_2023 | brisa-build | typescript | addSlot | function addSlot(slotName: string) {
detectedSlots.add(slotName);
} | /**
* Add a detected slot
*/ | https://github.com/brisa-build/brisa/blob/92fb8fe4766c6e2cd026adf1d07be0ccad1f64b9/packages/brisa/src/utils/context-provider/server.ts#L51-L53 | 92fb8fe4766c6e2cd026adf1d07be0ccad1f64b9 |
brisa | github_2023 | brisa-build | typescript | hasSlot | function hasSlot(slotName: string) {
return detectedSlots.has(slotName);
} | /**
* Check if a slot was detected
*/ | https://github.com/brisa-build/brisa/blob/92fb8fe4766c6e2cd026adf1d07be0ccad1f64b9/packages/brisa/src/utils/context-provider/server.ts#L58-L60 | 92fb8fe4766c6e2cd026adf1d07be0ccad1f64b9 |
brisa | github_2023 | brisa-build | typescript | hasSomeSlot | function hasSomeSlot() {
return detectedSlots.size > 0;
} | /**
* Check if some slot was detected
*/ | https://github.com/brisa-build/brisa/blob/92fb8fe4766c6e2cd026adf1d07be0ccad1f64b9/packages/brisa/src/utils/context-provider/server.ts#L65-L67 | 92fb8fe4766c6e2cd026adf1d07be0ccad1f64b9 |
brisa | github_2023 | brisa-build | typescript | clearProvider | function clearProvider() {
const { contextStore, providerStore } = getStores();
providerStore.delete(id);
providerStore.set(CURRENT_PROVIDER_ID, currentProviderId);
setStores(contextStore, providerStore);
} | /**
* Clear the context provider
*
* Remove the context provider from the store.
* Useful on close <context-provider>.
*/ | https://github.com/brisa-build/brisa/blob/92fb8fe4766c6e2cd026adf1d07be0ccad1f64b9/packages/brisa/src/utils/context-provider/server.ts#L75-L80 | 92fb8fe4766c6e2cd026adf1d07be0ccad1f64b9 |
brisa | github_2023 | brisa-build | typescript | pauseProvider | function pauseProvider() {
const { contextStore, providerStore } = getStores();
isPaused = true;
providerStore.set(CURRENT_PROVIDER_ID, currentProviderId);
setStores(contextStore, providerStore);
} | /**
* Pause the context provider
*
* Useful on close <context-provider> after detecting an <slot>,
* pausing to then restore the context provider on the slot content.
*/ | https://github.com/brisa-build/brisa/blob/92fb8fe4766c6e2cd026adf1d07be0ccad1f64b9/packages/brisa/src/utils/context-provider/server.ts#L88-L93 | 92fb8fe4766c6e2cd026adf1d07be0ccad1f64b9 |
brisa | github_2023 | brisa-build | typescript | restoreProvider | function restoreProvider() {
const { contextStore, providerStore } = getStores();
isPaused = false;
currentProviderId = providerStore.get(CURRENT_PROVIDER_ID);
providerStore.set(CURRENT_PROVIDER_ID, id);
setStores(contextStore, providerStore);
} | /**
* Restore the context provider
*
* Useful on close <context-provider> after detecting an <slot>,
* pausing to then restore the context provider on the slot content.
*/ | https://github.com/brisa-build/brisa/blob/92fb8fe4766c6e2cd026adf1d07be0ccad1f64b9/packages/brisa/src/utils/context-provider/server.ts#L101-L107 | 92fb8fe4766c6e2cd026adf1d07be0ccad1f64b9 |
brisa | github_2023 | brisa-build | typescript | millisecondsSinceStartOfMonth | function millisecondsSinceStartOfMonth() {
const now = new Date();
const startOfMonth = new Date(now.getFullYear(), now.getMonth(), 1);
return now.getTime() - startOfMonth.getTime();
} | /**
* The reason of using this function is to generate an initial id value to
* increment then for each component and return it as radix 36, which is
* a string representation of the number much shorter than the decimal one or
* using crypto.randomUUID() which is too long and more expensive in order to
* generate ... | https://github.com/brisa-build/brisa/blob/92fb8fe4766c6e2cd026adf1d07be0ccad1f64b9/packages/brisa/src/utils/extend-stream-controller/index.ts#L225-L229 | 92fb8fe4766c6e2cd026adf1d07be0ccad1f64b9 |
brisa | github_2023 | brisa-build | typescript | fixBunParams | function fixBunParams(obj: Record<string, string>, filePath: string) {
const url = new URL(filePath.replace(/\/+/g, '/'), 'http://localhost');
const test = url.searchParams.get('test');
return Object.fromEntries(
Object.entries(obj).map(([key, value]) => {
if (value.includes('#')) v... | // There are some bugs in the Bun.FileSystemRouter that we need to fix | https://github.com/brisa-build/brisa/blob/92fb8fe4766c6e2cd026adf1d07be0ccad1f64b9/packages/brisa/src/utils/file-system-router/index.test.ts#L741-L763 | 92fb8fe4766c6e2cd026adf1d07be0ccad1f64b9 |
brisa | github_2023 | brisa-build | typescript | sortPathsBySegments | function sortPathsBySegments([a]: [string, string], [b]: [string, string]) {
const partsA = a.split('/');
const partsB = b.split('/');
const len = Math.min(partsA.length, partsB.length);
for (let i = 0; i < len; i++) {
const partA = partsA[i];
const partB = partsB[i];
const isPartASymbol = SYMBOLS.... | // Be sure in all OS the order is the same | https://github.com/brisa-build/brisa/blob/92fb8fe4766c6e2cd026adf1d07be0ccad1f64b9/packages/brisa/src/utils/file-system-router/index.ts#L180-L213 | 92fb8fe4766c6e2cd026adf1d07be0ccad1f64b9 |
brisa | github_2023 | brisa-build | typescript | step1_modifyJSXToPrerenderComponents | function step1_modifyJSXToPrerenderComponents(
this: any,
key: string,
value: any,
webComponents?: Map<string, string>,
dir?: string,
) {
if (value?.type === 'ImportDeclaration') {
for (const specifier of value.specifiers) {
const componentPath = value.source.value;
const... | /**
* This function should be used during AST traversal to analyze any node and
* transform it if necessary.
*/ | https://github.com/brisa-build/brisa/blob/92fb8fe4766c6e2cd026adf1d07be0ccad1f64b9/packages/brisa/src/utils/prerender-util/index.ts#L17-L157 | 92fb8fe4766c6e2cd026adf1d07be0ccad1f64b9 |
brisa | github_2023 | brisa-build | typescript | step2_addPrerenderImport | function step2_addPrerenderImport(ast: ESTree.Program) {
if (needsPrerenderImport) {
ast.body.unshift({
type: 'ImportDeclaration',
specifiers: [
{
type: 'ImportSpecifier',
imported: {
type: 'Identifier',
name: '__prerender__macro',
... | /**
* This function should be used after applying the step1_modifyJSXToPrerenderComponents
* to the AST. It should be used to add any necessary imports to the AST.
*/ | https://github.com/brisa-build/brisa/blob/92fb8fe4766c6e2cd026adf1d07be0ccad1f64b9/packages/brisa/src/utils/prerender-util/index.ts#L163-L202 | 92fb8fe4766c6e2cd026adf1d07be0ccad1f64b9 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.