type
stringclasses 7
values | content
stringlengths 4
9.55k
| repo
stringlengths 7
96
| path
stringlengths 4
178
| language
stringclasses 1
value |
---|---|---|---|---|
MethodDeclaration |
public getUserInfo() {
let info = this.getLocalStorageToken();
if (info) { return { id: info["session_id"], username: info["username"], name: info["name"] }; }
} | PauloHenriqueFernandesAraujo/AngularMaterializeStruct | src/app/generic/services/communication.service.ts | TypeScript |
MethodDeclaration |
private getLocalStorageToken() {
let local = localStorage.getItem(Constants.STORAGE_USER_SESSION);
if (isNullOrUndefined(local)) return null;
let obj = JSON.parse(local);
if (isNullOrUndefined(obj)) return null;
return obj;
} | PauloHenriqueFernandesAraujo/AngularMaterializeStruct | src/app/generic/services/communication.service.ts | TypeScript |
MethodDeclaration |
private errorValidate(result: any) {
if (!result.success) {
if (!isNullOrUndefined(result.modelState)) {
if (result.modelState.message == "USR_LOGIN") { this.router.navigate(['/entrar']); }
//adicionar demais erros aqui
}
}
} | PauloHenriqueFernandesAraujo/AngularMaterializeStruct | src/app/generic/services/communication.service.ts | TypeScript |
ClassDeclaration |
@Component({
selector: "ngx-powerbi-component",
template: '<div #ngxPowerBiIFrame style="height:100%; width: 100%;"></div>',
styles: [],
})
export class NgxPowerBiComponent
implements AfterViewInit, OnChanges, OnDestroy
{
// Public properties
@Input() accessToken: string;
@Input() tokenType: TokenType;
@Input() embedUrl: string;
@Input() id: string;
@Input() type: ReportType;
@Input() name: string;
@Input() viewMode: number = models.ViewMode.View;
@Input() options: models.ISettings;
@Output() embedded = new EventEmitter<number>();
@ViewChild("ngxPowerBiIFrame", { static: true })
ngxPowerBiIFrameRef: ElementRef;
// Private fields
private component: pbi.Embed;
private powerBiService: NgxPowerBiService;
constructor(private ngxPowerBiService: NgxPowerBiService) {
this.powerBiService = ngxPowerBiService;
}
ngAfterViewInit() {
// Embed the report inside the view child that we have fetched from the DOM
if (
this.ngxPowerBiIFrameRef.nativeElement &&
this.validateRequiredAttributes()
) {
this.embed(this.ngxPowerBiIFrameRef.nativeElement, this.getConfig());
}
}
ngOnChanges(changes: SimpleChanges) {
if (!this.ngxPowerBiIFrameRef) {
return;
}
const {
accessToken,
tokenType,
embedUrl,
id,
type,
name,
options,
viewMode,
} = changes;
// TODO: Validate these conditions
/*if (
(accessToken.previousValue !== undefined || accessToken.previousValue === accessToken.currentValue) &&
embedUrl.previousValue === embedUrl.currentValue
) {
return;
}*/
if (this.validateRequiredAttributes()) {
const config = this.getConfig(
accessToken && accessToken.currentValue,
tokenType && tokenType.currentValue,
embedUrl && embedUrl.currentValue,
id && id.currentValue,
type && type.currentValue,
name && name.currentValue,
options && options.currentValue,
viewMode && viewMode.currentValue
);
this.embed(this.ngxPowerBiIFrameRef.nativeElement, config);
} else if (this.component) {
this.reset(this.ngxPowerBiIFrameRef.nativeElement);
}
}
ngOnDestroy() {
if (this.component) {
this.reset(this.ngxPowerBiIFrameRef.nativeElement);
}
}
/**
* Ensure required attributes (embedUrl and accessToken are valid before attempting to embed)
*/
private validateRequiredAttributes(): boolean {
return (
typeof this.embedUrl === "string" &&
this.embedUrl.length > 0 &&
typeof this.accessToken === "string" &&
this.accessToken.length > 0
);
}
/**
* Get the model class compatible token enum from our token type enum
* @param tokenType - Token type in our custom enum format
* @returns Token type in powerbi-models.TokenType enum format
*/
private getTokenType(tokenType: TokenType): models.TokenType {
if (tokenType) {
switch (tokenType) {
case TokenType.Aad:
return models.TokenType.Aad;
case TokenType.Embed:
return models.TokenType.Embed;
default:
return models.TokenType.Aad;
}
} else {
// default is AAD
return models.TokenType.Aad;
}
}
/**
* Returns an embed configuration object.
* @param accessToken - Access token required to embed a component
* @param tokenType - type of accessToken: Aad or Embed
* @param embedUrl - Embed URL obtained through Power BI REST API or Portal
* @param id - component/element GUID
* @param type - type of embedded component e.g. 'dashboard, report or tile'
* @param name - name of the embedded component
* @param options - Embed configuration options
* @returns Embed configuration object
*/
private getConfig(
accessToken?: string,
tokenType?: TokenType,
embedUrl?: string,
id?: string,
type?: ReportType,
name?: string,
options?: models.ISettings,
viewMode?: models.ViewMode
): pbi.IEmbedConfiguration {
// For null arguments - use the initial value
// For specified arguments - use the current value
return {
type: type ? type : this.type ? this.type : ReportType.Report,
embedUrl: embedUrl ? embedUrl : this.embedUrl,
accessToken: accessToken ? accessToken : this.accessToken,
tokenType: tokenType
? this.getTokenType(tokenType)
: this.getTokenType(this.tokenType),
id: id ? id : this.id,
uniqueId: name ? name : this.name,
viewMode: viewMode ? viewMode : this.viewMode,
settings: options ? options : this.options,
};
}
/**
* Given an HTMLElement, construct an embed configuration based on attributes and pass to service.
* @param element - native element where the embedding needs to be done
* @param config - configuration to be embedded
*/
private embed(element: HTMLElement, config: pbi.IEmbedConfiguration) {
/*if (this.options) {
const newConfig = { config, ...this.options };
}*/
this.component = this.powerBiService.embed(element, config);
this.embedded.emit(this.component as any);
}
/**
* Reset the component that has been removed from DOM.
* @param element - native element where the embedded was made
*/
reset(element: HTMLElement) {
this.powerBiService.reset(element);
this.component = null;
}
} | fanil-kashapov/ngx-powerbi | projects/ngx-powerbi/src/lib/ngx-powerbi.component.ts | TypeScript |
EnumDeclaration |
export const enum TokenType {
Aad = "Aad",
Embed = "Embed",
} | fanil-kashapov/ngx-powerbi | projects/ngx-powerbi/src/lib/ngx-powerbi.component.ts | TypeScript |
EnumDeclaration |
export const enum ReportType {
Dashboard = "Dashboard",
Report = "Report",
Tile = "Tile",
} | fanil-kashapov/ngx-powerbi | projects/ngx-powerbi/src/lib/ngx-powerbi.component.ts | TypeScript |
MethodDeclaration |
ngAfterViewInit() {
// Embed the report inside the view child that we have fetched from the DOM
if (
this.ngxPowerBiIFrameRef.nativeElement &&
this.validateRequiredAttributes()
) {
this.embed(this.ngxPowerBiIFrameRef.nativeElement, this.getConfig());
}
} | fanil-kashapov/ngx-powerbi | projects/ngx-powerbi/src/lib/ngx-powerbi.component.ts | TypeScript |
MethodDeclaration |
ngOnChanges(changes: SimpleChanges) {
if (!this.ngxPowerBiIFrameRef) {
return;
}
const {
accessToken,
tokenType,
embedUrl,
id,
type,
name,
options,
viewMode,
} = changes;
// TODO: Validate these conditions
/*if (
(accessToken.previousValue !== undefined || accessToken.previousValue === accessToken.currentValue) &&
embedUrl.previousValue === embedUrl.currentValue
) {
return;
}*/
if (this.validateRequiredAttributes()) {
const config = this.getConfig(
accessToken && accessToken.currentValue,
tokenType && tokenType.currentValue,
embedUrl && embedUrl.currentValue,
id && id.currentValue,
type && type.currentValue,
name && name.currentValue,
options && options.currentValue,
viewMode && viewMode.currentValue
);
this.embed(this.ngxPowerBiIFrameRef.nativeElement, config);
} else if (this.component) {
this.reset(this.ngxPowerBiIFrameRef.nativeElement);
}
} | fanil-kashapov/ngx-powerbi | projects/ngx-powerbi/src/lib/ngx-powerbi.component.ts | TypeScript |
MethodDeclaration |
ngOnDestroy() {
if (this.component) {
this.reset(this.ngxPowerBiIFrameRef.nativeElement);
}
} | fanil-kashapov/ngx-powerbi | projects/ngx-powerbi/src/lib/ngx-powerbi.component.ts | TypeScript |
MethodDeclaration | /**
* Ensure required attributes (embedUrl and accessToken are valid before attempting to embed)
*/
private validateRequiredAttributes(): boolean {
return (
typeof this.embedUrl === "string" &&
this.embedUrl.length > 0 &&
typeof this.accessToken === "string" &&
this.accessToken.length > 0
);
} | fanil-kashapov/ngx-powerbi | projects/ngx-powerbi/src/lib/ngx-powerbi.component.ts | TypeScript |
MethodDeclaration | /**
* Get the model class compatible token enum from our token type enum
* @param tokenType - Token type in our custom enum format
* @returns Token type in powerbi-models.TokenType enum format
*/
private getTokenType(tokenType: TokenType): models.TokenType {
if (tokenType) {
switch (tokenType) {
case TokenType.Aad:
return models.TokenType.Aad;
case TokenType.Embed:
return models.TokenType.Embed;
default:
return models.TokenType.Aad;
}
} else {
// default is AAD
return models.TokenType.Aad;
}
} | fanil-kashapov/ngx-powerbi | projects/ngx-powerbi/src/lib/ngx-powerbi.component.ts | TypeScript |
MethodDeclaration | /**
* Returns an embed configuration object.
* @param accessToken - Access token required to embed a component
* @param tokenType - type of accessToken: Aad or Embed
* @param embedUrl - Embed URL obtained through Power BI REST API or Portal
* @param id - component/element GUID
* @param type - type of embedded component e.g. 'dashboard, report or tile'
* @param name - name of the embedded component
* @param options - Embed configuration options
* @returns Embed configuration object
*/
private getConfig(
accessToken?: string,
tokenType?: TokenType,
embedUrl?: string,
id?: string,
type?: ReportType,
name?: string,
options?: models.ISettings,
viewMode?: models.ViewMode
): pbi.IEmbedConfiguration {
// For null arguments - use the initial value
// For specified arguments - use the current value
return {
type: type ? type : this.type ? this.type : ReportType.Report,
embedUrl: embedUrl ? embedUrl : this.embedUrl,
accessToken: accessToken ? accessToken : this.accessToken,
tokenType: tokenType
? this.getTokenType(tokenType)
: this.getTokenType(this.tokenType),
id: id ? id : this.id,
uniqueId: name ? name : this.name,
viewMode: viewMode ? viewMode : this.viewMode,
settings: options ? options : this.options,
};
} | fanil-kashapov/ngx-powerbi | projects/ngx-powerbi/src/lib/ngx-powerbi.component.ts | TypeScript |
MethodDeclaration | /**
* Given an HTMLElement, construct an embed configuration based on attributes and pass to service.
* @param element - native element where the embedding needs to be done
* @param config - configuration to be embedded
*/
private embed(element: HTMLElement, config: pbi.IEmbedConfiguration) {
/*if (this.options) {
const newConfig = { config, ...this.options };
}*/
this.component = this.powerBiService.embed(element, config);
this.embedded.emit(this.component as any);
} | fanil-kashapov/ngx-powerbi | projects/ngx-powerbi/src/lib/ngx-powerbi.component.ts | TypeScript |
MethodDeclaration | /**
* Reset the component that has been removed from DOM.
* @param element - native element where the embedded was made
*/
reset(element: HTMLElement) {
this.powerBiService.reset(element);
this.component = null;
} | fanil-kashapov/ngx-powerbi | projects/ngx-powerbi/src/lib/ngx-powerbi.component.ts | TypeScript |
ArrowFunction |
() => {
let component: PresupuestoContainerComponent;
let fixture: ComponentFixture<PresupuestoContainerComponent>;
beforeEach(async(() => {
TestBed.configureTestingModule({
declarations: [ PresupuestoContainerComponent ]
})
.compileComponents();
}));
beforeEach(() => {
fixture = TestBed.createComponent(PresupuestoContainerComponent);
component = fixture.componentInstance;
fixture.detectChanges();
});
it('should create', () => {
expect(component).toBeTruthy();
});
} | noetipo/SB-Admin-BS4-Angular-6 | src/app/layout/partida/presupuesto-container/presupuesto-container.component.spec.ts | TypeScript |
ArrowFunction |
() => {
TestBed.configureTestingModule({
declarations: [ PresupuestoContainerComponent ]
})
.compileComponents();
} | noetipo/SB-Admin-BS4-Angular-6 | src/app/layout/partida/presupuesto-container/presupuesto-container.component.spec.ts | TypeScript |
ArrowFunction |
() => {
fixture = TestBed.createComponent(PresupuestoContainerComponent);
component = fixture.componentInstance;
fixture.detectChanges();
} | noetipo/SB-Admin-BS4-Angular-6 | src/app/layout/partida/presupuesto-container/presupuesto-container.component.spec.ts | TypeScript |
ArrowFunction |
(lang: string): void => {
document.querySelector("html")?.setAttribute("lang", lang);
const defaultVariables = defaultVars[lang] || defaultVars.en;
if (i18next.options.interpolation) {
i18next.options.interpolation.defaultVariables = defaultVariables;
} else {
i18next.options.interpolation = { defaultVariables };
}
} | kongkang/flat | desktop/renderer-app/src/utils/i18n.ts | TypeScript |
FunctionDeclaration |
function SvgCat(props: React.SVGProps<SVGSVGElement>) {
return (
<svg
data-name='Layer 3'
xmlns='http://www.w3.org/2000/svg'
viewBox='0 0 24 24'
width='1em'
height='1em'
{...props}
>
<path
d='M15.074 6.42l2.389-2.047A1.537 1.537 0 0120 5.54V13a8 8 0 01-8 8h0a8 8 0 01-8-8V5.54a1.537 1.537 0 012.537-1.167l2.389 2.046a9.223 9.223 0 016.148 0z'
fill='none'
stroke='currentColor'
strokeLinecap='round'
strokeLinejoin='round'
strokeWidth={1.5}
/>
<path
d='M10.25 10.75a.25.25 0 11-.25-.25.25.25 0 01.25.25M14.25 10.75a.25.25 0 11-.25-.25.25.25 0 01.25.25M12 14.5h0a.5.5 0 01-.5-.5h0a.167.167 0 01.167-.167h.666A.167.167 0 0112.5 14h0a.5.5 0 01-.5.5zM9.813 17.125a1.277 1.277 0 00.906.375h0A1.281 1.281 0 0012 16.219a1.281 1.281 0 002.187.906M12 14.5v1.719M17 12.807l4-.667M21 16l-4-.667M7 12.807l-4-.667M3 16l4-.667'
fill='none'
stroke='currentColor'
strokeLinecap='round'
strokeLinejoin='round'
strokeWidth={1.5}
/>
<path fill='none' d='M0 0h24v24H0z' />
</svg>
)
} | ProNoob702/suivi-icons | src/icons/Cat.tsx | TypeScript |
ArrowFunction |
() => {
store = createStore(clone(wpSource()));
store.state.source.api = "https://test.frontity.org/wp-json";
store.actions.source.init();
api = store.libraries.source.api as jest.Mocked<Api>;
} | kbav/frontity | packages/wp-source/src/libraries/handlers/__tests__/post-type.tests.ts | TypeScript |
ArrowFunction |
() => {
test("returns 404 if not found", async () => {
// Mock Api responses
// We have to use this form instead of:
// .mockResolvedValueOnce(mockResponse([]))
// because the latter always returns the same instance of Response.
// which results in error because response.json() can only be run once
api.get = jest.fn((_) => Promise.resolve(mockResponse([])));
// Fetch entities
await store.actions.source.fetch("/non-existent/");
expect(api.get).toHaveBeenCalledTimes(3);
expect(store.state.source).toMatchSnapshot();
});
test("should contain the correct error code on error", async () => {
// Mock Api responses
api.get = jest.fn(async (_) => {
throw new ServerError("statusText", 400, "statusText");
});
// Fetch entities
await store.actions.source.fetch("/post-1/");
expect(store.state.source.data["/post-1/"].isError).toBe(true);
expect(store.state.source.data["/post-1/"]["is400"]).toBe(true);
expect(store.state.source).toMatchSnapshot();
});
} | kbav/frontity | packages/wp-source/src/libraries/handlers/__tests__/post-type.tests.ts | TypeScript |
ArrowFunction |
async () => {
// Mock Api responses
// We have to use this form instead of:
// .mockResolvedValueOnce(mockResponse([]))
// because the latter always returns the same instance of Response.
// which results in error because response.json() can only be run once
api.get = jest.fn((_) => Promise.resolve(mockResponse([])));
// Fetch entities
await store.actions.source.fetch("/non-existent/");
expect(api.get).toHaveBeenCalledTimes(3);
expect(store.state.source).toMatchSnapshot();
} | kbav/frontity | packages/wp-source/src/libraries/handlers/__tests__/post-type.tests.ts | TypeScript |
ArrowFunction |
(_) => Promise.resolve(mockResponse([])) | kbav/frontity | packages/wp-source/src/libraries/handlers/__tests__/post-type.tests.ts | TypeScript |
ArrowFunction |
async () => {
// Mock Api responses
api.get = jest.fn(async (_) => {
throw new ServerError("statusText", 400, "statusText");
});
// Fetch entities
await store.actions.source.fetch("/post-1/");
expect(store.state.source.data["/post-1/"].isError).toBe(true);
expect(store.state.source.data["/post-1/"]["is400"]).toBe(true);
expect(store.state.source).toMatchSnapshot();
} | kbav/frontity | packages/wp-source/src/libraries/handlers/__tests__/post-type.tests.ts | TypeScript |
ArrowFunction |
async (_) => {
throw new ServerError("statusText", 400, "statusText");
} | kbav/frontity | packages/wp-source/src/libraries/handlers/__tests__/post-type.tests.ts | TypeScript |
ArrowFunction |
() => {
test("doesn't exist in source.post", async () => {
// Mock Api responses
api.get = jest.fn().mockResolvedValueOnce(mockResponse([post1]));
// Fetch entities
await store.actions.source.fetch("/post-1/");
expect(store.state.source).toMatchSnapshot();
});
test("exists in source.post", async () => {
// Add post to the store
await store.libraries.source.populate({
state: store.state,
response: mockResponse(post1),
});
// Mock Api responses
api.get = jest.fn();
// Fetch entities
await store.actions.source.fetch("/post-1/");
expect(api.get).not.toHaveBeenCalled();
expect(store.state.source).toMatchSnapshot();
});
test("fetchs from a different endpoint with extra params", async () => {
// Add custom post endpoint and params
store.state.source.postEndpoint = "multiple-post-type";
store.state.source.params = { type: ["post", "cpt"] };
// Mock Api responses
api.get = jest.fn().mockResolvedValueOnce(mockResponse([cpt11]));
// Fetch entities
await store.actions.source.fetch("/cpt/cpt-11");
expect(api.get.mock.calls).toMatchSnapshot();
expect(store.state.source).toMatchSnapshot();
});
test("works with query params (doesn't exist in source.post)", async () => {
// Mock Api responses
api.get = jest.fn().mockResolvedValueOnce(mockResponse([post1]));
// Fetch entities
await store.actions.source.fetch("/post-1/?some=param");
expect(store.state.source).toMatchSnapshot();
});
test("works with query params (exists in source.post)", async () => {
// Add post to the store
await store.libraries.source.populate({
state: store.state,
response: mockResponse(post1),
});
// Mock Api responses
api.get = jest.fn();
// Fetch entities
await store.actions.source.fetch("/post-1/?some=param");
expect(api.get).not.toHaveBeenCalled();
expect(store.state.source).toMatchSnapshot();
});
test("works with types embedded", async () => {
// Mock Api responses
api.get = jest.fn().mockResolvedValueOnce(mockResponse([post1withType]));
// Fetch entities
await store.actions.source.fetch("/post-1/");
expect(store.state.source).toMatchSnapshot();
});
} | kbav/frontity | packages/wp-source/src/libraries/handlers/__tests__/post-type.tests.ts | TypeScript |
ArrowFunction |
async () => {
// Mock Api responses
api.get = jest.fn().mockResolvedValueOnce(mockResponse([post1]));
// Fetch entities
await store.actions.source.fetch("/post-1/");
expect(store.state.source).toMatchSnapshot();
} | kbav/frontity | packages/wp-source/src/libraries/handlers/__tests__/post-type.tests.ts | TypeScript |
ArrowFunction |
async () => {
// Add post to the store
await store.libraries.source.populate({
state: store.state,
response: mockResponse(post1),
});
// Mock Api responses
api.get = jest.fn();
// Fetch entities
await store.actions.source.fetch("/post-1/");
expect(api.get).not.toHaveBeenCalled();
expect(store.state.source).toMatchSnapshot();
} | kbav/frontity | packages/wp-source/src/libraries/handlers/__tests__/post-type.tests.ts | TypeScript |
ArrowFunction |
async () => {
// Add custom post endpoint and params
store.state.source.postEndpoint = "multiple-post-type";
store.state.source.params = { type: ["post", "cpt"] };
// Mock Api responses
api.get = jest.fn().mockResolvedValueOnce(mockResponse([cpt11]));
// Fetch entities
await store.actions.source.fetch("/cpt/cpt-11");
expect(api.get.mock.calls).toMatchSnapshot();
expect(store.state.source).toMatchSnapshot();
} | kbav/frontity | packages/wp-source/src/libraries/handlers/__tests__/post-type.tests.ts | TypeScript |
ArrowFunction |
async () => {
// Mock Api responses
api.get = jest.fn().mockResolvedValueOnce(mockResponse([post1]));
// Fetch entities
await store.actions.source.fetch("/post-1/?some=param");
expect(store.state.source).toMatchSnapshot();
} | kbav/frontity | packages/wp-source/src/libraries/handlers/__tests__/post-type.tests.ts | TypeScript |
ArrowFunction |
async () => {
// Add post to the store
await store.libraries.source.populate({
state: store.state,
response: mockResponse(post1),
});
// Mock Api responses
api.get = jest.fn();
// Fetch entities
await store.actions.source.fetch("/post-1/?some=param");
expect(api.get).not.toHaveBeenCalled();
expect(store.state.source).toMatchSnapshot();
} | kbav/frontity | packages/wp-source/src/libraries/handlers/__tests__/post-type.tests.ts | TypeScript |
ArrowFunction |
async () => {
// Mock Api responses
api.get = jest.fn().mockResolvedValueOnce(mockResponse([post1withType]));
// Fetch entities
await store.actions.source.fetch("/post-1/");
expect(store.state.source).toMatchSnapshot();
} | kbav/frontity | packages/wp-source/src/libraries/handlers/__tests__/post-type.tests.ts | TypeScript |
ArrowFunction |
() => {
test("doesn't exist in source.page", async () => {
// Mock Api responses
api.get = jest
.fn()
.mockResolvedValueOnce(mockResponse([]))
.mockResolvedValueOnce(mockResponse([page1]));
// Fetch entities
await store.actions.source.fetch("/page-1/");
expect(store.state.source).toMatchSnapshot();
});
test("exists in source.page", async () => {
// Add page to the store
await store.libraries.source.populate({
state: store.state,
response: mockResponse(page1),
});
// Mock Api responses
api.get = jest.fn().mockResolvedValueOnce(mockResponse([]));
// Fetch entities
await store.actions.source.fetch("/page-1/");
expect(api.get).toHaveBeenCalledTimes(0);
expect(store.state.source).toMatchSnapshot();
});
test("works with query params (doesn't exist in source.page)", async () => {
// Mock Api responses
api.get = jest
.fn()
.mockResolvedValueOnce(mockResponse([]))
.mockResolvedValueOnce(mockResponse([page1]));
// Fetch entities
await store.actions.source.fetch("/page-1/?some=param");
expect(store.state.source).toMatchSnapshot();
});
test("works with query params (exists in source.page)", async () => {
// Add page to the store
await store.libraries.source.populate({
state: store.state,
response: mockResponse(page1),
});
// Mock Api responses
api.get = jest.fn().mockResolvedValueOnce(mockResponse([]));
// Fetch entities
await store.actions.source.fetch("/page-1/?some=param");
expect(api.get).toHaveBeenCalledTimes(0);
expect(store.state.source).toMatchSnapshot();
});
} | kbav/frontity | packages/wp-source/src/libraries/handlers/__tests__/post-type.tests.ts | TypeScript |
ArrowFunction |
async () => {
// Mock Api responses
api.get = jest
.fn()
.mockResolvedValueOnce(mockResponse([]))
.mockResolvedValueOnce(mockResponse([page1]));
// Fetch entities
await store.actions.source.fetch("/page-1/");
expect(store.state.source).toMatchSnapshot();
} | kbav/frontity | packages/wp-source/src/libraries/handlers/__tests__/post-type.tests.ts | TypeScript |
ArrowFunction |
async () => {
// Add page to the store
await store.libraries.source.populate({
state: store.state,
response: mockResponse(page1),
});
// Mock Api responses
api.get = jest.fn().mockResolvedValueOnce(mockResponse([]));
// Fetch entities
await store.actions.source.fetch("/page-1/");
expect(api.get).toHaveBeenCalledTimes(0);
expect(store.state.source).toMatchSnapshot();
} | kbav/frontity | packages/wp-source/src/libraries/handlers/__tests__/post-type.tests.ts | TypeScript |
ArrowFunction |
async () => {
// Mock Api responses
api.get = jest
.fn()
.mockResolvedValueOnce(mockResponse([]))
.mockResolvedValueOnce(mockResponse([page1]));
// Fetch entities
await store.actions.source.fetch("/page-1/?some=param");
expect(store.state.source).toMatchSnapshot();
} | kbav/frontity | packages/wp-source/src/libraries/handlers/__tests__/post-type.tests.ts | TypeScript |
ArrowFunction |
async () => {
// Add page to the store
await store.libraries.source.populate({
state: store.state,
response: mockResponse(page1),
});
// Mock Api responses
api.get = jest.fn().mockResolvedValueOnce(mockResponse([]));
// Fetch entities
await store.actions.source.fetch("/page-1/?some=param");
expect(api.get).toHaveBeenCalledTimes(0);
expect(store.state.source).toMatchSnapshot();
} | kbav/frontity | packages/wp-source/src/libraries/handlers/__tests__/post-type.tests.ts | TypeScript |
ArrowFunction |
() => {
test("doesn't exist in source.attachment", async () => {
// Mock Api responses
api.get = jest
.fn()
.mockResolvedValueOnce(mockResponse([]))
.mockResolvedValueOnce(mockResponse([attachment1]));
// Fetch entities
await store.actions.source.fetch("/post-1/attachment-1/");
expect(store.state.source).toMatchSnapshot();
});
test("exists in source.attachment", async () => {
// Add attachment to the store
await store.libraries.source.populate({
state: store.state,
response: mockResponse(attachment1),
});
// Mock Api responses
api.get = jest.fn().mockResolvedValue(mockResponse([]));
// Fetch entities
await store.actions.source.fetch("/post-1/attachment-1/");
expect(api.get).toHaveBeenCalledTimes(0);
expect(store.state.source).toMatchSnapshot();
});
test("works with query params (doesn't exist in source.attachment)", async () => {
// Mock Api responses
api.get = jest
.fn()
.mockResolvedValueOnce(mockResponse([]))
.mockResolvedValueOnce(mockResponse([attachment1]));
// Fetch entities
await store.actions.source.fetch("/post-1/attachment-1/?some=param");
expect(store.state.source).toMatchSnapshot();
});
test("works with query params (exists in source.attachment)", async () => {
// Add attachment to the store
await store.libraries.source.populate({
state: store.state,
response: mockResponse(attachment1),
});
// Mock Api responses
api.get = jest.fn().mockResolvedValue(mockResponse([]));
// Fetch entities
await store.actions.source.fetch("/post-1/attachment-1/?some=param");
expect(api.get).toHaveBeenCalledTimes(0);
expect(store.state.source).toMatchSnapshot();
});
test("overwrites the data when fetched with { force: true }", async () => {
// Mock Api responses
api.get = jest
.fn()
.mockResolvedValueOnce(mockResponse([post1]))
.mockResolvedValueOnce(mockResponse(attachment1));
// Fetch entities
await store.actions.source.fetch("/post-1");
await store.actions.source.fetch("/post-1", { force: true });
expect(store.state.source).toMatchSnapshot();
});
test("Every unknown URL should return a 404 even if it's substring matches a path", async () => {
api.get = jest.fn((_) =>
Promise.resolve(
mockResponse([
{
id: 1,
slug: "post-1",
type: "post",
link: "https://test.frontity.org/post-1/",
},
])
)
);
await store.actions.source.fetch("/undefined/post-1/");
expect(store.state.source).toMatchSnapshot();
});
test("Every unknown URL should return a 404 even if it's substring matches a path 2", async () => {
api.get = jest.fn((_) =>
Promise.resolve(
mockResponse([
{
id: 1,
slug: "post-1",
type: "post",
link: "https://test.frontity.org/post-1/",
},
])
)
);
await store.actions.source.fetch("/does/not/exist/");
expect(store.state.source).toMatchSnapshot();
});
} | kbav/frontity | packages/wp-source/src/libraries/handlers/__tests__/post-type.tests.ts | TypeScript |
ArrowFunction |
async () => {
// Mock Api responses
api.get = jest
.fn()
.mockResolvedValueOnce(mockResponse([]))
.mockResolvedValueOnce(mockResponse([attachment1]));
// Fetch entities
await store.actions.source.fetch("/post-1/attachment-1/");
expect(store.state.source).toMatchSnapshot();
} | kbav/frontity | packages/wp-source/src/libraries/handlers/__tests__/post-type.tests.ts | TypeScript |
ArrowFunction |
async () => {
// Add attachment to the store
await store.libraries.source.populate({
state: store.state,
response: mockResponse(attachment1),
});
// Mock Api responses
api.get = jest.fn().mockResolvedValue(mockResponse([]));
// Fetch entities
await store.actions.source.fetch("/post-1/attachment-1/");
expect(api.get).toHaveBeenCalledTimes(0);
expect(store.state.source).toMatchSnapshot();
} | kbav/frontity | packages/wp-source/src/libraries/handlers/__tests__/post-type.tests.ts | TypeScript |
ArrowFunction |
async () => {
// Mock Api responses
api.get = jest
.fn()
.mockResolvedValueOnce(mockResponse([]))
.mockResolvedValueOnce(mockResponse([attachment1]));
// Fetch entities
await store.actions.source.fetch("/post-1/attachment-1/?some=param");
expect(store.state.source).toMatchSnapshot();
} | kbav/frontity | packages/wp-source/src/libraries/handlers/__tests__/post-type.tests.ts | TypeScript |
ArrowFunction |
async () => {
// Add attachment to the store
await store.libraries.source.populate({
state: store.state,
response: mockResponse(attachment1),
});
// Mock Api responses
api.get = jest.fn().mockResolvedValue(mockResponse([]));
// Fetch entities
await store.actions.source.fetch("/post-1/attachment-1/?some=param");
expect(api.get).toHaveBeenCalledTimes(0);
expect(store.state.source).toMatchSnapshot();
} | kbav/frontity | packages/wp-source/src/libraries/handlers/__tests__/post-type.tests.ts | TypeScript |
ArrowFunction |
async () => {
// Mock Api responses
api.get = jest
.fn()
.mockResolvedValueOnce(mockResponse([post1]))
.mockResolvedValueOnce(mockResponse(attachment1));
// Fetch entities
await store.actions.source.fetch("/post-1");
await store.actions.source.fetch("/post-1", { force: true });
expect(store.state.source).toMatchSnapshot();
} | kbav/frontity | packages/wp-source/src/libraries/handlers/__tests__/post-type.tests.ts | TypeScript |
ArrowFunction |
async () => {
api.get = jest.fn((_) =>
Promise.resolve(
mockResponse([
{
id: 1,
slug: "post-1",
type: "post",
link: "https://test.frontity.org/post-1/",
},
])
)
);
await store.actions.source.fetch("/undefined/post-1/");
expect(store.state.source).toMatchSnapshot();
} | kbav/frontity | packages/wp-source/src/libraries/handlers/__tests__/post-type.tests.ts | TypeScript |
ArrowFunction |
(_) =>
Promise.resolve(
mockResponse([
{
id: 1,
slug: "post-1",
type: "post",
link: "https://test.frontity.org/post-1/",
},
])
) | kbav/frontity | packages/wp-source/src/libraries/handlers/__tests__/post-type.tests.ts | TypeScript |
ArrowFunction |
async () => {
api.get = jest.fn((_) =>
Promise.resolve(
mockResponse([
{
id: 1,
slug: "post-1",
type: "post",
link: "https://test.frontity.org/post-1/",
},
])
)
);
await store.actions.source.fetch("/does/not/exist/");
expect(store.state.source).toMatchSnapshot();
} | kbav/frontity | packages/wp-source/src/libraries/handlers/__tests__/post-type.tests.ts | TypeScript |
FunctionDeclaration | /**
* Given a URL pointing to a file on a provider, returns a URL that is suitable
* for fetching the contents of the data.
*
* Converts
* from: https://dev.azure.com/{organization}/{project}/_git/reponame?path={path}&version=GB{commitOrBranch}&_a=contents
* to: https://dev.azure.com/{organization}/{project}/_apis/git/repositories/reponame/items?path={path}&version={commitOrBranch}
*
* @param url A URL pointing to a file
*/
export function getAzureFileFetchUrl(url: string): string {
try {
const parsedUrl = new URL(url);
const [
empty,
userOrOrg,
project,
srcKeyword,
repoName,
] = parsedUrl.pathname.split('/');
const path = parsedUrl.searchParams.get('path') || '';
const ref = parsedUrl.searchParams.get('version')?.substr(2);
if (
empty !== '' ||
userOrOrg === '' ||
project === '' ||
srcKeyword !== '_git' ||
repoName === '' ||
path === '' ||
ref === ''
) {
throw new Error('Wrong Azure Devops URL or Invalid file path');
}
// transform to api
parsedUrl.pathname = [
empty,
userOrOrg,
project,
'_apis',
'git',
'repositories',
repoName,
'items',
].join('/');
const queryParams = [`path=${path}`];
if (ref) {
queryParams.push(`version=${ref}`);
}
parsedUrl.search = queryParams.join('&');
parsedUrl.protocol = 'https';
return parsedUrl.toString();
} catch (e) {
throw new Error(`Incorrect URL: ${url}, ${e}`);
}
} | Xantier/backstage | packages/integration/src/azure/core.ts | TypeScript |
FunctionDeclaration | /**
* Given a URL pointing to a path on a provider, returns a URL that is suitable
* for downloading the subtree.
*
* @param url A URL pointing to a path
*/
export function getAzureDownloadUrl(url: string): string {
const {
name: repoName,
owner: project,
organization,
protocol,
resource,
filepath,
} = parseGitUrl(url);
// scopePath will limit the downloaded content
// /docs will only download the docs folder and everything below it
// /docs/index.md will only download index.md but put it in the root of the archive
const scopePath = filepath
? `&scopePath=${encodeURIComponent(filepath)}`
: '';
return `${protocol}://${resource}/${organization}/${project}/_apis/git/repositories/${repoName}/items?recursionLevel=full&download=true&api-version=6.0${scopePath}`;
} | Xantier/backstage | packages/integration/src/azure/core.ts | TypeScript |
FunctionDeclaration | /**
* Gets the request options necessary to make requests to a given provider.
*
* @param config The relevant provider config
*/
export function getAzureRequestOptions(
config: AzureIntegrationConfig,
additionalHeaders?: Record<string, string>,
): RequestInit {
const headers: HeadersInit = additionalHeaders
? { ...additionalHeaders }
: {};
if (config.token) {
const buffer = Buffer.from(`:${config.token}`, 'utf8');
headers.Authorization = `Basic ${buffer.toString('base64')}`;
}
return { headers };
} | Xantier/backstage | packages/integration/src/azure/core.ts | TypeScript |
InterfaceDeclaration |
export interface Card {
title: string;
type: CardType;
icon: IconName;
href: string;
check: () => Promise<boolean>;
done: boolean;
heading: string;
learnHref?: string;
} | 3LOQ/grafana | public/app/plugins/panel/gettingstarted/types.ts | TypeScript |
InterfaceDeclaration |
export interface TutorialCardType extends Card {
info?: string;
// For local storage
key: string;
} | 3LOQ/grafana | public/app/plugins/panel/gettingstarted/types.ts | TypeScript |
InterfaceDeclaration |
export interface SetupStep {
heading: string;
subheading: string;
title: string;
info: string;
cards: (Card | TutorialCardType)[];
done: boolean;
} | 3LOQ/grafana | public/app/plugins/panel/gettingstarted/types.ts | TypeScript |
TypeAliasDeclaration |
export type CardType = 'tutorial' | 'docs' | 'other'; | 3LOQ/grafana | public/app/plugins/panel/gettingstarted/types.ts | TypeScript |
ArrowFunction |
(props) => {
// const [topics, setTopics] = useState<firebase.firestore.DocumentData>({});
const { data, loading } = useContext(LadderContext);
// useEffect(() => {
// const fetchData = () => {
// firestore
// .collection("ladders")
// .get()
// .then((ladderList) => {
// setTopics({ ...ladderList.docs[0].data().topics });
// })
// .catch((err) => console.log(err));
// };
// fetchData();
// //eslint-disable-next-line react-hooks/exhaustive-deps
// }, []);
return (
<>
{!loading && data[0] !== undefined ? (
<div className="grid grid-cols-12 gap-2 p-5 rounded-md sm:space-x-0 sm:gap-4 sm:p-3">
{Object.keys(data[0].topics).map((keyName, keyIndex) => {
return (
<Card
key={keyIndex}
title={keyName}
questions={data[0].topics[keyName]}
className="w-full col-span-12 sm:col-span-6 lg:col-span-4"
topicLink={keyName}
/>
);
})} | AyaanJaved/ladderly-web | ladderly-react/src/pages/AppContainer/Topics.page.tsx | TypeScript |
ArrowFunction |
(keyName, keyIndex) => {
return (
<Card
key={keyIndex}
title={keyName}
questions={data[0].topics[keyName]}
className="w-full col-span-12 sm:col-span-6 lg:col-span-4"
topicLink={keyName}
/> | AyaanJaved/ladderly-web | ladderly-react/src/pages/AppContainer/Topics.page.tsx | TypeScript |
InterfaceDeclaration |
interface Props {} | AyaanJaved/ladderly-web | ladderly-react/src/pages/AppContainer/Topics.page.tsx | TypeScript |
FunctionDeclaration |
function Demo() {
return (
<Group position="center">
<Badge variant="gradient" gradient={{ from: 'indigo', to: 'cyan' }} | Anishpras/mantine | src/mantine-demos/src/demos/packages/Badge/gradient.tsx | TypeScript |
ArrowFunction |
async (packet, referrerObj) => {
const query = new Query(packet);
const referrer = new Referrer(referrerObj);
this.emit("query", query, referrer);
} | dizzyluo/spread-the-word | src/Transports/MDNSTransport.ts | TypeScript |
ArrowFunction |
(packet, referrerObj) => {
const res = Response.parse(packet, { binaryTXT: this.options.binaryTXT });
const referrer = new Referrer(referrerObj);
this.emit("response", res, referrer);
} | dizzyluo/spread-the-word | src/Transports/MDNSTransport.ts | TypeScript |
ArrowFunction |
(resolve, reject) => {
this.mdns.query(query, err => {
if (err) return reject(err);
resolve();
});
} | dizzyluo/spread-the-word | src/Transports/MDNSTransport.ts | TypeScript |
ArrowFunction |
err => {
if (err) return reject(err);
resolve();
} | dizzyluo/spread-the-word | src/Transports/MDNSTransport.ts | TypeScript |
ArrowFunction |
(resolve, reject) => {
this.mdns.respond(Response.serialize(res, { binaryTXT: this.options.binaryTXT }), err => {
if (err) return reject(err);
resolve();
});
} | dizzyluo/spread-the-word | src/Transports/MDNSTransport.ts | TypeScript |
ArrowFunction |
(resolve, reject) => {
this.mdns.destroy(err => {
if (err) return reject(err);
resolve();
});
} | dizzyluo/spread-the-word | src/Transports/MDNSTransport.ts | TypeScript |
ClassDeclaration |
export default class MDNSTransport extends EventEmitter implements Transport {
options: TransportOptions;
destroyed: boolean = false;
// tslint:disable-next-line:no-any
mdns: any;
constructor(options: TransportOptions = {}) {
super();
this.options = options;
this.mdns = multicastdns();
this.mdns.setMaxListeners(0);
this.mdns.on("query", async (packet, referrerObj) => {
const query = new Query(packet);
const referrer = new Referrer(referrerObj);
this.emit("query", query, referrer);
});
this.mdns.on("response", (packet, referrerObj) => {
const res = Response.parse(packet, { binaryTXT: this.options.binaryTXT });
const referrer = new Referrer(referrerObj);
this.emit("response", res, referrer);
});
}
async query(query: Query) {
return new Promise<void>((resolve, reject) => {
this.mdns.query(query, err => {
if (err) return reject(err);
resolve();
});
});
}
async respond(res: Response) {
return await new Promise<void>((resolve, reject) => {
this.mdns.respond(Response.serialize(res, { binaryTXT: this.options.binaryTXT }), err => {
if (err) return reject(err);
resolve();
});
});
}
async destroy() {
if (this.destroyed) return;
this.destroyed = true;
await new Promise<void>((resolve, reject) => {
this.mdns.destroy(err => {
if (err) return reject(err);
resolve();
});
});
}
getAddresses(): Array<{ family: string, address: string }> {
return MDNSUtils.getExternalAddresses();
}
} | dizzyluo/spread-the-word | src/Transports/MDNSTransport.ts | TypeScript |
MethodDeclaration |
async query(query: Query) {
return new Promise<void>((resolve, reject) => {
this.mdns.query(query, err => {
if (err) return reject(err);
resolve();
});
});
} | dizzyluo/spread-the-word | src/Transports/MDNSTransport.ts | TypeScript |
MethodDeclaration |
async respond(res: Response) {
return await new Promise<void>((resolve, reject) => {
this.mdns.respond(Response.serialize(res, { binaryTXT: this.options.binaryTXT }), err => {
if (err) return reject(err);
resolve();
});
});
} | dizzyluo/spread-the-word | src/Transports/MDNSTransport.ts | TypeScript |
MethodDeclaration |
async destroy() {
if (this.destroyed) return;
this.destroyed = true;
await new Promise<void>((resolve, reject) => {
this.mdns.destroy(err => {
if (err) return reject(err);
resolve();
});
});
} | dizzyluo/spread-the-word | src/Transports/MDNSTransport.ts | TypeScript |
MethodDeclaration |
getAddresses(): Array<{ family: string, address: string }> {
return MDNSUtils.getExternalAddresses();
} | dizzyluo/spread-the-word | src/Transports/MDNSTransport.ts | TypeScript |
FunctionDeclaration |
function handleNavigateToBack() {
navigation.goBack();
} | huandrey/Ecoleta | Booster/mobile/src/pages/Detail/index.tsx | TypeScript |
FunctionDeclaration |
function handleComposeMail() {
MailComposer.composeAsync({
subject: 'Gostaria de saber um pouco mais sobre a coleta de resíduos',
recipients: [data.point.email]
})
} | huandrey/Ecoleta | Booster/mobile/src/pages/Detail/index.tsx | TypeScript |
FunctionDeclaration |
function handleWhatsapp() {
Linking.openURL(`whatsapp://send?phone=${data.point.whatsapp}&tenho interesse sobre a coleta de resíduos`);
} | huandrey/Ecoleta | Booster/mobile/src/pages/Detail/index.tsx | TypeScript |
ArrowFunction |
() => {
const [data, setData] = useState<Data>({} as Data);
const navigation = useNavigation();
const route = useRoute();
const routeParams = route.params as Params;
useEffect(() => {
api.get(`points/${routeParams.point_id}`).then(response => {
setData(response.data)
})
})
function handleNavigateToBack() {
navigation.goBack();
}
function handleComposeMail() {
MailComposer.composeAsync({
subject: 'Gostaria de saber um pouco mais sobre a coleta de resíduos',
recipients: [data.point.email]
})
}
function handleWhatsapp() {
Linking.openURL(`whatsapp://send?phone=${data.point.whatsapp}&tenho interesse sobre a coleta de resíduos`);
}
if(!data.point) {
return null
}
return (
<SafeAreaView style={{flex: 1}} | huandrey/Ecoleta | Booster/mobile/src/pages/Detail/index.tsx | TypeScript |
ArrowFunction |
() => {
api.get(`points/${routeParams.point_id}`).then(response => {
setData(response.data)
})
} | huandrey/Ecoleta | Booster/mobile/src/pages/Detail/index.tsx | TypeScript |
ArrowFunction |
response => {
setData(response.data)
} | huandrey/Ecoleta | Booster/mobile/src/pages/Detail/index.tsx | TypeScript |
ArrowFunction |
item => item.title | huandrey/Ecoleta | Booster/mobile/src/pages/Detail/index.tsx | TypeScript |
InterfaceDeclaration |
interface Params {
point_id: number;
} | huandrey/Ecoleta | Booster/mobile/src/pages/Detail/index.tsx | TypeScript |
InterfaceDeclaration |
interface Data {
point: {
image: string;
image_url: string;
name: string;
email: string;
whatsapp: string;
city: string;
uf: string;
};
items: {
title: string;
}[];
} | huandrey/Ecoleta | Booster/mobile/src/pages/Detail/index.tsx | TypeScript |
InterfaceDeclaration |
export interface SparklineOptions {
show: boolean;
} | smartems/smartems | public/app/plugins/panel/singlestat2/types.ts | TypeScript |
InterfaceDeclaration | // Structure copied from angular
export interface SingleStatOptions extends SingleStatBaseOptions {
sparkline: SparklineOptions;
colorMode: ColorMode;
displayMode: SingleStatDisplayMode;
} | smartems/smartems | public/app/plugins/panel/singlestat2/types.ts | TypeScript |
EnumDeclaration |
export enum ColorMode {
Thresholds,
Series,
} | smartems/smartems | public/app/plugins/panel/singlestat2/types.ts | TypeScript |
EnumDeclaration | /*
* Copyright 2020 Salto Labs Ltd.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
export enum Keywords {
TYPE_DEFINITION = 'type',
VARIABLES_DEFINITION = 'vars',
SETTINGS_DEFINITION = 'settings',
LIST_DEFINITION = 'list',
TYPE_INHERITANCE_SEPARATOR = 'is',
ANNOTATIONS_DEFINITION = 'annotations',
NAMESPACE_SEPARATOR = '.',
// Primitive types
TYPE_STRING = 'string',
TYPE_NUMBER = 'number',
TYPE_BOOL = 'boolean',
TYPE_OBJECT = 'object',
// Generics Types
LIST_PREFIX = 'List<',
GENERICS_SUFFIX = '>'
} | eladmallel/salto | packages/workspace/src/parser/language.ts | TypeScript |
InterfaceDeclaration |
export interface RespCoreCacheMiss {
time: number[];
values: {
mpki: {
l1d_mpki: number[],
l1i_mpki: number[],
l2d_mpki: number[],
l2i_mpki: number[],
},
percentage: {
l1d_missrate: number[],
l1i_missrate: number[],
l2d_missrate: number[],
l2i_missrate: number[],
}
};
} | kunpengcompute/devkit-vscode-plugin | workspace/projects/sys/src-com/app/mission-analysis/ddrtab-detail/ddr-summury/domain/resp-core-cache-miss.interface.ts | TypeScript |
ArrowFunction |
(): JSX.Element => {
return <BlogSearch />;
} | almond-hydroponics/almond-dashboard | src/pages/blog-search.tsx | TypeScript |
ArrowFunction |
(name, value) => {
this.setState({
isInline: value === 'inline',
});
} | uidu-org/guidu | packages/forms/radio/examples/Grid.tsx | TypeScript |
ClassDeclaration |
export default class Grid extends Component<any, any> {
state = {
isInline: false,
};
onChange = (name, value) => {
this.setState({
isInline: value === 'inline',
});
};
render() {
const { isInline } = this.state;
return (
<Form {...formDefaultProps}>
<RadioGrid
{...inputDefaultProps}
isInline={isInline}
options={defaultOptions.slice(0, 5)}
// onBlur={this.onBlur}
// onFocus={this.onFocus}
label="With change, blur & focus handlers"
questions={[
{ id: 1, name: 'Test question' },
{
id: 2,
name:
'Lei dice che è solo stanchezza, ma secondo me non può essere.. vediamo i prossimi giorni come sta',
},
]}
/>
</Form>
);
}
} | uidu-org/guidu | packages/forms/radio/examples/Grid.tsx | TypeScript |
MethodDeclaration |
render() {
const { isInline } = this.state;
return (
<Form {...formDefaultProps}>
<RadioGrid
{...inputDefaultProps}
isInline={isInline}
options={defaultOptions.slice(0, 5)}
// onBlur={this.onBlur}
// onFocus={this.onFocus}
label="With change, blur & focus handlers"
questions={[
{ id: 1, name: 'Test question' },
{
id: 2,
name:
'Lei dice che è solo stanchezza, ma secondo me non può essere.. vediamo i prossimi giorni come sta',
},
]}
/>
</Form>
);
} | uidu-org/guidu | packages/forms/radio/examples/Grid.tsx | TypeScript |
FunctionDeclaration | /**
* The description of the IoT hub.
*/
export function getIotHubResource(args: GetIotHubResourceArgs, opts?: pulumi.InvokeOptions): Promise<GetIotHubResourceResult> {
if (!opts) {
opts = {}
}
if (!opts.version) {
opts.version = utilities.getVersion();
}
return pulumi.runtime.invoke("azure-native:devices/v20181201preview:getIotHubResource", {
"resourceGroupName": args.resourceGroupName,
"resourceName": args.resourceName,
}, opts);
} | polivbr/pulumi-azure-native | sdk/nodejs/devices/v20181201preview/getIotHubResource.ts | TypeScript |
InterfaceDeclaration |
export interface GetIotHubResourceArgs {
/**
* The name of the resource group that contains the IoT hub.
*/
resourceGroupName: string;
/**
* The name of the IoT hub.
*/
resourceName: string;
} | polivbr/pulumi-azure-native | sdk/nodejs/devices/v20181201preview/getIotHubResource.ts | TypeScript |
InterfaceDeclaration | /**
* The description of the IoT hub.
*/
export interface GetIotHubResourceResult {
/**
* The Etag field is *not* required. If it is provided in the response body, it must also be provided as a header per the normal ETag convention.
*/
readonly etag?: string;
/**
* The resource identifier.
*/
readonly id: string;
/**
* The resource location.
*/
readonly location: string;
/**
* The resource name.
*/
readonly name: string;
/**
* IotHub properties
*/
readonly properties: outputs.devices.v20181201preview.IotHubPropertiesResponse;
/**
* IotHub SKU info
*/
readonly sku: outputs.devices.v20181201preview.IotHubSkuInfoResponse;
/**
* The resource tags.
*/
readonly tags?: {[key: string]: string};
/**
* The resource type.
*/
readonly type: string;
} | polivbr/pulumi-azure-native | sdk/nodejs/devices/v20181201preview/getIotHubResource.ts | TypeScript |
ArrowFunction |
() => {
let component: TextFieldEditorValidationComponent;
let fixture: ComponentFixture<TextFieldEditorValidationComponent>;
beforeEach(async(() => {
TestBed.configureTestingModule({
declarations: [
TextFieldEditorValidationComponent,
TextFieldComponent
],
imports: [
FormsModule
]
})
.compileComponents();
}));
beforeEach(() => {
fixture = TestBed.createComponent(TextFieldEditorValidationComponent);
component = fixture.componentInstance;
component.component = new TextFieldComponent();
fixture.detectChanges();
});
it('should create', () => {
expect(component).toBeTruthy();
});
} | Softheon/angular-forge | projects/forge-lib/src/lib/shared/form-editor-components/concrete/text-field-editor/validation/text-field-editor-validation.component.spec.ts | TypeScript |
ArrowFunction |
() => {
TestBed.configureTestingModule({
declarations: [
TextFieldEditorValidationComponent,
TextFieldComponent
],
imports: [
FormsModule
]
})
.compileComponents();
} | Softheon/angular-forge | projects/forge-lib/src/lib/shared/form-editor-components/concrete/text-field-editor/validation/text-field-editor-validation.component.spec.ts | TypeScript |
ArrowFunction |
() => {
fixture = TestBed.createComponent(TextFieldEditorValidationComponent);
component = fixture.componentInstance;
component.component = new TextFieldComponent();
fixture.detectChanges();
} | Softheon/angular-forge | projects/forge-lib/src/lib/shared/form-editor-components/concrete/text-field-editor/validation/text-field-editor-validation.component.spec.ts | TypeScript |
ArrowFunction |
event => {
} | congphuong1606/hrmOmi | resources/assets/src/app/services/TokenInterceptor.ts | TypeScript |
ArrowFunction |
error => {
if (error.status === 401) {
this.router.navigate(['/login']);
localStorage.clear();
}
} | congphuong1606/hrmOmi | resources/assets/src/app/services/TokenInterceptor.ts | TypeScript |
ArrowFunction |
() => {
} | congphuong1606/hrmOmi | resources/assets/src/app/services/TokenInterceptor.ts | TypeScript |
ClassDeclaration |
@Injectable()
export class TokenInterceptor implements HttpInterceptor {
constructor(public auth: AuthService, private router: Router) {
}
intercept(request: HttpRequest<any>, next: HttpHandler): Observable<HttpEvent<any>> {
request = request.clone({
setHeaders: {
Authorization: 'Bearer' + this.auth.getToken(),
Accept: 'application/json',
}
});
return next.handle(request).pipe(
tap(
event => {
},
error => {
if (error.status === 401) {
this.router.navigate(['/login']);
localStorage.clear();
}
}
),
finalize(() => {
})
);
}
} | congphuong1606/hrmOmi | resources/assets/src/app/services/TokenInterceptor.ts | TypeScript |
MethodDeclaration |
intercept(request: HttpRequest<any>, next: HttpHandler): Observable<HttpEvent<any>> {
request = request.clone({
setHeaders: {
Authorization: 'Bearer' + this.auth.getToken(),
Accept: 'application/json',
}
});
return next.handle(request).pipe(
tap(
event => {
},
error => {
if (error.status === 401) {
this.router.navigate(['/login']);
localStorage.clear();
}
}
),
finalize(() => {
})
);
} | congphuong1606/hrmOmi | resources/assets/src/app/services/TokenInterceptor.ts | TypeScript |
ArrowFunction |
async <T>(
logger: ILogger,
name: string,
fn: () => T | Promise<T>,
metadata: object = {},
): Promise<T> => {
const start = Date.now();
try {
return await fn();
} finally {
logger.verbose(LogTag.PerfFunction, '', {
method: name,
duration: Date.now() - start,
...metadata,
});
}
} | Ashikpaul/vscode-js-debug | src/telemetry/performance.ts | TypeScript |
ArrowFunction |
(request, response) => response.json({ message: 'Hello World' }) | erickSuh/005-typescript-nodejs-example | src/server.ts | TypeScript |
ArrowFunction |
() => {
const { mnemonic } = useMemo(() => new MnemonicKey(), []) // must be memoized
return (
<CreateWalletWizard defaultMnemonic={mnemonic} beforeCreate={<Quiz />} | daodiseomoney/station | src/auth/modules/create/NewWalletForm.tsx | TypeScript |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.