type
stringclasses
7 values
content
stringlengths
4
9.55k
repo
stringlengths
7
96
path
stringlengths
4
178
language
stringclasses
1 value
MethodDeclaration
public register<T>( token: InjectionToken<T>, provider: FactoryProvider<T> ): InternalDependencyContainer;
launchtray/tsyringe
src/dependency-container.ts
TypeScript
MethodDeclaration
public register<T>( token: InjectionToken<T>, provider: TokenProvider<T>, options?: RegistrationOptions ): InternalDependencyContainer;
launchtray/tsyringe
src/dependency-container.ts
TypeScript
MethodDeclaration
public register<T>( token: InjectionToken<T>, provider: ClassProvider<T>, options?: RegistrationOptions ): InternalDependencyContainer;
launchtray/tsyringe
src/dependency-container.ts
TypeScript
MethodDeclaration
public register<T>( token: InjectionToken<T>, provider: constructor<T>, options?: RegistrationOptions ): InternalDependencyContainer;
launchtray/tsyringe
src/dependency-container.ts
TypeScript
MethodDeclaration
public register<T>( token: InjectionToken<T>, providerOrConstructor: Provider<T> | constructor<T>, options: RegistrationOptions = {lifecycle: Lifecycle.Transient} ): InternalDependencyContainer { let provider: Provider<T>; if (!isProvider(providerOrConstructor)) { provider = {useClass: pro...
launchtray/tsyringe
src/dependency-container.ts
TypeScript
MethodDeclaration
public registerType<T>( from: InjectionToken<T>, to: InjectionToken<T> ): InternalDependencyContainer { if (isNormalToken(to)) { return this.register(from, { useToken: to }); } return this.register(from, { useClass: to }); }
launchtray/tsyringe
src/dependency-container.ts
TypeScript
MethodDeclaration
public registerInstance<T>( token: InjectionToken<T>, instance: T ): InternalDependencyContainer { return this.register(token, { useValue: instance }); }
launchtray/tsyringe
src/dependency-container.ts
TypeScript
MethodDeclaration
public registerSingleton<T>( from: InjectionToken<T>, to: InjectionToken<T> ): InternalDependencyContainer;
launchtray/tsyringe
src/dependency-container.ts
TypeScript
MethodDeclaration
public registerSingleton<T>( token: constructor<T>, to?: constructor<any> ): InternalDependencyContainer;
launchtray/tsyringe
src/dependency-container.ts
TypeScript
MethodDeclaration
public registerSingleton<T>( from: InjectionToken<T>, to?: InjectionToken<T> ): InternalDependencyContainer { if (isNormalToken(from)) { if (isNormalToken(to)) { return this.register( from, { useToken: to }, {lifecycle: Lifecycle.Singleton...
launchtray/tsyringe
src/dependency-container.ts
TypeScript
MethodDeclaration
public async resolve<T>( token: InjectionToken<T>, context: ResolutionContext = new ResolutionContext() ): Promise<T> { const registration = this.getRegistration(token); if (!registration && isNormalToken(token)) { throw new Error( `Attempted to resolve unregistered dependency token: "...
launchtray/tsyringe
src/dependency-container.ts
TypeScript
MethodDeclaration
private resolveRegistration<T>( registration: Registration, context: ResolutionContext ): Promise<T> { // If we have already resolved or are already resolving this scoped dependency, return its promise if ( registration.options.lifecycle === Lifecycle.ResolutionScoped && context.scopedRes...
launchtray/tsyringe
src/dependency-container.ts
TypeScript
MethodDeclaration
private async resolveRegistrationHelper<T>( registration: Registration, context: ResolutionContext ): Promise<T> { const isSingleton = registration.options.lifecycle === Lifecycle.Singleton; const isContainerScoped = registration.options.lifecycle === Lifecycle.ContainerScoped; const retur...
launchtray/tsyringe
src/dependency-container.ts
TypeScript
MethodDeclaration
public async resolveAll<T>( token: InjectionToken<T>, context: ResolutionContext = new ResolutionContext() ): Promise<T[]> { let registrations = this.getAllRegistrations(token); if (!registrations && isNormalToken(token)) { registrations = []; } if (registrations) { const instan...
launchtray/tsyringe
src/dependency-container.ts
TypeScript
MethodDeclaration
public isRegistered<T>(token: InjectionToken<T>, recursive = false): boolean { return ( this._registry.has(token) || (recursive && (this.parent || false) && this.parent.isRegistered(token, true)) ); }
launchtray/tsyringe
src/dependency-container.ts
TypeScript
MethodDeclaration
public reset(): void { this._registry.clear(); }
launchtray/tsyringe
src/dependency-container.ts
TypeScript
MethodDeclaration
public clearInstances(): void { for (const [token, registrations] of this._registry.entries()) { this._registry.setAll( token, registrations // Clear ValueProvider registrations .filter(registration => !isValueProvider(registration.provider)) // Clear instances ...
launchtray/tsyringe
src/dependency-container.ts
TypeScript
MethodDeclaration
public createChildContainer(): DependencyContainer { const childContainer = new InternalDependencyContainer(this); for (const [token, registrations] of this._registry.entries()) { // If there are any ContainerScoped registrations, we need to copy // ALL registrations to the child container, if we ...
launchtray/tsyringe
src/dependency-container.ts
TypeScript
MethodDeclaration
private getRegistration<T>(token: InjectionToken<T>): Registration | null { if (this.isRegistered(token)) { return this._registry.get(token)!; } if (this.parent) { return this.parent.getRegistration(token); } return null; }
launchtray/tsyringe
src/dependency-container.ts
TypeScript
MethodDeclaration
private getAllRegistrations<T>( token: InjectionToken<T> ): Registration[] | null { if (this.isRegistered(token)) { return this._registry.getAll(token); } if (this.parent) { return this.parent.getAllRegistrations(token); } return null; }
launchtray/tsyringe
src/dependency-container.ts
TypeScript
MethodDeclaration
private async construct<T>( ctor: constructor<T>, context: ResolutionContext ): Promise<T> { if (typeof ctor === "undefined") { throw new Error( "Attempted to construct an undefined constructor. Could mean a circular dependency problem." ); } if (ctor.length === 0) { re...
launchtray/tsyringe
src/dependency-container.ts
TypeScript
MethodDeclaration
private resolveParams<T>(context: ResolutionContext, ctor: constructor<T>) { return async (param: ParamInfo, idx: number) => { try { if (isTokenDescriptor(param)) { return param.multiple ? await this.resolveAll(param.token) : await this.resolve(param.token, context);...
launchtray/tsyringe
src/dependency-container.ts
TypeScript
ArrowFunction
() => { const targetRef = useRef<HTMLDivElement>(null) const onHeightChange = (height: number) => { const ratio = height / maxHeight console.log(ratio) const target = targetRef.current if (!target) return target.style.height = '100%' target.style.backgroundImage = `linear-gradient(rgba(185...
IronKinoko/ant-design-mobile
src/components/floating-panel/demos/demo2.tsx
TypeScript
ArrowFunction
(height: number) => { const ratio = height / maxHeight console.log(ratio) const target = targetRef.current if (!target) return target.style.height = '100%' target.style.backgroundImage = `linear-gradient(rgba(185,147,214,${ratio}),rgba(140,166,219,${ratio}))` }
IronKinoko/ant-design-mobile
src/components/floating-panel/demos/demo2.tsx
TypeScript
ArrowFunction
() => { onHeightChange(minHeight) }
IronKinoko/ant-design-mobile
src/components/floating-panel/demos/demo2.tsx
TypeScript
ArrowFunction
() => { let page: AppPage; beforeEach(() => { page = new AppPage(); }); it('should display welcome message', () => { page.navigateTo(); expect(page.getTitleText()).toEqual('OCDE app is running!'); }); afterEach(async () => { // Assert that there are no errors emitted from the browser ...
HARSHIT-GUPTA-coder/OCDE
frontend/e2e/src/app.e2e-spec.ts
TypeScript
ArrowFunction
() => { page.navigateTo(); expect(page.getTitleText()).toEqual('OCDE app is running!'); }
HARSHIT-GUPTA-coder/OCDE
frontend/e2e/src/app.e2e-spec.ts
TypeScript
ArrowFunction
({ hideMobile }) => hideMobile && css` display: none `
PeterTheOne/rLogin
src/ux/step1/WalletProviders.tsx
TypeScript
ArrowFunction
({ userProvider, handleConnect }: { userProvider: IProviderUserOptions, handleConnect: (provider: any) => void }) => <Provider key
PeterTheOne/rLogin
src/ux/step1/WalletProviders.tsx
TypeScript
ArrowFunction
(userProviders: IProviderUserOptions[]) => { const providersByName: { [name: string]: IProviderUserOptions } = {} for (const userProvider of userProviders) { providersByName[userProvider.name] = userProvider } return providersByName }
PeterTheOne/rLogin
src/ux/step1/WalletProviders.tsx
TypeScript
ArrowFunction
({ userProviders, connectToWallet, changeLanguage, changeTheme, availableLanguages, selectedLanguageCode, selectedTheme }: IWalletProvidersProps) => { // the providers that are hardcoded into the layout below const hardCodedProviderNames = [ providers.METAMASK.name, providers.NIFTY.name, providers.LIQUALITY.na...
PeterTheOne/rLogin
src/ux/step1/WalletProviders.tsx
TypeScript
ArrowFunction
(providerName: string) => !hardCodedProviderNames.includes(providerName) ? providerName : null
PeterTheOne/rLogin
src/ux/step1/WalletProviders.tsx
TypeScript
ArrowFunction
(provider: IProviderUserOptions) => connectToWallet(provider)
PeterTheOne/rLogin
src/ux/step1/WalletProviders.tsx
TypeScript
ArrowFunction
(providerName: string) => <UserProvider key
PeterTheOne/rLogin
src/ux/step1/WalletProviders.tsx
TypeScript
InterfaceDeclaration
interface IWalletProvidersProps { userProviders: IProviderUserOptions[] connectToWallet: (provider: IProviderUserOptions) => void changeLanguage: (event: any) => void changeTheme: (theme: themesOptions) => void availableLanguages: { code:string, name:string } [] selectedLanguageCode: string selectedTheme...
PeterTheOne/rLogin
src/ux/step1/WalletProviders.tsx
TypeScript
MethodDeclaration
wallet<
PeterTheOne/rLogin
src/ux/step1/WalletProviders.tsx
TypeScript
ClassDeclaration
@NgModule({ bootstrap: [LanguageDemoComponent], declarations: [LanguageDemoComponent], imports: [ BrowserModule, RecaptchaModule.forRoot(), DemoWrapperModule, ], providers: [ { provide: RECAPTCHA_LANGUAGE, useValue: 'fr', }, { provide: PAGE_SETTINGS, useValue: settings }, ...
Nelinho/ng-recaptcha
demo/src/app/examples/language/language-demo.module.ts
TypeScript
FunctionDeclaration
function subnetTypeTagValue(type: SubnetType) { switch (type) { case SubnetType.Public: return 'Public'; case SubnetType.Private: return 'Private'; case SubnetType.Isolated: return 'Isolated'; } }
allisaurus/aws-cdk
packages/@aws-cdk/aws-ec2/lib/vpc.ts
TypeScript
FunctionDeclaration
function ifUndefined<T>(value: T | undefined, defaultValue: T): T { return value !== undefined ? value : defaultValue; }
allisaurus/aws-cdk
packages/@aws-cdk/aws-ec2/lib/vpc.ts
TypeScript
ArrowFunction
subnet => (subnet.subnetType !== SubnetType.Isolated)
allisaurus/aws-cdk
packages/@aws-cdk/aws-ec2/lib/vpc.ts
TypeScript
ArrowFunction
publicSubnet => { publicSubnet.addDefaultIGWRouteEntry(igw, att); }
allisaurus/aws-cdk
packages/@aws-cdk/aws-ec2/lib/vpc.ts
TypeScript
ArrowFunction
(privateSubnet, i) => { let ngwId = this.natGatewayByAZ[privateSubnet.availabilityZone]; if (ngwId === undefined) { const ngwArray = Array.from(Object.values(this.natGatewayByAZ)); // round robin the available NatGW since one is not in your AZ ngwId = ngwArray[i % ngwArray...
allisaurus/aws-cdk
packages/@aws-cdk/aws-ec2/lib/vpc.ts
TypeScript
ArrowFunction
subnet => (subnet.subnetType === SubnetType.Private)
allisaurus/aws-cdk
packages/@aws-cdk/aws-ec2/lib/vpc.ts
TypeScript
ArrowFunction
(zone, index) => { const name = subnetId(subnetConfig.name, index); const subnetProps: VpcSubnetProps = { availabilityZone: zone, vpcId: this.vpcId, cidrBlock: this.networkBuilder.addSubnet(cidrMask), mapPublicIpOnLaunch: (subnetConfig.subnetType === SubnetType.Public), ...
allisaurus/aws-cdk
packages/@aws-cdk/aws-ec2/lib/vpc.ts
TypeScript
ClassDeclaration
/** * Represents a new VPC subnet resource */ export class VpcSubnet extends cdk.Construct implements IVpcSubnet { public static import(scope: cdk.Construct, id: string, props: VpcSubnetImportProps): IVpcSubnet { return new ImportedVpcSubnet(scope, id, props); } /** * The Availability Zone the subnet is...
allisaurus/aws-cdk
packages/@aws-cdk/aws-ec2/lib/vpc.ts
TypeScript
ClassDeclaration
/** * Represents a public VPC subnet resource */ export class VpcPublicSubnet extends VpcSubnet { constructor(scope: cdk.Construct, id: string, props: VpcSubnetProps) { super(scope, id, props); } /** * Create a default route that points to a passed IGW, with a dependency * on the IGW's attachment to...
allisaurus/aws-cdk
packages/@aws-cdk/aws-ec2/lib/vpc.ts
TypeScript
ClassDeclaration
/** * Represents a private VPC subnet resource */ export class VpcPrivateSubnet extends VpcSubnet { constructor(scope: cdk.Construct, id: string, props: VpcSubnetProps) { super(scope, id, props); } /** * Adds an entry to this subnets route table that points to the passed NATGatwayId */ public addDe...
allisaurus/aws-cdk
packages/@aws-cdk/aws-ec2/lib/vpc.ts
TypeScript
ClassDeclaration
class ImportedVpcNetwork extends VpcNetworkBase { public readonly vpcId: string; public readonly publicSubnets: IVpcSubnet[]; public readonly privateSubnets: IVpcSubnet[]; public readonly isolatedSubnets: IVpcSubnet[]; public readonly availabilityZones: string[]; constructor(scope: cdk.Construct, id: stri...
allisaurus/aws-cdk
packages/@aws-cdk/aws-ec2/lib/vpc.ts
TypeScript
ClassDeclaration
class ImportedVpcSubnet extends cdk.Construct implements IVpcSubnet { public readonly internetConnectivityEstablished: cdk.IDependable = new cdk.ConcreteDependable(); public readonly availabilityZone: string; public readonly subnetId: string; constructor(scope: cdk.Construct, id: string, private readonly prop...
allisaurus/aws-cdk
packages/@aws-cdk/aws-ec2/lib/vpc.ts
TypeScript
InterfaceDeclaration
/** * VpcNetworkProps allows you to specify configuration options for a VPC */ export interface VpcNetworkProps { /** * The CIDR range to use for the VPC (e.g. '10.0.0.0/16'). Should be a minimum of /28 and maximum size of /16. * The range will be split evenly into two subnets per Availability Zone (one publ...
allisaurus/aws-cdk
packages/@aws-cdk/aws-ec2/lib/vpc.ts
TypeScript
InterfaceDeclaration
/** * Specify configuration parameters for a VPC to be built */ export interface SubnetConfiguration { /** * The CIDR Mask or the number of leading 1 bits in the routing mask * * Valid values are 16 - 28 */ cidrMask?: number; /** * The type of Subnet to configure. * * The Subnet type will ...
allisaurus/aws-cdk
packages/@aws-cdk/aws-ec2/lib/vpc.ts
TypeScript
InterfaceDeclaration
/** * Specify configuration parameters for a VPC subnet */ export interface VpcSubnetProps { /** * The availability zone for the subnet */ availabilityZone: string; /** * The VPC which this subnet is part of */ vpcId: string; /** * The CIDR notation for this subnet */ cidrBlock: strin...
allisaurus/aws-cdk
packages/@aws-cdk/aws-ec2/lib/vpc.ts
TypeScript
EnumDeclaration
/** * The default tenancy of instances launched into the VPC. */ export enum DefaultInstanceTenancy { /** * Instances can be launched with any tenancy. */ Default = 'default', /** * Any instance launched into the VPC automatically has dedicated tenancy, unless you launch it with the default tenancy. ...
allisaurus/aws-cdk
packages/@aws-cdk/aws-ec2/lib/vpc.ts
TypeScript
MethodDeclaration
/** * Import an exported VPC */ public static import(scope: cdk.Construct, id: string, props: VpcNetworkImportProps): IVpcNetwork { return new ImportedVpcNetwork(scope, id, props); }
allisaurus/aws-cdk
packages/@aws-cdk/aws-ec2/lib/vpc.ts
TypeScript
MethodDeclaration
/** * Import an existing VPC from context */ public static importFromContext(scope: cdk.Construct, id: string, props: VpcNetworkProviderProps): IVpcNetwork { return VpcNetwork.import(scope, id, new VpcNetworkProvider(scope, props).vpcProps); }
allisaurus/aws-cdk
packages/@aws-cdk/aws-ec2/lib/vpc.ts
TypeScript
MethodDeclaration
/** * Export this VPC from the stack */ public export(): VpcNetworkImportProps { const pub = new ExportSubnetGroup(this, 'PublicSubnetIDs', this.publicSubnets, SubnetType.Public, this.availabilityZones.length); const priv = new ExportSubnetGroup(this, 'PrivateSubnetIDs', this.privateSubnets, SubnetType.Pr...
allisaurus/aws-cdk
packages/@aws-cdk/aws-ec2/lib/vpc.ts
TypeScript
MethodDeclaration
private createNatGateways(gateways?: number, placement?: VpcPlacementStrategy): void { const useNatGateway = this.subnetConfiguration.filter( subnet => (subnet.subnetType === SubnetType.Private)).length > 0; const natCount = ifUndefined(gateways, useNatGateway ? this.availabilityZones.length : 0);...
allisaurus/aws-cdk
packages/@aws-cdk/aws-ec2/lib/vpc.ts
TypeScript
MethodDeclaration
/** * createSubnets creates the subnets specified by the subnet configuration * array or creates the `DEFAULT_SUBNETS` configuration */ private createSubnets() { const remainingSpaceSubnets: SubnetConfiguration[] = []; // Calculate number of public/private subnets based on number of AZs const zone...
allisaurus/aws-cdk
packages/@aws-cdk/aws-ec2/lib/vpc.ts
TypeScript
MethodDeclaration
private createSubnetResources(subnetConfig: SubnetConfiguration, cidrMask: number) { this.availabilityZones.forEach((zone, index) => { const name = subnetId(subnetConfig.name, index); const subnetProps: VpcSubnetProps = { availabilityZone: zone, vpcId: this.vpcId, cidrBlock: thi...
allisaurus/aws-cdk
packages/@aws-cdk/aws-ec2/lib/vpc.ts
TypeScript
MethodDeclaration
public static import(scope: cdk.Construct, id: string, props: VpcSubnetImportProps): IVpcSubnet { return new ImportedVpcSubnet(scope, id, props); }
allisaurus/aws-cdk
packages/@aws-cdk/aws-ec2/lib/vpc.ts
TypeScript
MethodDeclaration
public export(): VpcSubnetImportProps { return { availabilityZone: new cdk.Output(this, 'AvailabilityZone', { value: this.availabilityZone }).makeImportValue().toString(), subnetId: new cdk.Output(this, 'VpcSubnetId', { value: this.subnetId }).makeImportValue().toString(), }; }
allisaurus/aws-cdk
packages/@aws-cdk/aws-ec2/lib/vpc.ts
TypeScript
MethodDeclaration
protected addDefaultRouteToNAT(natGatewayId: string) { const route = new CfnRoute(this, `DefaultRoute`, { routeTableId: this.routeTableId, destinationCidrBlock: '0.0.0.0/0', natGatewayId }); this.internetDependencies.add(route); }
allisaurus/aws-cdk
packages/@aws-cdk/aws-ec2/lib/vpc.ts
TypeScript
MethodDeclaration
/** * Create a default route that points to a passed IGW, with a dependency * on the IGW's attachment to the VPC. */ protected addDefaultRouteToIGW( gateway: CfnInternetGateway, gatewayAttachment: CfnVPCGatewayAttachment) { const route = new CfnRoute(this, `DefaultRoute`, { routeTableId: this...
allisaurus/aws-cdk
packages/@aws-cdk/aws-ec2/lib/vpc.ts
TypeScript
MethodDeclaration
/** * Create a default route that points to a passed IGW, with a dependency * on the IGW's attachment to the VPC. */ public addDefaultIGWRouteEntry( gateway: CfnInternetGateway, gatewayAttachment: CfnVPCGatewayAttachment) { this.addDefaultRouteToIGW(gateway, gatewayAttachment); }
allisaurus/aws-cdk
packages/@aws-cdk/aws-ec2/lib/vpc.ts
TypeScript
MethodDeclaration
/** * Creates a new managed NAT gateway attached to this public subnet. * Also adds the EIP for the managed NAT. * @returns A ref to the the NAT Gateway ID */ public addNatGateway() { // Create a NAT Gateway in this public subnet const ngw = new CfnNatGateway(this, `NATGateway`, { subnetId: th...
allisaurus/aws-cdk
packages/@aws-cdk/aws-ec2/lib/vpc.ts
TypeScript
MethodDeclaration
/** * Adds an entry to this subnets route table that points to the passed NATGatwayId */ public addDefaultNatRouteEntry(natGatewayId: string) { this.addDefaultRouteToNAT(natGatewayId); }
allisaurus/aws-cdk
packages/@aws-cdk/aws-ec2/lib/vpc.ts
TypeScript
MethodDeclaration
public export() { return this.props; }
allisaurus/aws-cdk
packages/@aws-cdk/aws-ec2/lib/vpc.ts
TypeScript
ClassDeclaration
/** Provides operations to call the restore method. */ export class RestoreRequestBuilder { /** Path parameters for the request */ private readonly pathParameters: Record<string, unknown>; /** The request adapter to use to execute the requests. */ private readonly requestAdapter: RequestAdapter; /**...
microsoftgraph/msgraph-sdk-typescript
src/directoryRoles/item/restore/restoreRequestBuilder.ts
TypeScript
MethodDeclaration
/** * Invoke action restore * @param requestConfiguration Configuration for the request such as headers, query parameters, and middleware options. * @returns a RequestInformation */ public createPostRequestInformation(requestConfiguration?: RestoreRequestBuilderPostRequestConfiguration | undefined) ...
microsoftgraph/msgraph-sdk-typescript
src/directoryRoles/item/restore/restoreRequestBuilder.ts
TypeScript
MethodDeclaration
/** * Invoke action restore * @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 Directory...
microsoftgraph/msgraph-sdk-typescript
src/directoryRoles/item/restore/restoreRequestBuilder.ts
TypeScript
ArrowFunction
(index: number, _piece: PieceProps) => { if (Math.floor(index / 8 + index) % 2) { const [color, setColor] = React.useState("black"); const [piece, setPiece] = React.useState(_piece); return { piece: piece, setPiece: setPiece, color: color, setColor: setColo...
07kshitij/chess
src/components/Board.tsx
TypeScript
ArrowFunction
() => { let BoardConfig: Array<BoardStatusProps> = []; const white_row = [ PieceDetails.WHITE_ROOK, PieceDetails.WHITE_KNIGHT, PieceDetails.WHITE_BISHOP, PieceDetails.WHITE_QUEEN, PieceDetails.WHITE_KING, PieceDetails.WHITE_BISHOP, PieceDetails.WHITE_KNIGHT, ...
07kshitij/chess
src/components/Board.tsx
TypeScript
ArrowFunction
() => { socket.once("updateMoveTable", (data) => { if (process.env.NODE_ENV === "development") { console.log("+++ updateMoveTable +++", data); } setGameMoves((gameMoves) => [...gameMoves, data.move]); if (data.checkmate || data.stalemate) { socket.emit("game-complete"...
07kshitij/chess
src/components/Board.tsx
TypeScript
ArrowFunction
(data) => { if (process.env.NODE_ENV === "development") { console.log("+++ updateMoveTable +++", data); } setGameMoves((gameMoves) => [...gameMoves, data.move]); if (data.checkmate || data.stalemate) { socket.emit("game-complete", { result: data.result, ...
07kshitij/chess
src/components/Board.tsx
TypeScript
ArrowFunction
(gameMoves) => [...gameMoves, data.move]
07kshitij/chess
src/components/Board.tsx
TypeScript
ArrowFunction
() => { socket.once("nextTurn", (data) => { if (process.env.NODE_ENV === "development") { console.log(socket.id === data.socket ? "+++ moveSelf +++" : "+++ moveOpponent +++"); } const [from, to, moveType, sockId] = [data.fromPiece, data.toPiece, data.moveType, data.socket]; if...
07kshitij/chess
src/components/Board.tsx
TypeScript
ArrowFunction
(data) => { if (process.env.NODE_ENV === "development") { console.log(socket.id === data.socket ? "+++ moveSelf +++" : "+++ moveOpponent +++"); } const [from, to, moveType, sockId] = [data.fromPiece, data.toPiece, data.moveType, data.socket]; if (BoardConfig[data.fromPos].piece !==...
07kshitij/chess
src/components/Board.tsx
TypeScript
ArrowFunction
() => { socket.off("nextTurn"); }
07kshitij/chess
src/components/Board.tsx
TypeScript
ArrowFunction
() => { socket.once("performCastling", (data) => { if (process.env.NODE_ENV === "development") { console.log("+++ performCastling +++", data); } const [from, to, sockId] = [data.newRookPiece, data.newKingPiece, data.socket]; if (BoardConfig[data.oldKingPos].piece !== data.oldK...
07kshitij/chess
src/components/Board.tsx
TypeScript
ArrowFunction
(data) => { if (process.env.NODE_ENV === "development") { console.log("+++ performCastling +++", data); } const [from, to, sockId] = [data.newRookPiece, data.newKingPiece, data.socket]; if (BoardConfig[data.oldKingPos].piece !== data.oldKingPiece) { BoardConfig[data.oldKin...
07kshitij/chess
src/components/Board.tsx
TypeScript
ArrowFunction
() => { socket.off("performCastling"); }
07kshitij/chess
src/components/Board.tsx
TypeScript
ArrowFunction
() => { socket.once("performPromotion", (data) => { const [from, to, sockId] = [data.oldPiece, data.newPiece, data.socket]; if (BoardConfig[data.oldPiecePos].piece !== data.oldPiece) { BoardConfig[data.oldPiecePos].setPiece(data.oldPiece); } if (BoardConfig[data.newPiecePos].p...
07kshitij/chess
src/components/Board.tsx
TypeScript
ArrowFunction
(data) => { const [from, to, sockId] = [data.oldPiece, data.newPiece, data.socket]; if (BoardConfig[data.oldPiecePos].piece !== data.oldPiece) { BoardConfig[data.oldPiecePos].setPiece(data.oldPiece); } if (BoardConfig[data.newPiecePos].piece !== data.newPiece) { BoardConfi...
07kshitij/chess
src/components/Board.tsx
TypeScript
ArrowFunction
() => { socket.off("performPromotion"); }
07kshitij/chess
src/components/Board.tsx
TypeScript
ArrowFunction
() => { socket.once("markCheck", (data) => { if (process.env.NODE_ENV === "development") { console.log("King in check", data); } BoardConfig[data.position].setColor(data.color); pieceInCheck = data.position; }); return () => { socket.off("markCheck"); }; ...
07kshitij/chess
src/components/Board.tsx
TypeScript
ArrowFunction
(data) => { if (process.env.NODE_ENV === "development") { console.log("King in check", data); } BoardConfig[data.position].setColor(data.color); pieceInCheck = data.position; }
07kshitij/chess
src/components/Board.tsx
TypeScript
ArrowFunction
() => { socket.off("markCheck"); }
07kshitij/chess
src/components/Board.tsx
TypeScript
ArrowFunction
() => { socket.once("unmarkCheck", (data) => { if (process.env.NODE_ENV === "development") { console.log("King avoided check", data); } BoardConfig[data.position].setColor(data.color); pieceInCheck = -1; }); return () => { socket.off("unmarkCheck"); }; ...
07kshitij/chess
src/components/Board.tsx
TypeScript
ArrowFunction
(data) => { if (process.env.NODE_ENV === "development") { console.log("King avoided check", data); } BoardConfig[data.position].setColor(data.color); pieceInCheck = -1; }
07kshitij/chess
src/components/Board.tsx
TypeScript
ArrowFunction
() => { socket.off("unmarkCheck"); }
07kshitij/chess
src/components/Board.tsx
TypeScript
ArrowFunction
() => { socket.once("gameComplete", (data) => { if (process.env.NODE_ENV === "development") { console.log("+++ gameComplete +++", data); } setGameComplete(true); const message = data.result.outcome + " by " + data.result.message; setGameResult(message); }); re...
07kshitij/chess
src/components/Board.tsx
TypeScript
ArrowFunction
(data) => { if (process.env.NODE_ENV === "development") { console.log("+++ gameComplete +++", data); } setGameComplete(true); const message = data.result.outcome + " by " + data.result.message; setGameResult(message); }
07kshitij/chess
src/components/Board.tsx
TypeScript
ArrowFunction
() => { socket.off("gameComplete"); }
07kshitij/chess
src/components/Board.tsx
TypeScript
ArrowFunction
(from: PieceProps, value: number) => { if (utils.getPieceColor(from) === "white") { setWhitePoints(whitePoints + value); } else { setBlackPoints(blackPoints + value); } }
07kshitij/chess
src/components/Board.tsx
TypeScript
ArrowFunction
( from: PieceProps, to: PieceProps, moveType: number, isCheck: boolean, isCheckMate: boolean ) => { const posTo = to.position; const [x, y] = [(8 - Math.floor(posTo / 8)).toString(), String.fromCharCode(97 + (posTo % 8))]; let moveRep = ""; if (moveType === 2) { m...
07kshitij/chess
src/components/Board.tsx
TypeScript
ArrowFunction
(kingPos: number, oppMoves: number[], selfMoves: number[], attacks: number[]) => { const moves = new Hints(BoardConfig); const ischeckMate = moves.isCheckMate(kingPos, oppMoves, selfMoves, attacks); return ischeckMate; }
07kshitij/chess
src/components/Board.tsx
TypeScript
ArrowFunction
(piece: PieceProps): [boolean, boolean] => { const moves = new Hints(BoardConfig); const outVal = moves.isCheck(utils.getPieceColor(piece)); if (outVal.attackingPieces.length > 0) { socket.emit("setCheck", { gameCode: gameCode, position: outVal.oppKingPos, color: "check...
07kshitij/chess
src/components/Board.tsx
TypeScript
ArrowFunction
(piece: PieceProps) => { const moves = new Hints(BoardConfig); return moves.isStaleMate(utils.getPieceColor(piece)); }
07kshitij/chess
src/components/Board.tsx
TypeScript
ArrowFunction
(from: PieceProps, to: PieceProps): boolean => { let possible: boolean = true; possible &&= utils.getPieceName(from) === "pawn"; let rank = Math.floor(to.position / 8); possible &&= rank == 0 || rank == 7; return possible; }
07kshitij/chess
src/components/Board.tsx
TypeScript
ArrowFunction
(from: PieceProps, to: PieceProps) => { const [posFrom, posTo] = [from.position, to.position]; if (process.env.NODE_ENV === "development") { console.log(`Making a move from ${posFrom} to ${posTo}`); } to.position = posFrom; from.position = posTo; from.numMoves += 1; socket.e...
07kshitij/chess
src/components/Board.tsx
TypeScript