type
stringclasses
7 values
content
stringlengths
4
9.55k
repo
stringlengths
7
96
path
stringlengths
4
178
language
stringclasses
1 value
MethodDeclaration
videoReady() { this._ready = true; this.ready.emit(true); this.loading = false; this.length = this._player.duration; }
swimmadude66/movienight
src/client/components/player/component.ts
TypeScript
MethodDeclaration
videoEnded() { this.playing = false; this._ended = true; this.percentPlayed = 100; this.ended.emit(true); }
swimmadude66/movienight
src/client/components/player/component.ts
TypeScript
MethodDeclaration
playerWaiting() { this.resumed.emit(false); this.playing = false; }
swimmadude66/movienight
src/client/components/player/component.ts
TypeScript
MethodDeclaration
playbackResumed() { this.resumed.emit(true); this._cancelProgress(); this._progressSub = timer(0, 50) .pipe( takeWhile(_ => !this._ended) ).subscribe( _ => { this.currTime = this.getCurrentTime(); this.percentPlayed = Math.floor((this.currTime / this.length) * 100); } ) }
swimmadude66/movienight
src/client/components/player/component.ts
TypeScript
MethodDeclaration
// Host-only controls startVideo() { this.starting = true; this.hostStart.emit(this.video); }
swimmadude66/movienight
src/client/components/player/component.ts
TypeScript
MethodDeclaration
stopVideo() { this.stopping = true; this.hostStop.emit(this.video); }
swimmadude66/movienight
src/client/components/player/component.ts
TypeScript
MethodDeclaration
selectVideo() { this.hostSelect.emit(this.video); }
swimmadude66/movienight
src/client/components/player/component.ts
TypeScript
MethodDeclaration
private _cancelProgress() { if (this._progressSub) { try { this._progressSub.unsubscribe(); this._progressSub = null; } catch (e) { // do nothing } } }
swimmadude66/movienight
src/client/components/player/component.ts
TypeScript
InterfaceDeclaration
/** * @description This plugin generates React Apollo components and HOC with TypeScript typings. * * It extends the basic TypeScript plugins: `@graphql-codegen/typescript`, `@graphql-codegen/typescript-operations` - and thus shares a similar configuration. */ export interface ReactApolloRawPluginConfig extends RawClientSideBasePluginConfig { /** * @description Customize the output by enabling/disabling the generated Component (deprecated since Apollo-Client v3). For more details: https://www.apollographql.com/docs/react/api/react/components/ * @default false * * @exampleMarkdown * ```yml * generates: * path/to/file.ts: * plugins: * - typescript * - typescript-operations * - typescript-react-apollo * config: * withComponent: true * ``` */ withComponent?: boolean; /** * @description Customize the output by enabling/disabling the HOC (deprecated since Apollo-Client v3). For more details: https://www.apollographql.com/docs/react/api/react/hoc/ * @default false * * @exampleMarkdown * ```yml * generates: * path/to/file.ts: * plugins: * - typescript * - typescript-operations * - typescript-react-apollo * config: * withHOC: true * ``` */ withHOC?: boolean; /** * @description Customized the output by enabling/disabling the generated React Hooks. For more details: https://www.apollographql.com/docs/react/api/react/hooks/ * @default true * * @exampleMarkdown * ```yml * generates: * path/to/file.ts: * plugins: * - typescript * - typescript-operations * - typescript-react-apollo * config: * withHooks: true * ``` */ withHooks?: boolean; /** * @description Customized the output by enabling/disabling the generated mutation function signature. * @default true * * @exampleMarkdown * ```yml * generates: * path/to/file.ts: * plugins: * - typescript * - typescript-operations * - typescript-react-apollo * config: * withMutationFn: true * ``` */ withMutationFn?: boolean; /** * @description Enable generating a function to be used with refetchQueries * @default false * * @exampleMarkdown * ```yml * generates: * path/to/file.ts: * plugins: * - typescript * - typescript-operations * - typescript-react-apollo * config: * withRefetchFn: false * ``` */ withRefetchFn?: boolean; /** * @description Customize the package where apollo-react common lib is loaded from. * @default "@apollo/react-common" */ apolloReactCommonImportFrom?: string; /** * @description Customize the package where apollo-react component lib is loaded from. * @default "@apollo/react-components" */ apolloReactComponentsImportFrom?: string; /** * @description Customize the package where apollo-react HOC lib is loaded from. * @default "@apollo/react-hoc" */ apolloReactHocImportFrom?: string; /** * @description Customize the package where apollo-react hooks lib is loaded from. * @default "@apollo/react-hooks" */ apolloReactHooksImportFrom?: string; /** * @description You can specify a suffix that gets attached to the name of the generated component. * @default Component */ componentSuffix?: string; /** * @description Sets the version of react-apollo. * If you are using the old (deprecated) package of `react-apollo`, please set this configuration to `2`. * If you are using Apollo-Client v3, please set this to `3`. * @default 3 * * @exampleMarkdown * ```yml * generates: * path/to/file.ts: * plugins: * - typescript * - typescript-operations * - typescript-react-apollo * config: * reactApolloVersion: 2 * ``` */ reactApolloVersion?: 2 | 3; /** * @description Customized the output by enabling/disabling the generated result type. * @default true * * @exampleMarkdown * ```yml * generates: * path/to/file.ts: * plugins: * - typescript * - typescript-operations * - typescript-react-apollo * config: * withResultType: true * ``` */ withResultType?: boolean; /** * @description Customized the output by enabling/disabling the generated mutation option type. * @default true * * @exampleMarkdown * ```yml * generates: * path/to/file.ts: * plugins: * - typescript * - typescript-operations * - typescript-react-apollo * config: * withMutationOptionsType: true * ``` */ withMutationOptionsType?: boolean; /** * @description Allows you to enable/disable the generation of docblocks in generated code. * Some IDE's (like VSCode) add extra inline information with docblocks, you can disable this feature if your preferred IDE does not. * @default true * * @exampleMarkdown * ```yml * generates: * path/to/file.ts: * plugins: * - typescript * - typescript-operations * - typescript-react-apollo * config: * addDocBlocks: true * ``` */ addDocBlocks?: boolean; defaultBaseOptions?: { [key: string]: string }; hooksSuffix?: string; }
B2o5T/graphql-code-generator
packages/plugins/typescript/react-apollo/src/config.ts
TypeScript
ArrowFunction
(response) => response.status === 200
Mu-L/pixie
src/ui/src/api/api.ts
TypeScript
ArrowFunction
(client) => client.health()
Mu-L/pixie
src/ui/src/api/api.ts
TypeScript
ArrowFunction
(client) => client.executeScript(script, funcs, hasMutation, opts)
Mu-L/pixie
src/ui/src/api/api.ts
TypeScript
ClassDeclaration
export abstract class PixieAPIClientAbstract { static readonly DEFAULT_OPTIONS: Required<PixieAPIClientOptions>; readonly options: Required<PixieAPIClientOptions>; abstract health(cluster: string | ClusterConfig): Observable<Status>; abstract executeScript( cluster: string | ClusterConfig, script: string, opts: ExecuteScriptOptions, funcs?: VizierQueryFunc[], ): Observable<ExecutionStateUpdate>; abstract isAuthenticated(): Promise<boolean>; }
Mu-L/pixie
src/ui/src/api/api.ts
TypeScript
ClassDeclaration
/** * API client library for [Pixie](https://px.dev). * See the [documentation](https://docs.px.dev/reference/api/overview/) for a complete reference. */ export class PixieAPIClient extends PixieAPIClientAbstract { /** * By default, a new Pixie API Client assumes a matching origin between the UI and API, that a direct connection is * sufficient on the current network, and that authentication is being checked elsewhere. */ static readonly DEFAULT_OPTIONS: Required<PixieAPIClientOptions> = Object.freeze({ apiKey: '', uri: `${globalThis?.location?.origin || 'https://work.withpixie.ai'}/api`, onUnauthorized: () => {}, authToken: '', }); private gqlClient: CloudClient; private clusterConnections: Map<string, VizierGRPCClient>; /** * Builds an API client to speak to Pixie's gRPC and GraphQL backends. The former connects to specific clusters; * the latter connects to Pixie Cloud. * * @param options Set these to change the client's behavior or to listen for authorization errors. */ static async create( options: PixieAPIClientOptions, ): Promise<PixieAPIClient> { const client = new PixieAPIClient({ ...PixieAPIClient.DEFAULT_OPTIONS, ...options }); return client.init(); } private constructor( readonly options: Required<PixieAPIClientOptions>, ) { super(); } private async init(): Promise<PixieAPIClient> { this.gqlClient = new CloudClient(this.options); await this.gqlClient.getGraphQLPersist(); this.clusterConnections = new Map(); return this; } // Note: this doesn't check if the client already exists, and clobbers any existing client. private async createVizierClient(cluster: ClusterConfig) { const { ipAddress, token } = await this.gqlClient.getClusterConnection(cluster.id, true); const client = new VizierGRPCClient( cluster.passthroughClusterAddress ?? ipAddress, // If in embed mode, we should always use the auth token with bearer auth. this.options.authToken ? this.options.authToken : token, cluster.id, (this.options.authToken ? false : cluster.attachCredentials ?? false), ); // Note that this doesn't currently clean up clients that haven't been used in a while, so a particularly long // user session could hold onto a large number of stale connections. A simple page refresh drops them all. // If this becomes a problem, limit the number of clients and rotate out those that haven't been used in a while. this.clusterConnections.set(cluster.id, client); return client; } private async getClusterClient(cluster: string | ClusterConfig) { let id: string; let passthroughClusterAddress: string; let attachCredentials = false; if (typeof cluster === 'string') { id = cluster; } else { ({ id, passthroughClusterAddress, attachCredentials } = cluster); } return this.clusterConnections.has(id) ? Promise.resolve(this.clusterConnections.get(id)) : this.createVizierClient({ id, passthroughClusterAddress, attachCredentials }); } // TODO(nick): Once the authentication model settles down, make this easier to use outside of the browser. /** * Checks whether the current cookies include a valid authentication token. * Checks by querying a purpose-built endpoint, to be certain the user really is authenticated. */ isAuthenticated(): Promise<boolean> { return fetch(`${this.options.uri}/authorized`, { headers: { ...{ 'x-csrf': GetCSRFCookie(), }, ...(this.options.authToken ? { authorization: `Bearer ${this.options.authToken}`, 'X-Use-Bearer': 'true' } : {}), }, }).then((response) => response.status === 200); } /** * Creates a stream that listens for the health of the cluster and the API client's connection to it. * This is an Observable, so don't forget to unsubscribe when you're done with it. * @param cluster Which cluster to use. Either just its ID, or a full config. If that cluster has previously been * connected in this session, that connection will be reused without changing its configuration. */ health(cluster: string | ClusterConfig): Observable<Status> { return from(this.getClusterClient(cluster)) .pipe(switchMap((client) => client.health())); } /** * Asks a connected cluster to run a PxL script. Returns an event stream that updates at each stage of execution. * * A typical event stream might look something like this: * - start * - metadata * - mutation info (if the script uses tracepoints) * - data * - stats * * @param cluster Which cluster to use. Either just its ID, or a full config. If that cluster has previously been * connected in this session, that connection will be reused without changing its configuration. * @param script The source code of the script to be compiled and executed; whitespace and all. * @param opts Any extra options, such as encryption. * @param funcs Descriptions of which functions in the script to run, and what to do with their output. */ executeScript( cluster: string | ClusterConfig, script: string, opts: ExecuteScriptOptions, funcs: VizierQueryFunc[] = [], ): Observable<ExecutionStateUpdate> { const hasMutation = containsMutation(script); return from(this.getClusterClient(cluster)) .pipe(switchMap((client) => client.executeScript(script, funcs, hasMutation, opts))); } /** * Implementation detail for adapters. * Do not use directly unless writing such an adapter. * * Provides the internal CloudClient, which has a graphQL property. * That property is an ApolloClient, with which GraphQL queries can be run directly. * * @internal */ getCloudClient(): CloudClient { return this.gqlClient; } }
Mu-L/pixie
src/ui/src/api/api.ts
TypeScript
InterfaceDeclaration
/** * When calling `PixieAPIClient.create`, this specifies which clusters to connect to, and any special configuration for * each of those connections as needed. */ export interface ClusterConfig { id: string; /** * If provided, this overrides the endpoint for connections to the GRPC API on a cluster. * This includes the protocol, the host, and optionally the port. For example, `https://pixie.example.com:1234`. */ passthroughClusterAddress?: string | undefined; /** * If true, passes an HTTP Authorization header as part of each request to gRPC services. */ attachCredentials?: boolean; }
Mu-L/pixie
src/ui/src/api/api.ts
TypeScript
MethodDeclaration
abstract health(cluster: string | ClusterConfig): Observable<Status>;
Mu-L/pixie
src/ui/src/api/api.ts
TypeScript
MethodDeclaration
abstract executeScript( cluster: string | ClusterConfig, script: string, opts: ExecuteScriptOptions, funcs?: VizierQueryFunc[], ): Observable<ExecutionStateUpdate>;
Mu-L/pixie
src/ui/src/api/api.ts
TypeScript
MethodDeclaration
abstract isAuthenticated(): Promise<boolean>;
Mu-L/pixie
src/ui/src/api/api.ts
TypeScript
MethodDeclaration
/** * Builds an API client to speak to Pixie's gRPC and GraphQL backends. The former connects to specific clusters; * the latter connects to Pixie Cloud. * * @param options Set these to change the client's behavior or to listen for authorization errors. */ static async create( options: PixieAPIClientOptions, ): Promise<PixieAPIClient> { const client = new PixieAPIClient({ ...PixieAPIClient.DEFAULT_OPTIONS, ...options }); return client.init(); }
Mu-L/pixie
src/ui/src/api/api.ts
TypeScript
MethodDeclaration
private async init(): Promise<PixieAPIClient> { this.gqlClient = new CloudClient(this.options); await this.gqlClient.getGraphQLPersist(); this.clusterConnections = new Map(); return this; }
Mu-L/pixie
src/ui/src/api/api.ts
TypeScript
MethodDeclaration
// Note: this doesn't check if the client already exists, and clobbers any existing client. private async createVizierClient(cluster: ClusterConfig) { const { ipAddress, token } = await this.gqlClient.getClusterConnection(cluster.id, true); const client = new VizierGRPCClient( cluster.passthroughClusterAddress ?? ipAddress, // If in embed mode, we should always use the auth token with bearer auth. this.options.authToken ? this.options.authToken : token, cluster.id, (this.options.authToken ? false : cluster.attachCredentials ?? false), ); // Note that this doesn't currently clean up clients that haven't been used in a while, so a particularly long // user session could hold onto a large number of stale connections. A simple page refresh drops them all. // If this becomes a problem, limit the number of clients and rotate out those that haven't been used in a while. this.clusterConnections.set(cluster.id, client); return client; }
Mu-L/pixie
src/ui/src/api/api.ts
TypeScript
MethodDeclaration
private async getClusterClient(cluster: string | ClusterConfig) { let id: string; let passthroughClusterAddress: string; let attachCredentials = false; if (typeof cluster === 'string') { id = cluster; } else { ({ id, passthroughClusterAddress, attachCredentials } = cluster); } return this.clusterConnections.has(id) ? Promise.resolve(this.clusterConnections.get(id)) : this.createVizierClient({ id, passthroughClusterAddress, attachCredentials }); }
Mu-L/pixie
src/ui/src/api/api.ts
TypeScript
MethodDeclaration
// TODO(nick): Once the authentication model settles down, make this easier to use outside of the browser. /** * Checks whether the current cookies include a valid authentication token. * Checks by querying a purpose-built endpoint, to be certain the user really is authenticated. */ isAuthenticated(): Promise<boolean> { return fetch(`${this.options.uri}/authorized`, { headers: { ...{ 'x-csrf': GetCSRFCookie(), }, ...(this.options.authToken ? { authorization: `Bearer ${this.options.authToken}`, 'X-Use-Bearer': 'true' } : {}), }, }).then((response) => response.status === 200); }
Mu-L/pixie
src/ui/src/api/api.ts
TypeScript
MethodDeclaration
/** * Creates a stream that listens for the health of the cluster and the API client's connection to it. * This is an Observable, so don't forget to unsubscribe when you're done with it. * @param cluster Which cluster to use. Either just its ID, or a full config. If that cluster has previously been * connected in this session, that connection will be reused without changing its configuration. */ health(cluster: string | ClusterConfig): Observable<Status> { return from(this.getClusterClient(cluster)) .pipe(switchMap((client) => client.health())); }
Mu-L/pixie
src/ui/src/api/api.ts
TypeScript
MethodDeclaration
/** * Asks a connected cluster to run a PxL script. Returns an event stream that updates at each stage of execution. * * A typical event stream might look something like this: * - start * - metadata * - mutation info (if the script uses tracepoints) * - data * - stats * * @param cluster Which cluster to use. Either just its ID, or a full config. If that cluster has previously been * connected in this session, that connection will be reused without changing its configuration. * @param script The source code of the script to be compiled and executed; whitespace and all. * @param opts Any extra options, such as encryption. * @param funcs Descriptions of which functions in the script to run, and what to do with their output. */ executeScript( cluster: string | ClusterConfig, script: string, opts: ExecuteScriptOptions, funcs: VizierQueryFunc[] = [], ): Observable<ExecutionStateUpdate> { const hasMutation = containsMutation(script); return from(this.getClusterClient(cluster)) .pipe(switchMap((client) => client.executeScript(script, funcs, hasMutation, opts))); }
Mu-L/pixie
src/ui/src/api/api.ts
TypeScript
MethodDeclaration
/** * Implementation detail for adapters. * Do not use directly unless writing such an adapter. * * Provides the internal CloudClient, which has a graphQL property. * That property is an ApolloClient, with which GraphQL queries can be run directly. * * @internal */ getCloudClient(): CloudClient { return this.gqlClient; }
Mu-L/pixie
src/ui/src/api/api.ts
TypeScript
ArrowFunction
() => { describe('VDomModel', () => { describe('#constructor()', () => { it('should create a VDomModel', () => { const model = new VDomModel(); expect(model).to.be.an.instanceof(VDomModel); }); it('should create a TestModel', () => { const model = new TestModel(); expect(model).to.be.an.instanceof(TestModel); }); it('should be properly disposed', () => { const model = new TestModel(); model.dispose(); expect(model.isDisposed).to.be.equal(true); }); }); describe('#stateChanged()', () => { it('should fire the stateChanged signal on a change', () => { const model = new TestModel(); let changed = false; model.stateChanged.connect(() => { changed = true; }); model.value = 'newvalue'; expect(changed).to.equal(true); }); }); }); describe('VDomRenderer', () => { describe('#constructor()', () => { it('should create a TestWidget', () => { const widget = new TestWidget(); expect(widget).to.be.an.instanceof(TestWidget); }); it('should be properly disposed', () => { const widget = new TestWidget(); widget.dispose(); expect(widget.isDisposed).to.equal(true); }); }); describe('#modelChanged()', () => { it('should fire the stateChanged signal on a change', () => { const widget = new TestWidget(); const model = new TestModel(); let changed = false; widget.modelChanged.connect(() => { changed = true; }); widget.model = model; expect(changed).to.equal(true); }); }); describe('#render()', () => { it('should render the contents after a model change', async () => { const widget = new TestWidget(); const model = new TestModel(); widget.model = model; model.value = 'foo'; await framePromise(); let span = widget.node.firstChild as HTMLElement; expect(span.textContent).to.equal('foo'); }); }); describe('#noModel()', () => { it('should work with a null model', async () => { const widget = new TestWidgetNoModel(); Widget.attach(widget, document.body); await framePromise(); const span = widget.node.firstChild as HTMLElement; expect(span.textContent).to.equal('No model!'); }); }); }); }
AlokTakshak/jupyterlab
tests/test-apputils/src/vdom.spec.ts
TypeScript
ArrowFunction
() => { describe('#constructor()', () => { it('should create a VDomModel', () => { const model = new VDomModel(); expect(model).to.be.an.instanceof(VDomModel); }); it('should create a TestModel', () => { const model = new TestModel(); expect(model).to.be.an.instanceof(TestModel); }); it('should be properly disposed', () => { const model = new TestModel(); model.dispose(); expect(model.isDisposed).to.be.equal(true); }); }); describe('#stateChanged()', () => { it('should fire the stateChanged signal on a change', () => { const model = new TestModel(); let changed = false; model.stateChanged.connect(() => { changed = true; }); model.value = 'newvalue'; expect(changed).to.equal(true); }); }); }
AlokTakshak/jupyterlab
tests/test-apputils/src/vdom.spec.ts
TypeScript
ArrowFunction
() => { it('should create a VDomModel', () => { const model = new VDomModel(); expect(model).to.be.an.instanceof(VDomModel); }); it('should create a TestModel', () => { const model = new TestModel(); expect(model).to.be.an.instanceof(TestModel); }); it('should be properly disposed', () => { const model = new TestModel(); model.dispose(); expect(model.isDisposed).to.be.equal(true); }); }
AlokTakshak/jupyterlab
tests/test-apputils/src/vdom.spec.ts
TypeScript
ArrowFunction
() => { const model = new VDomModel(); expect(model).to.be.an.instanceof(VDomModel); }
AlokTakshak/jupyterlab
tests/test-apputils/src/vdom.spec.ts
TypeScript
ArrowFunction
() => { const model = new TestModel(); expect(model).to.be.an.instanceof(TestModel); }
AlokTakshak/jupyterlab
tests/test-apputils/src/vdom.spec.ts
TypeScript
ArrowFunction
() => { const model = new TestModel(); model.dispose(); expect(model.isDisposed).to.be.equal(true); }
AlokTakshak/jupyterlab
tests/test-apputils/src/vdom.spec.ts
TypeScript
ArrowFunction
() => { it('should fire the stateChanged signal on a change', () => { const model = new TestModel(); let changed = false; model.stateChanged.connect(() => { changed = true; }); model.value = 'newvalue'; expect(changed).to.equal(true); }); }
AlokTakshak/jupyterlab
tests/test-apputils/src/vdom.spec.ts
TypeScript
ArrowFunction
() => { const model = new TestModel(); let changed = false; model.stateChanged.connect(() => { changed = true; }); model.value = 'newvalue'; expect(changed).to.equal(true); }
AlokTakshak/jupyterlab
tests/test-apputils/src/vdom.spec.ts
TypeScript
ArrowFunction
() => { changed = true; }
AlokTakshak/jupyterlab
tests/test-apputils/src/vdom.spec.ts
TypeScript
ArrowFunction
() => { describe('#constructor()', () => { it('should create a TestWidget', () => { const widget = new TestWidget(); expect(widget).to.be.an.instanceof(TestWidget); }); it('should be properly disposed', () => { const widget = new TestWidget(); widget.dispose(); expect(widget.isDisposed).to.equal(true); }); }); describe('#modelChanged()', () => { it('should fire the stateChanged signal on a change', () => { const widget = new TestWidget(); const model = new TestModel(); let changed = false; widget.modelChanged.connect(() => { changed = true; }); widget.model = model; expect(changed).to.equal(true); }); }); describe('#render()', () => { it('should render the contents after a model change', async () => { const widget = new TestWidget(); const model = new TestModel(); widget.model = model; model.value = 'foo'; await framePromise(); let span = widget.node.firstChild as HTMLElement; expect(span.textContent).to.equal('foo'); }); }); describe('#noModel()', () => { it('should work with a null model', async () => { const widget = new TestWidgetNoModel(); Widget.attach(widget, document.body); await framePromise(); const span = widget.node.firstChild as HTMLElement; expect(span.textContent).to.equal('No model!'); }); }); }
AlokTakshak/jupyterlab
tests/test-apputils/src/vdom.spec.ts
TypeScript
ArrowFunction
() => { it('should create a TestWidget', () => { const widget = new TestWidget(); expect(widget).to.be.an.instanceof(TestWidget); }); it('should be properly disposed', () => { const widget = new TestWidget(); widget.dispose(); expect(widget.isDisposed).to.equal(true); }); }
AlokTakshak/jupyterlab
tests/test-apputils/src/vdom.spec.ts
TypeScript
ArrowFunction
() => { const widget = new TestWidget(); expect(widget).to.be.an.instanceof(TestWidget); }
AlokTakshak/jupyterlab
tests/test-apputils/src/vdom.spec.ts
TypeScript
ArrowFunction
() => { const widget = new TestWidget(); widget.dispose(); expect(widget.isDisposed).to.equal(true); }
AlokTakshak/jupyterlab
tests/test-apputils/src/vdom.spec.ts
TypeScript
ArrowFunction
() => { it('should fire the stateChanged signal on a change', () => { const widget = new TestWidget(); const model = new TestModel(); let changed = false; widget.modelChanged.connect(() => { changed = true; }); widget.model = model; expect(changed).to.equal(true); }); }
AlokTakshak/jupyterlab
tests/test-apputils/src/vdom.spec.ts
TypeScript
ArrowFunction
() => { const widget = new TestWidget(); const model = new TestModel(); let changed = false; widget.modelChanged.connect(() => { changed = true; }); widget.model = model; expect(changed).to.equal(true); }
AlokTakshak/jupyterlab
tests/test-apputils/src/vdom.spec.ts
TypeScript
ArrowFunction
() => { it('should render the contents after a model change', async () => { const widget = new TestWidget(); const model = new TestModel(); widget.model = model; model.value = 'foo'; await framePromise(); let span = widget.node.firstChild as HTMLElement; expect(span.textContent).to.equal('foo'); }); }
AlokTakshak/jupyterlab
tests/test-apputils/src/vdom.spec.ts
TypeScript
ArrowFunction
async () => { const widget = new TestWidget(); const model = new TestModel(); widget.model = model; model.value = 'foo'; await framePromise(); let span = widget.node.firstChild as HTMLElement; expect(span.textContent).to.equal('foo'); }
AlokTakshak/jupyterlab
tests/test-apputils/src/vdom.spec.ts
TypeScript
ArrowFunction
() => { it('should work with a null model', async () => { const widget = new TestWidgetNoModel(); Widget.attach(widget, document.body); await framePromise(); const span = widget.node.firstChild as HTMLElement; expect(span.textContent).to.equal('No model!'); }); }
AlokTakshak/jupyterlab
tests/test-apputils/src/vdom.spec.ts
TypeScript
ArrowFunction
async () => { const widget = new TestWidgetNoModel(); Widget.attach(widget, document.body); await framePromise(); const span = widget.node.firstChild as HTMLElement; expect(span.textContent).to.equal('No model!'); }
AlokTakshak/jupyterlab
tests/test-apputils/src/vdom.spec.ts
TypeScript
ClassDeclaration
class TestModel extends VDomModel { get value(): string { return this._value; } set value(newValue: string) { this._value = newValue; this.stateChanged.emit(void 0); } private _value = ''; }
AlokTakshak/jupyterlab
tests/test-apputils/src/vdom.spec.ts
TypeScript
ClassDeclaration
class TestWidget extends VDomRenderer<TestModel> { protected render(): React.ReactElement<any> { return React.createElement('span', null, this.model.value); } }
AlokTakshak/jupyterlab
tests/test-apputils/src/vdom.spec.ts
TypeScript
ClassDeclaration
class TestWidgetNoModel extends VDomRenderer<null> { protected render(): React.ReactElement<any> { return React.createElement('span', null, 'No model!'); } }
AlokTakshak/jupyterlab
tests/test-apputils/src/vdom.spec.ts
TypeScript
MethodDeclaration
protected render(): React.ReactElement<any> { return React.createElement('span', null, this.model.value); }
AlokTakshak/jupyterlab
tests/test-apputils/src/vdom.spec.ts
TypeScript
MethodDeclaration
protected render(): React.ReactElement<any> { return React.createElement('span', null, 'No model!'); }
AlokTakshak/jupyterlab
tests/test-apputils/src/vdom.spec.ts
TypeScript
FunctionDeclaration
async function claim() { if (isAppReady) { try { setClaimError(null); setClaimTxModalOpen(true); const contract = getContract(stakedAsset, signer); const gasLimit = await synthetix.getGasEstimateForTransaction({ txArgs: [], method: contract.estimateGas.getReward, }); const transaction: ethers.ContractTransaction = await contract.getReward({ gasPrice: normalizedGasPrice(claimGasPrice), gasLimit, }); if (transaction) { setClaimTxHash(transaction.hash); setClaimTransactionState(Transaction.WAITING); monitorTransaction({ txHash: transaction.hash, onTxConfirmed: () => setClaimTransactionState(Transaction.SUCCESS), }); setClaimTxModalOpen(false); } } catch (e) { setClaimTransactionState(Transaction.PRESUBMIT); setClaimError(e.message); } } }
crypto-supporter/staking
sections/earn/LPTab/LPTab.tsx
TypeScript
ArrowFunction
({ stakedAsset, icon = stakedAsset, type, tokenRewards, allowance, userBalance, userBalanceBN, staked, stakedBN, needsToSettle, secondTokenRate, }) => { const { t } = useTranslation(); const { signer } = Connector.useContainer(); const { monitorTransaction } = TransactionNotifier.useContainer(); const [showApproveOverlayModal, setShowApproveOverlayModal] = useState<boolean>(false); const [showSettleOverlayModal, setShowSettleOverlayModal] = useState<boolean>(false); const isAppReady = useRecoilValue(appReadyState); const [claimGasPrice, setClaimGasPrice] = useState<number>(0); const [claimTransactionState, setClaimTransactionState] = useState<Transaction>( Transaction.PRESUBMIT ); const [claimTxHash, setClaimTxHash] = useState<string | null>(null); const [claimError, setClaimError] = useState<string | null>(null); const [claimTxModalOpen, setClaimTxModalOpen] = useState<boolean>(false); const { blockExplorerInstance } = Etherscan.useContainer(); const claimLink = blockExplorerInstance != null && claimTxHash != null ? blockExplorerInstance.txLink(claimTxHash) : undefined; const exchangeRatesQuery = useExchangeRatesQuery(); const SNXRate = exchangeRatesQuery.data?.SNX ?? 0; const tabData = useMemo(() => { const commonStakeTabProps = { stakedAsset, userBalance, userBalanceBN, staked, stakedBN, icon, type, }; return [ { title: t('earn.actions.stake.title'), tabChildren: <StakeTab {...commonStakeTabProps} isStake={true} />, blue: true, key: 'stake', }, { title: t('earn.actions.unstake.title'), tabChildren: <StakeTab {...commonStakeTabProps} isStake={false} />, blue: false, key: 'unstake', }, ]; // eslint-disable-next-line react-hooks/exhaustive-deps }, [t, stakedAsset, userBalance, staked]); useEffect(() => { if (allowance === 0 && userBalance > 0) { setShowApproveOverlayModal(true); } }, [allowance, userBalance]); useEffect(() => { if (needsToSettle) { setShowSettleOverlayModal(true); } }, [needsToSettle]); const handleClaim = useCallback(() => { async function claim() { if (isAppReady) { try { setClaimError(null); setClaimTxModalOpen(true); const contract = getContract(stakedAsset, signer); const gasLimit = await synthetix.getGasEstimateForTransaction({ txArgs: [], method: contract.estimateGas.getReward, }); const transaction: ethers.ContractTransaction = await contract.getReward({ gasPrice: normalizedGasPrice(claimGasPrice), gasLimit, }); if (transaction) { setClaimTxHash(transaction.hash); setClaimTransactionState(Transaction.WAITING); monitorTransaction({ txHash: transaction.hash, onTxConfirmed: () => setClaimTransactionState(Transaction.SUCCESS), }); setClaimTxModalOpen(false); } } catch (e) { setClaimTransactionState(Transaction.PRESUBMIT); setClaimError(e.message); } } } claim(); }, [stakedAsset, signer, claimGasPrice, monitorTransaction, isAppReady]); const translationKey = useMemo(() => { if (stakedAsset === Synths.iETH) { return 'earn.incentives.options.ieth.description'; } else if (stakedAsset === Synths.iBTC) { return 'earn.incentives.options.ibtc.description'; } else if (stakedAsset === LP.CURVE_sUSD) { return 'earn.incentives.options.curve.description'; } else if (stakedAsset === LP.CURVE_sEURO) { return 'earn.incentives.options.seur.description'; } else if (stakedAsset === LP.BALANCER_sTSLA) { return 'earn.incentives.options.stsla.description'; } else if (stakedAsset === LP.UNISWAP_DHT) { return 'earn.incentives.options.dht.description'; } else if (stakedAsset in lpToSynthTranslationKey) { return `earn.incentives.options.${lpToSynthTranslationKey[stakedAsset]}.description`; } else { throw new Error('unexpected staking asset for translation key'); } }, [stakedAsset]); const DualRewardsClaimInfo = ( <StyledFlexDiv> <StyledFlexDivColCentered> <GreyHeader>{t('earn.actions.claim.claiming')}</GreyHeader> <WhiteSubheader> {t('earn.actions.claim.amount', { amount: formatNumber((tokenRewards as DualRewards).a, { decimals: DEFAULT_CRYPTO_DECIMALS, }), asset: CryptoCurrency.SNX, })} </WhiteSubheader> </StyledFlexDivColCentered> <StyledFlexDivColCentered> <GreyHeader>{t('earn.actions.claim.claiming')}</GreyHeader> <WhiteSubheader> {t('earn.actions.claim.amount', { amount: formatNumber((tokenRewards as DualRewards).b, { decimals: DEFAULT_CRYPTO_DECIMALS, }), asset: CryptoCurrency.DHT, })} </WhiteSubheader> </StyledFlexDivColCentered> </StyledFlexDiv>
crypto-supporter/staking
sections/earn/LPTab/LPTab.tsx
TypeScript
ArrowFunction
() => { const commonStakeTabProps = { stakedAsset, userBalance, userBalanceBN, staked, stakedBN, icon, type, }; return [ { title: t('earn.actions.stake.title'), tabChildren: <StakeTab {...commonStakeTabProps} isStake={true} />, blue: true, key: 'stake', }, { title: t('earn.actions.unstake.title'), tabChildren: <StakeTab {...commonStakeTabProps} isStake={false} />, blue: false, key: 'unstake', }, ]; // eslint-disable-next-line react-hooks/exhaustive-deps }
crypto-supporter/staking
sections/earn/LPTab/LPTab.tsx
TypeScript
ArrowFunction
() => { if (allowance === 0 && userBalance > 0) { setShowApproveOverlayModal(true); } }
crypto-supporter/staking
sections/earn/LPTab/LPTab.tsx
TypeScript
ArrowFunction
() => { if (needsToSettle) { setShowSettleOverlayModal(true); } }
crypto-supporter/staking
sections/earn/LPTab/LPTab.tsx
TypeScript
ArrowFunction
() => { async function claim() { if (isAppReady) { try { setClaimError(null); setClaimTxModalOpen(true); const contract = getContract(stakedAsset, signer); const gasLimit = await synthetix.getGasEstimateForTransaction({ txArgs: [], method: contract.estimateGas.getReward, }); const transaction: ethers.ContractTransaction = await contract.getReward({ gasPrice: normalizedGasPrice(claimGasPrice), gasLimit, }); if (transaction) { setClaimTxHash(transaction.hash); setClaimTransactionState(Transaction.WAITING); monitorTransaction({ txHash: transaction.hash, onTxConfirmed: () => setClaimTransactionState(Transaction.SUCCESS), }); setClaimTxModalOpen(false); } } catch (e) { setClaimTransactionState(Transaction.PRESUBMIT); setClaimError(e.message); } } } claim(); }
crypto-supporter/staking
sections/earn/LPTab/LPTab.tsx
TypeScript
ArrowFunction
() => setClaimTransactionState(Transaction.SUCCESS)
crypto-supporter/staking
sections/earn/LPTab/LPTab.tsx
TypeScript
ArrowFunction
() => { if (stakedAsset === Synths.iETH) { return 'earn.incentives.options.ieth.description'; } else if (stakedAsset === Synths.iBTC) { return 'earn.incentives.options.ibtc.description'; } else if (stakedAsset === LP.CURVE_sUSD) { return 'earn.incentives.options.curve.description'; } else if (stakedAsset === LP.CURVE_sEURO) { return 'earn.incentives.options.seur.description'; } else if (stakedAsset === LP.BALANCER_sTSLA) { return 'earn.incentives.options.stsla.description'; } else if (stakedAsset === LP.UNISWAP_DHT) { return 'earn.incentives.options.dht.description'; } else if (stakedAsset in lpToSynthTranslationKey) { return `earn.incentives.options.${lpToSynthTranslationKey[stakedAsset]}.description`; } else { throw new Error('unexpected staking asset for translation key'); } }
crypto-supporter/staking
sections/earn/LPTab/LPTab.tsx
TypeScript
ArrowFunction
() => { switch (stakedAsset) { case LP.BALANCER_sTSLA: return `https://pools.balancer.exchange/#/pool/0x055db9aff4311788264798356bbf3a733ae181c6/`; case LP.BALANCER_sFB: return `https://pools.balancer.exchange/#/pool/0x3f2d077acff8a66c4e0c79c37b6a662a7197889b/`; case LP.BALANCER_sAAPL: return `https://pools.balancer.exchange/#/pool/0xb94865e18b25114b2b10bd9ecbd689c877f949e8/`; case LP.BALANCER_sAMZN: return `https://pools.balancer.exchange/#/pool/0x74821343b5b969c0d4b31aff3931e00a40990cfd/`; case LP.BALANCER_sNFLX: return `https://pools.balancer.exchange/#/pool/0x6418c69b0de51873a1cc01cf73ba6e408acc1940/`; case LP.BALANCER_sGOOG: return `https://pools.balancer.exchange/#/pool/0x608410f602ce8967d1e59f599566aed340280efc/`; case LP.UNISWAP_DHT: return `https://uniswap.exchange/add/0x57ab1ec28d129707052df4df418d58a2d46d5f51/0xca1207647ff814039530d7d35df0e1dd2e91fa84`; default: return EXTERNAL_LINKS.Synthetix.Incentives; } }
crypto-supporter/staking
sections/earn/LPTab/LPTab.tsx
TypeScript
TypeAliasDeclaration
type DualRewards = { a: number; b: number; };
crypto-supporter/staking
sections/earn/LPTab/LPTab.tsx
TypeScript
TypeAliasDeclaration
type LPTabProps = { stakedAsset: CurrencyKey; icon?: CurrencyKey; type?: CurrencyIconType; tokenRewards: number | DualRewards; allowance: number | null; userBalance: number; userBalanceBN: BigNumber; staked: number; stakedBN: BigNumber; needsToSettle?: boolean; secondTokenRate?: number; };
crypto-supporter/staking
sections/earn/LPTab/LPTab.tsx
TypeScript
MethodDeclaration
t('earn.actions.rewards.waiting')
crypto-supporter/staking
sections/earn/LPTab/LPTab.tsx
TypeScript
MethodDeclaration
getLink()
crypto-supporter/staking
sections/earn/LPTab/LPTab.tsx
TypeScript
FunctionDeclaration
async function setOneImpliedJson( id: string, val: unknown, ): Promise<{id: string; val: unknown}> { const [result] = await db.query(sql` INSERT INTO json_test.json (id, val) VALUES (${id}, ${val}) ON CONFLICT (id) DO UPDATE SET val=EXCLUDED.val RETURNING *; `); return result; }
AmitMY/atdatabases
packages/pg/src/__tests__/index.test.pg.ts
TypeScript
FunctionDeclaration
async function setOneExplicitJson( id: string, val: unknown, ): Promise<{id: string; val: unknown}> { const [result] = await db.query(sql` INSERT INTO json_test.json (id, val) VALUES (${id}, ${JSON.stringify( val, )}) ON CONFLICT (id) DO UPDATE SET val=EXCLUDED.val RETURNING *; `); return result; }
AmitMY/atdatabases
packages/pg/src/__tests__/index.test.pg.ts
TypeScript
FunctionDeclaration
async function setMany( ...values: readonly { readonly id: string; readonly val: unknown; }[] ): Promise<{id: string; val: unknown}[]> { const results = await db.query( values.map( ({id, val}) => sql` INSERT INTO json_test.json (id, val) VALUES (${id}, ${JSON.stringify(val)}) ON CONFLICT (id) DO UPDATE SET val=EXCLUDED.val RETURNING *; `, ), ); return results.map(([{id, val}]) => ({id, val})); }
AmitMY/atdatabases
packages/pg/src/__tests__/index.test.pg.ts
TypeScript
ArrowFunction
async () => { await db.dispose(); }
AmitMY/atdatabases
packages/pg/src/__tests__/index.test.pg.ts
TypeScript
ArrowFunction
async () => { const [{foo}] = await db.query(sql`SELECT 1 + 1 as foo`); expect(foo).toBe(2); }
AmitMY/atdatabases
packages/pg/src/__tests__/index.test.pg.ts
TypeScript
ArrowFunction
async () => { const resultA = await db.query([sql`SELECT 1 + 1 as foo`]); expect(resultA).toEqual([[{foo: 2}]]); const resultB = await db.query([ sql`SELECT ${1} + 1 as foo;`, sql`SELECT 1 + ${2} as bar;`, ]); expect(resultB).toEqual([[{foo: 2}], [{bar: 3}]]); }
AmitMY/atdatabases
packages/pg/src/__tests__/index.test.pg.ts
TypeScript
ArrowFunction
async () => { const [{foo}] = await db.query(sql`SELECT 1 + ${41} as ${sql.ident('foo')}`); expect(foo).toBe(42); }
AmitMY/atdatabases
packages/pg/src/__tests__/index.test.pg.ts
TypeScript
ArrowFunction
async () => { await db.query(sql`CREATE SCHEMA json_test`); await db.query( sql`CREATE TABLE json_test.json (id TEXT NOT NULL PRIMARY KEY, val JSONB NOT NULL);`, ); async function setOneImpliedJson( id: string, val: unknown, ): Promise<{id: string; val: unknown}> { const [result] = await db.query(sql` INSERT INTO json_test.json (id, val) VALUES (${id}, ${val}) ON CONFLICT (id) DO UPDATE SET val=EXCLUDED.val RETURNING *; `); return result; } async function setOneExplicitJson( id: string, val: unknown, ): Promise<{id: string; val: unknown}> { const [result] = await db.query(sql` INSERT INTO json_test.json (id, val) VALUES (${id}, ${JSON.stringify( val, )}) ON CONFLICT (id) DO UPDATE SET val=EXCLUDED.val RETURNING *; `); return result; } async function setMany( ...values: readonly { readonly id: string; readonly val: unknown; }[] ): Promise<{id: string; val: unknown}[]> { const results = await db.query( values.map( ({id, val}) => sql` INSERT INTO json_test.json (id, val) VALUES (${id}, ${JSON.stringify(val)}) ON CONFLICT (id) DO UPDATE SET val=EXCLUDED.val RETURNING *; `, ), ); return results.map(([{id, val}]) => ({id, val})); } await expect(setOneImpliedJson('obj', {foo: 'bar'})).resolves.toEqual({ id: 'obj', val: { foo: 'bar', }, }); await expect(setOneExplicitJson('arr', ['my string', 56])).resolves.toEqual({ id: 'arr', val: ['my string', 56], }); await expect(setOneExplicitJson('str', 'my string')).resolves.toEqual({ id: 'str', val: 'my string', }); await expect(setOneExplicitJson('num', 42)).resolves.toEqual({ id: 'num', val: 42, }); await expect(setOneImpliedJson('obj', {foo: 'bing'})).resolves.toEqual({ id: 'obj', val: { foo: 'bing', }, }); await expect(setOneExplicitJson('arr', [56, 'my string'])).resolves.toEqual({ id: 'arr', val: [56, 'my string'], }); await expect(setOneExplicitJson('str', 'my other string')).resolves.toEqual({ id: 'str', val: 'my other string', }); await expect(setOneExplicitJson('num', 21)).resolves.toEqual({ id: 'num', val: 21, }); await expect( setMany( {id: 'obj', val: {foo: 'bar'}}, {id: 'arr', val: ['my string', 56]}, {id: 'str', val: 'my string'}, {id: 'num', val: 42}, ), ).resolves.toEqual([ {id: 'obj', val: {foo: 'bar'}}, {id: 'arr', val: ['my string', 56]}, {id: 'str', val: 'my string'}, {id: 'num', val: 42}, ]); }
AmitMY/atdatabases
packages/pg/src/__tests__/index.test.pg.ts
TypeScript
ArrowFunction
({id, val}) => sql` INSERT INTO json_test.json (id, val) VALUES (${id}, ${JSON.stringify(val)}) ON CONFLICT (id) DO UPDATE SET val=EXCLUDED.val RETURNING *; `
AmitMY/atdatabases
packages/pg/src/__tests__/index.test.pg.ts
TypeScript
ArrowFunction
([{id, val}]) => ({id, val})
AmitMY/atdatabases
packages/pg/src/__tests__/index.test.pg.ts
TypeScript
ArrowFunction
async () => { await db.query(sql`CREATE SCHEMA bigint_test`); await db.query( sql`CREATE TABLE bigint_test.bigints (id BIGINT NOT NULL PRIMARY KEY);`, ); await db.query(sql` INSERT INTO bigint_test.bigints (id) VALUES (1), (2), (42); `); const result = await db.query(sql`SELECT id from bigint_test.bigints;`); expect(result).toEqual([{id: 1}, {id: 2}, {id: 42}]); expect(await db.query(sql`SELECT id from bigint_test.bigints;`)).toEqual([ {id: 1}, {id: 2}, {id: 42}, ]); }
AmitMY/atdatabases
packages/pg/src/__tests__/index.test.pg.ts
TypeScript
ClassDeclaration
@Component({ selector: 'dialog-github-initial-setup', templateUrl: './dialog-github-initial-setup.component.html', styleUrls: ['./dialog-github-initial-setup.component.scss'], changeDetection: ChangeDetectionStrategy.OnPush, }) export class DialogGithubInitialSetupComponent implements OnInit { T: typeof T = T; githubCfg: GithubCfg; formGroup: FormGroup = new FormGroup({}); formConfig: FormlyFieldConfig[] = GITHUB_CONFIG_FORM; constructor( @Inject(MAT_DIALOG_DATA) public data: any, private _matDialogRef: MatDialogRef<DialogGithubInitialSetupComponent>, ) { this.githubCfg = this.data.githubCfg || DEFAULT_GITHUB_CFG; } ngOnInit(): void {} saveGithubCfg(gitCfg: GithubCfg): void { this._matDialogRef.close(gitCfg); } close(): void { this._matDialogRef.close(); } }
AlexisPrel/super-productivity
src/app/features/issue/providers/github/github-view-components/dialog-github-initial-setup/dialog-github-initial-setup.component.ts
TypeScript
MethodDeclaration
saveGithubCfg(gitCfg: GithubCfg): void { this._matDialogRef.close(gitCfg); }
AlexisPrel/super-productivity
src/app/features/issue/providers/github/github-view-components/dialog-github-initial-setup/dialog-github-initial-setup.component.ts
TypeScript
MethodDeclaration
close(): void { this._matDialogRef.close(); }
AlexisPrel/super-productivity
src/app/features/issue/providers/github/github-view-components/dialog-github-initial-setup/dialog-github-initial-setup.component.ts
TypeScript
ClassDeclaration
export class PostgresQueryBuilder { constructor(private target, private queryModel) {} buildSchemaQuery() { var query = 'SELECT schema_name FROM information_schema.schemata WHERE'; query += " schema_name NOT LIKE 'pg_%' AND schema_name NOT LIKE '\\_%' AND schema_name <> 'information_schema';"; return query; } buildTableQuery() { var query = 'SELECT table_name FROM information_schema.tables WHERE '; query += 'table_schema = ' + this.queryModel.quoteLiteral(this.target.schema); return query; } buildColumnQuery(type?: string) { var query = 'SELECT column_name FROM information_schema.columns WHERE '; query += 'table_schema = ' + this.queryModel.quoteLiteral(this.target.schema); query += ' AND table_name = ' + this.queryModel.quoteLiteral(this.target.table); switch (type) { case 'time': { query += " AND data_type IN ('timestamp without time zone','timestamp with time zone','bigint','integer','double precision','real')"; break; } case 'metric': { query += " AND data_type IN ('text','char','varchar')"; break; } case 'value': { query += " AND data_type IN ('bigint','integer','double precision','real')"; break; } } return query; } buildValueQuery(column: string) { var query = 'SELECT DISTINCT ' + this.queryModel.quoteIdentifier(column) + '::text'; query += ' FROM ' + this.queryModel.quoteIdentifier(this.target.schema); query += '.' + this.queryModel.quoteIdentifier(this.target.table); query += ' ORDER BY ' + this.queryModel.quoteIdentifier(column); query += ' LIMIT 100'; return query; } }
vipin-pink/grafana
public/app/plugins/datasource/postgres/query_builder.ts
TypeScript
MethodDeclaration
buildSchemaQuery() { var query = 'SELECT schema_name FROM information_schema.schemata WHERE'; query += " schema_name NOT LIKE 'pg_%' AND schema_name NOT LIKE '\\_%' AND schema_name <> 'information_schema';"; return query; }
vipin-pink/grafana
public/app/plugins/datasource/postgres/query_builder.ts
TypeScript
MethodDeclaration
buildTableQuery() { var query = 'SELECT table_name FROM information_schema.tables WHERE '; query += 'table_schema = ' + this.queryModel.quoteLiteral(this.target.schema); return query; }
vipin-pink/grafana
public/app/plugins/datasource/postgres/query_builder.ts
TypeScript
MethodDeclaration
buildColumnQuery(type?: string) { var query = 'SELECT column_name FROM information_schema.columns WHERE '; query += 'table_schema = ' + this.queryModel.quoteLiteral(this.target.schema); query += ' AND table_name = ' + this.queryModel.quoteLiteral(this.target.table); switch (type) { case 'time': { query += " AND data_type IN ('timestamp without time zone','timestamp with time zone','bigint','integer','double precision','real')"; break; } case 'metric': { query += " AND data_type IN ('text','char','varchar')"; break; } case 'value': { query += " AND data_type IN ('bigint','integer','double precision','real')"; break; } } return query; }
vipin-pink/grafana
public/app/plugins/datasource/postgres/query_builder.ts
TypeScript
MethodDeclaration
buildValueQuery(column: string) { var query = 'SELECT DISTINCT ' + this.queryModel.quoteIdentifier(column) + '::text'; query += ' FROM ' + this.queryModel.quoteIdentifier(this.target.schema); query += '.' + this.queryModel.quoteIdentifier(this.target.table); query += ' ORDER BY ' + this.queryModel.quoteIdentifier(column); query += ' LIMIT 100'; return query; }
vipin-pink/grafana
public/app/plugins/datasource/postgres/query_builder.ts
TypeScript
ArrowFunction
({ children, title }) => { const [isThemeDark, setIsThemeDark] = useThemeState(false) return ( <> <Global styles={NORMALIZE} /> <SEO title={title} /> <ThemeContext.Provider value={{ isThemeDark, setIsThemeDark }}
ricopella/metta_vt
src/components/Layout/index.tsx
TypeScript
InterfaceDeclaration
interface ILayout { title?: string }
ricopella/metta_vt
src/components/Layout/index.tsx
TypeScript
ClassDeclaration
/* * Licensed to Elasticsearch B.V. under one or more contributor * license agreements. See the NOTICE file distributed with * this work for additional information regarding copyright * ownership. Elasticsearch B.V. licenses this file to you 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. */ class FunctionScoreQuery extends QueryBase { boost_mode?: FunctionBoostMode functions?: FunctionScoreContainer[] max_boost?: double min_score?: double query?: QueryContainer score_mode?: FunctionScoreMode boost?: float }
aparo/opendistro-client-generator
specification/specs/query_dsl/compound/function_score/FunctionScoreQuery.ts
TypeScript
ArrowFunction
() => MoveArgs
favware/website-api
src/services/MoveService.ts
TypeScript
ArrowFunction
() => FuzzyMoveArgs
favware/website-api
src/services/MoveService.ts
TypeScript
ClassDeclaration
export class MoveService { private static readonly fuzzySearch = new FuzzySearch(moves, ['name', 'aliases']); public static getByMoveName(@Args(() => MoveArgs) { move }: MoveArgs): PokemonTypes.Move | undefined { return moves.get(move); } public static mapMoveDataToMoveGraphQL({ data, requestedFields }: MapMoveDataToMoveGraphQLParameters): Move { const move = new Move(); addPropertyToClass(move, 'key', data.key, requestedFields); addPropertyToClass(move, 'name', data.name, requestedFields); addPropertyToClass(move, 'desc', data.desc, requestedFields); addPropertyToClass(move, 'shortDesc', data.shortDesc, requestedFields); addPropertyToClass(move, 'type', data.type, requestedFields); addPropertyToClass(move, 'contestType', data.contestType, requestedFields); addPropertyToClass(move, 'basePower', data.basePower, requestedFields); addPropertyToClass(move, 'pp', data.pp, requestedFields); addPropertyToClass(move, 'category', data.category, requestedFields); addPropertyToClass(move, 'accuracy', data.accuracy, requestedFields); addPropertyToClass(move, 'priority', data.priority, requestedFields); addPropertyToClass(move, 'target', data.target, requestedFields); addPropertyToClass(move, 'isNonstandard', data.isNonstandard, requestedFields); addPropertyToClass(move, 'isGMax', data.isGMax, requestedFields); addPropertyToClass(move, 'isZ', parseZCrystal(data.isZ), requestedFields); addPropertyToClass(move, 'isFieldMove', data.isFieldMove, requestedFields); addPropertyToClass(move, 'maxMovePower', data.maxMovePower, requestedFields); addPropertyToClass(move, 'zMovePower', this.parseZMovePower(data.basePower, data.zMovePower), requestedFields); addPropertyToClass(move, 'serebiiPage', `https://www.serebii.net/attackdex-swsh/${toLowerSingleWordCase(data.name)}.shtml`, requestedFields); addPropertyToClass(move, 'bulbapediaPage', `https://bulbapedia.bulbagarden.net/wiki/${toTitleSnakeCase(data.name)}_(move)`, requestedFields); addPropertyToClass(move, 'smogonPage', `https://www.smogon.com/dex/ss/moves/${toLowerHyphenCase(data.name)}`, requestedFields); return move; } public static findByFuzzy(@Args(() => FuzzyMoveArgs) { move, offset, reverse, take }: FuzzyMoveArgs): PokemonTypes.Move[] { move = preParseInput(move); const fuzzyResult = this.fuzzySearch.runFuzzy(move); if (reverse) { fuzzyResult.reverse(); } return fuzzyResult.slice(offset, offset + take); } /** * Converts basePower and zMovePower to the correct Z-Move power, using datamined conversion table seen below. * * | Base move power | Z-Move power | * |------------------|--------------| * | 0-55 | 100 | * | 60-65 | 120 | * | 70-75 | 140 | * | 80-85 | 160 | * | 90-95 | 175 | * | 100 | 180 | * | 110 | 185 | * | 120-125 | 190 | * | 130 | 195 | * | 140+ | 200 | * @param basePower The basepower of a move * @param zMovePower The z-move power of a move, if specified it is preferred. */ private static parseZMovePower(basePower: string, zMovePower: number | undefined): number { // If zMovePower was defined on the move data then just return that value if (typeof zMovePower === 'number') return zMovePower; // If the basePower is 0 (status moves) then return 0 if (basePower === '0') return 0; const basePowerAsNumber = Number(basePower); if (basePowerAsNumber >= 0 && basePowerAsNumber <= 55) return 100; if (basePowerAsNumber >= 60 && basePowerAsNumber <= 65) return 120; if (basePowerAsNumber >= 70 && basePowerAsNumber <= 75) return 140; if (basePowerAsNumber >= 80 && basePowerAsNumber <= 85) return 160; if (basePowerAsNumber >= 90 && basePowerAsNumber <= 95) return 175; if (basePowerAsNumber === 100) return 180; if (basePowerAsNumber === 110) return 185; if (basePowerAsNumber >= 120 && basePowerAsNumber <= 125) return 190; if (basePowerAsNumber === 130) return 195; if (basePowerAsNumber >= 140) return 200; // If none of the cases matched then we return 0. This can happen if the move cannot be a Z-move // Which is the case for moves that were exclusive to a game that didn't feature Z-Moves // Such as "Pika Papow" and "Veevee Volley" return 0; } }
favware/website-api
src/services/MoveService.ts
TypeScript
InterfaceDeclaration
interface MapMoveDataToMoveGraphQLParameters { data: PokemonTypes.Move; requestedFields: GraphQLSet<keyof Move>; }
favware/website-api
src/services/MoveService.ts
TypeScript
MethodDeclaration
public static getByMoveName(@Args(() => MoveArgs) { move }: MoveArgs): PokemonTypes.Move | undefined { return moves.get(move); }
favware/website-api
src/services/MoveService.ts
TypeScript
MethodDeclaration
public static mapMoveDataToMoveGraphQL({ data, requestedFields }: MapMoveDataToMoveGraphQLParameters): Move { const move = new Move(); addPropertyToClass(move, 'key', data.key, requestedFields); addPropertyToClass(move, 'name', data.name, requestedFields); addPropertyToClass(move, 'desc', data.desc, requestedFields); addPropertyToClass(move, 'shortDesc', data.shortDesc, requestedFields); addPropertyToClass(move, 'type', data.type, requestedFields); addPropertyToClass(move, 'contestType', data.contestType, requestedFields); addPropertyToClass(move, 'basePower', data.basePower, requestedFields); addPropertyToClass(move, 'pp', data.pp, requestedFields); addPropertyToClass(move, 'category', data.category, requestedFields); addPropertyToClass(move, 'accuracy', data.accuracy, requestedFields); addPropertyToClass(move, 'priority', data.priority, requestedFields); addPropertyToClass(move, 'target', data.target, requestedFields); addPropertyToClass(move, 'isNonstandard', data.isNonstandard, requestedFields); addPropertyToClass(move, 'isGMax', data.isGMax, requestedFields); addPropertyToClass(move, 'isZ', parseZCrystal(data.isZ), requestedFields); addPropertyToClass(move, 'isFieldMove', data.isFieldMove, requestedFields); addPropertyToClass(move, 'maxMovePower', data.maxMovePower, requestedFields); addPropertyToClass(move, 'zMovePower', this.parseZMovePower(data.basePower, data.zMovePower), requestedFields); addPropertyToClass(move, 'serebiiPage', `https://www.serebii.net/attackdex-swsh/${toLowerSingleWordCase(data.name)}.shtml`, requestedFields); addPropertyToClass(move, 'bulbapediaPage', `https://bulbapedia.bulbagarden.net/wiki/${toTitleSnakeCase(data.name)}_(move)`, requestedFields); addPropertyToClass(move, 'smogonPage', `https://www.smogon.com/dex/ss/moves/${toLowerHyphenCase(data.name)}`, requestedFields); return move; }
favware/website-api
src/services/MoveService.ts
TypeScript
MethodDeclaration
public static findByFuzzy(@Args(() => FuzzyMoveArgs) { move, offset, reverse, take }: FuzzyMoveArgs): PokemonTypes.Move[] { move = preParseInput(move); const fuzzyResult = this.fuzzySearch.runFuzzy(move); if (reverse) { fuzzyResult.reverse(); } return fuzzyResult.slice(offset, offset + take); }
favware/website-api
src/services/MoveService.ts
TypeScript
MethodDeclaration
/** * Converts basePower and zMovePower to the correct Z-Move power, using datamined conversion table seen below. * * | Base move power | Z-Move power | * |------------------|--------------| * | 0-55 | 100 | * | 60-65 | 120 | * | 70-75 | 140 | * | 80-85 | 160 | * | 90-95 | 175 | * | 100 | 180 | * | 110 | 185 | * | 120-125 | 190 | * | 130 | 195 | * | 140+ | 200 | * @param basePower The basepower of a move * @param zMovePower The z-move power of a move, if specified it is preferred. */ private static parseZMovePower(basePower: string, zMovePower: number | undefined): number { // If zMovePower was defined on the move data then just return that value if (typeof zMovePower === 'number') return zMovePower; // If the basePower is 0 (status moves) then return 0 if (basePower === '0') return 0; const basePowerAsNumber = Number(basePower); if (basePowerAsNumber >= 0 && basePowerAsNumber <= 55) return 100; if (basePowerAsNumber >= 60 && basePowerAsNumber <= 65) return 120; if (basePowerAsNumber >= 70 && basePowerAsNumber <= 75) return 140; if (basePowerAsNumber >= 80 && basePowerAsNumber <= 85) return 160; if (basePowerAsNumber >= 90 && basePowerAsNumber <= 95) return 175; if (basePowerAsNumber === 100) return 180; if (basePowerAsNumber === 110) return 185; if (basePowerAsNumber >= 120 && basePowerAsNumber <= 125) return 190; if (basePowerAsNumber === 130) return 195; if (basePowerAsNumber >= 140) return 200; // If none of the cases matched then we return 0. This can happen if the move cannot be a Z-move // Which is the case for moves that were exclusive to a game that didn't feature Z-Moves // Such as "Pika Papow" and "Veevee Volley" return 0; }
favware/website-api
src/services/MoveService.ts
TypeScript
ArrowFunction
() => { it('should create style instructions on the element', () => { const files = { app: { 'spec.ts': ` import {Component, NgModule} from '@angular/core'; @Component({ selector: 'my-component', template: \`<div [style]="myStyleExp"></div>\` }) export class MyComponent { myStyleExp = [{color:'red'}, {color:'blue', duration:1000}] } @NgModule({declarations: [MyComponent]}) export class MyModule {} ` } }; const template = ` template: function MyComponent_Template(rf, $ctx$) { if (rf & 1) { $r3$.ɵE(0, "div"); $r3$.ɵs(null, null, $r3$.ɵzss); $r3$.ɵe(); } if (rf & 2) { $r3$.ɵsm(0, null, $ctx$.myStyleExp); $r3$.ɵsa(0); } } `; const result = compile(files, angularFiles); expectEmit(result.source, template, 'Incorrect template'); }); it('should place initial, multi, singular and application followed by attribute style instructions in the template code in that order', () => { const files = { app: { 'spec.ts': ` import {Component, NgModule} from '@angular/core'; @Component({ selector: 'my-component', template: \`<div style="opacity:1" [attr.style]="'border-width: 10px'" [style.width]="myWidth" [style]="myStyleExp" [style.height]="myHeight"></div>\` }) export class MyComponent { myStyleExp = [{color:'red'}, {color:'blue', duration:1000}] myWidth = '100px'; myHeight = '100px'; } @NgModule({declarations: [MyComponent]}) export class MyModule {} ` } }; const template = ` const _c0 = ["opacity","width","height",${InitialStylingFlags.VALUES_MODE},"opacity","1"]; … MyComponent.ngComponentDef = $r3$.ɵdefineComponent({ type: MyComponent, selectors:[["my-component"]], factory:function MyComponent_Factory(){ return new MyComponent(); }, features: [$r3$.ɵPublicFeature], template: function MyComponent_Template(rf, $ctx$) { if (rf & 1) { $r3$.ɵE(0, "div"); $r3$.ɵs(null, _c0, $r3$.ɵzss); $r3$.ɵe(); } if (rf & 2) { $r3$.ɵsm(0, null, $ctx$.myStyleExp); $r3$.ɵsp(0, 1, $ctx$.myWidth); $r3$.ɵsp(0, 2, $ctx$.myHeight); $r3$.ɵsa(0); $r3$.ɵa(0, "style", $r3$.ɵb("border-width: 10px"), $r3$.ɵzs); } } }); `; const result = compile(files, angularFiles); expectEmit(result.source, template, 'Incorrect template'); }); it('should assign a sanitizer instance to the element style allocation instruction if any url-based properties are detected', () => { const files = { app: { 'spec.ts': ` import {Component, NgModule} from '@angular/core'; @Component({ selector: 'my-component', template: \`<div [style.background-image]="myImage">\` }) export class MyComponent { myImage = 'url(foo.jpg)'; } @NgModule({declarations: [MyComponent]}) export class MyModule {} ` } }; const template = ` const _c0 = ["background-image"]; export class MyComponent { constructor() { this.myImage = 'url(foo.jpg)'; } } MyComponent.ngComponentDef = $r3$.ɵdefineComponent({ type: MyComponent, selectors: [["my-component"]], factory: function MyComponent_Factory() { return new MyComponent(); }, features: [$r3$.ɵPublicFeature], template: function MyComponent_Template(rf, ctx) { if (rf & 1) { $r3$.ɵE(0, "div"); $r3$.ɵs(null, _c0, $r3$.ɵzss); $r3$.ɵe(); } if (rf & 2) { $r3$.ɵsp(0, 0, ctx.myImage); $r3$.ɵsa(0); } } }); `; const result = compile(files, angularFiles); expectEmit(result.source, template, 'Incorrect template'); }); }
DaveCheez/angular
packages/compiler-cli/test/compliance/r3_view_compiler_styling_spec.ts
TypeScript
ArrowFunction
() => { const files = { app: { 'spec.ts': ` import {Component, NgModule} from '@angular/core'; @Component({ selector: 'my-component', template: \`<div [style]="myStyleExp"></div>\` }) export class MyComponent { myStyleExp = [{color:'red'}, {color:'blue', duration:1000}] } @NgModule({declarations: [MyComponent]}) export class MyModule {} ` } }; const template = ` template: function MyComponent_Template(rf, $ctx$) { if (rf & 1) { $r3$.ɵE(0, "div"); $r3$.ɵs(null, null, $r3$.ɵzss); $r3$.ɵe(); } if (rf & 2) { $r3$.ɵsm(0, null, $ctx$.myStyleExp); $r3$.ɵsa(0); } } `; const result = compile(files, angularFiles); expectEmit(result.source, template, 'Incorrect template'); }
DaveCheez/angular
packages/compiler-cli/test/compliance/r3_view_compiler_styling_spec.ts
TypeScript
ArrowFunction
() => { const files = { app: { 'spec.ts': ` import {Component, NgModule} from '@angular/core'; @Component({ selector: 'my-component', template: \`<div style="opacity:1" [attr.style]="'border-width: 10px'" [style.width]="myWidth" [style]="myStyleExp" [style.height]="myHeight"></div>\` }) export class MyComponent { myStyleExp = [{color:'red'}, {color:'blue', duration:1000}] myWidth = '100px'; myHeight = '100px'; } @NgModule({declarations: [MyComponent]}) export class MyModule {} ` } }; const template = ` const _c0 = ["opacity","width","height",${InitialStylingFlags.VALUES_MODE},"opacity","1"]; … MyComponent.ngComponentDef = $r3$.ɵdefineComponent({ type: MyComponent, selectors:[["my-component"]], factory:function MyComponent_Factory(){ return new MyComponent(); }, features: [$r3$.ɵPublicFeature], template: function MyComponent_Template(rf, $ctx$) { if (rf & 1) { $r3$.ɵE(0, "div"); $r3$.ɵs(null, _c0, $r3$.ɵzss); $r3$.ɵe(); } if (rf & 2) { $r3$.ɵsm(0, null, $ctx$.myStyleExp); $r3$.ɵsp(0, 1, $ctx$.myWidth); $r3$.ɵsp(0, 2, $ctx$.myHeight); $r3$.ɵsa(0); $r3$.ɵa(0, "style", $r3$.ɵb("border-width: 10px"), $r3$.ɵzs); } } }); `; const result = compile(files, angularFiles); expectEmit(result.source, template, 'Incorrect template'); }
DaveCheez/angular
packages/compiler-cli/test/compliance/r3_view_compiler_styling_spec.ts
TypeScript
ArrowFunction
() => { const files = { app: { 'spec.ts': ` import {Component, NgModule} from '@angular/core'; @Component({ selector: 'my-component', template: \`<div [style.background-image]="myImage">\` }) export class MyComponent { myImage = 'url(foo.jpg)'; } @NgModule({declarations: [MyComponent]}) export class MyModule {} ` } }; const template = ` const _c0 = ["background-image"]; export class MyComponent { constructor() { this.myImage = 'url(foo.jpg)'; } } MyComponent.ngComponentDef = $r3$.ɵdefineComponent({ type: MyComponent, selectors: [["my-component"]], factory: function MyComponent_Factory() { return new MyComponent(); }, features: [$r3$.ɵPublicFeature], template: function MyComponent_Template(rf, ctx) { if (rf & 1) { $r3$.ɵE(0, "div"); $r3$.ɵs(null, _c0, $r3$.ɵzss); $r3$.ɵe(); } if (rf & 2) { $r3$.ɵsp(0, 0, ctx.myImage); $r3$.ɵsa(0); } } }); `; const result = compile(files, angularFiles); expectEmit(result.source, template, 'Incorrect template'); }
DaveCheez/angular
packages/compiler-cli/test/compliance/r3_view_compiler_styling_spec.ts
TypeScript
ArrowFunction
() => { it('should create class styling instructions on the element', () => { const files = { app: { 'spec.ts': ` import {Component, NgModule} from '@angular/core'; @Component({ selector: 'my-component', template: \`<div [class]="myClassExp"></div>\` }) export class MyComponent { myClassExp = {'foo':true} } @NgModule({declarations: [MyComponent]}) export class MyModule {} ` } }; const template = ` template: function MyComponent_Template(rf, $ctx$) { if (rf & 1) { $r3$.ɵE(0, "div"); $r3$.ɵs(); $r3$.ɵe(); } if (rf & 2) { $r3$.ɵsm(0,$ctx$.myClassExp); $r3$.ɵsa(0); } } `; const result = compile(files, angularFiles); expectEmit(result.source, template, 'Incorrect template'); }); it('should place initial, multi, singular and application followed by attribute class instructions in the template code in that order', () => { const files = { app: { 'spec.ts': ` import {Component, NgModule} from '@angular/core'; @Component({ selector: 'my-component', template: \`<div class="grape" [attr.class]="'banana'" [class.apple]="yesToApple" [class]="myClassExp" [class.orange]="yesToOrange"></div>\` }) export class MyComponent { myClassExp = {a:true, b:true}; yesToApple = true; yesToOrange = true; } @NgModule({declarations: [MyComponent]}) export class MyModule {} ` } }; const template = ` const _c0 = ["grape","apple","orange",${InitialStylingFlags.VALUES_MODE},"grape",true]; … MyComponent.ngComponentDef = $r3$.ɵdefineComponent({ type: MyComponent, selectors:[["my-component"]], factory:function MyComponent_Factory(){ return new MyComponent(); }, features: [$r3$.ɵPublicFeature], template: function MyComponent_Template(rf, $ctx$) { if (rf & 1) { $r3$.ɵE(0, "div"); $r3$.ɵs(_c0); $r3$.ɵe(); } if (rf & 2) { $r3$.ɵsm(0, $ctx$.myClassExp); $r3$.ɵcp(0, 1, $ctx$.yesToApple); $r3$.ɵcp(0, 2, $ctx$.yesToOrange); $r3$.ɵsa(0); $r3$.ɵa(0, "class", $r3$.ɵb("banana")); } } }); `; const result = compile(files, angularFiles); expectEmit(result.source, template, 'Incorrect template'); }); it('should not generate the styling apply instruction if there are only static style/class attributes', () => { const files = { app: { 'spec.ts': ` import {Component, NgModule} from '@angular/core'; @Component({ selector: 'my-component', template: \`<div class="foo" style="width:100px" [attr.class]="'round'" [attr.style]="'height:100px'"></div>\` }) export class MyComponent {} @NgModule({declarations: [MyComponent]}) export class MyModule {} ` } }; const template = ` const _c0 = ["foo",${InitialStylingFlags.VALUES_MODE},"foo",true]; const _c1 = ["width",${InitialStylingFlags.VALUES_MODE},"width","100px"]; … MyComponent.ngComponentDef = $r3$.ɵdefineComponent({ type: MyComponent, selectors:[["my-component"]], factory:function MyComponent_Factory(){ return new MyComponent(); }, features: [$r3$.ɵPublicFeature], template: function MyComponent_Template(rf, $ctx$) { if (rf & 1) { $r3$.ɵE(0, "div"); $r3$.ɵs(_c0, _c1); $r3$.ɵe(); } if (rf & 2) { $r3$.ɵa(0, "class", $r3$.ɵb("round")); $r3$.ɵa(0, "style", $r3$.ɵb("height:100px"), $r3$.ɵzs); } } }); `; const result = compile(files, angularFiles); expectEmit(result.source, template, 'Incorrect template'); }); }
DaveCheez/angular
packages/compiler-cli/test/compliance/r3_view_compiler_styling_spec.ts
TypeScript
ArrowFunction
() => { const files = { app: { 'spec.ts': ` import {Component, NgModule} from '@angular/core'; @Component({ selector: 'my-component', template: \`<div [class]="myClassExp"></div>\` }) export class MyComponent { myClassExp = {'foo':true} } @NgModule({declarations: [MyComponent]}) export class MyModule {} ` } }; const template = ` template: function MyComponent_Template(rf, $ctx$) { if (rf & 1) { $r3$.ɵE(0, "div"); $r3$.ɵs(); $r3$.ɵe(); } if (rf & 2) { $r3$.ɵsm(0,$ctx$.myClassExp); $r3$.ɵsa(0); } } `; const result = compile(files, angularFiles); expectEmit(result.source, template, 'Incorrect template'); }
DaveCheez/angular
packages/compiler-cli/test/compliance/r3_view_compiler_styling_spec.ts
TypeScript
ArrowFunction
() => { const files = { app: { 'spec.ts': ` import {Component, NgModule} from '@angular/core'; @Component({ selector: 'my-component', template: \`<div class="grape" [attr.class]="'banana'" [class.apple]="yesToApple" [class]="myClassExp" [class.orange]="yesToOrange"></div>\` }) export class MyComponent { myClassExp = {a:true, b:true}; yesToApple = true; yesToOrange = true; } @NgModule({declarations: [MyComponent]}) export class MyModule {} ` } }; const template = ` const _c0 = ["grape","apple","orange",${InitialStylingFlags.VALUES_MODE},"grape",true]; … MyComponent.ngComponentDef = $r3$.ɵdefineComponent({ type: MyComponent, selectors:[["my-component"]], factory:function MyComponent_Factory(){ return new MyComponent(); }, features: [$r3$.ɵPublicFeature], template: function MyComponent_Template(rf, $ctx$) { if (rf & 1) { $r3$.ɵE(0, "div"); $r3$.ɵs(_c0); $r3$.ɵe(); } if (rf & 2) { $r3$.ɵsm(0, $ctx$.myClassExp); $r3$.ɵcp(0, 1, $ctx$.yesToApple); $r3$.ɵcp(0, 2, $ctx$.yesToOrange); $r3$.ɵsa(0); $r3$.ɵa(0, "class", $r3$.ɵb("banana")); } } }); `; const result = compile(files, angularFiles); expectEmit(result.source, template, 'Incorrect template'); }
DaveCheez/angular
packages/compiler-cli/test/compliance/r3_view_compiler_styling_spec.ts
TypeScript