type
stringclasses 7
values | content
stringlengths 4
9.55k
| repo
stringlengths 7
96
| path
stringlengths 4
178
| language
stringclasses 1
value |
|---|---|---|---|---|
MethodDeclaration
|
private async fireFileSystemChangeCore() {
let e = this._pendingFileSystemChange;
if (e == null) return;
this._pendingFileSystemChange = undefined;
const uris = await this.container.git.excludeIgnoredUris(this.path, e.uris);
if (uris.length === 0) return;
if (uris.length !== e.uris.length) {
e = { ...e, uris: uris };
}
Logger.debug(`Repository(${this.id}) firing fs changes=${e.uris.map(u => u.fsPath).join(', ')}`);
this._onDidChangeFileSystem.fire(e);
}
|
Levistator/vscode-gitlens
|
src/git/models/repository.ts
|
TypeScript
|
MethodDeclaration
|
private runTerminalCommand(command: string, ...args: string[]) {
const parsedArgs = args.map(arg =>
arg.startsWith('#') || arg.includes("'") || arg.includes('(') || arg.includes(')') ? `"${arg}"` : arg,
);
runGitCommandInTerminal(command, parsedArgs.join(' '), this.path, true);
setTimeout(() => this.fireChange(RepositoryChange.Unknown), 2500);
}
|
Levistator/vscode-gitlens
|
src/git/models/repository.ts
|
TypeScript
|
TypeAliasDeclaration
|
type change = 500 | 1500 | 5000;
|
AviralCoder/Kaun_Banega_Gyanpati
|
src/lib/lib.ts
|
TypeScript
|
ArrowFunction
|
() => (
<TooltipGuide content="Lorem ipsum dolor sit amet, consectetur adipiscing elit. Nullam aliquet ornare est." />
|
Actyx/actyx-ui
|
src/components/TooltipGuide/TooltipGuide.stories.tsx
|
TypeScript
|
ArrowFunction
|
(slug: string): void => {
cy.visit('/wp-admin/plugins.php');
cy.get(`#the-list tr[data-slug="${slug}"]`).then($pluginRow => {
if ($pluginRow.find('.activate > a').length > 0) {
cy.get(`#the-list tr[data-slug="${slug}"] .activate > a`)
.should('have.text', 'Activate')
.click();
}
});
}
|
10up/cypress-wp-utils
|
src/commands/activate-plugin.ts
|
TypeScript
|
ArrowFunction
|
$pluginRow => {
if ($pluginRow.find('.activate > a').length > 0) {
cy.get(`#the-list tr[data-slug="${slug}"] .activate > a`)
.should('have.text', 'Activate')
.click();
}
}
|
10up/cypress-wp-utils
|
src/commands/activate-plugin.ts
|
TypeScript
|
ClassDeclaration
|
export class BitcoinCoreClient {
client: typeof Client;
/**
* Initialize the Bitcoin-core client, which is a js equivalent to bitcoin-cli
* @param network Bitcoin network (mainnet, testnet, regtest)
* @param host URL of Bitcoin node (e.g. localhost)
* @param username User for RPC authentication
* @param password Password for RPC authentication
* @param port Bitcoin node connection port (e.g. 18443)
* @param wallet Wallet to use if several are available. See https://github.com/ruimarinho/bitcoin-core#multiwallet
*/
constructor(network: string, host: string, username: string, password: string, port: string, wallet: string) {
this.client = new Client({
network,
host,
username,
password,
port,
wallet,
});
}
async sendBtcTxAndMine(
recipient: string,
amount: MonetaryAmount<WrappedCurrency, BitcoinUnit>,
blocksToMine: number,
data?: string
): Promise<{
// big endian
txid: string;
rawTx: string;
}> {
const tx = await this.broadcastTx(recipient, amount, data);
await this.mineBlocks(blocksToMine);
return tx;
}
formatRawTxInput(recipient: string, amount: Big, data?: string): RecipientsToUTXOAmounts[] {
const paidOutput: RecipientsToUTXOAmounts = {};
paidOutput[recipient] = amount.toString();
if (data !== undefined) {
return [{ data }, paidOutput];
}
return [paidOutput];
}
async broadcastTx(
recipient: string,
amount: MonetaryAmount<WrappedCurrency, BitcoinUnit>,
data?: string
): Promise<{
txid: string;
rawTx: string;
}> {
if (!this.client) {
throw new Error("Client needs to be initialized before usage");
}
console.log(`Broadcasting tx: ${amount.toString(Bitcoin.base)} BTC to ${recipient}`);
const raw = await this.client.command(
"createrawtransaction",
[],
this.formatRawTxInput(recipient, amount.toBig(Bitcoin.units.BTC), data)
);
const funded = await this.client.command("fundrawtransaction", raw);
const signed = await this.client.command("signrawtransactionwithwallet", funded.hex);
const response = await this.client.command("sendrawtransaction", signed.hex);
const txid = response;
return {
txid: txid,
rawTx: signed.hex,
};
}
async mineBlocks(n: number): Promise<void> {
console.log(`Mining ${n} Bitcoin block(s)`);
const newWalletAddress = await this.client.command("getnewaddress");
await this.client.command("generatetoaddress", n, newWalletAddress);
}
async getBalance(): Promise<string> {
return await this.client.command("getbalance");
}
async sendToAddress(address: string, amount: MonetaryAmount<WrappedCurrency, BitcoinUnit>): Promise<string> {
return await this.client.command("sendtoaddress", address, amount.toString(Bitcoin.units.BTC));
}
// eslint-disable-next-line @typescript-eslint/no-explicit-any
getMempoolInfo(): Promise<any> {
return this.client.command("getmempoolinfo");
}
getBestBlockHash(): Promise<string> {
return this.client.command("getbestblockhash");
}
createWallet(name: string): Promise<void> {
return this.client.command("createwallet", name);
}
loadWallet(name: string): Promise<void> {
return this.client.command("loadwallet", name);
}
}
|
crypto-engineer/interbtc-api
|
src/utils/bitcoin-core-client.ts
|
TypeScript
|
InterfaceDeclaration
|
interface RecipientsToUTXOAmounts {
[key: string]: string;
}
|
crypto-engineer/interbtc-api
|
src/utils/bitcoin-core-client.ts
|
TypeScript
|
MethodDeclaration
|
async sendBtcTxAndMine(
recipient: string,
amount: MonetaryAmount<WrappedCurrency, BitcoinUnit>,
blocksToMine: number,
data?: string
): Promise<{
// big endian
txid: string;
rawTx: string;
}> {
const tx = await this.broadcastTx(recipient, amount, data);
await this.mineBlocks(blocksToMine);
return tx;
}
|
crypto-engineer/interbtc-api
|
src/utils/bitcoin-core-client.ts
|
TypeScript
|
MethodDeclaration
|
formatRawTxInput(recipient: string, amount: Big, data?: string): RecipientsToUTXOAmounts[] {
const paidOutput: RecipientsToUTXOAmounts = {};
paidOutput[recipient] = amount.toString();
if (data !== undefined) {
return [{ data }, paidOutput];
}
return [paidOutput];
}
|
crypto-engineer/interbtc-api
|
src/utils/bitcoin-core-client.ts
|
TypeScript
|
MethodDeclaration
|
async broadcastTx(
recipient: string,
amount: MonetaryAmount<WrappedCurrency, BitcoinUnit>,
data?: string
): Promise<{
txid: string;
rawTx: string;
}> {
if (!this.client) {
throw new Error("Client needs to be initialized before usage");
}
console.log(`Broadcasting tx: ${amount.toString(Bitcoin.base)} BTC to ${recipient}`);
const raw = await this.client.command(
"createrawtransaction",
[],
this.formatRawTxInput(recipient, amount.toBig(Bitcoin.units.BTC), data)
);
const funded = await this.client.command("fundrawtransaction", raw);
const signed = await this.client.command("signrawtransactionwithwallet", funded.hex);
const response = await this.client.command("sendrawtransaction", signed.hex);
const txid = response;
return {
txid: txid,
rawTx: signed.hex,
};
}
|
crypto-engineer/interbtc-api
|
src/utils/bitcoin-core-client.ts
|
TypeScript
|
MethodDeclaration
|
async mineBlocks(n: number): Promise<void> {
console.log(`Mining ${n} Bitcoin block(s)`);
const newWalletAddress = await this.client.command("getnewaddress");
await this.client.command("generatetoaddress", n, newWalletAddress);
}
|
crypto-engineer/interbtc-api
|
src/utils/bitcoin-core-client.ts
|
TypeScript
|
MethodDeclaration
|
async getBalance(): Promise<string> {
return await this.client.command("getbalance");
}
|
crypto-engineer/interbtc-api
|
src/utils/bitcoin-core-client.ts
|
TypeScript
|
MethodDeclaration
|
async sendToAddress(address: string, amount: MonetaryAmount<WrappedCurrency, BitcoinUnit>): Promise<string> {
return await this.client.command("sendtoaddress", address, amount.toString(Bitcoin.units.BTC));
}
|
crypto-engineer/interbtc-api
|
src/utils/bitcoin-core-client.ts
|
TypeScript
|
MethodDeclaration
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
getMempoolInfo(): Promise<any> {
return this.client.command("getmempoolinfo");
}
|
crypto-engineer/interbtc-api
|
src/utils/bitcoin-core-client.ts
|
TypeScript
|
MethodDeclaration
|
getBestBlockHash(): Promise<string> {
return this.client.command("getbestblockhash");
}
|
crypto-engineer/interbtc-api
|
src/utils/bitcoin-core-client.ts
|
TypeScript
|
MethodDeclaration
|
createWallet(name: string): Promise<void> {
return this.client.command("createwallet", name);
}
|
crypto-engineer/interbtc-api
|
src/utils/bitcoin-core-client.ts
|
TypeScript
|
MethodDeclaration
|
loadWallet(name: string): Promise<void> {
return this.client.command("loadwallet", name);
}
|
crypto-engineer/interbtc-api
|
src/utils/bitcoin-core-client.ts
|
TypeScript
|
ArrowFunction
|
({ result }) => {
const [t] = useTranslation("plugins");
return (
<Entry>
<PaddingRightIcon color={"warning"} name={"exclamation-triangle"} />
<p>{t(result?.rule)}</p>
</Entry>
|
scm-manager/scm-review-plugin
|
src/main/js/OverrideModalRow.tsx
|
TypeScript
|
TypeAliasDeclaration
|
type Props = WithTranslation & {
result: Result;
};
|
scm-manager/scm-review-plugin
|
src/main/js/OverrideModalRow.tsx
|
TypeScript
|
MethodDeclaration
|
t(result?.rule)
|
scm-manager/scm-review-plugin
|
src/main/js/OverrideModalRow.tsx
|
TypeScript
|
InterfaceDeclaration
|
export interface User extends mongoose.Document{
id: string,
name: string,
email: string,
password: string
}
|
PatrickNiyogitare28/Nestjs_Demo
|
src/users/users.model.ts
|
TypeScript
|
ArrowFunction
|
(): void => {
const ruleRegistry = new RuleRegistry(),
availableCityBuildItemsRegistry = new AvailableCityBuildItemsRegistry(),
cityBuildRegistry = new CityBuildRegistry();
ruleRegistry.register(
...spend(),
...cityImprovementBuildCost(),
...unitBuildCost()
);
availableCityBuildItemsRegistry.register(Warrior, Temple);
([
[Temple, 0, 160],
[Temple, 1, 78],
[Temple, 39, 2],
[Warrior, 0, 50],
[Warrior, 1, 22],
[Warrior, 9, 2],
] as [typeof CityImprovement | typeof Unit, number, number][]).forEach(
([BuildItem, progress, expectedCost]): void => {
it(`should cost ${expectedCost} Gold to buy a ${BuildItem.name} with ${progress} progress`, (): void => {
const city = setUpCity({
ruleRegistry,
}),
cityBuild = new CityBuild(
city,
availableCityBuildItemsRegistry,
ruleRegistry
);
cityBuildRegistry.register(cityBuild);
const playerTreasury = new PlayerTreasury(
city.player(),
cityBuildRegistry,
ruleRegistry
);
playerTreasury.add(expectedCost);
expect(playerTreasury.value()).to.equal(expectedCost);
cityBuild.build(BuildItem);
expect(cityBuild.progress().value()).to.equal(0);
cityBuild.add(new Production(progress));
expect(cityBuild.progress().value()).to.equal(progress);
const goldCost = playerTreasury.cost(city);
expect(goldCost.value()).to.equal(expectedCost);
playerTreasury.buy(city);
expect(playerTreasury.value()).to.equal(0);
});
}
);
}
|
civ-clone/base-treasury-civ1
|
tests/spend.test.ts
|
TypeScript
|
ArrowFunction
|
([BuildItem, progress, expectedCost]): void => {
it(`should cost ${expectedCost} Gold to buy a ${BuildItem.name} with ${progress} progress`, (): void => {
const city = setUpCity({
ruleRegistry,
}),
cityBuild = new CityBuild(
city,
availableCityBuildItemsRegistry,
ruleRegistry
);
cityBuildRegistry.register(cityBuild);
const playerTreasury = new PlayerTreasury(
city.player(),
cityBuildRegistry,
ruleRegistry
);
playerTreasury.add(expectedCost);
expect(playerTreasury.value()).to.equal(expectedCost);
cityBuild.build(BuildItem);
expect(cityBuild.progress().value()).to.equal(0);
cityBuild.add(new Production(progress));
expect(cityBuild.progress().value()).to.equal(progress);
const goldCost = playerTreasury.cost(city);
expect(goldCost.value()).to.equal(expectedCost);
playerTreasury.buy(city);
expect(playerTreasury.value()).to.equal(0);
});
}
|
civ-clone/base-treasury-civ1
|
tests/spend.test.ts
|
TypeScript
|
ArrowFunction
|
(): void => {
const city = setUpCity({
ruleRegistry,
}),
cityBuild = new CityBuild(
city,
availableCityBuildItemsRegistry,
ruleRegistry
);
cityBuildRegistry.register(cityBuild);
const playerTreasury = new PlayerTreasury(
city.player(),
cityBuildRegistry,
ruleRegistry
);
playerTreasury.add(expectedCost);
expect(playerTreasury.value()).to.equal(expectedCost);
cityBuild.build(BuildItem);
expect(cityBuild.progress().value()).to.equal(0);
cityBuild.add(new Production(progress));
expect(cityBuild.progress().value()).to.equal(progress);
const goldCost = playerTreasury.cost(city);
expect(goldCost.value()).to.equal(expectedCost);
playerTreasury.buy(city);
expect(playerTreasury.value()).to.equal(0);
}
|
civ-clone/base-treasury-civ1
|
tests/spend.test.ts
|
TypeScript
|
ClassDeclaration
|
/** Provides operations to manage the directReports property of the microsoft.graph.user entity. */
export class DirectReportsRequestBuilder {
/** The count property */
public get count(): CountRequestBuilder {
return new CountRequestBuilder(this.pathParameters, this.requestAdapter);
}
/** The orgContact property */
public get orgContact(): OrgContactRequestBuilder {
return new OrgContactRequestBuilder(this.pathParameters, this.requestAdapter);
}
/** Path parameters for the request */
private readonly pathParameters: Record<string, unknown>;
/** The request adapter to use to execute the requests. */
private readonly requestAdapter: RequestAdapter;
/** Url template to use to build the URL for the current request builder */
private readonly urlTemplate: string;
/** The user property */
public get user(): UserRequestBuilder {
return new UserRequestBuilder(this.pathParameters, this.requestAdapter);
}
/**
* Instantiates a new DirectReportsRequestBuilder and sets the default values.
* @param pathParameters The raw url or the Url template parameters for the request.
* @param requestAdapter The request adapter to use to execute the requests.
*/
public constructor(pathParameters: Record<string, unknown> | string | undefined, requestAdapter: RequestAdapter) {
if(!pathParameters) throw new Error("pathParameters cannot be undefined");
if(!requestAdapter) throw new Error("requestAdapter cannot be undefined");
this.urlTemplate = "{+baseurl}/me/directReports{?%24top,%24skip,%24search,%24filter,%24count,%24orderby,%24select,%24expand}";
const urlTplParams = getPathParameters(pathParameters);
this.pathParameters = urlTplParams;
this.requestAdapter = requestAdapter;
};
/**
* The users and contacts that report to the user. (The users and contacts that have their manager property set to this user.) Read-only. Nullable. Supports $expand.
* @param requestConfiguration Configuration for the request such as headers, query parameters, and middleware options.
* @returns a RequestInformation
*/
public createGetRequestInformation(requestConfiguration?: DirectReportsRequestBuilderGetRequestConfiguration | undefined) : RequestInformation {
const requestInfo = new RequestInformation();
requestInfo.urlTemplate = this.urlTemplate;
requestInfo.pathParameters = this.pathParameters;
requestInfo.httpMethod = HttpMethod.GET;
if (requestConfiguration) {
requestInfo.addRequestHeaders(requestConfiguration.headers);
requestInfo.setQueryStringParametersFromRawObject(requestConfiguration.queryParameters);
requestInfo.addRequestOptions(requestConfiguration.options);
}
return requestInfo;
};
/**
* The users and contacts that report to the user. (The users and contacts that have their manager property set to this user.) Read-only. Nullable. Supports $expand.
* @param requestConfiguration Configuration for the request such as headers, query parameters, and middleware options.
* @param responseHandler Response handler to use in place of the default response handling provided by the core service
* @returns a Promise of DirectoryObjectCollectionResponse
*/
public get(requestConfiguration?: DirectReportsRequestBuilderGetRequestConfiguration | undefined, responseHandler?: ResponseHandler | undefined) : Promise<DirectoryObjectCollectionResponse | undefined> {
const requestInfo = this.createGetRequestInformation(
requestConfiguration
);
const errorMapping: Record<string, ParsableFactory<Parsable>> = {
"4XX": createODataErrorFromDiscriminatorValue,
"5XX": createODataErrorFromDiscriminatorValue,
};
return this.requestAdapter?.sendAsync<DirectoryObjectCollectionResponse>(requestInfo, createDirectoryObjectCollectionResponseFromDiscriminatorValue, responseHandler, errorMapping) ?? Promise.reject(new Error('http core is null'));
};
}
|
microsoftgraph/msgraph-sdk-typescript
|
src/me/directReports/directReportsRequestBuilder.ts
|
TypeScript
|
MethodDeclaration
|
/**
* The users and contacts that report to the user. (The users and contacts that have their manager property set to this user.) Read-only. Nullable. Supports $expand.
* @param requestConfiguration Configuration for the request such as headers, query parameters, and middleware options.
* @returns a RequestInformation
*/
public createGetRequestInformation(requestConfiguration?: DirectReportsRequestBuilderGetRequestConfiguration | undefined) : RequestInformation {
const requestInfo = new RequestInformation();
requestInfo.urlTemplate = this.urlTemplate;
requestInfo.pathParameters = this.pathParameters;
requestInfo.httpMethod = HttpMethod.GET;
if (requestConfiguration) {
requestInfo.addRequestHeaders(requestConfiguration.headers);
requestInfo.setQueryStringParametersFromRawObject(requestConfiguration.queryParameters);
requestInfo.addRequestOptions(requestConfiguration.options);
}
return requestInfo;
}
|
microsoftgraph/msgraph-sdk-typescript
|
src/me/directReports/directReportsRequestBuilder.ts
|
TypeScript
|
MethodDeclaration
|
/**
* The users and contacts that report to the user. (The users and contacts that have their manager property set to this user.) Read-only. Nullable. Supports $expand.
* @param requestConfiguration Configuration for the request such as headers, query parameters, and middleware options.
* @param responseHandler Response handler to use in place of the default response handling provided by the core service
* @returns a Promise of DirectoryObjectCollectionResponse
*/
public get(requestConfiguration?: DirectReportsRequestBuilderGetRequestConfiguration | undefined, responseHandler?: ResponseHandler | undefined) : Promise<DirectoryObjectCollectionResponse | undefined> {
const requestInfo = this.createGetRequestInformation(
requestConfiguration
);
const errorMapping: Record<string, ParsableFactory<Parsable>> = {
"4XX": createODataErrorFromDiscriminatorValue,
"5XX": createODataErrorFromDiscriminatorValue,
};
return this.requestAdapter?.sendAsync<DirectoryObjectCollectionResponse>(requestInfo, createDirectoryObjectCollectionResponseFromDiscriminatorValue, responseHandler, errorMapping) ?? Promise.reject(new Error('http core is null'));
}
|
microsoftgraph/msgraph-sdk-typescript
|
src/me/directReports/directReportsRequestBuilder.ts
|
TypeScript
|
ArrowFunction
|
() => {
const cursos = [];
if ( undefined === localStorage.getItem('exemploList') || null === localStorage.getItem('exemploList')
|| JSON.parse(localStorage.getItem('exemploList') )?.length === 0) {
for (let i = 0; i < 20; i++) {
cursos.push({
id: faker.random.number({min: 5, max: 100}),
titulo: 'Exemplo de ' + faker.lorem.words(2),
codigoReceita: '000-' + faker.random.number({min: 5, max: 100}),
objetivo: faker.lorem.words(6),
cargaHoraria: faker.random.number({min: 20, max: 60}),
valor: faker.finance.amount(100, 1000, 2, 'R$ '),
preRequisito: faker.random.words(4),
publicoAlvo: faker.random.words(1),
documentosObrigatorios: faker.random.words(4),
resultadoEsperado: faker.random.words(3),
conteudoProgramatico: faker.random.words(10),
modalidade: faker.lorem.words(1),
liberarComprarVoucher: faker.random.arrayElement(['sim', 'não']),
status: 'Ativo',
starred: null,
ano: '20' + faker.random.number({min: 10, max: 25})
});
}
}
return cursos;
}
|
paulotrc/AngularExemplo
|
exemplo-front-angular/src/app/common/helpers/fake-db/mocks/exemplo/ExemploMock.ts
|
TypeScript
|
ArrowFunction
|
(id) => {
return JSON.parse(localStorage.getItem('exemploList'))[id];
}
|
paulotrc/AngularExemplo
|
exemplo-front-angular/src/app/common/helpers/fake-db/mocks/exemplo/ExemploMock.ts
|
TypeScript
|
ClassDeclaration
|
export class ExemploMock {
public static itens = () => {
const cursos = [];
if ( undefined === localStorage.getItem('exemploList') || null === localStorage.getItem('exemploList')
|| JSON.parse(localStorage.getItem('exemploList') )?.length === 0) {
for (let i = 0; i < 20; i++) {
cursos.push({
id: faker.random.number({min: 5, max: 100}),
titulo: 'Exemplo de ' + faker.lorem.words(2),
codigoReceita: '000-' + faker.random.number({min: 5, max: 100}),
objetivo: faker.lorem.words(6),
cargaHoraria: faker.random.number({min: 20, max: 60}),
valor: faker.finance.amount(100, 1000, 2, 'R$ '),
preRequisito: faker.random.words(4),
publicoAlvo: faker.random.words(1),
documentosObrigatorios: faker.random.words(4),
resultadoEsperado: faker.random.words(3),
conteudoProgramatico: faker.random.words(10),
modalidade: faker.lorem.words(1),
liberarComprarVoucher: faker.random.arrayElement(['sim', 'não']),
status: 'Ativo',
starred: null,
ano: '20' + faker.random.number({min: 10, max: 25})
});
}
}
return cursos;
}
public static item = (id) => {
return JSON.parse(localStorage.getItem('exemploList'))[id];
}
}
|
paulotrc/AngularExemplo
|
exemplo-front-angular/src/app/common/helpers/fake-db/mocks/exemplo/ExemploMock.ts
|
TypeScript
|
ArrowFunction
|
({
dag,
tasks,
dagRuns,
isLoading,
errors,
}) => {
const formatCron = (cron: string) => (
cron[0] !== '@' ? cronstrue.toString(cron, { verbose: true }) : ''
);
return (
<DagContainer current="Overview">
{isLoading && (
<Text>Loading…</Text>
|
astronomer/airflow-ui
|
src/views/dag/index.tsx
|
TypeScript
|
ArrowFunction
|
(cron: string) => (
cron[0] !== '@' ? cronstrue.toString(cron, { verbose: true }) : ''
)
|
astronomer/airflow-ui
|
src/views/dag/index.tsx
|
TypeScript
|
ArrowFunction
|
(tag: DagTag) => (
<Tag key={tag.name}
|
astronomer/airflow-ui
|
src/views/dag/index.tsx
|
TypeScript
|
ArrowFunction
|
(dagRun: DagRunType) => (
<DagRun dagRun={dagRun}
|
astronomer/airflow-ui
|
src/views/dag/index.tsx
|
TypeScript
|
ArrowFunction
|
(task: Task) => (
<div key={task.taskId}>
<Button
m
|
astronomer/airflow-ui
|
src/views/dag/index.tsx
|
TypeScript
|
ArrowFunction
|
() => {
const { match: { params: { dagId } } }: RouterProps = useReactRouter();
const { data: dag, isLoading: dagLoading, error: dagError } = useDag(dagId);
const {
data: { tasks } = defaultTasks, isLoading: tasksLoading, error: tasksError,
} = useDagTasks(dagId);
const {
data: { dagRuns } = defaultDagRuns, isLoading: dagRunsLoading, error: dagRunsError,
} = useDagRuns(dagId);
if (!dag) return null;
return (
<MemoDag
dag={dag}
isLoading={dagLoading || dagRunsLoading || tasksLoading}
|
astronomer/airflow-ui
|
src/views/dag/index.tsx
|
TypeScript
|
InterfaceDeclaration
|
interface RouterProps {
match: { params: { dagId: DagType['dagId'] } }
}
|
astronomer/airflow-ui
|
src/views/dag/index.tsx
|
TypeScript
|
InterfaceDeclaration
|
interface DagProps {
dag: DagType;
tasks: Task[];
dagRuns: DagRunType[];
isLoading: boolean;
errors: (Error | null)[];
}
|
astronomer/airflow-ui
|
src/views/dag/index.tsx
|
TypeScript
|
MethodDeclaration
|
formatScheduleCode(dag
|
astronomer/airflow-ui
|
src/views/dag/index.tsx
|
TypeScript
|
ArrowFunction
|
({ children, defaultConfiguration }: Properties) => {
const [configuration, setConfig] = React.useState<any>({
// Domain specific configuration defaults
dashboard: null,
profileIsRestoring: false,
// Initial sync state of profile. Handled in profile synchronizer.
profileIsSyncing: true,
// Separate flag for exchange rate sync status. Updated by profile sync exchange job.
profileIsSyncingExchangeRates: false,
restoredProfiles: [],
...defaultConfiguration,
});
const setConfiguration = (config: any) => {
setConfig((latestConfig: any) => ({ ...latestConfig, ...config }));
};
return (
<ConfigurationContext.Provider value={{ ...configuration, setConfiguration } as ConfigurationContextType}
|
ArkEcosystem/ark-desktop
|
src/app/contexts/Configuration/Configuration.tsx
|
TypeScript
|
ArrowFunction
|
(config: any) => {
setConfig((latestConfig: any) => ({ ...latestConfig, ...config }));
}
|
ArkEcosystem/ark-desktop
|
src/app/contexts/Configuration/Configuration.tsx
|
TypeScript
|
ArrowFunction
|
(latestConfig: any) => ({ ...latestConfig, ...config })
|
ArkEcosystem/ark-desktop
|
src/app/contexts/Configuration/Configuration.tsx
|
TypeScript
|
ArrowFunction
|
() => {
const value = React.useContext(ConfigurationContext);
if (value === undefined) {
throw new Error("[useConfiguration] Component not wrapped within a Provider");
}
return value;
}
|
ArkEcosystem/ark-desktop
|
src/app/contexts/Configuration/Configuration.tsx
|
TypeScript
|
InterfaceDeclaration
|
interface ConfigurationContextType {
configuration: Record<string, any>;
setConfiguration: (configuration: Record<string, any>) => void;
}
|
ArkEcosystem/ark-desktop
|
src/app/contexts/Configuration/Configuration.tsx
|
TypeScript
|
InterfaceDeclaration
|
interface Properties {
children: React.ReactNode;
defaultConfiguration?: any;
}
|
ArkEcosystem/ark-desktop
|
src/app/contexts/Configuration/Configuration.tsx
|
TypeScript
|
ClassDeclaration
|
export default class MarkerComponent extends React.Component {
private scene: Scene;
public componentWillUnmount() {
this.scene.destroy();
}
public async componentDidMount() {
const response = await fetch(
'https://gw.alipayobjects.com/os/basement_prod/d2e0e930-fd44-4fca-8872-c1037b0fee7b.json',
);
const data = await response.json();
const scene = new Scene({
id: 'map',
map: new Mapbox({
style: 'dark',
center: [110.19382669582967, 30.258134],
pitch: 0,
zoom: 3,
}),
});
this.scene = scene;
const layer = new PolygonLayer({});
layer
.source(data)
.size('name', [0, 10000, 50000, 30000, 100000])
.color('name', [
'#2E8AE6',
'#69D1AB',
'#DAF291',
'#FFD591',
'#FF7A45',
'#CF1D49',
])
.shape('fill')
.style({
opacity: 0.3,
});
scene.addLayer(layer);
const marker = new Marker().setLnglat({
lng: 120.19382669582967,
lat: 30.258134,
});
scene.addMarker(marker);
}
public render() {
return (
<div
id="map"
style={{
position: 'absolute',
top: 0,
left: 0,
right: 0,
bottom: 0,
}}
|
Randysheng/L7
|
stories/Components/components/Marker.tsx
|
TypeScript
|
MethodDeclaration
|
public componentWillUnmount() {
this.scene.destroy();
}
|
Randysheng/L7
|
stories/Components/components/Marker.tsx
|
TypeScript
|
MethodDeclaration
|
public async componentDidMount() {
const response = await fetch(
'https://gw.alipayobjects.com/os/basement_prod/d2e0e930-fd44-4fca-8872-c1037b0fee7b.json',
);
const data = await response.json();
const scene = new Scene({
id: 'map',
map: new Mapbox({
style: 'dark',
center: [110.19382669582967, 30.258134],
pitch: 0,
zoom: 3,
}),
});
this.scene = scene;
const layer = new PolygonLayer({});
layer
.source(data)
.size('name', [0, 10000, 50000, 30000, 100000])
.color('name', [
'#2E8AE6',
'#69D1AB',
'#DAF291',
'#FFD591',
'#FF7A45',
'#CF1D49',
])
.shape('fill')
.style({
opacity: 0.3,
});
scene.addLayer(layer);
const marker = new Marker().setLnglat({
lng: 120.19382669582967,
lat: 30.258134,
});
scene.addMarker(marker);
}
|
Randysheng/L7
|
stories/Components/components/Marker.tsx
|
TypeScript
|
MethodDeclaration
|
public render() {
return (
<div
id="map"
style={{
position: 'absolute',
top: 0,
left: 0,
right: 0,
bottom: 0,
}}
|
Randysheng/L7
|
stories/Components/components/Marker.tsx
|
TypeScript
|
ArrowFunction
|
() => {
const [posts, setPosts] = useState<any>([]);
const [currentPage, setCurrentPage] = useState<number>(1);
const [hasNextPage, setHasNextPage] = useState<boolean>(false);
const [hasPreviousPage, setHasPreviousPage] = useState<boolean>(false);
useEffect(() => {
axios({
method: 'GET',
url: `${process.env.REACT_APP_GET_API}`,
params: {
Page: currentPage,
},
})
.then((res: any) => {
setPosts(res.data.data);
setCurrentPage(res.data.currentPage);
setHasNextPage(res.data.hasNextPage);
setHasPreviousPage(res.data.hasPreviousPage);
})
.catch((err: any) => {
console.log(err);
});
}, [currentPage, hasNextPage, hasPreviousPage]);
return (
<div>
<span className="flex justify-center mt-5 text-2xl font-semibold">
Posts
</span>
{posts.length === 0 && (
<div className="flex justify-center items-center font-bold text-3xl md:my-4">
No Posts Available
</div>
|
NVombat/MusicApp
|
client/src/components/Posts/Hero.tsx
|
TypeScript
|
ArrowFunction
|
() => {
axios({
method: 'GET',
url: `${process.env.REACT_APP_GET_API}`,
params: {
Page: currentPage,
},
})
.then((res: any) => {
setPosts(res.data.data);
setCurrentPage(res.data.currentPage);
setHasNextPage(res.data.hasNextPage);
setHasPreviousPage(res.data.hasPreviousPage);
})
.catch((err: any) => {
console.log(err);
});
}
|
NVombat/MusicApp
|
client/src/components/Posts/Hero.tsx
|
TypeScript
|
ArrowFunction
|
(res: any) => {
setPosts(res.data.data);
setCurrentPage(res.data.currentPage);
setHasNextPage(res.data.hasNextPage);
setHasPreviousPage(res.data.hasPreviousPage);
}
|
NVombat/MusicApp
|
client/src/components/Posts/Hero.tsx
|
TypeScript
|
ArrowFunction
|
(err: any) => {
console.log(err);
}
|
NVombat/MusicApp
|
client/src/components/Posts/Hero.tsx
|
TypeScript
|
ArrowFunction
|
(item, index) => (
<div key={index}
|
NVombat/MusicApp
|
client/src/components/Posts/Hero.tsx
|
TypeScript
|
ArrowFunction
|
() => setCurrentPage(currentPage - 1)
|
NVombat/MusicApp
|
client/src/components/Posts/Hero.tsx
|
TypeScript
|
ArrowFunction
|
() => setCurrentPage(currentPage + 1)
|
NVombat/MusicApp
|
client/src/components/Posts/Hero.tsx
|
TypeScript
|
InterfaceDeclaration
|
export interface HttpErrorCallback {
handleApiError(errorResponse: HttpErrorResponse): any;
}
|
formkiq/formkiq-console
|
src/app/services/api.service.ts
|
TypeScript
|
MethodDeclaration
|
getHttpOptions() {
return {
headers: new HttpHeaders({
Authorization: this.authenticationService.loggedInAccessToken
})
};
}
|
formkiq/formkiq-console
|
src/app/services/api.service.ts
|
TypeScript
|
MethodDeclaration
|
getAllDocuments(queryString: string, callback: HttpErrorCallback): Observable<{} | Document[]> {
return this.httpClient
.get<Document[]>(this.configurationService.apigateway.url + '/documents' + queryString, this.getHttpOptions())
.pipe(shareReplay(1),
catchError(callback.handleApiError));
}
|
formkiq/formkiq-console
|
src/app/services/api.service.ts
|
TypeScript
|
MethodDeclaration
|
getDocument(documentID: string, callback: HttpErrorCallback): Observable<{} | Document> {
return this.httpClient
.get<Document>(this.configurationService.apigateway.url + '/documents/' + documentID, this.getHttpOptions())
.pipe(shareReplay(1),
catchError(callback.handleApiError));
}
|
formkiq/formkiq-console
|
src/app/services/api.service.ts
|
TypeScript
|
MethodDeclaration
|
postDocument(json: string, callback: HttpErrorCallback): any {
const body = JSON.parse(json);
return this.httpClient
.post<Document>(this.configurationService.apigateway.url + '/documents', body, this.getHttpOptions())
.pipe(shareReplay(1),
catchError(callback.handleApiError));
}
|
formkiq/formkiq-console
|
src/app/services/api.service.ts
|
TypeScript
|
MethodDeclaration
|
patchDocument(documentID: string, json: string, callback: HttpErrorCallback): any {
const body = JSON.parse(json);
return this.httpClient
.patch<Document>(this.configurationService.apigateway.url + '/documents/' + documentID, body, this.getHttpOptions())
.pipe(shareReplay(1),
catchError(callback.handleApiError));
}
|
formkiq/formkiq-console
|
src/app/services/api.service.ts
|
TypeScript
|
MethodDeclaration
|
deleteDocument(documentID: string, callback: HttpErrorCallback): Observable<{} | Document> {
return this.httpClient
.delete<Document>(this.configurationService.apigateway.url + '/documents/' + documentID, this.getHttpOptions())
.pipe(shareReplay(1),
catchError(callback.handleApiError));
}
|
formkiq/formkiq-console
|
src/app/services/api.service.ts
|
TypeScript
|
MethodDeclaration
|
getDocumentTags(documentID: string, queryString: string, callback: HttpErrorCallback): Observable<{} | Array<Tag>> {
return this.httpClient
.get<Array<Tag>>(this.configurationService.apigateway.url + '/documents/' + documentID + '/tags' + queryString, this.getHttpOptions())
.pipe(shareReplay(1),
catchError(callback.handleApiError));
}
|
formkiq/formkiq-console
|
src/app/services/api.service.ts
|
TypeScript
|
MethodDeclaration
|
postDocumentTag(documentID: string, json: string, callback: HttpErrorCallback): Observable<any> {
const body = JSON.parse(json);
return this.httpClient
.post<Tag>(this.configurationService.apigateway.url + '/documents/' + documentID + '/tags', body, this.getHttpOptions())
.pipe(shareReplay(1),
catchError(callback.handleApiError));
}
|
formkiq/formkiq-console
|
src/app/services/api.service.ts
|
TypeScript
|
MethodDeclaration
|
getDocumentTag(documentID: string, key: string, callback: HttpErrorCallback): Observable<any> {
return this.httpClient
.get<Tag>(
this.configurationService.apigateway.url + '/documents/' + documentID + '/tags/' + encodeURIComponent(key), this.getHttpOptions()
)
.pipe(shareReplay(1),
catchError(callback.handleApiError));
}
|
formkiq/formkiq-console
|
src/app/services/api.service.ts
|
TypeScript
|
MethodDeclaration
|
deleteDocumentTag(documentID: string, key: string, callback: HttpErrorCallback): Observable<any> {
return this.httpClient
.delete<Tag>(
this.configurationService.apigateway.url + '/documents/' + documentID + '/tags/' + encodeURIComponent(key), this.getHttpOptions()
)
.pipe(shareReplay(1),
catchError(callback.handleApiError));
}
|
formkiq/formkiq-console
|
src/app/services/api.service.ts
|
TypeScript
|
MethodDeclaration
|
getDocumentUrl(documentID: string, queryString: string, callback: HttpErrorCallback): Observable<{} | string> {
return this.httpClient
.get<any>(this.configurationService.apigateway.url + '/documents/' + documentID + '/url' + queryString, this.getHttpOptions())
.pipe(shareReplay(1),
catchError(callback.handleApiError));
}
|
formkiq/formkiq-console
|
src/app/services/api.service.ts
|
TypeScript
|
MethodDeclaration
|
getDocumentContent(documentID: string, queryString: string, callback: HttpErrorCallback): Observable<any> {
return this.httpClient
.get<any>(this.configurationService.apigateway.url + '/documents/' + documentID + '/content' + queryString, this.getHttpOptions())
.pipe(shareReplay(1),
catchError(callback.handleApiError));
}
|
formkiq/formkiq-console
|
src/app/services/api.service.ts
|
TypeScript
|
MethodDeclaration
|
postDocumentFormat(documentID: string, json: string, callback: HttpErrorCallback): Observable<any> {
const body = JSON.parse(json);
return this.httpClient
.post<any>(this.configurationService.apigateway.url + '/documents/' + documentID + '/formats', body, this.getHttpOptions())
.pipe(shareReplay(1),
catchError(callback.handleApiError));
}
|
formkiq/formkiq-console
|
src/app/services/api.service.ts
|
TypeScript
|
MethodDeclaration
|
getDocumentVersions(documentID: string, callback: HttpErrorCallback): Observable<{} | string> {
return this.httpClient
.get<string>(this.configurationService.apigateway.url + '/documents/' + documentID + '/versions', this.getHttpOptions())
.pipe(shareReplay(1),
catchError(callback.handleApiError));
}
|
formkiq/formkiq-console
|
src/app/services/api.service.ts
|
TypeScript
|
MethodDeclaration
|
getDocumentsUpload(queryString: string, callback: HttpErrorCallback): Observable<{} | string> {
return this.httpClient
.get<string>(this.configurationService.apigateway.url + '/documents/upload' + queryString, this.getHttpOptions())
.pipe(shareReplay(1),
catchError(callback.handleApiError));
}
|
formkiq/formkiq-console
|
src/app/services/api.service.ts
|
TypeScript
|
MethodDeclaration
|
getDocumentUpload(documentID: string, queryString: string, callback: HttpErrorCallback): Observable<{} | string> {
return this.httpClient
.get<string>(this.configurationService.apigateway.url + '/documents/' + documentID + '/upload' + queryString, this.getHttpOptions())
.pipe(shareReplay(1),
catchError(callback.handleApiError));
}
|
formkiq/formkiq-console
|
src/app/services/api.service.ts
|
TypeScript
|
MethodDeclaration
|
postSearch(json: string, queryString: string, callback: HttpErrorCallback): Observable<{} | Document[]> {
const body = JSON.parse(json);
return this.httpClient
.post<Array<Document>>(this.configurationService.apigateway.url + '/search' + queryString, body, this.getHttpOptions())
.pipe(shareReplay(1),
catchError(callback.handleApiError));
}
|
formkiq/formkiq-console
|
src/app/services/api.service.ts
|
TypeScript
|
MethodDeclaration
|
getAllSites(queryString: string, callback: HttpErrorCallback): Observable<{} | Site[]> {
return this.httpClient
.get<Site[]>(this.configurationService.apigateway.url + '/sites' + queryString, this.getHttpOptions())
.pipe(shareReplay(1),
catchError(callback.handleApiError));
}
|
formkiq/formkiq-console
|
src/app/services/api.service.ts
|
TypeScript
|
MethodDeclaration
|
getAllPresets(queryString: string, callback: HttpErrorCallback): Observable<{} | Preset[]> {
return this.httpClient
.get<Preset[]>(this.configurationService.apigateway.url + '/presets' + queryString, this.getHttpOptions())
.pipe(shareReplay(1),
catchError(callback.handleApiError));
}
|
formkiq/formkiq-console
|
src/app/services/api.service.ts
|
TypeScript
|
MethodDeclaration
|
postPreset(json: string, callback: HttpErrorCallback): any {
const body = JSON.parse(json);
return this.httpClient
.post<Preset>(this.configurationService.apigateway.url + '/presets', body, this.getHttpOptions())
.pipe(shareReplay(1),
catchError(callback.handleApiError));
}
|
formkiq/formkiq-console
|
src/app/services/api.service.ts
|
TypeScript
|
MethodDeclaration
|
deletePreset(presetID: string, callback: HttpErrorCallback): Observable<{} | Preset> {
return this.httpClient
.delete<Preset>(this.configurationService.apigateway.url + '/presets/' + presetID, this.getHttpOptions())
.pipe(shareReplay(1),
catchError(callback.handleApiError));
}
|
formkiq/formkiq-console
|
src/app/services/api.service.ts
|
TypeScript
|
MethodDeclaration
|
getPresetTags(presetID: string, queryString: string, callback: HttpErrorCallback): Observable<{} | Array<Tag>> {
return this.httpClient
.get<Array<Tag>>(this.configurationService.apigateway.url + '/presets/' + presetID + '/tags' + queryString, this.getHttpOptions())
.pipe(shareReplay(1),
catchError(callback.handleApiError));
}
|
formkiq/formkiq-console
|
src/app/services/api.service.ts
|
TypeScript
|
MethodDeclaration
|
postPresetTag(presetID: string, json: string, callback: HttpErrorCallback): Observable<any> {
const body = JSON.parse(json);
return this.httpClient
.post<Tag>(this.configurationService.apigateway.url + '/presets/' + presetID + '/tags', body, this.getHttpOptions())
.pipe(shareReplay(1),
catchError(callback.handleApiError));
}
|
formkiq/formkiq-console
|
src/app/services/api.service.ts
|
TypeScript
|
MethodDeclaration
|
deletePresetTag(presetID: string, key: string, callback: HttpErrorCallback): Observable<any> {
return this.httpClient
.delete<Tag>(
this.configurationService.apigateway.url + '/presets/' + presetID + '/tags/' + encodeURIComponent(key), this.getHttpOptions()
)
.pipe(shareReplay(1),
catchError(callback.handleApiError));
}
|
formkiq/formkiq-console
|
src/app/services/api.service.ts
|
TypeScript
|
MethodDeclaration
|
getVersion(callback: HttpErrorCallback): Observable<any> {
return this.httpClient
.get<any>(
this.configurationService.apigateway.url + '/version', this.getHttpOptions()
)
.pipe(shareReplay(1),
catchError(callback.handleApiError));
}
|
formkiq/formkiq-console
|
src/app/services/api.service.ts
|
TypeScript
|
MethodDeclaration
|
getAllWebhooks(queryString: string, callback: HttpErrorCallback): Observable<{} | Webhook[]> {
return this.httpClient
.get<Webhook[]>(this.configurationService.apigateway.url + '/webhooks' + queryString, this.getHttpOptions())
.pipe(shareReplay(1),
catchError(callback.handleApiError));
}
|
formkiq/formkiq-console
|
src/app/services/api.service.ts
|
TypeScript
|
MethodDeclaration
|
postWebhook(json: string, callback: HttpErrorCallback): any {
const body = JSON.parse(json);
return this.httpClient
.post<Webhook>(this.configurationService.apigateway.url + '/webhooks', body, this.getHttpOptions())
.pipe(shareReplay(1),
catchError(callback.handleApiError));
}
|
formkiq/formkiq-console
|
src/app/services/api.service.ts
|
TypeScript
|
MethodDeclaration
|
deleteWebhook(webhookID: string, callback: HttpErrorCallback): any {
return this.httpClient
.delete<Webhook>(this.configurationService.apigateway.url + '/webhooks/' + webhookID, this.getHttpOptions())
.pipe(shareReplay(1),
catchError(callback.handleApiError));
}
|
formkiq/formkiq-console
|
src/app/services/api.service.ts
|
TypeScript
|
ClassDeclaration
|
export declare class TabBar implements ComponentInterface {
el: HTMLElement;
queue: QueueApi;
doc: Document;
keyboardVisible: boolean;
/**
* The mode determines which platform styles to use.
*/
mode: Mode;
/**
* The color to use from your application's color palette.
* Default options are: `"primary"`, `"secondary"`, `"tertiary"`, `"success"`, `"warning"`, `"danger"`, `"light"`, `"medium"`, and `"dark"`.
* For more information on colors, see [theming](/docs/theming/basics).
*/
color?: Color;
/**
* The selected tab component
*/
selectedTab?: string;
selectedTabChanged(): void;
/**
* If `true`, the tab bar will be translucent.
*/
translucent: boolean;
/** @internal */
ionTabBarChanged: EventEmitter<TabBarChangedEventDetail>;
protected onKeyboardWillHide(): void;
protected onKeyboardWillShow(): void;
componentWillLoad(): void;
hostData(): {
'role': string;
'aria-hidden': string | null;
class: {
'tab-bar-translucent': boolean;
'tab-bar-hidden': boolean;
} | {
[x: string]: boolean;
'tab-bar-translucent': boolean;
'tab-bar-hidden': boolean;
};
};
render(): JSX.Element;
}
|
Ignacio1224/FMS-Frontend
|
node_modules/@ionic/core/dist/types/components/tab-bar/tab-bar.d.ts
|
TypeScript
|
MethodDeclaration
|
selectedTabChanged(): void;
|
Ignacio1224/FMS-Frontend
|
node_modules/@ionic/core/dist/types/components/tab-bar/tab-bar.d.ts
|
TypeScript
|
MethodDeclaration
|
protected onKeyboardWillHide(): void;
|
Ignacio1224/FMS-Frontend
|
node_modules/@ionic/core/dist/types/components/tab-bar/tab-bar.d.ts
|
TypeScript
|
MethodDeclaration
|
protected onKeyboardWillShow(): void;
|
Ignacio1224/FMS-Frontend
|
node_modules/@ionic/core/dist/types/components/tab-bar/tab-bar.d.ts
|
TypeScript
|
MethodDeclaration
|
componentWillLoad(): void;
|
Ignacio1224/FMS-Frontend
|
node_modules/@ionic/core/dist/types/components/tab-bar/tab-bar.d.ts
|
TypeScript
|
MethodDeclaration
|
hostData(): {
'role': string;
'aria-hidden': string | null;
class: {
'tab-bar-translucent': boolean;
'tab-bar-hidden': boolean;
} | {
[x: string]: boolean;
'tab-bar-translucent': boolean;
'tab-bar-hidden': boolean;
};
};
|
Ignacio1224/FMS-Frontend
|
node_modules/@ionic/core/dist/types/components/tab-bar/tab-bar.d.ts
|
TypeScript
|
ClassDeclaration
|
export class Attendance {
attendance_id: number;
status: string;
in_time: any;
out_time: any;
date_of_attendance: string;
employees_id: number;
}
|
amalikh/frontend-ems-netlify
|
src/app/layout/attendance/attendace.model.ts
|
TypeScript
|
InterfaceDeclaration
|
interface utilisateur
|
9550327/salus
|
src/qt/locale/bitcoin_fr.ts
|
TypeScript
|
InterfaceDeclaration
|
interface de
|
9550327/salus
|
src/qt/locale/bitcoin_fr.ts
|
TypeScript
|
InterfaceDeclaration
|
interface et
|
9550327/salus
|
src/qt/locale/bitcoin_fr.ts
|
TypeScript
|
FunctionDeclaration
|
async function readJsonFile<T>(pathToFile: string): Promise<T | undefined> {
try {
await fs.access(pathToFile)
const contents = await fs.readFile(pathToFile, {encoding: 'utf-8'})
return JSON.parse(contents) as T
} catch {
return undefined
}
}
|
nessjs/ness
|
src/utils/next.ts
|
TypeScript
|
FunctionDeclaration
|
function zipDirectory(directory: string, outputFile: string): Promise<string> {
return new Promise(async (resolve, reject) => {
// The below options are needed to support following symlinks when building zip files:
// - nodir: This will prevent symlinks themselves from being copied into the zip.
// - follow: This will follow symlinks and copy the files within.
const globOptions = {
dot: true,
nodir: true,
follow: true,
cwd: directory,
}
const files = glob.sync('**', globOptions) // The output here is already sorted
const shasum = crypto.createHash('sha256')
const output = fs.createWriteStream(outputFile)
const archive = archiver('zip')
archive.on('warning', reject)
archive.on('error', reject)
archive.on('data', (data) => {
shasum.update(data)
})
// archive has been finalized and the output file descriptor has closed, resolve promise
// this has to be done before calling `finalize` since the events may fire immediately after.
// see https://www.npmjs.com/package/archiver
output.once('close', () => {
const hash = shasum.digest('hex')
resolve(hash)
})
archive.pipe(output)
// Append files serially to ensure file order
for (const file of files) {
const fullPath = path.resolve(directory, file)
const [data, stat] = await Promise.all([fs.readFile(fullPath), fs.stat(fullPath)])
archive.append(data, {
name: file,
mode: stat.mode,
})
}
await archive.finalize()
})
}
|
nessjs/ness
|
src/utils/next.ts
|
TypeScript
|
ArrowFunction
|
(config: CacheConfig) => {
return Object.keys(config).reduce(
(newConfig, nextConfigKey) => ({
...newConfig,
...(fs.pathExistsSync(config[nextConfigKey].path)
? {[nextConfigKey]: config[nextConfigKey]}
: {}),
}),
{} as CacheConfig,
)
}
|
nessjs/ness
|
src/utils/next.ts
|
TypeScript
|
ArrowFunction
|
(newConfig, nextConfigKey) => ({
...newConfig,
...(fs.pathExistsSync(config[nextConfigKey].path)
? {[nextConfigKey]: config[nextConfigKey]}
: {}),
})
|
nessjs/ness
|
src/utils/next.ts
|
TypeScript
|
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.