type stringclasses 7
values | content stringlengths 4 9.55k | repo stringlengths 7 96 | path stringlengths 4 178 | language stringclasses 1
value |
|---|---|---|---|---|
ArrowFunction |
() => setTextModeEnabled(true) | jschuler/kogito-tooling | packages/chrome-extension/src/app/components/single/SingleEditorApp.tsx | TypeScript |
ArrowFunction |
(
props: DefaultSidePanelProps
): JSX.Element => {
const { onSidePanelItemClick } = props;
return (
<SidePanelItems type="desktop" onSidePanelItemClick={ onSidePanelItemClick }/> | inthirakumaaran/identity-apps | apps/admin-portal/src/components/side-panel.tsx | TypeScript |
ArrowFunction |
(props: MobileSidePanelProps): JSX.Element => {
const { children, onPusherClick, visible, onSidePanelItemClick } = props;
return (
<Sidebar.Pushable>
<Sidebar
animation="push"
visible={ visible }
>
<SidePanelItems type="mobile" onS... | inthirakumaaran/identity-apps | apps/admin-portal/src/components/side-panel.tsx | TypeScript |
ArrowFunction |
(props: SidePanelItemsProps): JSX.Element => {
const { type, onSidePanelItemClick } = props;
const activeRoute = (path: string) => {
const pathname = window.location.pathname;
const urlTokens = path.split("/");
return pathname.indexOf(urlTokens[1]) > -1 ? "active" : "";
};
retur... | inthirakumaaran/identity-apps | apps/admin-portal/src/components/side-panel.tsx | TypeScript |
ArrowFunction |
(path: string) => {
const pathname = window.location.pathname;
const urlTokens = path.split("/");
return pathname.indexOf(urlTokens[1]) > -1 ? "active" : "";
} | inthirakumaaran/identity-apps | apps/admin-portal/src/components/side-panel.tsx | TypeScript |
ArrowFunction |
(route, index) => (
route.showOnSidePanel ?
<Menu.Item
as={ NavLink } | inthirakumaaran/identity-apps | apps/admin-portal/src/components/side-panel.tsx | TypeScript |
ArrowFunction |
(
props: SidePanelWrapperProps
): JSX.Element => {
const { mobileSidePanelVisibility, children, onSidePanelPusherClick, onSidePanelItemClick } = props;
return (
<>
<Responsive { ...Responsive.onlyMobile }>
<MobileSidePanel
onPusherClick={ onSidePanelP... | inthirakumaaran/identity-apps | apps/admin-portal/src/components/side-panel.tsx | TypeScript |
InterfaceDeclaration | /**
* Default side panel component Prop types.
*/
interface DefaultSidePanelProps {
onSidePanelItemClick: () => void;
} | inthirakumaaran/identity-apps | apps/admin-portal/src/components/side-panel.tsx | TypeScript |
InterfaceDeclaration | /**
* Mobile side panel component Prop types.
*/
interface MobileSidePanelProps extends DefaultSidePanelProps {
children?: React.ReactNode;
onPusherClick: () => void;
visible: boolean;
} | inthirakumaaran/identity-apps | apps/admin-portal/src/components/side-panel.tsx | TypeScript |
InterfaceDeclaration | /**
* Side panel items component Prop types.
*/
interface SidePanelItemsProps {
onSidePanelItemClick: () => void;
type: "desktop" | "mobile";
} | inthirakumaaran/identity-apps | apps/admin-portal/src/components/side-panel.tsx | TypeScript |
InterfaceDeclaration | /**
* Side panel wrapper component Prop types.
*/
interface SidePanelWrapperProps {
children?: React.ReactNode;
onSidePanelItemClick: () => void;
onSidePanelPusherClick: () => void;
mobileSidePanelVisibility: boolean;
} | inthirakumaaran/identity-apps | apps/admin-portal/src/components/side-panel.tsx | TypeScript |
MethodDeclaration |
activeRoute(route | inthirakumaaran/identity-apps | apps/admin-portal/src/components/side-panel.tsx | TypeScript |
InterfaceDeclaration |
interface SvgrComponent extends React.FC<React.SVGAttributes<SVGElement>> {} | TimLuo465/rgl-dnd | src/typings.d.ts | TypeScript |
ClassDeclaration |
@Component({
selector: 'ngx-contract',
styleUrls: ['./delete-customer.scss'],
template: `
<nb-card>
<nb-card-header>
{{ title }}
<h6 class="close " aria-label="Close" (click)="dismiss()">
<span aria-hidden="true">×</span>
... | vothiphuongnga200997/travello | .history/src/app/pages/contract/delete-customer_20191005031707.ts | TypeScript |
MethodDeclaration |
dismiss() {
this.ref.close();
} | vothiphuongnga200997/travello | .history/src/app/pages/contract/delete-customer_20191005031707.ts | TypeScript |
MethodDeclaration |
async delete() {
let i = this.contractService.delete(this.id);
} | vothiphuongnga200997/travello | .history/src/app/pages/contract/delete-customer_20191005031707.ts | TypeScript |
FunctionDeclaration |
function isNode() {
if (typeof process === 'object') {
if (typeof process.versions === 'object') {
if (typeof process.versions.node !== 'undefined') {
return true;
}
}
}
return false;
} | ChrisZieba/parquets | src/snappy/index.ts | TypeScript |
FunctionDeclaration |
function isUint8Array(object: any) {
return object instanceof Uint8Array && (!isNode() || !Buffer.isBuffer(object));
} | ChrisZieba/parquets | src/snappy/index.ts | TypeScript |
FunctionDeclaration |
function isArrayBuffer(object: any) {
return object instanceof ArrayBuffer;
} | ChrisZieba/parquets | src/snappy/index.ts | TypeScript |
FunctionDeclaration |
function isBuffer(object: any) {
if (!isNode()) {
return false;
}
return Buffer.isBuffer(object);
} | ChrisZieba/parquets | src/snappy/index.ts | TypeScript |
FunctionDeclaration |
export function uncompress(compressed: Buffer): Buffer; | ChrisZieba/parquets | src/snappy/index.ts | TypeScript |
FunctionDeclaration |
export function uncompress(compressed: Uint8Array): Uint8Array; | ChrisZieba/parquets | src/snappy/index.ts | TypeScript |
FunctionDeclaration |
export function uncompress(compressed: ArrayBuffer): ArrayBuffer; | ChrisZieba/parquets | src/snappy/index.ts | TypeScript |
FunctionDeclaration |
export function uncompress(compressed: any) {
if (!isUint8Array(compressed) && !isArrayBuffer(compressed) && !isBuffer(compressed)) {
throw new TypeError(TYPE_ERROR_MSG);
}
let uint8Mode = false;
let arrayBufferMode = false;
let buffer: Buffer;
if (isUint8Array(compressed)) {
uint8Mode = true;
... | ChrisZieba/parquets | src/snappy/index.ts | TypeScript |
FunctionDeclaration |
export function compress(uncompressed: Buffer): Buffer; | ChrisZieba/parquets | src/snappy/index.ts | TypeScript |
FunctionDeclaration |
export function compress(uncompressed: Uint8Array): Uint8Array; | ChrisZieba/parquets | src/snappy/index.ts | TypeScript |
FunctionDeclaration |
export function compress(uncompressed: ArrayBuffer): ArrayBuffer; | ChrisZieba/parquets | src/snappy/index.ts | TypeScript |
FunctionDeclaration |
export function compress(uncompressed: any) {
if (!isUint8Array(uncompressed) && !isArrayBuffer(uncompressed) && !isBuffer(uncompressed)) {
throw new TypeError(TYPE_ERROR_MSG);
}
let uint8Mode = false;
let arrayBufferMode = false;
let buffer: Buffer;
if (isUint8Array(uncompressed)) {
uint8Mode = tr... | ChrisZieba/parquets | src/snappy/index.ts | TypeScript |
ArrowFunction |
() => {
let junoClient: JunoClient;
let gitHubOAuthService: GitHubOAuthService;
let originalDataExplorer: Explorer;
beforeEach(() => {
junoClient = new JunoClient();
gitHubOAuthService = new GitHubOAuthService(junoClient);
originalDataExplorer = window.dataExplorer;
window.dataExplorer = {
... | Azure/cosmos-explorer | src/GitHub/GitHubOAuthService.test.ts | TypeScript |
ArrowFunction |
() => {
junoClient = new JunoClient();
gitHubOAuthService = new GitHubOAuthService(junoClient);
originalDataExplorer = window.dataExplorer;
window.dataExplorer = {
...originalDataExplorer,
} as Explorer;
window.dataExplorer.notebookManager = new NotebookManager();
window.dataExplorer.... | Azure/cosmos-explorer | src/GitHub/GitHubOAuthService.test.ts | TypeScript |
ArrowFunction |
() => {
jest.resetAllMocks();
window.dataExplorer = originalDataExplorer;
originalDataExplorer = undefined;
gitHubOAuthService = undefined;
junoClient = undefined;
} | Azure/cosmos-explorer | src/GitHub/GitHubOAuthService.test.ts | TypeScript |
ArrowFunction |
async () => {
const deleteAppAuthorizationCallback = jest.fn().mockReturnValue({ status: HttpStatusCodes.NoContent });
junoClient.deleteAppAuthorization = deleteAppAuthorizationCallback;
await gitHubOAuthService.logout();
expect(deleteAppAuthorizationCallback).toBeCalled();
expect(gitHubOAuthServi... | Azure/cosmos-explorer | src/GitHub/GitHubOAuthService.test.ts | TypeScript |
ArrowFunction |
() => {
gitHubOAuthService.resetToken();
expect(gitHubOAuthService.getTokenObservable()()).toBeUndefined();
} | Azure/cosmos-explorer | src/GitHub/GitHubOAuthService.test.ts | TypeScript |
ArrowFunction |
async () => {
let url: string;
const windowOpenCallback = jest.fn().mockImplementation((value: string) => {
url = value;
});
window.open = windowOpenCallback;
await gitHubOAuthService.startOAuth("scope");
expect(windowOpenCallback).toBeCalled();
const initialParams = new URLSearchPa... | Azure/cosmos-explorer | src/GitHub/GitHubOAuthService.test.ts | TypeScript |
ArrowFunction |
(value: string) => {
url = value;
} | Azure/cosmos-explorer | src/GitHub/GitHubOAuthService.test.ts | TypeScript |
ArrowFunction |
async () => {
const data = { key: "value" };
const getGitHubTokenCallback = jest.fn().mockReturnValue({ status: HttpStatusCodes.OK, data });
junoClient.getGitHubToken = getGitHubTokenCallback;
const initialToken = gitHubOAuthService.getTokenObservable()();
const state = await gitHubOAuthService.st... | Azure/cosmos-explorer | src/GitHub/GitHubOAuthService.test.ts | TypeScript |
ArrowFunction |
async () => {
await gitHubOAuthService.startOAuth("scope");
const params: IGitHubConnectorParams = {
state: "state",
code: "code",
};
await gitHubOAuthService.finishOAuth(params);
expect(gitHubOAuthService.getTokenObservable()().error).toBeDefined();
} | Azure/cosmos-explorer | src/GitHub/GitHubOAuthService.test.ts | TypeScript |
ArrowFunction |
async () => {
const getGitHubTokenCallback = jest.fn().mockReturnValue({ status: HttpStatusCodes.NotFound });
junoClient.getGitHubToken = getGitHubTokenCallback;
const state = await gitHubOAuthService.startOAuth("scope");
const params: IGitHubConnectorParams = {
state,
code: "code",
}... | Azure/cosmos-explorer | src/GitHub/GitHubOAuthService.test.ts | TypeScript |
ArrowFunction |
() => {
gitHubOAuthService.resetToken();
expect(gitHubOAuthService.isLoggedIn()).toBeFalsy();
} | Azure/cosmos-explorer | src/GitHub/GitHubOAuthService.test.ts | TypeScript |
ArrowFunction |
async () => {
const deleteAppAuthorizationCallback = jest.fn().mockReturnValue({ status: HttpStatusCodes.NoContent });
junoClient.deleteAppAuthorization = deleteAppAuthorizationCallback;
await gitHubOAuthService.logout();
expect(gitHubOAuthService.isLoggedIn()).toBeFalsy();
} | Azure/cosmos-explorer | src/GitHub/GitHubOAuthService.test.ts | TypeScript |
ArrowFunction |
(lang) => {
this.language = lang;
} | ffluffyhedgehog/xm-webapp | src/app/shared/register/register.component.ts | TypeScript |
ArrowFunction |
(result) => {
this.needCaptcha = result.isCaptchaNeed;
this.publicKey = result.publicKey;
} | ffluffyhedgehog/xm-webapp | src/app/shared/register/register.component.ts | TypeScript |
ArrowFunction |
(config) => {
this.socialConfig = config && config.social;
} | ffluffyhedgehog/xm-webapp | src/app/shared/register/register.component.ts | TypeScript |
ArrowFunction |
(config: any) => {
this.makePasswordSettings(config);
} | ffluffyhedgehog/xm-webapp | src/app/shared/register/register.component.ts | TypeScript |
ArrowFunction |
() => this.makePasswordSettings() | ffluffyhedgehog/xm-webapp | src/app/shared/register/register.component.ts | TypeScript |
ArrowFunction |
(r) => {
if (r === 'accept') {
this.registration();
}
} | ffluffyhedgehog/xm-webapp | src/app/shared/register/register.component.ts | TypeScript |
ArrowFunction |
(err) => {
console.info(err);
} | ffluffyhedgehog/xm-webapp | src/app/shared/register/register.component.ts | TypeScript |
ArrowFunction |
(key) => {
this.registerAccount.langKey = key;
this.makeLogins();
this.registerService.save(this.registerAccount).subscribe(() => {
this.success = true;
this.eventManager.broadcast({name: XM_EVENT_LIST.XM_REGISTRATION, content: ''});
... | ffluffyhedgehog/xm-webapp | src/app/shared/register/register.component.ts | TypeScript |
ArrowFunction |
() => {
this.success = true;
this.eventManager.broadcast({name: XM_EVENT_LIST.XM_REGISTRATION, content: ''});
} | ffluffyhedgehog/xm-webapp | src/app/shared/register/register.component.ts | TypeScript |
ArrowFunction |
(response) => this.processError(response) | ffluffyhedgehog/xm-webapp | src/app/shared/register/register.component.ts | TypeScript |
ArrowFunction |
(result) => {
this.publicKey = result.publicKey;
} | ffluffyhedgehog/xm-webapp | src/app/shared/register/register.component.ts | TypeScript |
ClassDeclaration |
@Component({
selector: 'xm-register',
templateUrl: './register.component.html',
})
export class RegisterComponent implements OnInit {
@Input() public config: any;
@ViewChild(ReCaptchaComponent, {static: false}) public captcha: ReCaptchaComponent;
public email: string;
public msisdn: string;
... | ffluffyhedgehog/xm-webapp | src/app/shared/register/register.component.ts | TypeScript |
MethodDeclaration |
public ngOnInit(): void {
this.success = false;
this.registerAccount = {};
this.xmConfigService.getUiConfig().subscribe((config) => {
this.socialConfig = config && config.social;
});
this.xmConfigService
.getPasswordConfig()
.subscribe((config... | ffluffyhedgehog/xm-webapp | src/app/shared/register/register.component.ts | TypeScript |
MethodDeclaration |
public register(): void {
if (this.registerAccount.password !== this.confirmPassword) {
this.doNotMatch = 'ERROR';
} else {
if (this.config && this.config.privacyAndTermsEnabled) {
const modalRef = this.modalService.open(PrivacyAndTermsDialogComponent, {
... | ffluffyhedgehog/xm-webapp | src/app/shared/register/register.component.ts | TypeScript |
MethodDeclaration |
public handleCorrectCaptcha($event: any): void {
this.registerAccount.captcha = $event;
this.captchaRequired = null;
} | ffluffyhedgehog/xm-webapp | src/app/shared/register/register.component.ts | TypeScript |
MethodDeclaration |
public handleCaptchaExpired(_$event: any): void {
this.registerAccount.captcha = null;
} | ffluffyhedgehog/xm-webapp | src/app/shared/register/register.component.ts | TypeScript |
MethodDeclaration |
private registration(): void {
this.doNotMatch = null;
this.error = null;
this.errorUserExists = null;
this.errorEmailEmpty = null;
this.captchaRequired = null;
this.jhiLanguageService.getCurrent().then((key) => {
this.registerAccount.langKey = key;
... | ffluffyhedgehog/xm-webapp | src/app/shared/register/register.component.ts | TypeScript |
MethodDeclaration |
private processError(response: any): void {
this.success = null;
if (response.status === 400 && response.error.error === 'error.login.already.used') {
this.errorUserExists = 'ERROR';
} else if (response.status === 400 && response.error.error === 'error.captcha.required') {
... | ffluffyhedgehog/xm-webapp | src/app/shared/register/register.component.ts | TypeScript |
MethodDeclaration |
private makeLogins(): void {
this.registerAccount.logins = [];
// email login
this.registerAccount.logins.push({
typeKey: 'LOGIN.EMAIL',
login: this.email,
});
// nickname login
if (this.nickname) {
this.registerAccount.logins.push({... | ffluffyhedgehog/xm-webapp | src/app/shared/register/register.component.ts | TypeScript |
MethodDeclaration |
private makePasswordSettings(config?: any): void {
this.passwordConfig = config;
this.passwordSettings = this.xmConfigService.mapPasswordSettings(config);
if (this.passwordSettings.patternMessage) {
this.patternMessage = this.xmConfigService.updatePatternMessage(this.passwordSetting... | ffluffyhedgehog/xm-webapp | src/app/shared/register/register.component.ts | TypeScript |
ArrowFunction |
() => (
<SvgIcon viewBox="0 0 512 512">
<linearGradient
gradientUnits | 435352980/tw-qc-static | src/svgIcons/ArmorSvg.tsx | TypeScript |
FunctionDeclaration |
function colRef<T>(ref: CollectionPredicate<T>): CollectionReference<T> {
const db = getFirestore();
return typeof ref === 'string' ? (collection(db, ref) as CollectionReference<T>) : ref;
} | jacobbowdoin/sveltefire-ts | src/lib/client/firestore-lite.ts | TypeScript |
FunctionDeclaration |
function docRef<T>(ref: DocPredicate<T>): DocumentReference<T> {
if (typeof ref === 'string') {
const pathParts = ref.split('/');
const documentId = pathParts.pop();
const collectionString = pathParts.join('/');
return doc<T>(colRef(collectionString), documentId);
} else {
return ref;
}
} | jacobbowdoin/sveltefire-ts | src/lib/client/firestore-lite.ts | TypeScript |
FunctionDeclaration | // not exporting lite versions of getCollection nor getDocument on client in favor of using full firestore cache-first versions.
async function getDocument<T>(ref: DocPredicate<T>): Promise<T> {
const docSnap = await getDoc(docRef(ref));
return docSnap.exists() ? { ...(docSnap.data() as T), id: docSnap.id } : null;... | jacobbowdoin/sveltefire-ts | src/lib/client/firestore-lite.ts | TypeScript |
FunctionDeclaration | /**
* Use when wanting to receive back promises that will resolve or error when internet is flaky, unlike regular firestore methods which won't resolve right away in these situations.
* Be sure to import firestore methods such as serverTimestamp() from firebase/firestore/lite otherwise you will receive errors */
expo... | jacobbowdoin/sveltefire-ts | src/lib/client/firestore-lite.ts | TypeScript |
FunctionDeclaration | /**
* Use when wanting to receive back promises that will resolve or error when internet is flaky, unlike regular firestore methods which won't resolve right away in these situations.
* Be sure to import firestore methods such as serverTimestamp() from firebase/firestore/lite otherwise you will receive errors */
expo... | jacobbowdoin/sveltefire-ts | src/lib/client/firestore-lite.ts | TypeScript |
FunctionDeclaration | /**
* Use when wanting to receive back promises that will resolve or error when internet is flaky, unlike regular firestore methods which won't resolve right away in these situations.
* Be sure to import firestore methods such as serverTimestamp() from firebase/firestore/lite otherwise you will receive errors */
expo... | jacobbowdoin/sveltefire-ts | src/lib/client/firestore-lite.ts | TypeScript |
FunctionDeclaration | /**
* Use when wanting to receive back promises that will resolve or error when internet is flaky, unlike regular firestore methods which won't resolve right away in these situations.
* Be sure to import firestore methods such as serverTimestamp() from firebase/firestore/lite otherwise you will receive errors */
expo... | jacobbowdoin/sveltefire-ts | src/lib/client/firestore-lite.ts | TypeScript |
ArrowFunction |
() => {
const u = get(authState);
return (u && u.uid) || 'anonymous'; // 'anonymous' allows support messages to be saved by non-logged-in users
} | jacobbowdoin/sveltefire-ts | src/lib/client/firestore-lite.ts | TypeScript |
TypeAliasDeclaration |
type CollectionPredicate<T> = string | CollectionReference<T>; | jacobbowdoin/sveltefire-ts | src/lib/client/firestore-lite.ts | TypeScript |
TypeAliasDeclaration |
type DocPredicate<T> = string | DocumentReference<T>; | jacobbowdoin/sveltefire-ts | src/lib/client/firestore-lite.ts | TypeScript |
ArrowFunction |
() => {
ws.send(JSON.stringify(Message.ConnectRequest));
} | STScript-2020/cc21-artifact | case-studies/Battleships/client/src/Battleships/P1/P1.tsx | TypeScript |
ArrowFunction |
(event) => {
this.setState({ elem: this.props.connectFailed });
} | STScript-2020/cc21-artifact | case-studies/Battleships/client/src/Battleships/P1/P1.tsx | TypeScript |
ArrowFunction |
(payload: T) => this.sendMessage(role, label, payload, successor) | STScript-2020/cc21-artifact | case-studies/Battleships/client/src/Battleships/P1/P1.tsx | TypeScript |
ArrowFunction |
(error?: any) => this.cancel(error) | STScript-2020/cc21-artifact | case-studies/Battleships/client/src/Battleships/P1/P1.tsx | TypeScript |
ArrowFunction |
(event: FunctionArguments<DOMEvents[K]>) => {
if (used) {
return;
}
used = true;
try {
const result = handler(event);
... | STScript-2020/cc21-artifact | case-studies/Battleships/client/src/Battleships/P1/P1.tsx | TypeScript |
ArrowFunction |
child => (
React.cloneElement(child as React.ReactElement, props)
) | STScript-2020/cc21-artifact | case-studies/Battleships/client/src/Battleships/P1/P1.tsx | TypeScript |
ClassDeclaration |
export default class Session extends React.Component<Props, Partial<Transport>> {
constructor(props: Props) {
super(props);
this.state = {
ws: undefined
};
}
componentDidMount() {
// Set up WebSocket connection
this.setState({
ws: new WebSoc... | STScript-2020/cc21-artifact | case-studies/Battleships/client/src/Battleships/P1/P1.tsx | TypeScript |
ClassDeclaration |
class P1 extends React.Component<Props & Transport, ComponentState> {
private messageQueue: RoleToMessageQueue
private handlerQueue: RoleToHandlerQueue
constructor(props: Props & Transport) {
super(props);
this.state = {
elem: props.waiting,
};
// Set up mess... | STScript-2020/cc21-artifact | case-studies/Battleships/client/src/Battleships/P1/P1.tsx | TypeScript |
TypeAliasDeclaration |
type RoleToMessageQueue = Roles.PeersToMapped<any[]>; | STScript-2020/cc21-artifact | case-studies/Battleships/client/src/Battleships/P1/P1.tsx | TypeScript |
TypeAliasDeclaration |
type RoleToHandlerQueue = Roles.PeersToMapped<ReceiveHandler[]>; | STScript-2020/cc21-artifact | case-studies/Battleships/client/src/Battleships/P1/P1.tsx | TypeScript |
TypeAliasDeclaration | // ==============
// Component type
// ==============
type Props = {
endpoint: string,
states: {
S17: Constructor<S17>,
S19: Constructor<S19>,
S21: Constructor<S21>,
S20: Constructor<S20>,
S18: Constructor<S18>,
},
waiting: React.ReactNode,
connectFailed: Rea... | STScript-2020/cc21-artifact | case-studies/Battleships/client/src/Battleships/P1/P1.tsx | TypeScript |
TypeAliasDeclaration |
type Transport = {
ws: WebSocket
}; | STScript-2020/cc21-artifact | case-studies/Battleships/client/src/Battleships/P1/P1.tsx | TypeScript |
TypeAliasDeclaration |
type ComponentState = {
elem: React.ReactNode
}; | STScript-2020/cc21-artifact | case-studies/Battleships/client/src/Battleships/P1/P1.tsx | TypeScript |
MethodDeclaration |
componentDidMount() {
// Set up WebSocket connection
this.setState({
ws: new WebSocket(this.props.endpoint),
});
} | STScript-2020/cc21-artifact | case-studies/Battleships/client/src/Battleships/P1/P1.tsx | TypeScript |
MethodDeclaration |
render() {
const { ws } = this.state;
return ws === undefined
? this.props.waiting
: <P1 ws={ws} {...this.props} />;
} | STScript-2020/cc21-artifact | case-studies/Battleships/client/src/Battleships/P1/P1.tsx | TypeScript |
MethodDeclaration |
componentDidMount() {
const { ws } = this.props;
ws.onmessage = this.onReceiveInit;
// Send connection message
ws.onopen = () => {
ws.send(JSON.stringify(Message.ConnectRequest));
};
// Handle error
ws.onerror = (event) => {
this.setStat... | STScript-2020/cc21-artifact | case-studies/Battleships/client/src/Battleships/P1/P1.tsx | TypeScript |
MethodDeclaration | // ===============
// Session joining
// ===============
private onReceiveInit(message: MessageEvent) {
const { ws } = this.props;
ws.onmessage = this.onReceiveMessage;
ws.onclose = this.onClose;
this.advance(SendState.S17);
} | STScript-2020/cc21-artifact | case-studies/Battleships/client/src/Battleships/P1/P1.tsx | TypeScript |
MethodDeclaration |
private onCloseInit({ code, wasClean, reason }: CloseEvent) {
if (!wasClean) {
// Not closed properly
this.setState({ elem: this.props.connectFailed });
return;
}
switch (code) {
case Cancellation.Receive.ROLE_OCCUPIED: {
this.pro... | STScript-2020/cc21-artifact | case-studies/Battleships/client/src/Battleships/P1/P1.tsx | TypeScript |
MethodDeclaration | // ===============
// EFSM operations
// ===============
private advance(state: State) {
if (isSendState(state)) {
const View = this.props.states[state];
this.setState({
elem: <View factory={this.buildSendElement} />
});
return;
} | STScript-2020/cc21-artifact | case-studies/Battleships/client/src/Battleships/P1/P1.tsx | TypeScript |
MethodDeclaration |
if (isReceiveState | STScript-2020/cc21-artifact | case-studies/Battleships/client/src/Battleships/P1/P1.tsx | TypeScript |
MethodDeclaration |
return <K extends keyof DOMEvents>(eventLabel: K, handler: EventHandler<T, K>) | STScript-2020/cc21-artifact | case-studies/Battleships/client/src/Battleships/P1/P1.tsx | TypeScript |
MethodDeclaration |
render() {
const props = {
[eventLabel as string]: (event: FunctionArguments<DOMEvents[K]>) => {
if (used) {
return;
}
used = true;
... | STScript-2020/cc21-artifact | case-studies/Battleships/client/src/Battleships/P1/P1.tsx | TypeScript |
ArrowFunction |
(letter: string): string => "_" + letter.toLowerCase() | Raisess/i3bcks-gen | src/Parser.ts | TypeScript |
ArrowFunction |
(item: string): string => item.trim() | Raisess/i3bcks-gen | src/Parser.ts | TypeScript |
ClassDeclaration |
export default class Parser {
private parsedBlocks: Array<string> = [
"command=/usr/share/i3blocks/$BLOCK_NAME\nseparator_block_width=20\nmarkup=none\n\n",
];
constructor(private blocks: Array<Block>) {}
public parse(): string {
for (const block of this.blocks) {
let parsedBlock: string = `[${b... | Raisess/i3bcks-gen | src/Parser.ts | TypeScript |
TypeAliasDeclaration |
export type Block = {
name: string;
label?: string;
align?: string;
color?: string;
fullText?: string;
shortText?: string;
instance?: string;
interval?: number | "once" | "persist" | "repeat";
minWidth?: string;
separator?: boolean;
separatorBlockWidth?: number;
signal?: number;
urgent?: stri... | Raisess/i3bcks-gen | src/Parser.ts | TypeScript |
MethodDeclaration |
public parse(): string {
for (const block of this.blocks) {
let parsedBlock: string = `[${block.name}]`;
const blockEntries: Array<[string, unknown]> = Object.entries(block);
for (const [key, value] of blockEntries) {
if (key !== "name" && key !== "command" && key !== "evalType") {
... | Raisess/i3bcks-gen | src/Parser.ts | TypeScript |
MethodDeclaration |
private parseField(key: string, value: unknown): string {
return `\n${key.replace(
/[A-Z]/g,
(letter: string): string => "_" + letter.toLowerCase()
)}=${value}`;
} | Raisess/i3bcks-gen | src/Parser.ts | TypeScript |
MethodDeclaration |
private functionToString(funct: () => unknown): string {
const expression: string = funct
.toString()
.split(/\n/)
.map((item: string): string => item.trim())
.join("");
return expression;
} | Raisess/i3bcks-gen | src/Parser.ts | TypeScript |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.