repo_name string | dataset string | owner string | lang string | func_name string | code string | docstring string | url string | sha string |
|---|---|---|---|---|---|---|---|---|
cli | github_2023 | code-pushup | typescript | duplicateRefsInGroupsErrorMsg | function duplicateRefsInGroupsErrorMsg(groups: WeightedRef[]) {
const duplicateRefs = getDuplicateRefsInGroups(groups);
return `In plugin groups the following references are not unique: ${errorItems(
duplicateRefs,
)}`;
} | // ============ | https://github.com/code-pushup/cli/blob/6c0097f518524481663ed2d2029ad6a8ea8d42c2/packages/models/src/lib/group.ts#L54-L59 | 6c0097f518524481663ed2d2029ad6a8ea8d42c2 |
cli | github_2023 | code-pushup | typescript | duplicateSlugsInGroupsErrorMsg | function duplicateSlugsInGroupsErrorMsg(groups: Group[] | undefined) {
const duplicateRefs = getDuplicateSlugsInGroups(groups);
return `In groups the following slugs are not unique: ${errorItems(
duplicateRefs,
)}`;
} | // helper for validator: group refs are unique | https://github.com/code-pushup/cli/blob/6c0097f518524481663ed2d2029ad6a8ea8d42c2/packages/models/src/lib/group.ts#L66-L71 | 6c0097f518524481663ed2d2029ad6a8ea8d42c2 |
cli | github_2023 | code-pushup | typescript | missingRefsFromGroupsErrorMsg | function missingRefsFromGroupsErrorMsg(pluginCfg: PluginData) {
const missingRefs = getMissingRefsFromGroups(pluginCfg);
return `The following group references need to point to an existing audit in this plugin config: ${errorItems(
missingRefs,
)}`;
} | // helper for validator: every listed group ref points to an audit within the plugin | https://github.com/code-pushup/cli/blob/6c0097f518524481663ed2d2029ad6a8ea8d42c2/packages/models/src/lib/plugin-config.ts#L50-L55 | 6c0097f518524481663ed2d2029ad6a8ea8d42c2 |
cli | github_2023 | code-pushup | typescript | missingRefsFromGroupsErrorMsg | function missingRefsFromGroupsErrorMsg(audits: AuditReport[], groups: Group[]) {
const missingRefs = getMissingRefsFromGroups(audits, groups);
return `group references need to point to an existing audit in this plugin report: ${errorItems(
missingRefs,
)}`;
} | // every listed group ref points to an audit within the plugin report | https://github.com/code-pushup/cli/blob/6c0097f518524481663ed2d2029ad6a8ea8d42c2/packages/models/src/lib/report.ts#L49-L54 | 6c0097f518524481663ed2d2029ad6a8ea8d42c2 |
cli | github_2023 | code-pushup | typescript | getTotalCoverageFromLcovRecords | function getTotalCoverageFromLcovRecords(
records: LCOVRecord[],
coverageTypes: CoverageType[],
): LCOVStats {
return records.reduce<LCOVStats>(
(acc, report) =>
Object.fromEntries([
...Object.entries(acc),
...(
Object.entries(
getCoverageStatsFromLcovRecord(report,... | /**
*
* @param records This function aggregates coverage stats from all coverage files
* @param coverageTypes Types of coverage to be gathered
* @returns Complete coverage stats for all defined types of coverage.
*/ | https://github.com/code-pushup/cli/blob/6c0097f518524481663ed2d2029ad6a8ea8d42c2/packages/plugin-coverage/src/lib/runner/lcov/lcov-runner.ts#L97-L120 | 6c0097f518524481663ed2d2029ad6a8ea8d42c2 |
cli | github_2023 | code-pushup | typescript | getCoverageStatsFromLcovRecord | function getCoverageStatsFromLcovRecord(
record: LCOVRecord,
coverageTypes: CoverageType[],
): LCOVStats {
return Object.fromEntries(
coverageTypes.map((coverageType): [CoverageType, LCOVStat] => [
coverageType,
recordToStatFunctionMapper[coverageType](record),
]),
);
} | /**
* @param record record file data
* @param coverageTypes types of coverage to be gathered
* @returns Relevant coverage data from one lcov record file.
*/ | https://github.com/code-pushup/cli/blob/6c0097f518524481663ed2d2029ad6a8ea8d42c2/packages/plugin-coverage/src/lib/runner/lcov/lcov-runner.ts#L127-L137 | 6c0097f518524481663ed2d2029ad6a8ea8d42c2 |
cli | github_2023 | code-pushup | typescript | Container.exampleMethod | exampleMethod(): string {
return 'exampleMethod';
} | /**
* An example method that returns a string
* @returns A string with the value 'exampleMethod'
*/ | https://github.com/code-pushup/cli/blob/6c0097f518524481663ed2d2029ad6a8ea8d42c2/packages/plugin-jsdocs/mocks/fixtures/filled-documentation/methods-coverage.ts#L7-L9 | 6c0097f518524481663ed2d2029ad6a8ea8d42c2 |
cli | github_2023 | code-pushup | typescript | getCoverageFromAllNodesOfFile | function getCoverageFromAllNodesOfFile(nodes: Node[], filePath: string) {
return nodes.reduce((acc: DocumentationReport, node: Node) => {
const nodeType = getCoverageTypeFromKind(node.getKind());
const currentTypeReport = acc[nodeType];
const updatedIssues =
node.getJsDocs().length === 0
? [... | /**
* Gets the coverage from all nodes of a file
* @param nodes - The nodes to process
* @param filePath - The file path where the nodes are located
* @returns The coverage report for the nodes
*/ | https://github.com/code-pushup/cli/blob/6c0097f518524481663ed2d2029ad6a8ea8d42c2/packages/plugin-jsdocs/src/lib/runner/doc-processor.ts#L113-L138 | 6c0097f518524481663ed2d2029ad6a8ea8d42c2 |
cli | github_2023 | code-pushup | typescript | wrapWithDefer | function wrapWithDefer<T>(
asyncFn: (options: CrawlFileSystemOptions<T>) => Promise<unknown[]>,
) {
return {
defer: true, // important for async functions
fn(deferred: { resolve: () => void }) {
return asyncFn(options)
.catch(() => [])
.then((result: unknown[]) => {
if (resul... | // ============================================================== | https://github.com/code-pushup/cli/blob/6c0097f518524481663ed2d2029ad6a8ea8d42c2/packages/utils/perf/crawl-file-system/index.ts#L85-L103 | 6c0097f518524481663ed2d2029ad6a8ea8d42c2 |
cli | github_2023 | code-pushup | typescript | scoreMinimalReportOptimized0 | function scoreMinimalReportOptimized0() {
scoreReportOptimized0(minimalReport());
} | // ============================================================== | https://github.com/code-pushup/cli/blob/6c0097f518524481663ed2d2029ad6a8ea8d42c2/packages/utils/perf/score-report/index.ts#L110-L112 | 6c0097f518524481663ed2d2029ad6a8ea8d42c2 |
cli | github_2023 | code-pushup | typescript | minimalReport | function minimalReport(opt?: MinimalReportOptions): Report {
const numAuditsP1 = opt?.numAuditsP1 ?? NUM_AUDITS_P1;
const numAuditsP2 = opt?.numAuditsP2 ?? NUM_AUDITS_P2;
const numGroupRefs2 = opt?.numGroupRefs2 ?? NUM_GROUPS_P2;
const date = new Date();
return {
date: date.toISOString(),
packageNam... | // ============================================================== | https://github.com/code-pushup/cli/blob/6c0097f518524481663ed2d2029ad6a8ea8d42c2/packages/utils/perf/score-report/index.ts#L129-L211 | 6c0097f518524481663ed2d2029ad6a8ea8d42c2 |
cli | github_2023 | code-pushup | typescript | sortPlugins | function sortPlugins(
plugins: (Omit<PluginReport, 'audits' | 'groups'> & {
audits: AuditReport[];
groups?: ScoredGroup[];
})[],
) {
return plugins.map(plugin => ({
...plugin,
audits: plugin.audits.toSorted(compareAudits).map(audit =>
audit.details?.issues
? {
...audit,
... | // NOTE: Only audits are sorted as groups are only listed within categories, not separately | https://github.com/code-pushup/cli/blob/6c0097f518524481663ed2d2029ad6a8ea8d42c2/packages/utils/src/lib/reports/sorting.ts#L139-L159 | 6c0097f518524481663ed2d2029ad6a8ea8d42c2 |
cli | github_2023 | code-pushup | typescript | collectDependencies | const collectDependencies = (
project: string,
visited: Set<string> = new Set(),
): Set<string> => {
// If the project has already been visited, return the accumulated set
if (visited.has(project)) {
return visited;
}
// Add the current project to the visited set
const updatedVisite... | // Helper function to recursively collect dependencies | https://github.com/code-pushup/cli/blob/6c0097f518524481663ed2d2029ad6a8ea8d42c2/tools/src/utils.ts#L45-L64 | 6c0097f518524481663ed2d2029ad6a8ea8d42c2 |
console | github_2023 | akash-network | typescript | MemoryCacheEngine.getFromCache | getFromCache(key: string) {
const cachedBody = mcache.get(key);
if (cachedBody) {
return cachedBody;
}
return false;
} | /**
* Used to retrieve data from memcache
* @param {*} key
*/ | https://github.com/akash-network/console/blob/f1a0c32422b3716010f936aa7d0a4abe38ee4762/apps/api/src/caching/memoryCacheEngine.ts#L8-L14 | f1a0c32422b3716010f936aa7d0a4abe38ee4762 |
console | github_2023 | akash-network | typescript | MemoryCacheEngine.storeInCache | storeInCache<T>(key: string, data: T, duration?: number) {
mcache.put(key, data, duration);
} | /**
* Used to store data in a memcache
* @param {*} key
* @param {*} data
* @param {*} duration
*/ | https://github.com/akash-network/console/blob/f1a0c32422b3716010f936aa7d0a4abe38ee4762/apps/api/src/caching/memoryCacheEngine.ts#L22-L24 | f1a0c32422b3716010f936aa7d0a4abe38ee4762 |
console | github_2023 | akash-network | typescript | MemoryCacheEngine.clearAllKeyInCache | clearAllKeyInCache() {
mcache.clear();
} | /**
* Used to delete all keys in a memcache
*/ | https://github.com/akash-network/console/blob/f1a0c32422b3716010f936aa7d0a4abe38ee4762/apps/api/src/caching/memoryCacheEngine.ts#L28-L30 | f1a0c32422b3716010f936aa7d0a4abe38ee4762 |
console | github_2023 | akash-network | typescript | MemoryCacheEngine.clearKeyInCache | clearKeyInCache(key: string) {
mcache.del(key);
} | /**
* Used to delete specific key from memcache
* @param {*} key
*/ | https://github.com/akash-network/console/blob/f1a0c32422b3716010f936aa7d0a4abe38ee4762/apps/api/src/caching/memoryCacheEngine.ts#L35-L37 | f1a0c32422b3716010f936aa7d0a4abe38ee4762 |
console | github_2023 | akash-network | typescript | getGpuPrices | async function getGpuPrices(debug: boolean) {
// Get list of GPUs (model,vendor, ram, interface) and their availability
const gpus = await getGpus();
const daysToInclude = 31;
// Get the height corresponding to the oldest time we want to include
const minHeight = (await Block.findOne({ where: { datetime: { ... | /**
* Get a list of gpu models with their availability and pricing.
* The prices are derived from recent bids made on the network.
* This is a temporary solution and should be replaced with a more accurate pricing mechanism once provider pricing becomes queryable.
*/ | https://github.com/akash-network/console/blob/f1a0c32422b3716010f936aa7d0a4abe38ee4762/apps/api/src/routes/v1/gpuPrices.ts#L112-L272 | f1a0c32422b3716010f936aa7d0a4abe38ee4762 |
console | github_2023 | akash-network | typescript | calculateAverageBlockTime | async function calculateAverageBlockTime(latestBlock: Block, blockCount: number) {
if (blockCount <= 1) throw new Error("blockCount must be greater than 1");
const earlierBlock = await Block.findOne({
where: {
height: Math.max(latestBlock.height - blockCount, 1)
}
});
const realBlockCount = late... | /**
* Calculate the estimated block time
* @param latestBlock Block to calculate the average from
* @param blockCount Block interval for calculating the average
* @returns Average block time in seconds
*/ | https://github.com/akash-network/console/blob/f1a0c32422b3716010f936aa7d0a4abe38ee4762/apps/api/src/services/db/blocksService.ts#L87-L99 | f1a0c32422b3716010f936aa7d0a4abe38ee4762 |
console | github_2023 | akash-network | typescript | fetchOmnibusTemplates | async function fetchOmnibusTemplates(octokit: Octokit, repoVersion: string) {
const response = await octokit.rest.repos.getContent({
owner: "akash-network",
repo: "cosmos-omnibus",
ref: repoVersion,
path: null,
mediaType: {
format: "raw"
}
});
githubRequestsRemaining = response.head... | // Fetch templates from the cosmos-omnibus repo | https://github.com/akash-network/console/blob/f1a0c32422b3716010f936aa7d0a4abe38ee4762/apps/api/src/services/external/templateReposService.ts#L166-L218 | f1a0c32422b3716010f936aa7d0a4abe38ee4762 |
console | github_2023 | akash-network | typescript | fetchAwesomeAkashTemplates | async function fetchAwesomeAkashTemplates(octokit: Octokit, repoVersion: string) {
// Fetch list of templates from README.md
const response = await octokit.rest.repos.getContent({
owner: "akash-network",
repo: "awesome-akash",
path: "README.md",
ref: repoVersion,
mediaType: {
format: "raw"... | // Fetch templates from the Awesome-Akash repo | https://github.com/akash-network/console/blob/f1a0c32422b3716010f936aa7d0a4abe38ee4762/apps/api/src/services/external/templateReposService.ts#L221-L280 | f1a0c32422b3716010f936aa7d0a4abe38ee4762 |
console | github_2023 | akash-network | typescript | fetchLinuxServerTemplates | async function fetchLinuxServerTemplates(octokit: Octokit, repoVersion: string) {
// Fetch list of templates from README.md
const response = await octokit.rest.repos.getContent({
owner: "cryptoandcoffee",
repo: "akash-linuxserver",
path: "README.md",
ref: repoVersion,
mediaType: {
format: ... | // Fetch templates from the akash-linuxserver repo | https://github.com/akash-network/console/blob/f1a0c32422b3716010f936aa7d0a4abe38ee4762/apps/api/src/services/external/templateReposService.ts#L283-L342 | f1a0c32422b3716010f936aa7d0a4abe38ee4762 |
console | github_2023 | akash-network | typescript | findFileContentAsync | async function findFileContentAsync(filename: string | string[], fileList: GithubDirectoryItem[]) {
const filenames = typeof filename === "string" ? [filename] : filename;
const fileDef = fileList.find(f => filenames.some(x => x.toLowerCase() === f.name.toLowerCase()));
if (!fileDef) return null;
const respon... | // Find a github file by name and dowload it | https://github.com/akash-network/console/blob/f1a0c32422b3716010f936aa7d0a4abe38ee4762/apps/api/src/services/external/templateReposService.ts#L512-L522 | f1a0c32422b3716010f936aa7d0a4abe38ee4762 |
console | github_2023 | akash-network | typescript | getTemplateSummary | function getTemplateSummary(readme: string) {
if (!readme) return null;
const markdown = readme
.replace(/!\[.*\]\(.+\)\n*/g, "") // Remove images
.replace(/^#+ .*\n+/g, ""); // Remove first header
const readmeTxt = markdownToTxt(markdown).trim();
const maxLength = 200;
const summary = readmeTxt.len... | // Create a short summary from the README.md | https://github.com/akash-network/console/blob/f1a0c32422b3716010f936aa7d0a4abe38ee4762/apps/api/src/services/external/templateReposService.ts#L525-L537 | f1a0c32422b3716010f936aa7d0a4abe38ee4762 |
console | github_2023 | akash-network | typescript | getLinuxServerTemplateSummary | function getLinuxServerTemplateSummary(readme: string) {
if (!readme) return null;
let markdown = readme;
const titleMatch = /# \[linuxserver\/[\w-]+\]\(.+\)/.exec(markdown);
if (titleMatch) {
markdown = markdown.substring(titleMatch.index + titleMatch[0].length); // Remove LinuxServer header
}
const ... | // Create a short summary from the README.md | https://github.com/akash-network/console/blob/f1a0c32422b3716010f936aa7d0a4abe38ee4762/apps/api/src/services/external/templateReposService.ts#L540-L559 | f1a0c32422b3716010f936aa7d0a4abe38ee4762 |
console | github_2023 | akash-network | typescript | replaceLinks | function replaceLinks(markdown: string, owner: string, repo: string, version: string, folder: string) {
let newMarkdown = markdown;
const linkRegex = /!?\[([^[]*)\]\((.*?)\)/gm;
const matches = newMarkdown.matchAll(linkRegex);
for (const match of matches) {
const originalUrl = match[2];
const url = orig... | // Replaces local links with absolute links | https://github.com/akash-network/console/blob/f1a0c32422b3716010f936aa7d0a4abe38ee4762/apps/api/src/services/external/templateReposService.ts#L562-L581 | f1a0c32422b3716010f936aa7d0a4abe38ee4762 |
console | github_2023 | akash-network | typescript | removeComments | function removeComments(markdown: string) {
return markdown.replace(/<!--.+-->/g, "");
} | // Remove markdown comments | https://github.com/akash-network/console/blob/f1a0c32422b3716010f936aa7d0a4abe38ee4762/apps/api/src/services/external/templateReposService.ts#L584-L586 | f1a0c32422b3716010f936aa7d0a4abe38ee4762 |
console | github_2023 | akash-network | typescript | createTestUser | async function createTestUser(trial = false) {
const { user, token } = await walletService.createUserAndWallet();
const userWithId = { ...user, userId: faker.string.uuid() };
jest.spyOn(userRepository, "findByUserId").mockImplementation(async id => {
if (id === userWithId.userId) {
return {
... | // TODO: This is a hack to avoid implementing proper auth0 mocking | https://github.com/akash-network/console/blob/f1a0c32422b3716010f936aa7d0a4abe38ee4762/apps/api/test/functional/api-key.spec.ts#L35-L60 | f1a0c32422b3716010f936aa7d0a4abe38ee4762 |
console | github_2023 | akash-network | typescript | loadNodeStatus | const loadNodeStatus = async (rpcUrl: string) => {
const start = performance.now();
let status: "active" | "inactive" = "inactive";
let nodeStatus: NodeStatus | null = null;
try {
const response = await axios.get(`${rpcUrl}/status`, { timeout: 10000 });
nodeStatus = response.data.result as ... | /**
* Load the node status from status rpc endpoint
* @param {string} rpcUrl
* @returns
*/ | https://github.com/akash-network/console/blob/f1a0c32422b3716010f936aa7d0a4abe38ee4762/apps/deploy-web/src/context/SettingsProvider/SettingsProviderContext.tsx#L152-L173 | f1a0c32422b3716010f936aa7d0a4abe38ee4762 |
console | github_2023 | akash-network | typescript | getFastestNode | const getFastestNode = (nodes: Array<BlockchainNode>) => {
const filteredNodes = nodes.filter(n => n.status === "active" && n.nodeInfo?.sync_info.catching_up === false);
let lowest = Number.POSITIVE_INFINITY,
fastestNode: BlockchainNode | null = null;
// No active node, return the first one
if (f... | /**
* Get the fastest node from the list based on latency
* @param {*} nodes
* @returns
*/ | https://github.com/akash-network/console/blob/f1a0c32422b3716010f936aa7d0a4abe38ee4762/apps/deploy-web/src/context/SettingsProvider/SettingsProviderContext.tsx#L180-L198 | f1a0c32422b3716010f936aa7d0a4abe38ee4762 |
console | github_2023 | akash-network | typescript | useCookieTheme | const useCookieTheme = (): string => {
const [_theme, _setTheme] = useState<string>("");
const { resolvedTheme } = useTheme();
useEffect(() => {
if (resolvedTheme) {
_setTheme(resolvedTheme);
} else {
_setTheme(document.documentElement.classList.contains("dark") ? "dark" : "light");
}
}... | /**
* Get the theme from the html class which is set from the cookie
*/ | https://github.com/akash-network/console/blob/f1a0c32422b3716010f936aa7d0a4abe38ee4762/apps/deploy-web/src/hooks/useTheme.ts#L7-L20 | f1a0c32422b3716010f936aa7d0a4abe38ee4762 |
console | github_2023 | akash-network | typescript | handleResize | function handleResize() {
// Set window width/height to state
setWindowSize({
width: window.innerWidth,
height: window.innerHeight
});
} | // Handler to call on window resize | https://github.com/akash-network/console/blob/f1a0c32422b3716010f936aa7d0a4abe38ee4762/apps/deploy-web/src/hooks/useWindowSize.ts#L19-L25 | f1a0c32422b3716010f936aa7d0a4abe38ee4762 |
console | github_2023 | akash-network | typescript | QueryKeys.getDeploymentListKey | static getDeploymentListKey = (address: string) => ["DEPLOYMENT_LIST", address] | // Remote deploy | https://github.com/akash-network/console/blob/f1a0c32422b3716010f936aa7d0a4abe38ee4762/apps/deploy-web/src/queries/queryKeys.ts | f1a0c32422b3716010f936aa7d0a4abe38ee4762 |
console | github_2023 | akash-network | typescript | getBlock | async function getBlock(apiEndpoint, id) {
const response = await axios.get(ApiUrlService.block(apiEndpoint, id));
return response.data;
} | // Block | https://github.com/akash-network/console/blob/f1a0c32422b3716010f936aa7d0a4abe38ee4762/apps/deploy-web/src/queries/useBlocksQuery.ts#L10-L14 | f1a0c32422b3716010f936aa7d0a4abe38ee4762 |
console | github_2023 | akash-network | typescript | getDeploymentList | async function getDeploymentList(apiEndpoint: string, address: string) {
if (!address) return [];
const deployments = await loadWithPagination<RpcDeployment[]>(ApiUrlService.deploymentList(apiEndpoint, address), "deployments", 1000);
return deployments.map(d => deploymentToDto(d));
} | // Deployment list | https://github.com/akash-network/console/blob/f1a0c32422b3716010f936aa7d0a4abe38ee4762/apps/deploy-web/src/queries/useDeploymentQuery.ts#L17-L23 | f1a0c32422b3716010f936aa7d0a4abe38ee4762 |
console | github_2023 | akash-network | typescript | getDeploymentDetail | async function getDeploymentDetail(apiEndpoint: string, address: string, dseq: string) {
if (!address || !apiEndpoint) return null;
const response = await axios.get(ApiUrlService.deploymentDetail(apiEndpoint, address, dseq));
return deploymentToDto(response.data);
} | // Deployment detail | https://github.com/akash-network/console/blob/f1a0c32422b3716010f936aa7d0a4abe38ee4762/apps/deploy-web/src/queries/useDeploymentQuery.ts#L31-L37 | f1a0c32422b3716010f936aa7d0a4abe38ee4762 |
console | github_2023 | akash-network | typescript | getDeploymentLeases | async function getDeploymentLeases(apiEndpoint: string, address: string, deployment) {
if (!address) {
return null;
}
const response = await loadWithPagination<RpcLease[]>(ApiUrlService.leaseList(apiEndpoint, address, deployment?.dseq), "leases", 1000);
const leases = response.map(l => leaseToDto(l, deplo... | // Leases | https://github.com/akash-network/console/blob/f1a0c32422b3716010f936aa7d0a4abe38ee4762/apps/deploy-web/src/queries/useLeaseQuery.ts#L15-L25 | f1a0c32422b3716010f936aa7d0a4abe38ee4762 |
console | github_2023 | akash-network | typescript | TransactionMessageData.getRevokeAllowanceMsg | static getRevokeAllowanceMsg(granter: string, grantee: string) {
const message = {
typeUrl: TransactionMessageData.Types.MSG_REVOKE_ALLOWANCE,
value: MsgRevokeAllowance.fromPartial({
granter: granter,
grantee: grantee
})
};
return message;
} | // } | https://github.com/akash-network/console/blob/f1a0c32422b3716010f936aa7d0a4abe38ee4762/apps/deploy-web/src/utils/TransactionMessageData.ts#L271-L281 | f1a0c32422b3716010f936aa7d0a4abe38ee4762 |
console | github_2023 | akash-network | typescript | UrlService.deploymentList | static userSettings = () => "/user/settings" | // New deployment | https://github.com/akash-network/console/blob/f1a0c32422b3716010f936aa7d0a4abe38ee4762/apps/deploy-web/src/utils/urlUtils.ts | f1a0c32422b3716010f936aa7d0a4abe38ee4762 |
console | github_2023 | akash-network | typescript | mapProviderAttributes | function mapProviderAttributes(attributes: Attribute[]) {
return attributes?.reduce((acc, curr) => ((acc[curr.key] = curr.value), acc), {});
} | // Attributes is a key value pair object, but we store it as an array of objects with key and value | https://github.com/akash-network/console/blob/f1a0c32422b3716010f936aa7d0a4abe38ee4762/apps/deploy-web/src/utils/deploymentData/v1beta3.ts#L78-L80 | f1a0c32422b3716010f936aa7d0a4abe38ee4762 |
console | github_2023 | akash-network | typescript | initApp | async function initApp() {
try {
if (env.STANDBY) {
console.log("STANDBY mode enabled. Doing nothing.");
// eslint-disable-next-line no-constant-condition
while (true) {
await sleep(5_000);
}
}
if (!(process.env.ACTIVE_CHAIN in chainDefinitions)) {
throw new Error(`U... | /**
* Initialize database schema
* Populate db
* Create backups per version
* Load from backup if exists for current version
*/ | https://github.com/akash-network/console/blob/f1a0c32422b3716010f936aa7d0a4abe38ee4762/apps/indexer/src/index.ts#L125-L162 | f1a0c32422b3716010f936aa7d0a4abe38ee4762 |
console | github_2023 | akash-network | typescript | accountSettleFullBlocks | function accountSettleFullBlocks(
deployment: Deployment,
activeLeases: Lease[],
heightDelta: number,
blockRate: number
): { overdrawn: boolean; remaining: number } {
const numFullBlocks = Math.min(Math.floor(deployment.balance / blockRate), heightDelta);
for (const lease of activeLeases) {
lease.withd... | // Port of https://github.com/akash-network/akash/blob/c2be64614f7417cf99447185f9d13b49bf33dadb/x/escrow/keeper/keeper.go#L543 | https://github.com/akash-network/console/blob/f1a0c32422b3716010f936aa7d0a4abe38ee4762/apps/indexer/src/shared/utils/akashPaymentSettle.ts#L54-L83 | f1a0c32422b3716010f936aa7d0a4abe38ee4762 |
console | github_2023 | akash-network | typescript | accountSettleDistributeWeighted | function accountSettleDistributeWeighted(deployment: Deployment, activeLeases: Lease[], blockRate: number, remaining: number) {
let transferred = 0;
for (const lease of activeLeases) {
const amount = (remaining * lease.price) / blockRate;
lease.withdrawnAmount += amount;
transferred += amount;
}
d... | // Port of https://github.com/akash-network/akash/blob/c2be64614f7417cf99447185f9d13b49bf33dadb/x/escrow/keeper/keeper.go#L594 | https://github.com/akash-network/console/blob/f1a0c32422b3716010f936aa7d0a4abe38ee4762/apps/indexer/src/shared/utils/akashPaymentSettle.ts#L86-L99 | f1a0c32422b3716010f936aa7d0a4abe38ee4762 |
console | github_2023 | akash-network | typescript | useCookieTheme | const useCookieTheme = (): string => {
const [_theme, _setTheme] = useState<string>("");
const { resolvedTheme } = useTheme();
useEffect(() => {
if (resolvedTheme) {
_setTheme(resolvedTheme);
} else {
_setTheme(document.documentElement.classList.contains("dark") ? "dark" : "light");
}
}... | /**
* Get the theme from the html class which is set from the cookie
*/ | https://github.com/akash-network/console/blob/f1a0c32422b3716010f936aa7d0a4abe38ee4762/apps/provider-console/src/hooks/useTheme.ts#L7-L20 | f1a0c32422b3716010f936aa7d0a4abe38ee4762 |
console | github_2023 | akash-network | typescript | QueryKeys.getDeploymentListKey | static getDeploymentListKey = (address: string) => ["DEPLOYMENT_LIST", address] | // Deploy | https://github.com/akash-network/console/blob/f1a0c32422b3716010f936aa7d0a4abe38ee4762/apps/provider-console/src/queries/queryKeys.ts | f1a0c32422b3716010f936aa7d0a4abe38ee4762 |
console | github_2023 | akash-network | typescript | getBlock | async function getBlock(apiEndpoint, id) {
const response = await axios.get(ApiUrlService.block(apiEndpoint, id));
return response.data;
} | // Block | https://github.com/akash-network/console/blob/f1a0c32422b3716010f936aa7d0a4abe38ee4762/apps/provider-console/src/queries/useBlocksQuery.ts#L10-L14 | f1a0c32422b3716010f936aa7d0a4abe38ee4762 |
console | github_2023 | akash-network | typescript | getTheme | function getTheme() {
const cookieStore = cookies();
const themeCookie = cookieStore.get("theme");
const theme = themeCookie ? themeCookie.value : "system";
return theme;
} | /**
* Get the theme from the cookie
* next-themes doesn't support SSR
* https://github.com/pacocoursey/next-themes/issues/169
*/ | https://github.com/akash-network/console/blob/f1a0c32422b3716010f936aa7d0a4abe38ee4762/apps/stats-web/src/app/layout.tsx#L86-L91 | f1a0c32422b3716010f936aa7d0a4abe38ee4762 |
console | github_2023 | akash-network | typescript | handleResize | const handleResize = () => {
chart.applyOptions({ width: chartContainerRef.current.clientWidth });
chart.resize(chartContainerRef.current.clientWidth, 400);
}; | // Handle resize | https://github.com/akash-network/console/blob/f1a0c32422b3716010f936aa7d0a4abe38ee4762/apps/stats-web/src/components/graph/Graph.tsx#L181-L184 | f1a0c32422b3716010f936aa7d0a4abe38ee4762 |
console | github_2023 | akash-network | typescript | useCookieTheme | const useCookieTheme = (): string => {
const [_theme, _setTheme] = useState<string>("");
const { resolvedTheme } = useTheme();
useEffect(() => {
if (resolvedTheme) {
_setTheme(resolvedTheme);
} else {
_setTheme(document.documentElement.classList.contains("dark") ? "dark" : "light");
}
}... | /**
* Get the theme from the html class which is set from the cookie
*/ | https://github.com/akash-network/console/blob/f1a0c32422b3716010f936aa7d0a4abe38ee4762/apps/stats-web/src/hooks/useTheme.ts#L7-L20 | f1a0c32422b3716010f936aa7d0a4abe38ee4762 |
console | github_2023 | akash-network | typescript | QueryKeys.getDeploymentListKey | static getDeploymentListKey = (address: string) => ["DEPLOYMENT_LIST", address] | // Deploy | https://github.com/akash-network/console/blob/f1a0c32422b3716010f936aa7d0a4abe38ee4762/apps/stats-web/src/queries/queryKeys.ts | f1a0c32422b3716010f936aa7d0a4abe38ee4762 |
runtime-compat | github_2023 | unjs | typescript | Tests.constructor | constructor(options: {
tests: TestsType & { __version: string; __resources: Resources };
httpOnly: any;
}) {
this.tests = Object.keys(options.tests)
.filter((key) => !key.startsWith("__"))
.reduce((obj, key) => {
obj[key] = options.tests[key];
return obj;
}, {});
this... | /**
* Constructs a new instance of the Tests class.
* @param options - The options for the Tests class.
* @param options.tests - The tests and resources object.
* @param options.httpOnly - Indicates if the HTTP-only flag is enabled.
*/ | https://github.com/unjs/runtime-compat/blob/ebfbb7db100405cd96a61917b57b978bdda14422/vendor/tests.ts#L31-L45 | ebfbb7db100405cd96a61917b57b978bdda14422 |
runtime-compat | github_2023 | unjs | typescript | Tests.buildEndpoints | buildEndpoints(): Endpoints {
const endpoints: Endpoints = {
"": [],
};
for (const ident of Object.keys(this.tests)) {
if (ident === "__resources") {
continue;
}
endpoints[""].push(ident);
let endpoint = "";
for (const part of ident.split(".")) {
endpoin... | /**
* Builds and returns the endpoints object.
* The endpoints object is a mapping of endpoint names to an array of test identifiers.
* Each test identifier represents a specific test case.
* @returns The endpoints object.
*/ | https://github.com/unjs/runtime-compat/blob/ebfbb7db100405cd96a61917b57b978bdda14422/vendor/tests.ts#L53-L79 | ebfbb7db100405cd96a61917b57b978bdda14422 |
runtime-compat | github_2023 | unjs | typescript | Tests.listEndpoints | listEndpoints(): string[] {
return Object.keys(this.endpoints);
} | /**
* Returns an array of all the endpoints in the collection.
* @returns An array of endpoint names.
*/ | https://github.com/unjs/runtime-compat/blob/ebfbb7db100405cd96a61917b57b978bdda14422/vendor/tests.ts#L85-L87 | ebfbb7db100405cd96a61917b57b978bdda14422 |
runtime-compat | github_2023 | unjs | typescript | Tests.getTests | getTests(
endpoint: keyof Endpoints,
testExposure?: Exposure | undefined,
ignoreIdents: string[] = [],
) {
if (!(endpoint in this.endpoints)) {
return [];
}
const idents = this.endpoints[endpoint];
const tests: any[] = [];
for (const ident of idents) {
const ignore = igno... | /**
* Retrieves the tests for a given endpoint.
* @param endpoint - The endpoint to retrieve tests for.
* @param testExposure - Optional. The exposure type of the tests to retrieve.
* @param ignoreIdents - Optional. An array of identifiers to ignore.
* @returns An array of tests for the specified endpoin... | https://github.com/unjs/runtime-compat/blob/ebfbb7db100405cd96a61917b57b978bdda14422/vendor/tests.ts#L105-L139 | ebfbb7db100405cd96a61917b57b978bdda14422 |
hassio-trash-card | github_2023 | idaho | typescript | TrashCardEditor.createPatternItem | protected createPatternItem (ev: CustomEvent): void {
ev.stopPropagation();
if (!this.config || !this.hass) {
return;
}
const customLocalize = setupCustomlocalize(this.hass);
const config = {
...this.config,
pattern: [
...this.config.pattern ?? []
]
};
cons... | // eslint-disable-next-line class-methods-use-this | https://github.com/idaho/hassio-trash-card/blob/c56d4caa198c7839f289c1ff94d18a2b452319ad/src/cards/trash-card/trash-card-editor.ts#L211-L239 | c56d4caa198c7839f289c1ff94d18a2b452319ad |
hassio-trash-card | github_2023 | idaho | typescript | Debug.render | public render () {
return html`
<div class="title">
<h3><slot name="title"></slot></h3>
<div><slot name="title-icon"></slot></div>
</div>`;
} | // eslint-disable-next-line class-methods-use-this | https://github.com/idaho/hassio-trash-card/blob/c56d4caa198c7839f289c1ff94d18a2b452319ad/src/cards/trash-card/elements/title.ts#L8-L14 | c56d4caa198c7839f289c1ff94d18a2b452319ad |
hassio-trash-card | github_2023 | idaho | typescript | BaseItemElement.renderPicture | protected renderPicture (pictureUrl: string) {
return html`
<ha-tile-image
.imageStyle=${'square'}
.imageUrl=${pictureUrl}
></ha-tile-image>`;
} | // eslint-disable-next-line class-methods-use-this | https://github.com/idaho/hassio-trash-card/blob/c56d4caa198c7839f289c1ff94d18a2b452319ad/src/cards/trash-card/items/BaseItemElement.ts#L25-L31 | c56d4caa198c7839f289c1ff94d18a2b452319ad |
hassio-trash-card | github_2023 | idaho | typescript | fireEvent | const fireEvent = <HassEvent extends ValidHassDomEvent>(
node: HTMLElement | Window,
type: HassEvent,
detail?: HASSDomEvents[HassEvent],
options?: {
bubbles?: boolean;
cancelable?: boolean;
composed?: boolean;
}
) => {
// eslint-disable-next-line no-param-reassign
options = options ?? {};
/... | // eslint-disable-next-line @typescript-eslint/naming-convention | https://github.com/idaho/hassio-trash-card/blob/c56d4caa198c7839f289c1ff94d18a2b452319ad/src/utils/fireEvent.ts#L11-L41 | c56d4caa198c7839f289c1ff94d18a2b452319ad |
client-vector-search | github_2023 | yusufhilmi | typescript | EmbeddingIndex.update | update(filter: Filter, vector: Filter) {
const index = this.findVectorIndex(filter);
if (index === -1) {
throw new Error('Vector not found');
}
if (vector.hasOwnProperty('embedding')) {
// Validate and add the new vector
this.validateAndAdd(vector);
}
// Replace the old vector ... | // Method to update an existing vector in the index | https://github.com/yusufhilmi/client-vector-search/blob/6c8272d3abc9ea83daf28743233534afe9786bbc/src/index.ts#L118-L129 | 6c8272d3abc9ea83daf28743233534afe9786bbc |
client-vector-search | github_2023 | yusufhilmi | typescript | EmbeddingIndex.remove | remove(filter: Filter) {
const index = this.findVectorIndex(filter);
if (index === -1) {
throw new Error('Vector not found');
}
// Remove the vector from the index
this.objects.splice(index, 1);
} | // Method to remove a vector from the index | https://github.com/yusufhilmi/client-vector-search/blob/6c8272d3abc9ea83daf28743233534afe9786bbc/src/index.ts#L132-L139 | 6c8272d3abc9ea83daf28743233534afe9786bbc |
client-vector-search | github_2023 | yusufhilmi | typescript | EmbeddingIndex.removeBatch | removeBatch(filters: Filter[]) {
filters.forEach((filter) => {
const index = this.findVectorIndex(filter);
if (index !== -1) {
// Remove the vector from the index
this.objects.splice(index, 1);
}
});
} | // Method to remove multiple vectors from the index | https://github.com/yusufhilmi/client-vector-search/blob/6c8272d3abc9ea83daf28743233534afe9786bbc/src/index.ts#L142-L150 | 6c8272d3abc9ea83daf28743233534afe9786bbc |
client-vector-search | github_2023 | yusufhilmi | typescript | EmbeddingIndex.get | get(filter: Filter) {
const vector = this.objects[this.findVectorIndex(filter)];
return vector || null;
} | // Method to retrieve a vector from the index | https://github.com/yusufhilmi/client-vector-search/blob/6c8272d3abc9ea83daf28743233534afe9786bbc/src/index.ts#L153-L156 | 6c8272d3abc9ea83daf28743233534afe9786bbc |
basehub | github_2023 | basehub-ai | typescript | help | async function help(code: number) {
console.log(`
Usage
$ basehub
$ basehub dev # turns on draft and watch mode automatically.
Options
--output, -o Output directory, if you don't want the default behavior.
--env-prefix, -ep Prefix for environment variables.
--banner, -b Add code at the to... | // Show usage and exit with code | https://github.com/basehub-ai/basehub/blob/b696afc0f9fb0737fb046dcce79b70b0a52ce354/packages/basehub/src/bin/index.ts#L23-L39 | b696afc0f9fb0737fb046dcce79b70b0a52ce354 |
basehub | github_2023 | basehub-ai | typescript | CodeBlockClientController | const CodeBlockClientController = ({
children,
snippets,
storeSnippetSelection,
groupId,
}: CodeBlockClientControllerProps) => {
"use client";
const isSingleSnippet = snippets.length === 1;
const [activeSnippet, setActiveSnippet] = React.useState<
ClientSnippet | undefined
>(snippets[0]);
React... | /* -------------------------------------------------------------------------------------------------
* Context
* -----------------------------------------------------------------------------------------------*/ | https://github.com/basehub-ai/basehub/blob/b696afc0f9fb0737fb046dcce79b70b0a52ce354/packages/basehub/src/react/code-block/client.tsx#L17-L113 | b696afc0f9fb0737fb046dcce79b70b0a52ce354 |
basehub | github_2023 | basehub-ai | typescript | handleSnippetChange | function handleSnippetChange(
event: CustomEvent<{ key: string; snippet: ClientSnippet }>
) {
if (event.detail.key !== localStorageKey) return;
const newActiveSnippet = snippets.find(
(s) =>
s.label === event.detail.snippet.label ||
s.id === event.detail.snippet.id
... | /**
* Sync active snippet throughout multiple code snippets throughout the page.
*/ | https://github.com/basehub-ai/basehub/blob/b696afc0f9fb0737fb046dcce79b70b0a52ce354/packages/basehub/src/react/code-block/client.tsx#L71-L83 | b696afc0f9fb0737fb046dcce79b70b0a52ce354 |
basehub | github_2023 | basehub-ai | typescript | Root | const Root = <
Document extends Record<string, unknown> = Record<string, unknown>,
>({
children,
search,
onHitSelect,
}: {
children?: React.ReactNode;
search: ReturnType<typeof useSearch<Document>>;
onHitSelect?: (hit: Hit<Document>) => void;
}) => {
const id = React.useId();
const [selectedIndex, set... | /* -------------------------------------------------------------------------------------------------
* Root
* -----------------------------------------------------------------------------------------------*/ | https://github.com/basehub-ai/basehub/blob/b696afc0f9fb0737fb046dcce79b70b0a52ce354/packages/basehub/src/react/search/primitive.tsx#L254-L375 | b696afc0f9fb0737fb046dcce79b70b0a52ce354 |
basehub | github_2023 | basehub-ai | typescript | getFallbackString | function getFallbackString(
current: unknown,
opts: { isRichText: boolean }
): string | undefined {
if (typeof current === "string") return current;
if (current === null || current === undefined) {
return undefined;
}
if (Array.isArray(current)) {
const found = current
.m... | // get first piece of text we find under `field` | https://github.com/basehub-ai/basehub/blob/b696afc0f9fb0737fb046dcce79b70b0a52ce354/packages/basehub/src/react/search/primitive.tsx#L757-L787 | b696afc0f9fb0737fb046dcce79b70b0a52ce354 |
basehub | github_2023 | basehub-ai | typescript | cyrb64 | const cyrb64 = (str: string, seed = 0) => {
let h1 = 0xdeadbeef ^ seed,
h2 = 0x41c6ce57 ^ seed;
for (let i = 0, ch; i < str.length; i++) {
ch = str.charCodeAt(i);
h1 = Math.imul(h1 ^ ch, 2654435761);
h2 = Math.imul(h2 ^ ch, 1597334677);
}
h1 = Math.imul(h1 ^ (h1 >>> 16), 2246822507);
h1 ^= Mat... | // https://github.com/bryc/code/blob/master/jshash/experimental/cyrb53.js | https://github.com/basehub-ai/basehub/blob/b696afc0f9fb0737fb046dcce79b70b0a52ce354/packages/basehub/src/search/helpers.ts#L13-L29 | b696afc0f9fb0737fb046dcce79b70b0a52ce354 |
basehub | github_2023 | basehub-ai | typescript | getFallbackString | function getFallbackString(
current: unknown,
opts: { isRichText: boolean }
): string | undefined {
if (typeof current === "string") return current;
if (current === null || current === undefined) {
return undefined;
}
if (Array.isArray(current)) {
const found = current
.m... | // get first piece of text we find under `field` | https://github.com/basehub-ai/basehub/blob/b696afc0f9fb0737fb046dcce79b70b0a52ce354/packages/basehub/src/search/primitive.tsx#L510-L540 | b696afc0f9fb0737fb046dcce79b70b0a52ce354 |
add-to-homescreen | github_2023 | philfung | typescript | createLocaleIndexFile | function createLocaleIndexFile(locale: string) {
let localeIndexContent = indexContent;
const localeConfig = { ...require(`${localesFilePath}/${locale}.json`) };
// Normalize how the i18n.__() calls are formatted so it makes it easier to
// in-place replace the config values with the localized language
loca... | // Create a new index file for each locale | https://github.com/philfung/add-to-homescreen/blob/03d6412f3c4222802ac29cb24f3aab13ad1d9a86/scripts/build.ts#L49-L124 | 03d6412f3c4222802ac29cb24f3aab13ad1d9a86 |
add-to-homescreen | github_2023 | philfung | typescript | _matchesUserAgent | function _matchesUserAgent(regex: RegExp): boolean {
return !!userAgent.match(regex);
} | /**** Device Detection Functions ****/ | https://github.com/philfung/add-to-homescreen/blob/03d6412f3c4222802ac29cb24f3aab13ad1d9a86/src/index.ts#L281-L283 | 03d6412f3c4222802ac29cb24f3aab13ad1d9a86 |
add-to-homescreen | github_2023 | philfung | typescript | isBrowserIOSSafari | function isBrowserIOSSafari(): boolean {
return (
isDeviceIOS() &&
_matchesUserAgent(/Safari/) &&
!isBrowserIOSChrome() &&
!isBrowserIOSFirefox() &&
!isBrowserIOSInAppFacebook() &&
!isBrowserIOSInAppLinkedin() &&
!isBrowserIOSInAppInstagram() &&
!isBrowserIOSInAppThre... | /* Mozilla/5.0 (iPhone; CPU iPhone OS 10_3 like Mac OS X)
AppleWebKit/603.1.23 (KHTML, like Gecko) Version/10.0
Mobile/14E5239e Safari/602.1 */ | https://github.com/philfung/add-to-homescreen/blob/03d6412f3c4222802ac29cb24f3aab13ad1d9a86/src/index.ts#L308-L320 | 03d6412f3c4222802ac29cb24f3aab13ad1d9a86 |
add-to-homescreen | github_2023 | philfung | typescript | isBrowserIOSChrome | function isBrowserIOSChrome(): boolean {
return isDeviceIOS() && _matchesUserAgent(/CriOS/);
} | /* Mozilla/5.0 (iPhone; CPU iPhone OS 10_3 like Mac OS X)
AppleWebKit/602.1.50 (KHTML, like Gecko) CriOS/56.0.2924.75
Mobile/14E5239e Safari/602.1 */ | https://github.com/philfung/add-to-homescreen/blob/03d6412f3c4222802ac29cb24f3aab13ad1d9a86/src/index.ts#L325-L327 | 03d6412f3c4222802ac29cb24f3aab13ad1d9a86 |
add-to-homescreen | github_2023 | philfung | typescript | isBrowserIOSFirefox | function isBrowserIOSFirefox(): boolean {
return isDeviceIOS() && _matchesUserAgent(/FxiOS/);
} | /* Mozilla/5.0 (iPhone; CPU iPhone OS 16_5 like Mac OS X)
AppleWebKit/605.1.15 (KHTML, like Gecko) FxiOS/114.1 Mobile/15E148 Safari/605.1.15 */ | https://github.com/philfung/add-to-homescreen/blob/03d6412f3c4222802ac29cb24f3aab13ad1d9a86/src/index.ts#L331-L333 | 03d6412f3c4222802ac29cb24f3aab13ad1d9a86 |
add-to-homescreen | github_2023 | philfung | typescript | isBrowserAndroidChrome | function isBrowserAndroidChrome(): boolean {
return (
isDeviceAndroid() &&
!!_matchesUserAgent(/Chrome/) &&
!isBrowserAndroidFacebook() &&
!isBrowserAndroidInstagram() &&
!isBrowserAndroidSamsung() &&
!isBrowserAndroidFirefox() &&
!isBrowserAndroidEdge() &&
!isBrowser... | /* Mozilla/5.0 (Linux; Android 10)
AppleWebKit/537.36 (KHTML, like Gecko) Chrome/116.0.5845.92 Mobile Safari/537.36 */ | https://github.com/philfung/add-to-homescreen/blob/03d6412f3c4222802ac29cb24f3aab13ad1d9a86/src/index.ts#L381-L392 | 03d6412f3c4222802ac29cb24f3aab13ad1d9a86 |
add-to-homescreen | github_2023 | philfung | typescript | isBrowserAndroidFacebook | function isBrowserAndroidFacebook(): boolean {
return isDeviceAndroid() && _matchesUserAgent(/FBAN|FBAV/);
} | /*Mozilla/5.0 (Linux; Android 12; SM-S908U1 Build/SP1A.210812.016; wv)
AppleWebKit/537.36 (KHTML, like Gecko) Version/4.0 Chrome/100.0.4896.88
Mobile Safari/537.36 [FB_IAB/FB4A;FBAV/377.0.0.22.107;]*/ | https://github.com/philfung/add-to-homescreen/blob/03d6412f3c4222802ac29cb24f3aab13ad1d9a86/src/index.ts#L397-L399 | 03d6412f3c4222802ac29cb24f3aab13ad1d9a86 |
add-to-homescreen | github_2023 | philfung | typescript | isBrowserAndroidSamsung | function isBrowserAndroidSamsung(): boolean {
return isDeviceAndroid() && _matchesUserAgent(/SamsungBrowser/);
} | /* Mozilla/5.0 (Linux; Android 13; SAMSUNG SM-S918B) AppleWebKit/537.36
(KHTML, like Gecko) SamsungBrowser/21.0 Chrome/110.0.5481.154 Mobile Safari/537.36 */ | https://github.com/philfung/add-to-homescreen/blob/03d6412f3c4222802ac29cb24f3aab13ad1d9a86/src/index.ts#L407-L409 | 03d6412f3c4222802ac29cb24f3aab13ad1d9a86 |
add-to-homescreen | github_2023 | philfung | typescript | isBrowserAndroidFirefox | function isBrowserAndroidFirefox(): boolean {
return isDeviceAndroid() && _matchesUserAgent(/Firefox/);
} | /* Mozilla/5.0 (Android 13; Mobile; rv:109.0) Gecko/114.0 Firefox/114.0 */ | https://github.com/philfung/add-to-homescreen/blob/03d6412f3c4222802ac29cb24f3aab13ad1d9a86/src/index.ts#L412-L414 | 03d6412f3c4222802ac29cb24f3aab13ad1d9a86 |
add-to-homescreen | github_2023 | philfung | typescript | _getAppDisplayUrl | function _getAppDisplayUrl(): string {
// return 'https://aardvark.app';
const currentUrl = new URL(window.location.href);
return currentUrl.href.replace(/\/$/, "");
} | /**** Internal Functions ****/ | https://github.com/philfung/add-to-homescreen/blob/03d6412f3c4222802ac29cb24f3aab13ad1d9a86/src/index.ts#L459-L463 | 03d6412f3c4222802ac29cb24f3aab13ad1d9a86 |
add-to-homescreen | github_2023 | philfung | typescript | showDesktopInstallPrompt | function showDesktopInstallPrompt() {
debugMessage("SHOW DESKTOP CHROME / EDGE PROMOTION");
if (_desktopInstallPromptWasShown) {
return;
}
// - if the prompt has not fired, wait for it the be fired, then show the promotion
// - Don't bother showing promotion if wait time > DESKTOP_INSTALL_MA... | // show the desktop chrome promotion | https://github.com/philfung/add-to-homescreen/blob/03d6412f3c4222802ac29cb24f3aab13ad1d9a86/src/index.ts#L1045-L1081 | 03d6412f3c4222802ac29cb24f3aab13ad1d9a86 |
vue-clerk | github_2023 | wobsoriano | typescript | IsomorphicClerk.setActive | setActive = ({ session, organization, beforeEmit }: SetActiveParams): Promise<void> => {
if (this.clerkjs) {
return this.clerkjs.setActive({ session, organization, beforeEmit })
}
else {
// eslint-disable-next-line prefer-promise-reject-errors
return Promise.reject()
}
} | /**
* `setActive` can be used to set the active session and/or organization.
*/ | https://github.com/wobsoriano/vue-clerk/blob/6aba0600b5dbaff23c7ff40d94552b83d4c4b1fc/packages/vue-clerk/src/isomorphicClerk.ts#L693-L701 | 6aba0600b5dbaff23c7ff40d94552b83d4c4b1fc |
vue-clerk | github_2023 | wobsoriano | typescript | clerkLoaded | function clerkLoaded(clerk: IsomorphicClerk) {
return new Promise<void>((resolve) => {
if (clerk.loaded)
resolve()
clerk.addOnLoaded(() => resolve())
})
} | /**
* @param clerk
* @internal
*/ | https://github.com/wobsoriano/vue-clerk/blob/6aba0600b5dbaff23c7ff40d94552b83d4c4b1fc/packages/vue-clerk/src/composables/useAuth.ts#L13-L20 | 6aba0600b5dbaff23c7ff40d94552b83d4c4b1fc |
vue-clerk | github_2023 | wobsoriano | typescript | createGetToken | function createGetToken(clerk: IsomorphicClerk) {
return async (options: any) => {
await clerkLoaded(clerk)
if (!clerk.session)
return null
return clerk.session.getToken(options)
}
} | /**
* @param clerk
* @internal
*/ | https://github.com/wobsoriano/vue-clerk/blob/6aba0600b5dbaff23c7ff40d94552b83d4c4b1fc/packages/vue-clerk/src/composables/useAuth.ts#L26-L34 | 6aba0600b5dbaff23c7ff40d94552b83d4c4b1fc |
vue-clerk | github_2023 | wobsoriano | typescript | createSignOut | function createSignOut(clerk: IsomorphicClerk) {
return async (...args: any) => {
await clerkLoaded(clerk)
return clerk.signOut(...args)
}
} | /**
* @param clerk
* @internal
*/ | https://github.com/wobsoriano/vue-clerk/blob/6aba0600b5dbaff23c7ff40d94552b83d4c4b1fc/packages/vue-clerk/src/composables/useAuth.ts#L40-L45 | 6aba0600b5dbaff23c7ff40d94552b83d4c4b1fc |
pdf-chat-ai-sdk | github_2023 | rajeshdavidbabu | typescript | createIndex | async function createIndex(client: PineconeClient, indexName: string) {
try {
await client.createIndex({
createRequest: {
name: indexName,
dimension: 1536,
metric: "cosine",
},
});
console.log(
`Waiting for ${env.INDEX_INIT_TIMEOUT} seconds for index initializatio... | // Create pineconeIndex if it doesn't exist | https://github.com/rajeshdavidbabu/pdf-chat-ai-sdk/blob/acad113924cfe19a80e08b7318a48f72434e5578/src/lib/pinecone-client.ts#L8-L26 | acad113924cfe19a80e08b7318a48f72434e5578 |
pdf-chat-ai-sdk | github_2023 | rajeshdavidbabu | typescript | initPineconeClient | async function initPineconeClient() {
try {
const pineconeClient = new PineconeClient();
await pineconeClient.init({
apiKey: env.PINECONE_API_KEY,
environment: env.PINECONE_ENVIRONMENT,
});
const indexName = env.PINECONE_INDEX_NAME;
const existingIndexes = await pineconeClient.listInd... | // Initialize index and ready to be accessed. | https://github.com/rajeshdavidbabu/pdf-chat-ai-sdk/blob/acad113924cfe19a80e08b7318a48f72434e5578/src/lib/pinecone-client.ts#L29-L51 | acad113924cfe19a80e08b7318a48f72434e5578 |
cat-town | github_2023 | ykhli | typescript | vectorSearch | const vectorSearch = async (embedding: number[], playerId: Id<'players'>, limit: number) =>
queryVectors('embeddings', embedding, { playerId }, limit); | // If Pinecone env variables are defined, use that. | https://github.com/ykhli/cat-town/blob/d76e3ca18db7fd8f743d47232c8fcd07a0d80a36/convex/lib/memory.ts#L51-L52 | d76e3ca18db7fd8f743d47232c8fcd07a0d80a36 |
cat-town | github_2023 | ykhli | typescript | getMemoryByEmbeddingId | async function getMemoryByEmbeddingId(
db: DatabaseReader,
playerId: Id<'players'>,
embeddingId: Id<'embeddings'>,
) {
const doc = await db
.query('memories')
.withIndex('by_playerId_embeddingId', (q) =>
q.eq('playerId', playerId).eq('embeddingId', embeddingId),
)
.order('desc')
.first... | // Technically it's redundant to retrieve them by playerId, since the embedding | https://github.com/ykhli/cat-town/blob/d76e3ca18db7fd8f743d47232c8fcd07a0d80a36/convex/lib/memory.ts#L331-L345 | d76e3ca18db7fd8f743d47232c8fcd07a0d80a36 |
cat-town | github_2023 | ykhli | typescript | MinHeap | function MinHeap<T>(compare: (a: T, b: T) => boolean) {
// Using 1 indexing. I know, it's goofy
const tree = [null as T];
let endIndex = 1;
return {
peek: (): T | undefined => tree[1],
length: () => endIndex - 1,
push: (newValue: T) => {
let destinationIndex = endIndex++;
let nextToCheck... | // Basic 1-indexed minheap implementation | https://github.com/ykhli/cat-town/blob/d76e3ca18db7fd8f743d47232c8fcd07a0d80a36/convex/lib/routing.ts#L245-L282 | d76e3ca18db7fd8f743d47232c8fcd07a0d80a36 |
lunar | github_2023 | TheLunarCompany | typescript | wait | function wait(ms: number): Promise<void> {
return new Promise(resolve => setTimeout(resolve, ms));
} | // eslint-disable-next-line @typescript-eslint/promise-function-async | https://github.com/TheLunarCompany/lunar/blob/02fd8d36f2df02045f8b1f969bfcb89619cb6c13/interceptors/lunar-ts-interceptor/src/fetchHelper.ts#L61-L63 | 02fd8d36f2df02045f8b1f969bfcb89619cb6c13 |
lunar | github_2023 | TheLunarCompany | typescript | LunarInterceptor.httpHookRequestFunc | private httpHookRequestFunc(scheme: string, functionName: string, arg0: unknown, arg1: unknown, arg2: unknown, ...args: unknown[]): ClientRequest {
let url: URL | null;
let options: LunarOptions;
let modifiedOptions: LunarOptions | null = null;
let callback: (res: IncomingMessage) => vo... | // https://github.com/nodejs/node/blob/717e233cd95602f79256c5b70c49703fa699174b/lib/_http_client.js#L130 | https://github.com/TheLunarCompany/lunar/blob/02fd8d36f2df02045f8b1f969bfcb89619cb6c13/interceptors/lunar-ts-interceptor/src/interceptor.ts#L185-L248 | 02fd8d36f2df02045f8b1f969bfcb89619cb6c13 |
NestjsProjectDemo | github_2023 | wzz778 | typescript | AdminGuard.constructor | constructor(private userService: UserService) {} | // 常见的错误:在使用AdminGuard未导入UserModule | https://github.com/wzz778/NestjsProjectDemo/blob/e01d87250708ee43ee47e2e72fa01a881b9a6d17/src/guards/admin/admin.guard.ts#L9-L9 | e01d87250708ee43ee47e2e72fa01a881b9a6d17 |
NestjsProjectDemo | github_2023 | wzz778 | typescript | UserService.update | async update(id: number, user: Partial<User>) {
const userTemp = await this.findAddProfile(id);
const newUser = this.userRepository.merge(userTemp, user);
// 联合模型更新,需要使用save方法或者queryBuilder
return this.userRepository.save(newUser);
1;
// 下面的update方法,只适合单模型的更新,不适合有关系的模型更新
// return this.userR... | //Partial会拼接没有传的数据,相当于动态sql | https://github.com/wzz778/NestjsProjectDemo/blob/e01d87250708ee43ee47e2e72fa01a881b9a6d17/src/user/user.service.ts#L78-L86 | e01d87250708ee43ee47e2e72fa01a881b9a6d17 |
homebridge-alexa-smarthome | github_2023 | joeyhage | typescript | ThermostatAccessory.handleTargetTempGet | async handleTargetTempGet(): Promise<number> {
const alexaValueName = 'targetSetpoint';
const determineTargetTemp = flow(
A.findFirst<ThermostatState>(
({ name, featureName }) =>
featureName === 'thermostat' && name === alexaValueName,
),
O.flatMap(({ value }) => tempMapper.m... | // } | https://github.com/joeyhage/homebridge-alexa-smarthome/blob/aa652d2224b293b36db72dabbc51675b535516f8/src/accessory/thermostat-accessory.ts#L325-L355 | aa652d2224b293b36db72dabbc51675b535516f8 |
homebridge-alexa-smarthome | github_2023 | joeyhage | typescript | hslToRgb | function hslToRgb(h: number, s = 1, l = 1) {
function padding(num: number) {
const numBase16 = num.toString(16);
if (numBase16.length < 2) {
return `0${numBase16}`;
}
return numBase16;
}
let r = 0;
let g = 0;
let b = 0;
h = h / 360;
const i = Math.floor(h * 6);
const f = h * 6 - i... | // expected hue range: [0, 360] | https://github.com/joeyhage/homebridge-alexa-smarthome/blob/aa652d2224b293b36db72dabbc51675b535516f8/src/mapper/light-mapper.ts#L8-L67 | aa652d2224b293b36db72dabbc51675b535516f8 |
pm2.web | github_2023 | oxdev03 | typescript | createInnerTRPCContext | const createInnerTRPCContext = (opts: CreateContextOptions) => {
return {
session: opts.session,
};
}; | /**
* This helper generates the "internals" for a tRPC context. If you need to use
* it, you can export it from here
*
* Examples of things you may need it for:
* - testing, so we don't have to mock Next.js' req/res
* - trpc's `createSSGHelpers` where we don't have req/res
* @see https://create.t3.gg/en/usage/tr... | https://github.com/oxdev03/pm2.web/blob/984b569e047bc30c184803ee7ca4646490bb8b31/apps/dashboard/server/context.ts#L20-L24 | 984b569e047bc30c184803ee7ca4646490bb8b31 |
jan | github_2023 | janhq | typescript | executeOnMain | const executeOnMain: (
extension: string,
method: string,
...args: any[]
) => Promise<any> = (extension, method, ...args) =>
globalThis.core?.api?.invokeExtensionFunc(extension, method, ...args) | /**
* Execute a extension module function in main process
*
* @param extension extension name to import
* @param method function name to execute
* @param args arguments to pass to the function
* @returns Promise<any>
*
*/ | https://github.com/janhq/jan/blob/f8f19af8c54989ad9f58e108bf93c08ef6beb03b/core/src/browser/core.ts#L17-L22 | f8f19af8c54989ad9f58e108bf93c08ef6beb03b |
jan | github_2023 | janhq | typescript | downloadFile | const downloadFile: (
downloadRequest: DownloadRequest,
network?: NetworkConfig
) => Promise<any> = (downloadRequest, network) =>
globalThis.core?.api?.downloadFile(downloadRequest, network) | /**
* Downloads a file from a URL and saves it to the local file system.
*
* @param {DownloadRequest} downloadRequest - The request to download the file.
* @param {NetworkConfig} network - Optional object to specify proxy/whether to ignore SSL certificates.
*
* @returns {Promise<any>} A promise that resolves when... | https://github.com/janhq/jan/blob/f8f19af8c54989ad9f58e108bf93c08ef6beb03b/core/src/browser/core.ts#L32-L36 | f8f19af8c54989ad9f58e108bf93c08ef6beb03b |
jan | github_2023 | janhq | typescript | abortDownload | const abortDownload: (fileName: string) => Promise<any> = (fileName) =>
globalThis.core.api?.abortDownload(fileName) | /**
* Aborts the download of a specific file.
* @param {string} fileName - The name of the file whose download is to be aborted.
* @returns {Promise<any>} A promise that resolves when the download has been aborted.
*/ | https://github.com/janhq/jan/blob/f8f19af8c54989ad9f58e108bf93c08ef6beb03b/core/src/browser/core.ts#L43-L44 | f8f19af8c54989ad9f58e108bf93c08ef6beb03b |
jan | github_2023 | janhq | typescript | getJanDataFolderPath | const getJanDataFolderPath = (): Promise<string> =>
globalThis.core.api?.getJanDataFolderPath() | /**
* Gets Jan's data folder path.
*
* @returns {Promise<string>} A Promise that resolves with Jan's data folder path.
*/ | https://github.com/janhq/jan/blob/f8f19af8c54989ad9f58e108bf93c08ef6beb03b/core/src/browser/core.ts#L51-L52 | f8f19af8c54989ad9f58e108bf93c08ef6beb03b |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.