type
stringclasses
7 values
content
stringlengths
4
9.55k
repo
stringlengths
7
96
path
stringlengths
4
178
language
stringclasses
1 value
MethodDeclaration
getEnvironment(w: Workflow): Observable<Environment> { if (this.destNode.context.environment_id) { if (w.environments && w.environments[this.destNode.context.environment_id]) { return of(w.environments[this.destNode.context.environment_id]); } return this._envService.getEnvironment(this.project.key, this.project.environment_names .find(e => e.id === this.destNode.context.environment_id).name); } return of(null); }
Kerguillec/cds
ui/src/app/shared/workflow/modal/node-add/workflow.trigger.component.ts
TypeScript
MethodDeclaration
getProjectIntegration(w: Workflow): Observable<ProjectIntegration> { if (this.destNode.context.project_integration_id) { return of(this.project.integrations.find(i => i.id === this.destNode.context.project_integration_id)); } return of(null); }
Kerguillec/cds
ui/src/app/shared/workflow/modal/node-add/workflow.trigger.component.ts
TypeScript
ArrowFunction
index => this.setState({ index })
limaofeng/vpsny
src/components/TabView.tsx
TypeScript
ArrowFunction
props => ( <TabBar {...props}
limaofeng/vpsny
src/components/TabView.tsx
TypeScript
ClassDeclaration
export default class TabView extends React.Component { static propTypes = { navigationState: PropTypes.object.isRequired, renderScene: PropTypes.func.isRequired }; constructor(props) { super(props); const { navigationState } = props; this.state = navigationState; } _handleIndexChange = index => this.setState({ index }); _renderHeader = props => ( <TabBar {...props} scrollEnabled style={
limaofeng/vpsny
src/components/TabView.tsx
TypeScript
InterfaceDeclaration
export interface IInsertionPoint { ignore: boolean; commentStrOffset: number; }
AeliusSaionji/vscode
src/vs/editor/contrib/comment/lineCommentCommand.ts
TypeScript
InterfaceDeclaration
export interface ILinePreflightData { ignore: boolean; commentStr: string; commentStrOffset: number; commentStrLength: number; }
AeliusSaionji/vscode
src/vs/editor/contrib/comment/lineCommentCommand.ts
TypeScript
InterfaceDeclaration
export interface IPreflightData { supported: boolean; shouldRemoveComments: boolean; lines: ILinePreflightData[]; }
AeliusSaionji/vscode
src/vs/editor/contrib/comment/lineCommentCommand.ts
TypeScript
InterfaceDeclaration
export interface ISimpleModel { getLineContent(lineNumber: number): string; }
AeliusSaionji/vscode
src/vs/editor/contrib/comment/lineCommentCommand.ts
TypeScript
EnumDeclaration
export const enum Type { Toggle = 0, ForceAdd = 1, ForceRemove = 2 }
AeliusSaionji/vscode
src/vs/editor/contrib/comment/lineCommentCommand.ts
TypeScript
MethodDeclaration
/** * Do an initial pass over the lines and gather info about the line comment string. * Returns null if any of the lines doesn't support a line comment string. */ public static _gatherPreflightCommentStrings(model: ITextModel, startLineNumber: number, endLineNumber: number): ILinePreflightData[] { model.tokenizeIfCheap(startLineNumber); const languageId = model.getLanguageIdAtPosition(startLineNumber, 1); const config = LanguageConfigurationRegistry.getComments(languageId); const commentStr = (config ? config.lineCommentToken : null); if (!commentStr) { // Mode does not support line comments return null; } let lines: ILinePreflightData[] = []; for (let i = 0, lineCount = endLineNumber - startLineNumber + 1; i < lineCount; i++) { lines[i] = { ignore: false, commentStr: commentStr, commentStrOffset: 0, commentStrLength: commentStr.length }; } return lines; }
AeliusSaionji/vscode
src/vs/editor/contrib/comment/lineCommentCommand.ts
TypeScript
MethodDeclaration
/** * Analyze lines and decide which lines are relevant and what the toggle should do. * Also, build up several offsets and lengths useful in the generation of editor operations. */ public static _analyzeLines(type: Type, model: ISimpleModel, lines: ILinePreflightData[], startLineNumber: number): IPreflightData { let onlyWhitespaceLines = true; let shouldRemoveComments: boolean; if (type === Type.Toggle) { shouldRemoveComments = true; } else if (type === Type.ForceAdd) { shouldRemoveComments = false; } else { shouldRemoveComments = true; } for (let i = 0, lineCount = lines.length; i < lineCount; i++) { const lineData = lines[i]; const lineNumber = startLineNumber + i; const lineContent = model.getLineContent(lineNumber); const lineContentStartOffset = strings.firstNonWhitespaceIndex(lineContent); if (lineContentStartOffset === -1) { // Empty or whitespace only line if (type === Type.Toggle) { lineData.ignore = true; } else if (type === Type.ForceAdd) { lineData.ignore = true; } else { lineData.ignore = true; } lineData.commentStrOffset = lineContent.length; continue; } onlyWhitespaceLines = false; lineData.ignore = false; lineData.commentStrOffset = lineContentStartOffset; if (shouldRemoveComments && !BlockCommentCommand._haystackHasNeedleAtOffset(lineContent, lineData.commentStr, lineContentStartOffset)) { if (type === Type.Toggle) { // Every line so far has been a line comment, but this one is not shouldRemoveComments = false; } else if (type === Type.ForceAdd) { // Will not happen } else { lineData.ignore = true; } } if (shouldRemoveComments) { const commentStrEndOffset = lineContentStartOffset + lineData.commentStrLength; if (commentStrEndOffset < lineContent.length && lineContent.charCodeAt(commentStrEndOffset) === CharCode.Space) { lineData.commentStrLength += 1; } } } if (type === Type.Toggle && onlyWhitespaceLines) { // For only whitespace lines, we insert comments shouldRemoveComments = false; // Also, no longer ignore them for (let i = 0, lineCount = lines.length; i < lineCount; i++) { lines[i].ignore = false; } } return { supported: true, shouldRemoveComments: shouldRemoveComments, lines: lines }; }
AeliusSaionji/vscode
src/vs/editor/contrib/comment/lineCommentCommand.ts
TypeScript
MethodDeclaration
/** * Analyze all lines and decide exactly what to do => not supported | insert line comments | remove line comments */ public static _gatherPreflightData(type: Type, model: ITextModel, startLineNumber: number, endLineNumber: number): IPreflightData { const lines = LineCommentCommand._gatherPreflightCommentStrings(model, startLineNumber, endLineNumber); if (lines === null) { return { supported: false, shouldRemoveComments: false, lines: null }; } return LineCommentCommand._analyzeLines(type, model, lines, startLineNumber); }
AeliusSaionji/vscode
src/vs/editor/contrib/comment/lineCommentCommand.ts
TypeScript
MethodDeclaration
/** * Given a successful analysis, execute either insert line comments, either remove line comments */ private _executeLineComments(model: ISimpleModel, builder: editorCommon.IEditOperationBuilder, data: IPreflightData, s: Selection): void { let ops: IIdentifiedSingleEditOperation[]; if (data.shouldRemoveComments) { ops = LineCommentCommand._createRemoveLineCommentsOperations(data.lines, s.startLineNumber); } else { LineCommentCommand._normalizeInsertionPoint(model, data.lines, s.startLineNumber, this._tabSize); ops = LineCommentCommand._createAddLineCommentsOperations(data.lines, s.startLineNumber); } const cursorPosition = new Position(s.positionLineNumber, s.positionColumn); for (let i = 0, len = ops.length; i < len; i++) { builder.addEditOperation(ops[i].range, ops[i].text); if (ops[i].range.isEmpty() && ops[i].range.getStartPosition().equals(cursorPosition)) { const lineContent = model.getLineContent(cursorPosition.lineNumber); if (lineContent.length + 1 === cursorPosition.column) { this._deltaColumn = ops[i].text.length; } } } this._selectionId = builder.trackSelection(s); }
AeliusSaionji/vscode
src/vs/editor/contrib/comment/lineCommentCommand.ts
TypeScript
MethodDeclaration
private _attemptRemoveBlockComment(model: ITextModel, s: Selection, startToken: string, endToken: string): IIdentifiedSingleEditOperation[] { let startLineNumber = s.startLineNumber; let endLineNumber = s.endLineNumber; let startTokenAllowedBeforeColumn = endToken.length + Math.max( model.getLineFirstNonWhitespaceColumn(s.startLineNumber), s.startColumn ); let startTokenIndex = model.getLineContent(startLineNumber).lastIndexOf(startToken, startTokenAllowedBeforeColumn - 1); let endTokenIndex = model.getLineContent(endLineNumber).indexOf(endToken, s.endColumn - 1 - startToken.length); if (startTokenIndex !== -1 && endTokenIndex === -1) { endTokenIndex = model.getLineContent(startLineNumber).indexOf(endToken, startTokenIndex + startToken.length); endLineNumber = startLineNumber; } if (startTokenIndex === -1 && endTokenIndex !== -1) { startTokenIndex = model.getLineContent(endLineNumber).lastIndexOf(startToken, endTokenIndex); startLineNumber = endLineNumber; } if (s.isEmpty() && (startTokenIndex === -1 || endTokenIndex === -1)) { startTokenIndex = model.getLineContent(startLineNumber).indexOf(startToken); if (startTokenIndex !== -1) { endTokenIndex = model.getLineContent(startLineNumber).indexOf(endToken, startTokenIndex + startToken.length); } } // We have to adjust to possible inner white space. // For Space after startToken, add Space to startToken - range math will work out. if (startTokenIndex !== -1 && model.getLineContent(startLineNumber).charCodeAt(startTokenIndex + startToken.length) === CharCode.Space) { startToken += ' '; } // For Space before endToken, add Space before endToken and shift index one left. if (endTokenIndex !== -1 && model.getLineContent(endLineNumber).charCodeAt(endTokenIndex - 1) === CharCode.Space) { endToken = ' ' + endToken; endTokenIndex -= 1; } if (startTokenIndex !== -1 && endTokenIndex !== -1) { return BlockCommentCommand._createRemoveBlockCommentOperations( new Range(startLineNumber, startTokenIndex + startToken.length + 1, endLineNumber, endTokenIndex + 1), startToken, endToken ); } return null; }
AeliusSaionji/vscode
src/vs/editor/contrib/comment/lineCommentCommand.ts
TypeScript
MethodDeclaration
/** * Given an unsuccessful analysis, delegate to the block comment command */ private _executeBlockComment(model: ITextModel, builder: editorCommon.IEditOperationBuilder, s: Selection): void { model.tokenizeIfCheap(s.startLineNumber); let languageId = model.getLanguageIdAtPosition(s.startLineNumber, 1); let config = LanguageConfigurationRegistry.getComments(languageId); if (!config || !config.blockCommentStartToken || !config.blockCommentEndToken) { // Mode does not support block comments return; } const startToken = config.blockCommentStartToken; const endToken = config.blockCommentEndToken; let ops = this._attemptRemoveBlockComment(model, s, startToken, endToken); if (!ops) { if (s.isEmpty()) { const lineContent = model.getLineContent(s.startLineNumber); let firstNonWhitespaceIndex = strings.firstNonWhitespaceIndex(lineContent); if (firstNonWhitespaceIndex === -1) { // Line is empty or contains only whitespace firstNonWhitespaceIndex = lineContent.length; } ops = BlockCommentCommand._createAddBlockCommentOperations( new Range(s.startLineNumber, firstNonWhitespaceIndex + 1, s.startLineNumber, lineContent.length + 1), startToken, endToken ); } else { ops = BlockCommentCommand._createAddBlockCommentOperations( new Range(s.startLineNumber, model.getLineFirstNonWhitespaceColumn(s.startLineNumber), s.endLineNumber, model.getLineMaxColumn(s.endLineNumber)), startToken, endToken ); } if (ops.length === 1) { // Leave cursor after token and Space this._deltaColumn = startToken.length + 1; } } this._selectionId = builder.trackSelection(s); for (let i = 0; i < ops.length; i++) { builder.addEditOperation(ops[i].range, ops[i].text); } }
AeliusSaionji/vscode
src/vs/editor/contrib/comment/lineCommentCommand.ts
TypeScript
MethodDeclaration
public getEditOperations(model: ITextModel, builder: editorCommon.IEditOperationBuilder): void { let s = this._selection; this._moveEndPositionDown = false; if (s.startLineNumber < s.endLineNumber && s.endColumn === 1) { this._moveEndPositionDown = true; s = s.setEndPosition(s.endLineNumber - 1, model.getLineMaxColumn(s.endLineNumber - 1)); } const data = LineCommentCommand._gatherPreflightData(this._type, model, s.startLineNumber, s.endLineNumber); if (data.supported) { return this._executeLineComments(model, builder, data, s); } return this._executeBlockComment(model, builder, s); }
AeliusSaionji/vscode
src/vs/editor/contrib/comment/lineCommentCommand.ts
TypeScript
MethodDeclaration
public computeCursorState(model: ITextModel, helper: editorCommon.ICursorStateComputerData): Selection { let result = helper.getTrackedSelection(this._selectionId); if (this._moveEndPositionDown) { result = result.setEndPosition(result.endLineNumber + 1, 1); } return new Selection( result.selectionStartLineNumber, result.selectionStartColumn + this._deltaColumn, result.positionLineNumber, result.positionColumn + this._deltaColumn ); }
AeliusSaionji/vscode
src/vs/editor/contrib/comment/lineCommentCommand.ts
TypeScript
MethodDeclaration
/** * Generate edit operations in the remove line comment case */ public static _createRemoveLineCommentsOperations(lines: ILinePreflightData[], startLineNumber: number): IIdentifiedSingleEditOperation[] { let res: IIdentifiedSingleEditOperation[] = []; for (let i = 0, len = lines.length; i < len; i++) { const lineData = lines[i]; if (lineData.ignore) { continue; } res.push(EditOperation.delete(new Range( startLineNumber + i, lineData.commentStrOffset + 1, startLineNumber + i, lineData.commentStrOffset + lineData.commentStrLength + 1 ))); } return res; }
AeliusSaionji/vscode
src/vs/editor/contrib/comment/lineCommentCommand.ts
TypeScript
MethodDeclaration
/** * Generate edit operations in the add line comment case */ public static _createAddLineCommentsOperations(lines: ILinePreflightData[], startLineNumber: number): IIdentifiedSingleEditOperation[] { let res: IIdentifiedSingleEditOperation[] = []; for (let i = 0, len = lines.length; i < len; i++) { const lineData = lines[i]; if (lineData.ignore) { continue; } res.push(EditOperation.insert(new Position(startLineNumber + i, lineData.commentStrOffset + 1), lineData.commentStr + ' ')); } return res; }
AeliusSaionji/vscode
src/vs/editor/contrib/comment/lineCommentCommand.ts
TypeScript
MethodDeclaration
// TODO@Alex -> duplicated in characterHardWrappingLineMapper private static nextVisibleColumn(currentVisibleColumn: number, tabSize: number, isTab: boolean, columnSize: number): number { if (isTab) { return currentVisibleColumn + (tabSize - (currentVisibleColumn % tabSize)); } return currentVisibleColumn + columnSize; }
AeliusSaionji/vscode
src/vs/editor/contrib/comment/lineCommentCommand.ts
TypeScript
MethodDeclaration
/** * Adjust insertion points to have them vertically aligned in the add line comment case */ public static _normalizeInsertionPoint(model: ISimpleModel, lines: IInsertionPoint[], startLineNumber: number, tabSize: number): void { let minVisibleColumn = Number.MAX_VALUE; let j: number; let lenJ: number; for (let i = 0, len = lines.length; i < len; i++) { if (lines[i].ignore) { continue; } const lineContent = model.getLineContent(startLineNumber + i); let currentVisibleColumn = 0; for (let j = 0, lenJ = lines[i].commentStrOffset; currentVisibleColumn < minVisibleColumn && j < lenJ; j++) { currentVisibleColumn = LineCommentCommand.nextVisibleColumn(currentVisibleColumn, tabSize, lineContent.charCodeAt(j) === CharCode.Tab, 1); } if (currentVisibleColumn < minVisibleColumn) { minVisibleColumn = currentVisibleColumn; } } minVisibleColumn = Math.floor(minVisibleColumn / tabSize) * tabSize; for (let i = 0, len = lines.length; i < len; i++) { if (lines[i].ignore) { continue; } const lineContent = model.getLineContent(startLineNumber + i); let currentVisibleColumn = 0; for (j = 0, lenJ = lines[i].commentStrOffset; currentVisibleColumn < minVisibleColumn && j < lenJ; j++) { currentVisibleColumn = LineCommentCommand.nextVisibleColumn(currentVisibleColumn, tabSize, lineContent.charCodeAt(j) === CharCode.Tab, 1); } if (currentVisibleColumn > minVisibleColumn) { lines[i].commentStrOffset = j - 1; } else { lines[i].commentStrOffset = j; } } }
AeliusSaionji/vscode
src/vs/editor/contrib/comment/lineCommentCommand.ts
TypeScript
ClassDeclaration
@Controller('auth') export class AuthController { constructor(private readonly authService: AuthService) {} @Post('register') createUser(@Body() authData: CreateUserDTO): Promise<IRESTResponse> { return this.authService.createUser(authData); } @Post('login') login(@Body() authData: LoginDTO): Promise<IRESTResponse> { return this.authService.login(authData); } }
cod3hunter/food-service-api
src/auth/auth.controller.ts
TypeScript
MethodDeclaration
@Post('register') createUser(@Body() authData: CreateUserDTO): Promise<IRESTResponse> { return this.authService.createUser(authData); }
cod3hunter/food-service-api
src/auth/auth.controller.ts
TypeScript
MethodDeclaration
@Post('login') login(@Body() authData: LoginDTO): Promise<IRESTResponse> { return this.authService.login(authData); }
cod3hunter/food-service-api
src/auth/auth.controller.ts
TypeScript
ArrowFunction
(params: any, options: MethodOptions|BodyResponseCallback<Schema$Output>, callback?: BodyResponseCallback<Schema$Output>) => { if (typeof options === 'function') { callback = options; options = {}; } options = options || {}; const rootUrl = options.rootUrl || 'https://www.googleapis.com/'; const parameters = { options: Object.assign( { url: (rootUrl + '/prediction/v1.5/hostedmodels/{hostedModelName}/predict') .replace(/([^:]\/)\/+/g, '$1'), method: 'POST' }, options), params, requiredParams: ['hostedModelName'], pathParams: ['hostedModelName'], context: this.root }; createAPIRequest<Schema$Output>(parameters, callback!); }
samaystops4no1/google-api-nodejs-client
src/apis/prediction/v1.5.ts
TypeScript
ArrowFunction
(params: any, options: MethodOptions|BodyResponseCallback<Schema$Analyze>, callback?: BodyResponseCallback<Schema$Analyze>) => { if (typeof options === 'function') { callback = options; options = {}; } options = options || {}; const rootUrl = options.rootUrl || 'https://www.googleapis.com/'; const parameters = { options: Object.assign( { url: (rootUrl + '/prediction/v1.5/trainedmodels/{id}/analyze') .replace(/([^:]\/)\/+/g, '$1'), method: 'GET' }, options), params, requiredParams: ['id'], pathParams: ['id'], context: this.root }; createAPIRequest<Schema$Analyze>(parameters, callback!); }
samaystops4no1/google-api-nodejs-client
src/apis/prediction/v1.5.ts
TypeScript
ArrowFunction
(params: any, options: MethodOptions|BodyResponseCallback<void>, callback?: BodyResponseCallback<void>) => { if (typeof options === 'function') { callback = options; options = {}; } options = options || {}; const rootUrl = options.rootUrl || 'https://www.googleapis.com/'; const parameters = { options: Object.assign( { url: (rootUrl + '/prediction/v1.5/trainedmodels/{id}') .replace(/([^:]\/)\/+/g, '$1'), method: 'DELETE' }, options), params, requiredParams: ['id'], pathParams: ['id'], context: this.root }; createAPIRequest<void>(parameters, callback!); }
samaystops4no1/google-api-nodejs-client
src/apis/prediction/v1.5.ts
TypeScript
ArrowFunction
(params: any, options: MethodOptions|BodyResponseCallback<Schema$Training>, callback?: BodyResponseCallback<Schema$Training>) => { if (typeof options === 'function') { callback = options; options = {}; } options = options || {}; const rootUrl = options.rootUrl || 'https://www.googleapis.com/'; const parameters = { options: Object.assign( { url: (rootUrl + '/prediction/v1.5/trainedmodels/{id}') .replace(/([^:]\/)\/+/g, '$1'), method: 'GET' }, options), params, requiredParams: ['id'], pathParams: ['id'], context: this.root }; createAPIRequest<Schema$Training>(parameters, callback!); }
samaystops4no1/google-api-nodejs-client
src/apis/prediction/v1.5.ts
TypeScript
ArrowFunction
(params: any, options: MethodOptions|BodyResponseCallback<Schema$Training>, callback?: BodyResponseCallback<Schema$Training>) => { if (typeof options === 'function') { callback = options; options = {}; } options = options || {}; const rootUrl = options.rootUrl || 'https://www.googleapis.com/'; const parameters = { options: Object.assign( { url: (rootUrl + '/prediction/v1.5/trainedmodels') .replace(/([^:]\/)\/+/g, '$1'), method: 'POST' }, options), params, requiredParams: [], pathParams: [], context: this.root }; createAPIRequest<Schema$Training>(parameters, callback!); }
samaystops4no1/google-api-nodejs-client
src/apis/prediction/v1.5.ts
TypeScript
ArrowFunction
(params: any, options: MethodOptions|BodyResponseCallback<Schema$List>, callback?: BodyResponseCallback<Schema$List>) => { if (typeof options === 'function') { callback = options; options = {}; } options = options || {}; const rootUrl = options.rootUrl || 'https://www.googleapis.com/'; const parameters = { options: Object.assign( { url: (rootUrl + '/prediction/v1.5/trainedmodels/list') .replace(/([^:]\/)\/+/g, '$1'), method: 'GET' }, options), params, requiredParams: [], pathParams: [], context: this.root }; createAPIRequest<Schema$List>(parameters, callback!); }
samaystops4no1/google-api-nodejs-client
src/apis/prediction/v1.5.ts
TypeScript
ArrowFunction
(params: any, options: MethodOptions|BodyResponseCallback<Schema$Output>, callback?: BodyResponseCallback<Schema$Output>) => { if (typeof options === 'function') { callback = options; options = {}; } options = options || {}; const rootUrl = options.rootUrl || 'https://www.googleapis.com/'; const parameters = { options: Object.assign( { url: (rootUrl + '/prediction/v1.5/trainedmodels/{id}/predict') .replace(/([^:]\/)\/+/g, '$1'), method: 'POST' }, options), params, requiredParams: ['id'], pathParams: ['id'], context: this.root }; createAPIRequest<Schema$Output>(parameters, callback!); }
samaystops4no1/google-api-nodejs-client
src/apis/prediction/v1.5.ts
TypeScript
ArrowFunction
(params: any, options: MethodOptions|BodyResponseCallback<Schema$Training>, callback?: BodyResponseCallback<Schema$Training>) => { if (typeof options === 'function') { callback = options; options = {}; } options = options || {}; const rootUrl = options.rootUrl || 'https://www.googleapis.com/'; const parameters = { options: Object.assign( { url: (rootUrl + '/prediction/v1.5/trainedmodels/{id}') .replace(/([^:]\/)\/+/g, '$1'), method: 'PUT' }, options), params, requiredParams: ['id'], pathParams: ['id'], context: this.root }; createAPIRequest<Schema$Training>(parameters, callback!); }
samaystops4no1/google-api-nodejs-client
src/apis/prediction/v1.5.ts
TypeScript
ClassDeclaration
// TODO: We will eventually get the `any` in here cleared out, but in the // interim we want to turn on no-implicit-any. // tslint:disable: no-any // tslint:disable: class-name // tslint:disable: variable-name // tslint:disable: jsdoc-format /** * Prediction API * * Lets you access a cloud hosted machine learning service that makes it easy to * build smart apps * * @example * const google = require('googleapis'); * const prediction = google.prediction('v1.5'); * * @namespace prediction * @type {Function} * @version v1.5 * @variation v1.5 * @param {object=} options Options for Prediction */ export class Prediction { _options: GlobalOptions; google: GoogleApis; root = this; hostedmodels: Resource$Hostedmodels; trainedmodels: Resource$Trainedmodels; constructor(options: GlobalOptions, google: GoogleApis) { this._options = options || {}; this.google = google; this.hostedmodels = new Resource$Hostedmodels(this); this.trainedmodels = new Resource$Trainedmodels(this); } }
samaystops4no1/google-api-nodejs-client
src/apis/prediction/v1.5.ts
TypeScript
ClassDeclaration
export class Resource$Hostedmodels { root: Prediction; constructor(root: Prediction) { this.root = root; } /** * prediction.hostedmodels.predict * @desc Submit input and request an output against a hosted model. * @alias prediction.hostedmodels.predict * @memberOf! () * * @param {object} params Parameters for request * @param {string} params.hostedModelName The name of a hosted model. * @param {().Input} params.resource Request body data * @param {object} [options] Optionally override request options, such as `url`, `method`, and `encoding`. * @param {callback} callback The callback that handles the response. * @return {object} Request object */ predict = (params: any, options: MethodOptions|BodyResponseCallback<Schema$Output>, callback?: BodyResponseCallback<Schema$Output>) => { if (typeof options === 'function') { callback = options; options = {}; } options = options || {}; const rootUrl = options.rootUrl || 'https://www.googleapis.com/'; const parameters = { options: Object.assign( { url: (rootUrl + '/prediction/v1.5/hostedmodels/{hostedModelName}/predict') .replace(/([^:]\/)\/+/g, '$1'), method: 'POST' }, options), params, requiredParams: ['hostedModelName'], pathParams: ['hostedModelName'], context: this.root }; createAPIRequest<Schema$Output>(parameters, callback!); }; }
samaystops4no1/google-api-nodejs-client
src/apis/prediction/v1.5.ts
TypeScript
InterfaceDeclaration
export interface Schema$Analyze { /** * Description of the data the model was trained on. */ dataDescription: any; /** * List of errors with the data. */ errors: any[]; /** * The unique name for the predictive model. */ id: string; /** * What kind of resource this is. */ kind: string; /** * Description of the model. */ modelDescription: any; /** * A URL to re-request this resource. */ selfLink: string; }
samaystops4no1/google-api-nodejs-client
src/apis/prediction/v1.5.ts
TypeScript
InterfaceDeclaration
export interface Schema$Input { /** * Input to the model for a prediction */ input: any; }
samaystops4no1/google-api-nodejs-client
src/apis/prediction/v1.5.ts
TypeScript
InterfaceDeclaration
export interface Schema$List { /** * List of models. */ items: Schema$Training[]; /** * What kind of resource this is. */ kind: string; /** * Pagination token to fetch the next page, if one exists. */ nextPageToken: string; /** * A URL to re-request this resource. */ selfLink: string; }
samaystops4no1/google-api-nodejs-client
src/apis/prediction/v1.5.ts
TypeScript
InterfaceDeclaration
export interface Schema$Output { /** * The unique name for the predictive model. */ id: string; /** * What kind of resource this is. */ kind: string; /** * The most likely class label [Categorical models only]. */ outputLabel: string; /** * A list of class labels with their estimated probabilities [Categorical * models only]. */ outputMulti: any[]; /** * The estimated regression value [Regression models only]. */ outputValue: number; /** * A URL to re-request this resource. */ selfLink: string; }
samaystops4no1/google-api-nodejs-client
src/apis/prediction/v1.5.ts
TypeScript
InterfaceDeclaration
export interface Schema$Training { /** * Insert time of the model (as a RFC 3339 timestamp). */ created: string; /** * The unique name for the predictive model. */ id: string; /** * What kind of resource this is. */ kind: string; /** * Model metadata. */ modelInfo: any; /** * Type of predictive model (classification or regression) */ modelType: string; /** * A URL to re-request this resource. */ selfLink: string; /** * Google storage location of the training data file. */ storageDataLocation: string; /** * Google storage location of the preprocessing pmml file. */ storagePMMLLocation: string; /** * Google storage location of the pmml model file. */ storagePMMLModelLocation: string; /** * Training completion time (as a RFC 3339 timestamp). */ trainingComplete: string; /** * Instances to train model on. */ trainingInstances: any[]; /** * The current status of the training job. This can be one of following: * RUNNING; DONE; ERROR; ERROR: TRAINING JOB NOT FOUND */ trainingStatus: string; /** * A class weighting function, which allows the importance weights for class * labels to be specified [Categorical models only]. */ utility: any[]; }
samaystops4no1/google-api-nodejs-client
src/apis/prediction/v1.5.ts
TypeScript
InterfaceDeclaration
export interface Schema$Update { /** * The input features for this instance */ csvInstance: any[]; /** * The class label of this instance */ label: string; /** * The generic output value - could be regression value or class label */ output: string; }
samaystops4no1/google-api-nodejs-client
src/apis/prediction/v1.5.ts
TypeScript
ArrowFunction
(mockData: TopologyDataResources) => { const workloadResources = getWorkloadResources(mockData, TEST_KINDS_MAP, WORKLOAD_TYPES); return getOperatorTopologyDataModel('test-project', mockData, workloadResources).then((model) => { const fullModel = baseDataModelGetter(model, 'test-project', mockData, workloadResources, []); operatorsDataModelReconciler(fullModel, mockData); return fullModel; }); }
Jayashree-panda/console
frontend/packages/topology/src/operators/__tests__/operator-data-transformer.spec.ts
TypeScript
ArrowFunction
(model) => { const fullModel = baseDataModelGetter(model, 'test-project', mockData, workloadResources, []); operatorsDataModelReconciler(fullModel, mockData); return fullModel; }
Jayashree-panda/console
frontend/packages/topology/src/operators/__tests__/operator-data-transformer.spec.ts
TypeScript
ArrowFunction
(id: string, graphData: Model): NodeModel => { return graphData.nodes.find((n) => n.id === id); }
Jayashree-panda/console
frontend/packages/topology/src/operators/__tests__/operator-data-transformer.spec.ts
TypeScript
ArrowFunction
(n) => n.id === id
Jayashree-panda/console
frontend/packages/topology/src/operators/__tests__/operator-data-transformer.spec.ts
TypeScript
ArrowFunction
(name: string, graphData: Model): NodeModel => { return graphData.nodes.find((n) => n.label === name); }
Jayashree-panda/console
frontend/packages/topology/src/operators/__tests__/operator-data-transformer.spec.ts
TypeScript
ArrowFunction
(n) => n.label === name
Jayashree-panda/console
frontend/packages/topology/src/operators/__tests__/operator-data-transformer.spec.ts
TypeScript
ArrowFunction
() => { let mockResources: TopologyDataResources; let filters; beforeEach(() => { mockResources = _.cloneDeep(MockResources); filters = _.cloneDeep(DEFAULT_TOPOLOGY_FILTERS); filters.push(...getTopologyFilters()); }); it('should return graph nodes for operator backed services', async () => { const graphData = await getTransformedTopologyData(mockResources); const operatorBackedServices = _.filter(graphData.nodes, { type: TYPE_OPERATOR_BACKED_SERVICE, }); expect(operatorBackedServices).toHaveLength(1); expect(getNodeById(operatorBackedServices[0].id, graphData).type).toBe( TYPE_OPERATOR_BACKED_SERVICE, ); expect(graphData.nodes.filter((n) => !n.group)).toHaveLength(10); expect(graphData.nodes.filter((n) => n.group)).toHaveLength(3); expect(graphData.edges).toHaveLength(1); }); it('should return csv icon for operator backed service', async () => { const icon = _.get(mockResources.clusterServiceVersions.data[0], 'spec.icon.0'); const csvIcon = getImageForCSVIcon(icon); const graphData = await getTransformedTopologyData(mockResources); const node = getNodeByName('jaeger-all-in-one-inmemory', graphData); expect((node.data.data as WorkloadData).builderImage).toBe(csvIcon); }); it('should flag operator groups as collapsed when display filter is set', async () => { const topologyTransformedData = await getTransformedTopologyData(mockResources); getFilterById(EXPAND_OPERATORS_RELEASE_FILTER, filters).value = false; const newModel = updateModelFromFilters( topologyTransformedData, filters, ALL_APPLICATIONS_KEY, filterers, ); expect(newModel.nodes.filter((n) => n.group).length).toBe(3); expect(newModel.nodes.filter((n) => n.group && n.collapsed).length).toBe(1); }); it('should flag operator groups as collapsed when all groups are collapsed', async () => { const topologyTransformedData = await getTransformedTopologyData(mockResources); getFilterById(EXPAND_OPERATORS_RELEASE_FILTER, filters).value = true; getFilterById(EXPAND_GROUPS_FILTER_ID, filters).value = false; const newModel = updateModelFromFilters( topologyTransformedData, filters, ALL_APPLICATIONS_KEY, filterers, ); expect(newModel.nodes.filter((n) => n.group).length).toBe(3); expect( newModel.nodes.filter((n) => n.type === TYPE_OPERATOR_BACKED_SERVICE && n.collapsed).length, ).toBe(1); }); it('should flag not show operator groups when show groups is false', async () => { const topologyTransformedData = await getTransformedTopologyData(mockResources); getFilterById(SHOW_GROUPS_FILTER_ID, filters).value = false; const newModel = updateModelFromFilters( topologyTransformedData, filters, ALL_APPLICATIONS_KEY, filterers, ); expect(newModel.nodes.filter((n) => n.type === TYPE_OPERATOR_BACKED_SERVICE).length).toBe(0); }); it('should show the operator group and its children when filtered by the group', async () => { const graphData = await getTransformedTopologyData(mockResources); filters.push({ type: TopologyDisplayFilterType.kind, id: 'jaegertracing.io~v1~Jaeger', label: 'Jaeger', priority: 1, value: true, }); const newModel = updateModelFromFilters(graphData, filters, ALL_APPLICATIONS_KEY, filterers); expect(newModel.nodes.filter((n) => n.type === TYPE_OPERATOR_BACKED_SERVICE)).toHaveLength(1); expect(newModel.nodes.filter((n) => n.type === TYPE_WORKLOAD)).toHaveLength(1); }); it('should support single binding service selectors', async () => { const deployments = sbrBackingServiceSelector.deployments.data; const obsGroups = getOperatorGroupResources(mockResources); const sbrs = sbrBackingServiceSelector.serviceBindingRequests.data; const installedOperators = mockResources?.clusterServiceVersions?.data; expect(getServiceBindingEdges(deployments[0], obsGroups, sbrs, installedOperators)).toEqual([ { id: `uid-app_3006a8f3-6e2b-4a19-b37e-fbddd9a41f51`, type: TYPE_SERVICE_BINDING, source: 'uid-app', target: '3006a8f3-6e2b-4a19-b37e-fbddd9a41f51', data: { sbr: sbrs[0] }, resource: sbrs[0], }, ]); }); it('should support multiple binding service selectors', async () => { const deployments = sbrBackingServiceSelectors.deployments.data; const obsGroups = getOperatorGroupResources(mockResources); const sbrs = sbrBackingServiceSelectors.serviceBindingRequests.data; const installedOperators = mockResources?.clusterServiceVersions?.data; expect(getServiceBindingEdges(deployments[0], obsGroups, sbrs, installedOperators)).toEqual([ { id: `uid-app_3006a8f3-6e2b-4a19-b37e-fbddd9a41f51`, type: TYPE_SERVICE_BINDING, source: 'uid-app', target: '3006a8f3-6e2b-4a19-b37e-fbddd9a41f51', data: { sbr: sbrs[0] }, resource: sbrs[0], }, { id: `uid-app_3006a8f3-6e2b-4a19-b37e-fbddd9a41f51`, type: TYPE_SERVICE_BINDING, source: 'uid-app', target: '3006a8f3-6e2b-4a19-b37e-fbddd9a41f51', data: { sbr: sbrs[0] }, resource: sbrs[0], }, ]); }); }
Jayashree-panda/console
frontend/packages/topology/src/operators/__tests__/operator-data-transformer.spec.ts
TypeScript
ArrowFunction
() => { mockResources = _.cloneDeep(MockResources); filters = _.cloneDeep(DEFAULT_TOPOLOGY_FILTERS); filters.push(...getTopologyFilters()); }
Jayashree-panda/console
frontend/packages/topology/src/operators/__tests__/operator-data-transformer.spec.ts
TypeScript
ArrowFunction
async () => { const graphData = await getTransformedTopologyData(mockResources); const operatorBackedServices = _.filter(graphData.nodes, { type: TYPE_OPERATOR_BACKED_SERVICE, }); expect(operatorBackedServices).toHaveLength(1); expect(getNodeById(operatorBackedServices[0].id, graphData).type).toBe( TYPE_OPERATOR_BACKED_SERVICE, ); expect(graphData.nodes.filter((n) => !n.group)).toHaveLength(10); expect(graphData.nodes.filter((n) => n.group)).toHaveLength(3); expect(graphData.edges).toHaveLength(1); }
Jayashree-panda/console
frontend/packages/topology/src/operators/__tests__/operator-data-transformer.spec.ts
TypeScript
ArrowFunction
(n) => !n.group
Jayashree-panda/console
frontend/packages/topology/src/operators/__tests__/operator-data-transformer.spec.ts
TypeScript
ArrowFunction
(n) => n.group
Jayashree-panda/console
frontend/packages/topology/src/operators/__tests__/operator-data-transformer.spec.ts
TypeScript
ArrowFunction
async () => { const icon = _.get(mockResources.clusterServiceVersions.data[0], 'spec.icon.0'); const csvIcon = getImageForCSVIcon(icon); const graphData = await getTransformedTopologyData(mockResources); const node = getNodeByName('jaeger-all-in-one-inmemory', graphData); expect((node.data.data as WorkloadData).builderImage).toBe(csvIcon); }
Jayashree-panda/console
frontend/packages/topology/src/operators/__tests__/operator-data-transformer.spec.ts
TypeScript
ArrowFunction
async () => { const topologyTransformedData = await getTransformedTopologyData(mockResources); getFilterById(EXPAND_OPERATORS_RELEASE_FILTER, filters).value = false; const newModel = updateModelFromFilters( topologyTransformedData, filters, ALL_APPLICATIONS_KEY, filterers, ); expect(newModel.nodes.filter((n) => n.group).length).toBe(3); expect(newModel.nodes.filter((n) => n.group && n.collapsed).length).toBe(1); }
Jayashree-panda/console
frontend/packages/topology/src/operators/__tests__/operator-data-transformer.spec.ts
TypeScript
ArrowFunction
(n) => n.group && n.collapsed
Jayashree-panda/console
frontend/packages/topology/src/operators/__tests__/operator-data-transformer.spec.ts
TypeScript
ArrowFunction
async () => { const topologyTransformedData = await getTransformedTopologyData(mockResources); getFilterById(EXPAND_OPERATORS_RELEASE_FILTER, filters).value = true; getFilterById(EXPAND_GROUPS_FILTER_ID, filters).value = false; const newModel = updateModelFromFilters( topologyTransformedData, filters, ALL_APPLICATIONS_KEY, filterers, ); expect(newModel.nodes.filter((n) => n.group).length).toBe(3); expect( newModel.nodes.filter((n) => n.type === TYPE_OPERATOR_BACKED_SERVICE && n.collapsed).length, ).toBe(1); }
Jayashree-panda/console
frontend/packages/topology/src/operators/__tests__/operator-data-transformer.spec.ts
TypeScript
ArrowFunction
(n) => n.type === TYPE_OPERATOR_BACKED_SERVICE && n.collapsed
Jayashree-panda/console
frontend/packages/topology/src/operators/__tests__/operator-data-transformer.spec.ts
TypeScript
ArrowFunction
async () => { const topologyTransformedData = await getTransformedTopologyData(mockResources); getFilterById(SHOW_GROUPS_FILTER_ID, filters).value = false; const newModel = updateModelFromFilters( topologyTransformedData, filters, ALL_APPLICATIONS_KEY, filterers, ); expect(newModel.nodes.filter((n) => n.type === TYPE_OPERATOR_BACKED_SERVICE).length).toBe(0); }
Jayashree-panda/console
frontend/packages/topology/src/operators/__tests__/operator-data-transformer.spec.ts
TypeScript
ArrowFunction
(n) => n.type === TYPE_OPERATOR_BACKED_SERVICE
Jayashree-panda/console
frontend/packages/topology/src/operators/__tests__/operator-data-transformer.spec.ts
TypeScript
ArrowFunction
async () => { const graphData = await getTransformedTopologyData(mockResources); filters.push({ type: TopologyDisplayFilterType.kind, id: 'jaegertracing.io~v1~Jaeger', label: 'Jaeger', priority: 1, value: true, }); const newModel = updateModelFromFilters(graphData, filters, ALL_APPLICATIONS_KEY, filterers); expect(newModel.nodes.filter((n) => n.type === TYPE_OPERATOR_BACKED_SERVICE)).toHaveLength(1); expect(newModel.nodes.filter((n) => n.type === TYPE_WORKLOAD)).toHaveLength(1); }
Jayashree-panda/console
frontend/packages/topology/src/operators/__tests__/operator-data-transformer.spec.ts
TypeScript
ArrowFunction
(n) => n.type === TYPE_WORKLOAD
Jayashree-panda/console
frontend/packages/topology/src/operators/__tests__/operator-data-transformer.spec.ts
TypeScript
ArrowFunction
async () => { const deployments = sbrBackingServiceSelector.deployments.data; const obsGroups = getOperatorGroupResources(mockResources); const sbrs = sbrBackingServiceSelector.serviceBindingRequests.data; const installedOperators = mockResources?.clusterServiceVersions?.data; expect(getServiceBindingEdges(deployments[0], obsGroups, sbrs, installedOperators)).toEqual([ { id: `uid-app_3006a8f3-6e2b-4a19-b37e-fbddd9a41f51`, type: TYPE_SERVICE_BINDING, source: 'uid-app', target: '3006a8f3-6e2b-4a19-b37e-fbddd9a41f51', data: { sbr: sbrs[0] }, resource: sbrs[0], }, ]); }
Jayashree-panda/console
frontend/packages/topology/src/operators/__tests__/operator-data-transformer.spec.ts
TypeScript
ArrowFunction
async () => { const deployments = sbrBackingServiceSelectors.deployments.data; const obsGroups = getOperatorGroupResources(mockResources); const sbrs = sbrBackingServiceSelectors.serviceBindingRequests.data; const installedOperators = mockResources?.clusterServiceVersions?.data; expect(getServiceBindingEdges(deployments[0], obsGroups, sbrs, installedOperators)).toEqual([ { id: `uid-app_3006a8f3-6e2b-4a19-b37e-fbddd9a41f51`, type: TYPE_SERVICE_BINDING, source: 'uid-app', target: '3006a8f3-6e2b-4a19-b37e-fbddd9a41f51', data: { sbr: sbrs[0] }, resource: sbrs[0], }, { id: `uid-app_3006a8f3-6e2b-4a19-b37e-fbddd9a41f51`, type: TYPE_SERVICE_BINDING, source: 'uid-app', target: '3006a8f3-6e2b-4a19-b37e-fbddd9a41f51', data: { sbr: sbrs[0] }, resource: sbrs[0], }, ]); }
Jayashree-panda/console
frontend/packages/topology/src/operators/__tests__/operator-data-transformer.spec.ts
TypeScript
ArrowFunction
() => { finallyCallback(); }
priyanka091088/EmployeeManagement-BoilerPlate
angular/src/shared/auth/app-auth.service.ts
TypeScript
ArrowFunction
(result: AuthenticateResultModel) => { this.processAuthenticateResult(result); }
priyanka091088/EmployeeManagement-BoilerPlate
angular/src/shared/auth/app-auth.service.ts
TypeScript
ClassDeclaration
@Injectable() export class AppAuthService { authenticateModel: AuthenticateModel; authenticateResult: AuthenticateResultModel; rememberMe: boolean; constructor( private _tokenAuthService: TokenAuthServiceProxy, private _router: Router, private _utilsService: UtilsService, private _tokenService: TokenService, private _logService: LogService ) { this.clear(); } logout(reload?: boolean): void { abp.auth.clearToken(); abp.utils.setCookieValue( AppConsts.authorization.encryptedAuthTokenName, undefined, undefined, abp.appPath ); if (reload !== false) { location.href = AppConsts.appBaseUrl; } } authenticate(finallyCallback?: () => void): void { finallyCallback = finallyCallback || (() => { }); this._tokenAuthService .authenticate(this.authenticateModel) .pipe( finalize(() => { finallyCallback(); }) ) .subscribe((result: AuthenticateResultModel) => { this.processAuthenticateResult(result); }); } private processAuthenticateResult( authenticateResult: AuthenticateResultModel ) { this.authenticateResult = authenticateResult; if (authenticateResult.accessToken) { // Successfully logged in this.login( authenticateResult.accessToken, authenticateResult.encryptedAccessToken, authenticateResult.expireInSeconds, this.rememberMe ); } else { // Unexpected result! this._logService.warn('Unexpected authenticateResult!'); this._router.navigate(['account/login']); } } private login( accessToken: string, encryptedAccessToken: string, expireInSeconds: number, rememberMe?: boolean ): void { const tokenExpireDate = rememberMe ? new Date(new Date().getTime() + 1000 * expireInSeconds) : undefined; this._tokenService.setToken(accessToken, tokenExpireDate); this._utilsService.setCookieValue( AppConsts.authorization.encryptedAuthTokenName, encryptedAccessToken, tokenExpireDate, abp.appPath ); let initialUrl = UrlHelper.initialUrl; if (initialUrl.indexOf('/login') > 0) { initialUrl = AppConsts.appBaseUrl; } location.href = initialUrl; } private clear(): void { this.authenticateModel = new AuthenticateModel(); this.authenticateModel.rememberClient = false; this.authenticateResult = null; this.rememberMe = false; } }
priyanka091088/EmployeeManagement-BoilerPlate
angular/src/shared/auth/app-auth.service.ts
TypeScript
MethodDeclaration
logout(reload?: boolean): void { abp.auth.clearToken(); abp.utils.setCookieValue( AppConsts.authorization.encryptedAuthTokenName, undefined, undefined, abp.appPath ); if (reload !== false) { location.href = AppConsts.appBaseUrl; } }
priyanka091088/EmployeeManagement-BoilerPlate
angular/src/shared/auth/app-auth.service.ts
TypeScript
MethodDeclaration
authenticate(finallyCallback?: () => void): void { finallyCallback = finallyCallback || (() => { }); this._tokenAuthService .authenticate(this.authenticateModel) .pipe( finalize(() => { finallyCallback(); }) ) .subscribe((result: AuthenticateResultModel) => { this.processAuthenticateResult(result); }); }
priyanka091088/EmployeeManagement-BoilerPlate
angular/src/shared/auth/app-auth.service.ts
TypeScript
MethodDeclaration
private processAuthenticateResult( authenticateResult: AuthenticateResultModel ) { this.authenticateResult = authenticateResult; if (authenticateResult.accessToken) { // Successfully logged in this.login( authenticateResult.accessToken, authenticateResult.encryptedAccessToken, authenticateResult.expireInSeconds, this.rememberMe ); } else { // Unexpected result! this._logService.warn('Unexpected authenticateResult!'); this._router.navigate(['account/login']); } }
priyanka091088/EmployeeManagement-BoilerPlate
angular/src/shared/auth/app-auth.service.ts
TypeScript
MethodDeclaration
private login( accessToken: string, encryptedAccessToken: string, expireInSeconds: number, rememberMe?: boolean ): void { const tokenExpireDate = rememberMe ? new Date(new Date().getTime() + 1000 * expireInSeconds) : undefined; this._tokenService.setToken(accessToken, tokenExpireDate); this._utilsService.setCookieValue( AppConsts.authorization.encryptedAuthTokenName, encryptedAccessToken, tokenExpireDate, abp.appPath ); let initialUrl = UrlHelper.initialUrl; if (initialUrl.indexOf('/login') > 0) { initialUrl = AppConsts.appBaseUrl; } location.href = initialUrl; }
priyanka091088/EmployeeManagement-BoilerPlate
angular/src/shared/auth/app-auth.service.ts
TypeScript
MethodDeclaration
private clear(): void { this.authenticateModel = new AuthenticateModel(); this.authenticateModel.rememberClient = false; this.authenticateResult = null; this.rememberMe = false; }
priyanka091088/EmployeeManagement-BoilerPlate
angular/src/shared/auth/app-auth.service.ts
TypeScript
ClassDeclaration
@Pipe({ name: "newLineToBr", }) export default class NewLineToBrPipe implements PipeTransform { public transform(text: string): string { return text.replace(/\n/g, "<br/>"); } }
burkovsky/AnthonyCakes2
src/app/products/shared/new-line-to-br.pipe.ts
TypeScript
MethodDeclaration
public transform(text: string): string { return text.replace(/\n/g, "<br/>"); }
burkovsky/AnthonyCakes2
src/app/products/shared/new-line-to-br.pipe.ts
TypeScript
EnumDeclaration
export enum EventDef { None = 0, App_CloseFirstLoadingView = 500, AD_OnShareAdFail = 501, //当界面打开 Game_OnViewOpen = 600,//{view : ViewDef} //当界面关闭 Game_OnViewClose = 601,//{view : ViewDef} //当玩家金币变动 Game_OnUserMoneyChange = 701,//{curr:number,last:number} //当玩家钻石变动 Game_OnUserCrystalChange = 702,//{curr:number,last:number} //当关卡开始 Game_OnLevelStart = 1000, //当关卡结束 Game_OnLevelComplate = 1001, //误点预加载完毕 AD_WudianBanner_LoadComplete = 2217, //显示误点Banner AD_WudianBanner_Show = 2218, //影藏误点Banner AD_WudianBanner_Hide = 2219, //预加载Banner AD_WudianBanner_PreLoad =2220, //Tips:在这条添加定义你自己需要的事件,从10000号开始。记得分段分类管理不同类型事件。如果事件有传递参数 "必须" 在事件后面用注释写明事件参数结构。 }
renyouwangluo/RYFrameWork
src/Event/EventDef.ts
TypeScript
FunctionDeclaration
/** * A class represents the access keys of SignalR service. */ export function listSignalRKeys(args: ListSignalRKeysArgs, opts?: pulumi.InvokeOptions): Promise<ListSignalRKeysResult> { if (!opts) { opts = {} } if (!opts.version) { opts.version = utilities.getVersion(); } return pulumi.runtime.invoke("azure-native:signalrservice/v20181001:listSignalRKeys", { "resourceGroupName": args.resourceGroupName, "resourceName": args.resourceName, }, opts); }
pulumi-bot/pulumi-azure-native
sdk/nodejs/signalrservice/v20181001/listSignalRKeys.ts
TypeScript
InterfaceDeclaration
export interface ListSignalRKeysArgs { /** * The name of the resource group that contains the resource. You can obtain this value from the Azure Resource Manager API or the portal. */ readonly resourceGroupName: string; /** * The name of the SignalR resource. */ readonly resourceName: string; }
pulumi-bot/pulumi-azure-native
sdk/nodejs/signalrservice/v20181001/listSignalRKeys.ts
TypeScript
InterfaceDeclaration
/** * A class represents the access keys of SignalR service. */ export interface ListSignalRKeysResult { /** * SignalR connection string constructed via the primaryKey */ readonly primaryConnectionString?: string; /** * The primary access key. */ readonly primaryKey?: string; /** * SignalR connection string constructed via the secondaryKey */ readonly secondaryConnectionString?: string; /** * The secondary access key. */ readonly secondaryKey?: string; }
pulumi-bot/pulumi-azure-native
sdk/nodejs/signalrservice/v20181001/listSignalRKeys.ts
TypeScript
ArrowFunction
async () => { jest.restoreAllMocks(); }
Plusid/core-infinity
__tests__/unit/core-forger/manager.test.ts
TypeScript
ArrowFunction
() => { jest.restoreAllMocks(); mockTransaction = TransactionFactory.transfer().createOne(); defaults.hosts = [{ hostname: "127.0.0.1", port: 4000 }]; forgeManager = new ForgerManager(defaults); }
Plusid/core-infinity
__tests__/unit/core-forger/manager.test.ts
TypeScript
ArrowFunction
() => { it("should forge a block", async () => { // NOTE: make sure we have valid transactions from an existing wallet const transactions = TransactionFactory.transfer() .withNetwork("testnet") .withPassphrase("clay harbor enemy utility margin pretty hub comic piece aerobic umbrella acquire") .build(); // @ts-ignore forgeManager.client.getTransactions.mockReturnValue({ transactions: transactions.map(tx => tx.serialized.toString("hex")), }); forgeManager.usernames = []; const del = new Delegate("a secret", testnet.network); const round = { lastBlock: { id: sampleBlock.data.id, height: sampleBlock.data.height }, timestamp: Crypto.Slots.getTime(), reward: 2 * 1e5, }; jest.spyOn(Crypto.Slots, "getTimeInMsUntilNextSlot").mockReturnValueOnce(2000); await forgeManager.forgeNewBlock(del, round, { lastBlockId: round.lastBlock.id, nodeHeight: round.lastBlock.height, }); expect(forgeManager.client.broadcastBlock).toHaveBeenCalledWith( expect.objectContaining({ data: expect.objectContaining({ height: round.lastBlock.height + 1, reward: Utils.BigNumber.make(round.reward), }), }), ); expect(forgeManager.client.emitEvent).toHaveBeenCalledWith( ApplicationEvents.BlockForged, expect.any(Object), ); expect(forgeManager.client.emitEvent).toHaveBeenCalledWith( ApplicationEvents.TransactionForged, expect.any(Object), ); }); it("should not forge a block when not enough time left", async () => { // NOTE: make sure we have valid transactions from an existing wallet const transactions = TransactionFactory.transfer() .withNetwork("testnet") .withPassphrase("clay harbor enemy utility margin pretty hub comic piece aerobic umbrella acquire") .build(); // @ts-ignore forgeManager.client.getTransactions.mockReturnValue({ transactions: transactions.map(tx => tx.serialized.toString("hex")), }); forgeManager.usernames = []; const del = new Delegate("a secret", testnet.network); const round = { lastBlock: { id: sampleBlock.data.id, height: sampleBlock.data.height }, timestamp: Crypto.Slots.getTime(), reward: 2 * 1e5, }; jest.spyOn(Crypto.Slots, "getTimeInMsUntilNextSlot").mockReturnValueOnce(2000); await forgeManager.forgeNewBlock(del, round, { lastBlockId: round.lastBlock.id, nodeHeight: round.lastBlock.height, }); expect(forgeManager.client.broadcastBlock).toHaveBeenCalled(); jest.resetAllMocks(); jest.spyOn(Crypto.Slots, "getTimeInMsUntilNextSlot").mockReturnValueOnce(1000); await forgeManager.forgeNewBlock(del, round, { lastBlockId: round.lastBlock.id, nodeHeight: round.lastBlock.height, }); expect(forgeManager.client.broadcastBlock).not.toHaveBeenCalled(); jest.resetAllMocks(); jest.spyOn(Crypto.Slots, "getTimeInMsUntilNextSlot").mockReturnValueOnce(2000); jest.spyOn(Crypto.Slots, "getSlotNumber").mockImplementation(timestamp => { return timestamp === undefined ? 1 : 2; }); await forgeManager.forgeNewBlock(del, round, { lastBlockId: round.lastBlock.id, nodeHeight: round.lastBlock.height, }); expect(forgeManager.client.broadcastBlock).not.toHaveBeenCalled(); }); }
Plusid/core-infinity
__tests__/unit/core-forger/manager.test.ts
TypeScript
ArrowFunction
async () => { // NOTE: make sure we have valid transactions from an existing wallet const transactions = TransactionFactory.transfer() .withNetwork("testnet") .withPassphrase("clay harbor enemy utility margin pretty hub comic piece aerobic umbrella acquire") .build(); // @ts-ignore forgeManager.client.getTransactions.mockReturnValue({ transactions: transactions.map(tx => tx.serialized.toString("hex")), }); forgeManager.usernames = []; const del = new Delegate("a secret", testnet.network); const round = { lastBlock: { id: sampleBlock.data.id, height: sampleBlock.data.height }, timestamp: Crypto.Slots.getTime(), reward: 2 * 1e5, }; jest.spyOn(Crypto.Slots, "getTimeInMsUntilNextSlot").mockReturnValueOnce(2000); await forgeManager.forgeNewBlock(del, round, { lastBlockId: round.lastBlock.id, nodeHeight: round.lastBlock.height, }); expect(forgeManager.client.broadcastBlock).toHaveBeenCalledWith( expect.objectContaining({ data: expect.objectContaining({ height: round.lastBlock.height + 1, reward: Utils.BigNumber.make(round.reward), }), }), ); expect(forgeManager.client.emitEvent).toHaveBeenCalledWith( ApplicationEvents.BlockForged, expect.any(Object), ); expect(forgeManager.client.emitEvent).toHaveBeenCalledWith( ApplicationEvents.TransactionForged, expect.any(Object), ); }
Plusid/core-infinity
__tests__/unit/core-forger/manager.test.ts
TypeScript
ArrowFunction
tx => tx.serialized.toString("hex")
Plusid/core-infinity
__tests__/unit/core-forger/manager.test.ts
TypeScript
ArrowFunction
async () => { // NOTE: make sure we have valid transactions from an existing wallet const transactions = TransactionFactory.transfer() .withNetwork("testnet") .withPassphrase("clay harbor enemy utility margin pretty hub comic piece aerobic umbrella acquire") .build(); // @ts-ignore forgeManager.client.getTransactions.mockReturnValue({ transactions: transactions.map(tx => tx.serialized.toString("hex")), }); forgeManager.usernames = []; const del = new Delegate("a secret", testnet.network); const round = { lastBlock: { id: sampleBlock.data.id, height: sampleBlock.data.height }, timestamp: Crypto.Slots.getTime(), reward: 2 * 1e5, }; jest.spyOn(Crypto.Slots, "getTimeInMsUntilNextSlot").mockReturnValueOnce(2000); await forgeManager.forgeNewBlock(del, round, { lastBlockId: round.lastBlock.id, nodeHeight: round.lastBlock.height, }); expect(forgeManager.client.broadcastBlock).toHaveBeenCalled(); jest.resetAllMocks(); jest.spyOn(Crypto.Slots, "getTimeInMsUntilNextSlot").mockReturnValueOnce(1000); await forgeManager.forgeNewBlock(del, round, { lastBlockId: round.lastBlock.id, nodeHeight: round.lastBlock.height, }); expect(forgeManager.client.broadcastBlock).not.toHaveBeenCalled(); jest.resetAllMocks(); jest.spyOn(Crypto.Slots, "getTimeInMsUntilNextSlot").mockReturnValueOnce(2000); jest.spyOn(Crypto.Slots, "getSlotNumber").mockImplementation(timestamp => { return timestamp === undefined ? 1 : 2; }); await forgeManager.forgeNewBlock(del, round, { lastBlockId: round.lastBlock.id, nodeHeight: round.lastBlock.height, }); expect(forgeManager.client.broadcastBlock).not.toHaveBeenCalled(); }
Plusid/core-infinity
__tests__/unit/core-forger/manager.test.ts
TypeScript
ArrowFunction
timestamp => { return timestamp === undefined ? 1 : 2; }
Plusid/core-infinity
__tests__/unit/core-forger/manager.test.ts
TypeScript
ArrowFunction
() => { it("should emit failed event if error while monitoring", async () => { forgeManager.client.getRound.mockRejectedValue(new Error("oh bollocks")); setTimeout(() => forgeManager.stopForging(), 1000); await forgeManager.checkSlot(); expect(forgeManager.client.emitEvent).toHaveBeenCalledWith(ApplicationEvents.ForgerFailed, { error: "oh bollocks", }); }); }
Plusid/core-infinity
__tests__/unit/core-forger/manager.test.ts
TypeScript
ArrowFunction
async () => { forgeManager.client.getRound.mockRejectedValue(new Error("oh bollocks")); setTimeout(() => forgeManager.stopForging(), 1000); await forgeManager.checkSlot(); expect(forgeManager.client.emitEvent).toHaveBeenCalledWith(ApplicationEvents.ForgerFailed, { error: "oh bollocks", }); }
Plusid/core-infinity
__tests__/unit/core-forger/manager.test.ts
TypeScript
ArrowFunction
() => forgeManager.stopForging()
Plusid/core-infinity
__tests__/unit/core-forger/manager.test.ts
TypeScript
ArrowFunction
() => { it("should emit forger.started event", async () => { const passphrase = "secret"; const manager = new ForgerManager(defaults); (manager as any).client.getRound.mockResolvedValueOnce({ delegates: [] }); (manager as any).secrets = [passphrase]; const publicKey = Identities.PublicKey.fromPassphrase(passphrase); await manager.startForging("", ""); expect((manager as any).client.emitEvent).toHaveBeenCalledWith(ApplicationEvents.ForgerStarted, { activeDelegates: [publicKey], }); }); }
Plusid/core-infinity
__tests__/unit/core-forger/manager.test.ts
TypeScript
ArrowFunction
async () => { const passphrase = "secret"; const manager = new ForgerManager(defaults); (manager as any).client.getRound.mockResolvedValueOnce({ delegates: [] }); (manager as any).secrets = [passphrase]; const publicKey = Identities.PublicKey.fromPassphrase(passphrase); await manager.startForging("", ""); expect((manager as any).client.emitEvent).toHaveBeenCalledWith(ApplicationEvents.ForgerStarted, { activeDelegates: [publicKey], }); }
Plusid/core-infinity
__tests__/unit/core-forger/manager.test.ts
TypeScript
ArrowFunction
() => { it("should return zero transactions if none to forge", async () => { // @ts-ignore forgeManager.client.getTransactions.mockReturnValue({}); const transactions = await forgeManager.getTransactionsForForging(); expect(transactions).toHaveLength(0); expect(forgeManager.client.getTransactions).toHaveBeenCalled(); }); it("should return deserialized transactions", async () => { // @ts-ignore forgeManager.client.getTransactions.mockReturnValue({ transactions: [Transactions.TransactionFactory.fromData(mockTransaction).serialized.toString("hex")], }); const transactions = await forgeManager.getTransactionsForForging(); expect(transactions).toHaveLength(1); expect(forgeManager.client.getTransactions).toHaveBeenCalled(); expect(transactions[0].recipientId).toEqual(mockTransaction.recipientId); expect(transactions[0].senderPublicKey).toEqual(mockTransaction.senderPublicKey); }); }
Plusid/core-infinity
__tests__/unit/core-forger/manager.test.ts
TypeScript
ArrowFunction
async () => { // @ts-ignore forgeManager.client.getTransactions.mockReturnValue({}); const transactions = await forgeManager.getTransactionsForForging(); expect(transactions).toHaveLength(0); expect(forgeManager.client.getTransactions).toHaveBeenCalled(); }
Plusid/core-infinity
__tests__/unit/core-forger/manager.test.ts
TypeScript
ArrowFunction
async () => { // @ts-ignore forgeManager.client.getTransactions.mockReturnValue({ transactions: [Transactions.TransactionFactory.fromData(mockTransaction).serialized.toString("hex")], }); const transactions = await forgeManager.getTransactionsForForging(); expect(transactions).toHaveLength(1); expect(forgeManager.client.getTransactions).toHaveBeenCalled(); expect(transactions[0].recipientId).toEqual(mockTransaction.recipientId); expect(transactions[0].senderPublicKey).toEqual(mockTransaction.senderPublicKey); }
Plusid/core-infinity
__tests__/unit/core-forger/manager.test.ts
TypeScript
ArrowFunction
() => { it("should be TRUE when quorum > 0.66", async () => { const networkState = new NetworkState(NetworkStateStatus.Default); Object.assign(networkState, { getQuorum: () => 0.9, nodeHeight: 100, lastBlockId: "1233443" }); const canForge = await forgeManager.isForgingAllowed(networkState, delegate); expect(canForge).toBeTrue(); }); it("should be FALSE when unknown", async () => { const networkState = new NetworkState(NetworkStateStatus.Unknown); Object.assign(networkState, { getQuorum: () => 1, nodeHeight: 100, lastBlockId: "1233443" }); const canForge = await forgeManager.isForgingAllowed(networkState, delegate); expect(canForge).toBeFalse(); }); it("should be FALSE when quorum < 0.66", async () => { const networkState = new NetworkState(NetworkStateStatus.Default); Object.assign(networkState, { getQuorum: () => 0.65, nodeHeight: 100, lastBlockId: "1233443" }); const canForge = await forgeManager.isForgingAllowed(networkState, delegate); expect(canForge).toBeFalse(); }); it("should be FALSE when minimumNetworkReach is not sufficient", async () => { const networkState = new NetworkState(NetworkStateStatus.BelowMinimumPeers); const canForge = await forgeManager.isForgingAllowed(networkState, delegate); expect(canForge).toBeFalse(); }); it("should be TRUE and detect possible double forging", async () => { forgeManager.usernames = []; const networkState = new NetworkState(NetworkStateStatus.Default); Object.assign(networkState, { getQuorum: () => 1, nodeHeight: 100, lastBlockId: "1233443", quorumDetails: { peersOverHeightBlockHeaders: { "2816806946235018296": { id: "2816806946235018296", height: 2360065, generatorPublicKey: "0310ad026647eed112d1a46145eed58b8c19c67c505a67f1199361a511ce7860c0", }, }, }, }); const canForge = await forgeManager.isForgingAllowed(networkState, delegate); expect(canForge).toBeTrue(); }); }
Plusid/core-infinity
__tests__/unit/core-forger/manager.test.ts
TypeScript
ArrowFunction
async () => { const networkState = new NetworkState(NetworkStateStatus.Default); Object.assign(networkState, { getQuorum: () => 0.9, nodeHeight: 100, lastBlockId: "1233443" }); const canForge = await forgeManager.isForgingAllowed(networkState, delegate); expect(canForge).toBeTrue(); }
Plusid/core-infinity
__tests__/unit/core-forger/manager.test.ts
TypeScript
ArrowFunction
() => 0.9
Plusid/core-infinity
__tests__/unit/core-forger/manager.test.ts
TypeScript
ArrowFunction
async () => { const networkState = new NetworkState(NetworkStateStatus.Unknown); Object.assign(networkState, { getQuorum: () => 1, nodeHeight: 100, lastBlockId: "1233443" }); const canForge = await forgeManager.isForgingAllowed(networkState, delegate); expect(canForge).toBeFalse(); }
Plusid/core-infinity
__tests__/unit/core-forger/manager.test.ts
TypeScript
ArrowFunction
async () => { const networkState = new NetworkState(NetworkStateStatus.Default); Object.assign(networkState, { getQuorum: () => 0.65, nodeHeight: 100, lastBlockId: "1233443" }); const canForge = await forgeManager.isForgingAllowed(networkState, delegate); expect(canForge).toBeFalse(); }
Plusid/core-infinity
__tests__/unit/core-forger/manager.test.ts
TypeScript
ArrowFunction
() => 0.65
Plusid/core-infinity
__tests__/unit/core-forger/manager.test.ts
TypeScript
ArrowFunction
async () => { const networkState = new NetworkState(NetworkStateStatus.BelowMinimumPeers); const canForge = await forgeManager.isForgingAllowed(networkState, delegate); expect(canForge).toBeFalse(); }
Plusid/core-infinity
__tests__/unit/core-forger/manager.test.ts
TypeScript
ArrowFunction
async () => { forgeManager.usernames = []; const networkState = new NetworkState(NetworkStateStatus.Default); Object.assign(networkState, { getQuorum: () => 1, nodeHeight: 100, lastBlockId: "1233443", quorumDetails: { peersOverHeightBlockHeaders: { "2816806946235018296": { id: "2816806946235018296", height: 2360065, generatorPublicKey: "0310ad026647eed112d1a46145eed58b8c19c67c505a67f1199361a511ce7860c0", }, }, }, }); const canForge = await forgeManager.isForgingAllowed(networkState, delegate); expect(canForge).toBeTrue(); }
Plusid/core-infinity
__tests__/unit/core-forger/manager.test.ts
TypeScript