type
stringclasses
7 values
content
stringlengths
4
9.55k
repo
stringlengths
7
96
path
stringlengths
4
178
language
stringclasses
1 value
ClassDeclaration
export class TelegramError extends Error { constructor(readonly response: ErrorPayload, readonly on = {}) { super(`${response.error_code}: ${response.description}`) } get code() { return this.response.error_code } get description() { return this.response.description } get parameters() { return this.response.parameters } }
AlbertEinsteinTG/telegraf
src/core/network/error.ts
TypeScript
InterfaceDeclaration
interface ErrorPayload { error_code: number description: string parameters?: ResponseParameters }
AlbertEinsteinTG/telegraf
src/core/network/error.ts
TypeScript
ArrowFunction
col => col.getId()
Hyeong-jin/ag-grid
packages/ag-grid-community/src/ts/columnController/columnFactory.ts
TypeScript
ArrowFunction
(child: OriginalColumnGroupChild)=> { if (child instanceof OriginalColumnGroup) { (<OriginalColumnGroup>child).setupExpandable(); } }
Hyeong-jin/ag-grid
packages/ag-grid-community/src/ts/columnController/columnFactory.ts
TypeScript
ArrowFunction
col => { let fakeTreeItem = this.createAutoGroupTreeItem(gridBalancedTree, col); autoColBalancedTree.push(fakeTreeItem); }
Hyeong-jin/ag-grid
packages/ag-grid-community/src/ts/columnController/columnFactory.ts
TypeScript
ArrowFunction
(child: OriginalColumnGroupChild)=> { if (child instanceof OriginalColumnGroup) { let originalGroup = <OriginalColumnGroup> child; let newChildren = this.balanceColumnTree(originalGroup.getChildren(), currentDept + 1, columnDept, columnKeyCreator); originalGroup.setChildren(newChildren); result.push(originalGroup); } else { let newChild = child; for (let i = columnDept-1; i>=currentDept; i--) { let newColId = columnKeyCreator.getUniqueKey(null, null); let colGroupDefMerged = this.createMergedColGroupDef(null); let paddedGroup = new OriginalColumnGroup(colGroupDefMerged, newColId, true, currentDept); this.context.wireBean(paddedGroup); paddedGroup.setChildren([newChild]); newChild = paddedGroup; } result.push(newChild); } }
Hyeong-jin/ag-grid
packages/ag-grid-community/src/ts/columnController/columnFactory.ts
TypeScript
ArrowFunction
(def: ColDef|ColGroupDef)=> { let newGroupOrColumn: OriginalColumnGroupChild; if (this.isColumnGroup(def)) { newGroupOrColumn = this.createColumnGroup(primaryColumns, <ColGroupDef> def, level, existingColsCopy, columnKeyCreator); } else { newGroupOrColumn = this.createColumn(primaryColumns, <ColDef> def, existingColsCopy, columnKeyCreator); } result.push(newGroupOrColumn); }
Hyeong-jin/ag-grid
packages/ag-grid-community/src/ts/columnController/columnFactory.ts
TypeScript
ArrowFunction
col => { let oldColDef = col.getUserProvidedColDef(); if (!oldColDef) { return false; } // first check object references if (oldColDef===colDef) { return true; } // second check id's let oldColHadId = oldColDef.colId !== null && oldColDef.colId !== undefined; if (oldColHadId) { return oldColDef.colId === colDef.colId; } else { return false; } }
Hyeong-jin/ag-grid
packages/ag-grid-community/src/ts/columnController/columnFactory.ts
TypeScript
ArrowFunction
a => typeof a !== 'string'
Hyeong-jin/ag-grid
packages/ag-grid-community/src/ts/columnController/columnFactory.ts
TypeScript
ArrowFunction
(t) => { let typeColDef = allColumnTypes[t.trim()]; if (typeColDef) { _.assign(colDefMerged, typeColDef); } else { console.warn("ag-grid: colDef.type '" + t + "' does not correspond to defined gridOptions.columnTypes"); } }
Hyeong-jin/ag-grid
packages/ag-grid-community/src/ts/columnController/columnFactory.ts
TypeScript
MethodDeclaration
private setBeans(@Qualifier('loggerFactory') loggerFactory: LoggerFactory) { this.logger = loggerFactory.create('ColumnFactory'); }
Hyeong-jin/ag-grid
packages/ag-grid-community/src/ts/columnController/columnFactory.ts
TypeScript
MethodDeclaration
public createColumnTree(defs: (ColDef|ColGroupDef)[], primaryColumns: boolean, existingColumns?: Column[]) : {columnTree: OriginalColumnGroupChild[], treeDept: number} { // column key creator dishes out unique column id's in a deterministic way, // so if we have two grids (that could be master/slave) with same column definitions, // then this ensures the two grids use identical id's. let columnKeyCreator = new ColumnKeyCreator(); if (existingColumns) { let existingKeys: string[] = existingColumns.map( col => col.getId() ); columnKeyCreator.addExistingKeys(existingKeys); } // we take a copy of the columns as we are going to be removing from them let existingColsCopy = existingColumns ? existingColumns.slice() : null; // create am unbalanced tree that maps the provided definitions let unbalancedTree = this.recursivelyCreateColumns(defs, 0, primaryColumns, existingColsCopy, columnKeyCreator); let treeDept = this.findMaxDept(unbalancedTree, 0); this.logger.log('Number of levels for grouped columns is ' + treeDept); let res = this.balanceColumnTree(unbalancedTree, 0, treeDept, columnKeyCreator); this.columnUtils.depthFirstOriginalTreeSearch(res, (child: OriginalColumnGroupChild)=> { if (child instanceof OriginalColumnGroup) { (<OriginalColumnGroup>child).setupExpandable(); } }); return { columnTree: res, treeDept: treeDept }; }
Hyeong-jin/ag-grid
packages/ag-grid-community/src/ts/columnController/columnFactory.ts
TypeScript
MethodDeclaration
public createForAutoGroups(autoGroupCols: Column[], gridBalancedTree: OriginalColumnGroupChild[]): OriginalColumnGroupChild[] { let autoColBalancedTree: OriginalColumnGroupChild[] = []; autoGroupCols.forEach( col => { let fakeTreeItem = this.createAutoGroupTreeItem(gridBalancedTree, col); autoColBalancedTree.push(fakeTreeItem); }); return autoColBalancedTree; }
Hyeong-jin/ag-grid
packages/ag-grid-community/src/ts/columnController/columnFactory.ts
TypeScript
MethodDeclaration
private createAutoGroupTreeItem(balancedColumnTree: OriginalColumnGroupChild[], column: Column): OriginalColumnGroupChild { let dept = this.findDept(balancedColumnTree); // at the end, this will be the top of the tree item. let nextChild: OriginalColumnGroupChild = column; for (let i = dept - 1; i>=0; i--) { let autoGroup = new OriginalColumnGroup( null, `FAKE_PATH_${column.getId()}}_${i}`, true, i); this.context.wireBean(autoGroup); autoGroup.setChildren([nextChild]); nextChild = autoGroup; } // at this point, the nextChild is the top most item in the tree return nextChild; }
Hyeong-jin/ag-grid
packages/ag-grid-community/src/ts/columnController/columnFactory.ts
TypeScript
MethodDeclaration
private findDept(balancedColumnTree: OriginalColumnGroupChild[]): number { let dept = 0; let pointer = balancedColumnTree; while (pointer && pointer[0] && pointer[0] instanceof OriginalColumnGroup) { dept++; pointer = (<OriginalColumnGroup>pointer[0]).getChildren(); } return dept; }
Hyeong-jin/ag-grid
packages/ag-grid-community/src/ts/columnController/columnFactory.ts
TypeScript
MethodDeclaration
private balanceColumnTree(unbalancedTree: OriginalColumnGroupChild[], currentDept: number, columnDept: number, columnKeyCreator: ColumnKeyCreator): OriginalColumnGroupChild[] { let result: OriginalColumnGroupChild[] = []; // go through each child, for groups, recurse a level deeper, // for columns we need to pad unbalancedTree.forEach( (child: OriginalColumnGroupChild)=> { if (child instanceof OriginalColumnGroup) { let originalGroup = <OriginalColumnGroup> child; let newChildren = this.balanceColumnTree(originalGroup.getChildren(), currentDept + 1, columnDept, columnKeyCreator); originalGroup.setChildren(newChildren); result.push(originalGroup); } else { let newChild = child; for (let i = columnDept-1; i>=currentDept; i--) { let newColId = columnKeyCreator.getUniqueKey(null, null); let colGroupDefMerged = this.createMergedColGroupDef(null); let paddedGroup = new OriginalColumnGroup(colGroupDefMerged, newColId, true, currentDept); this.context.wireBean(paddedGroup); paddedGroup.setChildren([newChild]); newChild = paddedGroup; } result.push(newChild); } }); return result; }
Hyeong-jin/ag-grid
packages/ag-grid-community/src/ts/columnController/columnFactory.ts
TypeScript
MethodDeclaration
private findMaxDept(treeChildren: OriginalColumnGroupChild[], dept: number): number { let maxDeptThisLevel = dept; for (let i = 0; i<treeChildren.length; i++) { let abstractColumn = treeChildren[i]; if (abstractColumn instanceof OriginalColumnGroup) { let originalGroup = <OriginalColumnGroup> abstractColumn; let newDept = this.findMaxDept(originalGroup.getChildren(), dept+1); if (maxDeptThisLevel<newDept) { maxDeptThisLevel = newDept; } } } return maxDeptThisLevel; }
Hyeong-jin/ag-grid
packages/ag-grid-community/src/ts/columnController/columnFactory.ts
TypeScript
MethodDeclaration
private recursivelyCreateColumns(defs: (ColDef|ColGroupDef)[], level: number, primaryColumns: boolean, existingColsCopy: Column[], columnKeyCreator: ColumnKeyCreator): OriginalColumnGroupChild[] { let result: OriginalColumnGroupChild[] = []; if (!defs) { return result; } defs.forEach( (def: ColDef|ColGroupDef)=> { let newGroupOrColumn: OriginalColumnGroupChild; if (this.isColumnGroup(def)) { newGroupOrColumn = this.createColumnGroup(primaryColumns, <ColGroupDef> def, level, existingColsCopy, columnKeyCreator); } else { newGroupOrColumn = this.createColumn(primaryColumns, <ColDef> def, existingColsCopy, columnKeyCreator); } result.push(newGroupOrColumn); }); return result; }
Hyeong-jin/ag-grid
packages/ag-grid-community/src/ts/columnController/columnFactory.ts
TypeScript
MethodDeclaration
private createColumnGroup(primaryColumns: boolean, colGroupDef: ColGroupDef, level: number, existingColumns: Column[], columnKeyCreator: ColumnKeyCreator): OriginalColumnGroup { let colGroupDefMerged = this.createMergedColGroupDef(colGroupDef); let groupId = columnKeyCreator.getUniqueKey(colGroupDefMerged.groupId, null); let originalGroup = new OriginalColumnGroup(colGroupDefMerged, groupId, false, level); this.context.wireBean(originalGroup); let children = this.recursivelyCreateColumns(colGroupDefMerged.children, level + 1, primaryColumns, existingColumns, columnKeyCreator); originalGroup.setChildren(children); return originalGroup; }
Hyeong-jin/ag-grid
packages/ag-grid-community/src/ts/columnController/columnFactory.ts
TypeScript
MethodDeclaration
private createMergedColGroupDef(colGroupDef: ColGroupDef): ColGroupDef { let colGroupDefMerged: ColGroupDef = <ColGroupDef> {}; _.assign(colGroupDefMerged, this.gridOptionsWrapper.getDefaultColGroupDef()); _.assign(colGroupDefMerged, colGroupDef); this.checkForDeprecatedItems(colGroupDefMerged); return colGroupDefMerged; }
Hyeong-jin/ag-grid
packages/ag-grid-community/src/ts/columnController/columnFactory.ts
TypeScript
MethodDeclaration
private createColumn(primaryColumns: boolean, colDef: ColDef, existingColsCopy: Column[], columnKeyCreator: ColumnKeyCreator): Column { let colDefMerged = this.mergeColDefs(colDef); this.checkForDeprecatedItems(colDefMerged); // see if column already exists let column = this.findExistingColumn(colDef, existingColsCopy); // no existing column, need to create one if (!column) { let colId = columnKeyCreator.getUniqueKey(colDefMerged.colId, colDefMerged.field); column = new Column(colDefMerged, colDef, colId, primaryColumns); this.context.wireBean(column); } return column; }
Hyeong-jin/ag-grid
packages/ag-grid-community/src/ts/columnController/columnFactory.ts
TypeScript
MethodDeclaration
private findExistingColumn(colDef: ColDef, existingColsCopy: Column[]): Column { let res: Column = _.find(existingColsCopy, col => { let oldColDef = col.getUserProvidedColDef(); if (!oldColDef) { return false; } // first check object references if (oldColDef===colDef) { return true; } // second check id's let oldColHadId = oldColDef.colId !== null && oldColDef.colId !== undefined; if (oldColHadId) { return oldColDef.colId === colDef.colId; } else { return false; } }); // make sure we remove, so if user provided duplicate id, then we don't have more than // one column instance for colDef's with common id if (res) { _.removeFromArray(existingColsCopy, res); } return res; }
Hyeong-jin/ag-grid
packages/ag-grid-community/src/ts/columnController/columnFactory.ts
TypeScript
MethodDeclaration
public mergeColDefs(colDef: ColDef) { // start with empty merged definition let colDefMerged: ColDef = <ColDef> {}; // merge properties from default column definitions _.assign(colDefMerged, this.gridOptionsWrapper.getDefaultColDef()); // merge properties from column type properties if (colDef.type) { this.assignColumnTypes(colDef, colDefMerged); } // merge properties from column definitions _.assign(colDefMerged, colDef); return colDefMerged; }
Hyeong-jin/ag-grid
packages/ag-grid-community/src/ts/columnController/columnFactory.ts
TypeScript
MethodDeclaration
private assignColumnTypes(colDef: ColDef, colDefMerged: ColDef) { let typeKeys: string[]; if (colDef.type instanceof Array) { let invalidArray = colDef.type.some(a => typeof a !== 'string'); if (invalidArray) { console.warn("ag-grid: if colDef.type is supplied an array it should be of type 'string[]'"); } else { typeKeys = colDef.type; } } else if (typeof colDef.type === 'string') { typeKeys = colDef.type.split(','); } else { console.warn("ag-grid: colDef.type should be of type 'string' | 'string[]'"); return; } // merge user defined with default column types let allColumnTypes = _.assign({}, this.gridOptionsWrapper.getColumnTypes(), DefaultColumnTypes); typeKeys.forEach((t) => { let typeColDef = allColumnTypes[t.trim()]; if (typeColDef) { _.assign(colDefMerged, typeColDef); } else { console.warn("ag-grid: colDef.type '" + t + "' does not correspond to defined gridOptions.columnTypes"); } }); }
Hyeong-jin/ag-grid
packages/ag-grid-community/src/ts/columnController/columnFactory.ts
TypeScript
MethodDeclaration
private checkForDeprecatedItems(colDef: AbstractColDef) { if (colDef) { let colDefNoType = <any> colDef; // take out the type, so we can access attributes not defined in the type if (colDefNoType.group !== undefined) { console.warn('ag-grid: colDef.group is invalid, please check documentation on how to do grouping as it changed in version 3'); } if (colDefNoType.headerGroup !== undefined) { console.warn('ag-grid: colDef.headerGroup is invalid, please check documentation on how to do grouping as it changed in version 3'); } if (colDefNoType.headerGroupShow !== undefined) { console.warn('ag-grid: colDef.headerGroupShow is invalid, should be columnGroupShow, please check documentation on how to do grouping as it changed in version 3'); } if (colDefNoType.suppressRowGroup !== undefined) { console.warn('ag-grid: colDef.suppressRowGroup is deprecated, please use colDef.type instead'); } if (colDefNoType.suppressAggregation !== undefined) { console.warn('ag-grid: colDef.suppressAggregation is deprecated, please use colDef.type instead'); } if (colDefNoType.suppressRowGroup || colDefNoType.suppressAggregation) { console.warn('ag-grid: colDef.suppressAggregation and colDef.suppressRowGroup are deprecated, use allowRowGroup, allowPivot and allowValue instead'); } if (colDefNoType.displayName) { console.warn("ag-grid: Found displayName " + colDefNoType.displayName + ", please use headerName instead, displayName is deprecated."); colDefNoType.headerName = colDefNoType.displayName; } } }
Hyeong-jin/ag-grid
packages/ag-grid-community/src/ts/columnController/columnFactory.ts
TypeScript
MethodDeclaration
// if object has children, we assume it's a group private isColumnGroup(abstractColDef: ColDef|ColGroupDef): boolean { return (<ColGroupDef>abstractColDef).children !== undefined; }
Hyeong-jin/ag-grid
packages/ag-grid-community/src/ts/columnController/columnFactory.ts
TypeScript
ArrowFunction
() => { self.registerKeyboardInputs(); }
faridv/hop
src/modules/games/games.module.ts
TypeScript
ArrowFunction
() => { if (typeof callback === 'function') callback(games); }
faridv/hop
src/modules/games/games.module.ts
TypeScript
ArrowFunction
() => { self.setActive('prev'); }
faridv/hop
src/modules/games/games.module.ts
TypeScript
ArrowFunction
() => { self.setActive('next'); }
faridv/hop
src/modules/games/games.module.ts
TypeScript
ArrowFunction
() => { self.loadGame(); }
faridv/hop
src/modules/games/games.module.ts
TypeScript
ClassDeclaration
export default class GamesModule extends Module { protected events = { 'games.prev': {control: 'up', title: 'بازی قبلی', icon: 'up'}, 'games.next': {control: 'down', title: 'بازی بعدی', icon: 'bottom'}, 'games.enter': {control: 'enter', title: 'انتخاب', icon: 'enter'}, }; constructor(config?, layoutInstance?, moduleType?: string) { super(config, layoutInstance, moduleType); const self = this; this.events = this.prepareControls(); this.render(GamesConfig, () => { self.registerKeyboardInputs(); }); return this; } reInit() { this.layoutInstance.prepareUnloadModule(this); this.registerKeyboardInputs(); this.render(GamesConfig); } render(games, callback?) { this.templateHelper.render(template, {items: games}, this.$el, 'html', () => { if (typeof callback === 'function') callback(games); }); } setActive(which: string): void { const $current = $('.game-items').find('li.active').length ? $('.game-items li.active') : $('.game-items li:first'); let $el; this.templateHelper.removeClass('active', $current); if (which === 'next') { if ($current.next().length) { $el = $current.next(); } else { $el = $current.parents('ul:first').find('li:first'); } } else { if ($current.prev().length) { $el = $current.prev(); } else { $el = $current.parents('ul:first').find('li:last'); } } this.templateHelper.addClass('active', $el); } loadGame() { const $current = $('.game-items li.active'); if ($current.length < 1) { return false; } const game = $current.attr('data-game').toString(); let gameObject: any = null; switch (game) { case '2048': gameObject = Game2048; break; case 'blockrain': gameObject = BlockrainGame; break; case 'tower': gameObject = TowerGame; } new gameObject(this); this.input.removeEvent('back,backspace', {key: 'module.exit'}); } registerKeyboardInputs() { const self = this; this.input.addEvent('up', false, this.events['games.prev'], () => { self.setActive('prev'); }); this.input.addEvent('down', false, this.events['games.next'], () => { self.setActive('next'); }); this.input.addEvent('enter', false, this.events['games.enter'], () => { self.loadGame(); }); } }
faridv/hop
src/modules/games/games.module.ts
TypeScript
MethodDeclaration
reInit() { this.layoutInstance.prepareUnloadModule(this); this.registerKeyboardInputs(); this.render(GamesConfig); }
faridv/hop
src/modules/games/games.module.ts
TypeScript
MethodDeclaration
render(games, callback?) { this.templateHelper.render(template, {items: games}, this.$el, 'html', () => { if (typeof callback === 'function') callback(games); }); }
faridv/hop
src/modules/games/games.module.ts
TypeScript
MethodDeclaration
setActive(which: string): void { const $current = $('.game-items').find('li.active').length ? $('.game-items li.active') : $('.game-items li:first'); let $el; this.templateHelper.removeClass('active', $current); if (which === 'next') { if ($current.next().length) { $el = $current.next(); } else { $el = $current.parents('ul:first').find('li:first'); } } else { if ($current.prev().length) { $el = $current.prev(); } else { $el = $current.parents('ul:first').find('li:last'); } } this.templateHelper.addClass('active', $el); }
faridv/hop
src/modules/games/games.module.ts
TypeScript
MethodDeclaration
loadGame() { const $current = $('.game-items li.active'); if ($current.length < 1) { return false; } const game = $current.attr('data-game').toString(); let gameObject: any = null; switch (game) { case '2048': gameObject = Game2048; break; case 'blockrain': gameObject = BlockrainGame; break; case 'tower': gameObject = TowerGame; } new gameObject(this); this.input.removeEvent('back,backspace', {key: 'module.exit'}); }
faridv/hop
src/modules/games/games.module.ts
TypeScript
MethodDeclaration
registerKeyboardInputs() { const self = this; this.input.addEvent('up', false, this.events['games.prev'], () => { self.setActive('prev'); }); this.input.addEvent('down', false, this.events['games.next'], () => { self.setActive('next'); }); this.input.addEvent('enter', false, this.events['games.enter'], () => { self.loadGame(); }); }
faridv/hop
src/modules/games/games.module.ts
TypeScript
ArrowFunction
() => { const mockedSignupUser = jest.spyOn(api, "signupApi") signupUser({ userEmail: "mockUserEmail", password: "mockpassword" })( jest.fn(), ) expect(mockedSignupUser).toHaveBeenCalledWith({ userEmail: "mockUserEmail", password: "mockpassword", }) }
ishantsolanki/products-listing
src/redux/actions/userActions.test.ts
TypeScript
ArrowFunction
() => { const mockedCheckUser = jest.spyOn(api, "checkUserCredentialsApi") checkUser({ userEmail: "mockUserEmail", password: "mockpassword" })(jest.fn()) expect(mockedCheckUser).toHaveBeenCalledWith({ userEmail: "mockUserEmail", password: "mockpassword", }) }
ishantsolanki/products-listing
src/redux/actions/userActions.test.ts
TypeScript
FunctionDeclaration
function initialize () { window.i18nTemplate.process(window.document, window.loadTimeData) if (window.loadTimeData && window.loadTimeData.data_) { initLocale(window.loadTimeData.data_) } const dialogArgsRaw = chrome.getVariableValue('dialogArguments') let dialogArgs try { dialogArgs = JSON.parse(dialogArgsRaw) chrome.send('brave_rewards_tip.getPublisherBanner', [dialogArgs.publisherKey]) } catch (e) { console.error('Error parsing incoming dialog args', dialogArgsRaw, e) } render( <Provider store={store}> <ThemeProvider theme={Theme}> <App dialogArgs={dialogArgs} /> </ThemeProvider> </Provider>, document.getElementById('root')) }
RSerhii/defiant-core
components/brave_rewards/resources/tip/brave_tip.tsx
TypeScript
FunctionDeclaration
function getActions () { if (actions) { return actions } actions = bindActionCreators(rewardsActions, store.dispatch.bind(store)) return actions }
RSerhii/defiant-core
components/brave_rewards/resources/tip/brave_tip.tsx
TypeScript
FunctionDeclaration
function publisherBanner (data: RewardsTip.Publisher) { getActions().onPublisherBanner(data) }
RSerhii/defiant-core
components/brave_rewards/resources/tip/brave_tip.tsx
TypeScript
FunctionDeclaration
function walletProperties (properties: {status: number, wallet: RewardsTip.WalletProperties}) { getActions().onWalletProperties(properties) }
RSerhii/defiant-core
components/brave_rewards/resources/tip/brave_tip.tsx
TypeScript
FunctionDeclaration
function recurringTips (list: string[]) { getActions().onRecurringTips(list) }
RSerhii/defiant-core
components/brave_rewards/resources/tip/brave_tip.tsx
TypeScript
FunctionDeclaration
function reconcileStamp (stamp: number) { getActions().onReconcileStamp(stamp) }
RSerhii/defiant-core
components/brave_rewards/resources/tip/brave_tip.tsx
TypeScript
FunctionDeclaration
function recurringTipRemoved (success: boolean) { getActions().onRecurringTipRemoved(success) }
RSerhii/defiant-core
components/brave_rewards/resources/tip/brave_tip.tsx
TypeScript
FunctionDeclaration
function recurringTipSaved (success: boolean) { getActions().onRecurringTipSaved(success) }
RSerhii/defiant-core
components/brave_rewards/resources/tip/brave_tip.tsx
TypeScript
FunctionDeclaration
function balance (properties: {status: number, balance: RewardsTip.Balance}) { getActions().onBalance(properties.status, properties.balance) }
RSerhii/defiant-core
components/brave_rewards/resources/tip/brave_tip.tsx
TypeScript
FunctionDeclaration
function externalWallet (wallet: RewardsTip.ExternalWallet) { getActions().onExternalWallet(wallet) }
RSerhii/defiant-core
components/brave_rewards/resources/tip/brave_tip.tsx
TypeScript
ArrowFunction
(a, b) => a.lastTransitionTime.localeCompare(b.lastTransitionTime)
2733284198/kubeapps
dashboard/src/components/BindingList/BindingListEntry.tsx
TypeScript
ArrowFunction
() => { this.setState({ modalIsOpen: true, }); }
2733284198/kubeapps
dashboard/src/components/BindingList/BindingListEntry.tsx
TypeScript
ArrowFunction
async () => { this.setState({ modalIsOpen: false, }); }
2733284198/kubeapps
dashboard/src/components/BindingList/BindingListEntry.tsx
TypeScript
ClassDeclaration
class BindingListEntry extends React.Component<IBindingListEntryProps, IBindingListEntryState> { public state = { modalIsOpen: false, }; public render() { const { bindingWithSecret, bindingWithSecret: { binding }, } = this.props; const { name } = binding.metadata; let reason = <span />; let message = ""; const condition = [...binding.status.conditions] .sort((a, b) => a.lastTransitionTime.localeCompare(b.lastTransitionTime)) .pop(); if (condition) { reason = <code>{condition.reason}</code>; message = condition.message; } return ( <tr> <td>{name}</td> <td>{reason}</td> <td> <button className="button button-small" onClick={this.openModal}> Show message </button> <TerminalModal modalIsOpen={this.state.modalIsOpen} closeModal={this.closeModal} title="Status Message" message={message} /> </td> <td> <BindingDetails {...bindingWithSecret} /> </td> <td> <RemoveBindingButton {...this.props} /> </td> </tr> ); } public openModal = () => { this.setState({ modalIsOpen: true, }); }; public closeModal = async () => { this.setState({ modalIsOpen: false, }); }; }
2733284198/kubeapps
dashboard/src/components/BindingList/BindingListEntry.tsx
TypeScript
InterfaceDeclaration
interface IBindingListEntryProps { bindingWithSecret: IServiceBindingWithSecret; removeBinding: (name: string, namespace: string) => Promise<boolean>; }
2733284198/kubeapps
dashboard/src/components/BindingList/BindingListEntry.tsx
TypeScript
InterfaceDeclaration
interface IBindingListEntryState { modalIsOpen: boolean; }
2733284198/kubeapps
dashboard/src/components/BindingList/BindingListEntry.tsx
TypeScript
MethodDeclaration
public render() { const { bindingWithSecret, bindingWithSecret: { binding }, } = this.props; const { name } = binding.metadata; let reason = <span />; let message = ""; const condition = [...binding.status.conditions] .sort((a, b) => a.lastTransitionTime.localeCompare(b.lastTransitionTime)) .pop(); if (condition) { reason = <code>{condition.reason}</code>; message = condition.message; } return ( <tr> <td>{name}</td> <td>{reason}</td> <td> <button className="button button-small" onClick={this.openModal}> Show message </button> <TerminalModal modalIsOpen={this.state.modalIsOpen} closeModal={this.closeModal} title="Status Message" message={message} /> </td> <td> <BindingDetails {...bindingWithSecret} /> </td> <td> <RemoveBindingButton {...this.props} /> </td> </tr> ); }
2733284198/kubeapps
dashboard/src/components/BindingList/BindingListEntry.tsx
TypeScript
ArrowFunction
(theme: Theme) => createStyles({ root: { position: 'absolute', top: '1rem', right: '1rem', left: '1rem', bottom: '1rem', }, })
Language-Mapping/language-map
src/components/about/FeedbackForm.tsx
TypeScript
ArrowFunction
(props) => { const classes = useStyles() return ( <div className={classes.root}> <iframe src={DOCS_FORM_SRC} width="100%" height="100%" frameBorder="0" marginHeight={0} marginWidth={0} title="Feedback and questions" > Loading… </iframe> </div>
Language-Mapping/language-map
src/components/about/FeedbackForm.tsx
TypeScript
FunctionDeclaration
function innerPatch<T extends StateTree>( target: T, patchToApply: DeepPartial<T> ): T { // TODO: get all keys like symbols as well for (const key in patchToApply) { const subPatch = patchToApply[key] const targetValue = target[key] if (isPlainObject(targetValue) && isPlainObject(subPatch)) { target[key] = innerPatch(targetValue, subPatch) } else { // @ts-ignore target[key] = subPatch } } return target }
JerryYuanJ/pinia
src/store.ts
TypeScript
FunctionDeclaration
/** * Create an object of computed properties referring to * * @param rootStateRef - pinia.state * @param id - unique name */ function computedFromState<T, Id extends string>( rootStateRef: Ref<Record<Id, T>>, id: Id ) { // let asComputed = computed<T>() const reactiveObject = {} as { [k in keyof T]: Ref<T[k]> } const state = rootStateRef.value[id] for (const key in state) { // @ts-ignore: the key matches reactiveObject[key] = computed({ get: () => rootStateRef.value[id][key as keyof T], set: (value) => (rootStateRef.value[id][key as keyof T] = value), }) } return reactiveObject }
JerryYuanJ/pinia
src/store.ts
TypeScript
FunctionDeclaration
/** * Creates a store with its state object. This is meant to be augmented with getters and actions * * @param id - unique identifier of the store, like a name. eg: main, cart, user * @param buildState - function to build the initial state * @param initialState - initial state applied to the store, Must be correctly typed to infer typings */ function initStore<Id extends string, S extends StateTree>( $id: Id, buildState: () => S = () => ({} as S), initialState?: S | undefined ): [StoreWithState<Id, S>, { get: () => S; set: (newValue: S) => void }] { const pinia = getActivePinia() pinia.state.value[$id] = initialState || buildState() // const state: Ref<S> = toRef(_p.state.value, $id) let isListening = true let subscriptions: SubscriptionCallback<S>[] = [] function $patch(stateMutation: (state: S) => void): void function $patch(partialState: DeepPartial<S>): void function $patch( partialStateOrMutator: DeepPartial<S> | ((state: S) => void) ): void { let partialState: DeepPartial<S> = {} let type: string isListening = false if (typeof partialStateOrMutator === 'function') { partialStateOrMutator(pinia.state.value[$id]) type = '🧩 patch' } else { innerPatch(pinia.state.value[$id], partialStateOrMutator) partialState = partialStateOrMutator type = '⤵️ patch' } isListening = true // because we paused the watcher, we need to manually call the subscriptions subscriptions.forEach((callback) => { callback( { storeName: $id, type, payload: partialState }, pinia.state.value[$id] ) }) } function $subscribe(callback: SubscriptionCallback<S>) { subscriptions.push(callback) // watch here to link the subscription to the current active instance // e.g. inside the setup of a component const stopWatcher = watch( () => pinia.state.value[$id], (state) => { if (isListening) { subscriptions.forEach((callback) => { callback( { storeName: $id, type: '🧩 in place', payload: {} }, state ) }) } }, { deep: true, flush: 'sync', } ) return () => { const idx = subscriptions.indexOf(callback) if (idx > -1) { subscriptions.splice(idx, 1) stopWatcher() } } } function $reset() { subscriptions = [] pinia.state.value[$id] = buildState() } const storeWithState: StoreWithState<Id, S> = { $id, _p: pinia, // $state is added underneath $patch, $subscribe, $reset, } as StoreWithState<Id, S> return [ storeWithState, { get: () => pinia.state.value[$id] as S, set: (newState: S) => { isListening = false pinia.state.value[$id] = newState isListening = true }, }, ] }
JerryYuanJ/pinia
src/store.ts
TypeScript
FunctionDeclaration
function $patch(stateMutation: (state: S) => void): void
JerryYuanJ/pinia
src/store.ts
TypeScript
FunctionDeclaration
function $patch(partialState: DeepPartial<S>): void
JerryYuanJ/pinia
src/store.ts
TypeScript
FunctionDeclaration
function $patch( partialStateOrMutator: DeepPartial<S> | ((state: S) => void) ): void { let partialState: DeepPartial<S> = {} let type: string isListening = false if (typeof partialStateOrMutator === 'function') { partialStateOrMutator(pinia.state.value[$id]) type = '🧩 patch' } else { innerPatch(pinia.state.value[$id], partialStateOrMutator) partialState = partialStateOrMutator type = '⤵️ patch' } isListening = true // because we paused the watcher, we need to manually call the subscriptions subscriptions.forEach((callback) => { callback( { storeName: $id, type, payload: partialState }, pinia.state.value[$id] ) }) }
JerryYuanJ/pinia
src/store.ts
TypeScript
FunctionDeclaration
function $subscribe(callback: SubscriptionCallback<S>) { subscriptions.push(callback) // watch here to link the subscription to the current active instance // e.g. inside the setup of a component const stopWatcher = watch( () => pinia.state.value[$id], (state) => { if (isListening) { subscriptions.forEach((callback) => { callback( { storeName: $id, type: '🧩 in place', payload: {} }, state ) }) } }, { deep: true, flush: 'sync', } ) return () => { const idx = subscriptions.indexOf(callback) if (idx > -1) { subscriptions.splice(idx, 1) stopWatcher() } } }
JerryYuanJ/pinia
src/store.ts
TypeScript
FunctionDeclaration
function $reset() { subscriptions = [] pinia.state.value[$id] = buildState() }
JerryYuanJ/pinia
src/store.ts
TypeScript
FunctionDeclaration
/** * Creates a store bound to the lifespan of where the function is called. This * means creating the store inside of a component's setup will bound it to the * lifespan of that component while creating it outside of a component will * create an ever living store * * @param partialStore - store with state returned by initStore * @param descriptor - descriptor to setup $state property * @param $id - unique name of the store * @param getters - getters of the store * @param actions - actions of the store */ function buildStoreToUse< Id extends string, S extends StateTree, G extends Record<string, Method>, A extends Record<string, Method> >( partialStore: StoreWithState<Id, S>, descriptor: StateDescriptor<S>, $id: Id, getters: G = {} as G, actions: A = {} as A ) { const pinia = getActivePinia() const computedGetters: StoreWithGetters<G> = {} as StoreWithGetters<G> for (const getterName in getters) { computedGetters[getterName] = computed(() => { setActivePinia(pinia) // eslint-disable-next-line @typescript-eslint/no-use-before-define return getters[getterName].call(store, store) }) as StoreWithGetters<G>[typeof getterName] } const wrappedActions: StoreWithActions<A> = {} as StoreWithActions<A> for (const actionName in actions) { wrappedActions[actionName] = function () { setActivePinia(pinia) // eslint-disable-next-line return actions[actionName].apply(store, (arguments as unknown) as any[]) } as StoreWithActions<A>[typeof actionName] } const extensions = pinia._p.reduce( (extended, extender) => assign({}, extended, extender()), {} as PiniaCustomProperties ) const store: Store<Id, S, G, A> = reactive( assign( {}, extensions, partialStore, // using this means no new properties can be added as state computedFromState(pinia.state, $id), computedGetters, wrappedActions ) ) as Store<Id, S, G, A> // use this instead of a computed with setter to be able to create it anywhere // without linking the computed lifespan to wherever the store is first // created. Object.defineProperty(store, '$state', descriptor) return store }
JerryYuanJ/pinia
src/store.ts
TypeScript
FunctionDeclaration
/** * Creates a `useStore` function that retrieves the store instance * @param options - options to define the store */ export function defineStore< Id extends string, S extends StateTree, G /* extends Record<string, StoreGetterThis> */, A /* extends Record<string, StoreAction> */ >(options: { id: Id state?: () => S getters?: G & ThisType<S & StoreWithGetters<G> & PiniaCustomProperties> // allow actions use other actions actions?: A & ThisType< A & S & StoreWithState<Id, S> & StoreWithGetters<G> & PiniaCustomProperties > }) { const { id, state, getters, actions } = options return function useStore(pinia?: Pinia | null): Store<Id, S, G, A> { // avoid injecting if `useStore` when not possible pinia = pinia || (getCurrentInstance() && inject(piniaSymbol)) if (pinia) setActivePinia(pinia) // TODO: worth warning on server if no piniaKey as it can leak data pinia = getActivePinia() let stores = storesMap.get(pinia) if (!stores) storesMap.set(pinia, (stores = new Map())) let storeAndDescriptor = stores.get(id) as | [StoreWithState<Id, S>, StateDescriptor<S>] | undefined if (!storeAndDescriptor) { storeAndDescriptor = initStore(id, state, pinia.state.value[id]) stores.set(id, storeAndDescriptor) const store = buildStoreToUse( storeAndDescriptor[0], storeAndDescriptor[1], id, getters as Record<string, Method> | undefined, actions as Record<string, Method> | undefined ) if ( IS_CLIENT && __BROWSER__ && __DEV__ /*|| __FEATURE_PROD_DEVTOOLS__*/ ) { const app = getClientApp() /* istanbul ignore else */ if (app) { addDevtools(app, store) } else if (!isDevWarned && !__TEST__) { isDevWarned = true console.warn( `[🍍]: store was instantiated before calling\n` + `app.use(pinia)\n` + `Make sure to install pinia's plugin by using createPinia:\n` + `https://github.com/posva/pinia/tree/v2#install-the-plugin\n` + `It will enable devtools and overall a better developer experience.` ) } } return store } return buildStoreToUse( storeAndDescriptor[0], storeAndDescriptor[1], id, getters as Record<string, Method> | undefined, actions as Record<string, Method> | undefined ) } }
JerryYuanJ/pinia
src/store.ts
TypeScript
ArrowFunction
() => rootStateRef.value[id][key as keyof T]
JerryYuanJ/pinia
src/store.ts
TypeScript
ArrowFunction
(value) => (rootStateRef.value[id][key as keyof T] = value)
JerryYuanJ/pinia
src/store.ts
TypeScript
ArrowFunction
() => ({} as S)
JerryYuanJ/pinia
src/store.ts
TypeScript
ArrowFunction
(callback) => { callback( { storeName: $id, type, payload: partialState }, pinia.state.value[$id] ) }
JerryYuanJ/pinia
src/store.ts
TypeScript
ArrowFunction
() => pinia.state.value[$id]
JerryYuanJ/pinia
src/store.ts
TypeScript
ArrowFunction
(state) => { if (isListening) { subscriptions.forEach((callback) => { callback( { storeName: $id, type: '🧩 in place', payload: {} }, state ) }) } }
JerryYuanJ/pinia
src/store.ts
TypeScript
ArrowFunction
(callback) => { callback( { storeName: $id, type: '🧩 in place', payload: {} }, state ) }
JerryYuanJ/pinia
src/store.ts
TypeScript
ArrowFunction
() => { const idx = subscriptions.indexOf(callback) if (idx > -1) { subscriptions.splice(idx, 1) stopWatcher() } }
JerryYuanJ/pinia
src/store.ts
TypeScript
ArrowFunction
() => pinia.state.value[$id] as S
JerryYuanJ/pinia
src/store.ts
TypeScript
ArrowFunction
(newState: S) => { isListening = false pinia.state.value[$id] = newState isListening = true }
JerryYuanJ/pinia
src/store.ts
TypeScript
ArrowFunction
() => { setActivePinia(pinia) // eslint-disable-next-line @typescript-eslint/no-use-before-define return getters[getterName].call(store, store) }
JerryYuanJ/pinia
src/store.ts
TypeScript
ArrowFunction
(extended, extender) => assign({}, extended, extender())
JerryYuanJ/pinia
src/store.ts
TypeScript
InterfaceDeclaration
export interface HopeThemeEncryptLocaleData { /** * Encrypt title */ title: string; /** * Passwrod error hint */ errorHint: string; }
yuyueq/hopeword
node_modules/vuepress-theme-hope/lib/shared/options/feature/encrypt.d.ts
TypeScript
InterfaceDeclaration
/** * Encrypt Options * * 加密选项 */ export interface HopeThemeEncryptOptions { /** * Whether encrypt gloablly * * 是否全局加密 * * @default 'local' */ global?: boolean; /** * Admin passwords, which has the highest authority * * 最高权限密码 */ admin?: string | string[]; /** * Encrypt Configuration * * E.g.: * * ```json * { * // This will encrypt the entire guide directory and both passwords will be available * "/guide/": ["1234", "5678"], * // this will only encrypt config/page.html * "/config/page.html": "1234" * } * ``` * * 加密配置 * * ```json * { * // 这会加密整个 guide 目录,并且两个密码都是可用的 * "/guide/": ["1234", "5678"], * // 这只会加密 config/page.html * "/config/page.html": "1234" * } * ``` */ config?: Record<string, string | string[]>; }
yuyueq/hopeword
node_modules/vuepress-theme-hope/lib/shared/options/feature/encrypt.d.ts
TypeScript
ArrowFunction
() => { ++this.timeoutCounter; this.timeoutText.innerHTML = this.timeoutCounter.toString(); }
riccoarntz/seng-disposable-manager
example/src/CustomInstance.ts
TypeScript
ClassDeclaration
export default class CustomInstance { private disposableManager:DisposableManager = new DisposableManager(); private element:HTMLElement; private timeoutCounter:number = 0; private timeoutText:HTMLElement; constructor(element:HTMLElement) { this.element = element; this.timeoutText = <HTMLElement>this.element.querySelector('.js-running-timeout'); } /** * @public * @method startInterval */ public startInterval():void { this.disposableManager.add( setInterval(() => { ++this.timeoutCounter; this.timeoutText.innerHTML = this.timeoutCounter.toString(); }, 500), ); } public destruct() { this.disposableManager.dispose(); } }
riccoarntz/seng-disposable-manager
example/src/CustomInstance.ts
TypeScript
MethodDeclaration
/** * @public * @method startInterval */ public startInterval():void { this.disposableManager.add( setInterval(() => { ++this.timeoutCounter; this.timeoutText.innerHTML = this.timeoutCounter.toString(); }, 500), ); }
riccoarntz/seng-disposable-manager
example/src/CustomInstance.ts
TypeScript
MethodDeclaration
public destruct() { this.disposableManager.dispose(); }
riccoarntz/seng-disposable-manager
example/src/CustomInstance.ts
TypeScript
ClassDeclaration
export class Offset extends XmlComponent { constructor() { super("a:off"); this.root.push( new OffsetAttributes({ x: 0, y: 0, }), ); } }
1shaked/docx
src/file/drawing/inline/graphic/graphic-data/pic/shape-properties/form/offset/off.ts
TypeScript
FunctionDeclaration
function handleChange(event: SyntheticEvent<HTMLInputElement>) { handle.current.validity.valueMissing = required === true && !event.currentTarget.checked && value.filter(v => v !== event.currentTarget.value).length === 0 onChange(event) }
makeswift-hq/makeswift
packages/runtime/src/components/builtin/Form/components/Field/components/MultipleSelectTableField/index.tsx
TypeScript
ArrowFunction
() => handle.current
makeswift-hq/makeswift
packages/runtime/src/components/builtin/Form/components/Field/components/MultipleSelectTableField/index.tsx
TypeScript
ArrowFunction
v => v !== event.currentTarget.value
makeswift-hq/makeswift
packages/runtime/src/components/builtin/Form/components/Field/components/MultipleSelectTableField/index.tsx
TypeScript
ArrowFunction
option => ( <StyledLabel key={option.id}
makeswift-hq/makeswift
packages/runtime/src/components/builtin/Form/components/Field/components/MultipleSelectTableField/index.tsx
TypeScript
TypeAliasDeclaration
type Props = { id: string tableColumn: { options: Array<{ id: string name: string }> } value?: Array<string> label?: string onChange: (arg0: SyntheticEvent<HTMLInputElement>) => unknown required?: boolean hideLabel?: boolean }
makeswift-hq/makeswift
packages/runtime/src/components/builtin/Form/components/Field/components/MultipleSelectTableField/index.tsx
TypeScript
ClassDeclaration
@Injectable({ providedIn: 'root', }) export class TimeAPIService { constructor() {} }
justnat3/Meteo
src/app/Services/Time/time-api.service.ts
TypeScript
ArrowFunction
(resp) => { this.qs.queryResult = resp; this.qs.queryResult.status = "done"; this.showSpinner = false; this.rows = this.qs.queryResult.getData(); let cols = this.qs.queryResult.getColumns(); cols.forEach( (col) => { col.prop = col.name; }); this.columns = cols; //this.qs.queryResult.getColumns(); }
sandyc316/redash
client/app/modules/dashboards/dashboards/component/widget.ts
TypeScript
ArrowFunction
(col) => { col.prop = col.name; }
sandyc316/redash
client/app/modules/dashboards/dashboards/component/widget.ts
TypeScript
ArrowFunction
(err) => { console.log("Unable to get results for the query", err); }
sandyc316/redash
client/app/modules/dashboards/dashboards/component/widget.ts
TypeScript
ClassDeclaration
@Component({ selector: 'dashboard-widget', templateUrl: 'widget.html', }) export class DashboardWidget { @Input() set widget(widget) { if (widget) { this._widget = widget; if (widget.visualization) { Object.assign(this.qs, widget.visualization.query); this.type = widget.visualization.type; this.getQueryResult(); } } } @Output() removeWidget: EventEmitter<any> = new EventEmitter<any>(); queryResult: any; rows: any = []; columns: any = []; type: string = "Chart"; _widget: any; showSpinner: boolean = true; constructor(private qs: QueryService) { } getQueryResult() { this.qs.getQueryResult(10000).subscribe((resp) => { this.qs.queryResult = resp; this.qs.queryResult.status = "done"; this.showSpinner = false; this.rows = this.qs.queryResult.getData(); let cols = this.qs.queryResult.getColumns(); cols.forEach( (col) => { col.prop = col.name; }); this.columns = cols; //this.qs.queryResult.getColumns(); }, (err) => { console.log("Unable to get results for the query", err); }); } deleteWidget(id) { this.removeWidget.emit(id); } }
sandyc316/redash
client/app/modules/dashboards/dashboards/component/widget.ts
TypeScript
MethodDeclaration
getQueryResult() { this.qs.getQueryResult(10000).subscribe((resp) => { this.qs.queryResult = resp; this.qs.queryResult.status = "done"; this.showSpinner = false; this.rows = this.qs.queryResult.getData(); let cols = this.qs.queryResult.getColumns(); cols.forEach( (col) => { col.prop = col.name; }); this.columns = cols; //this.qs.queryResult.getColumns(); }, (err) => { console.log("Unable to get results for the query", err); }); }
sandyc316/redash
client/app/modules/dashboards/dashboards/component/widget.ts
TypeScript
MethodDeclaration
deleteWidget(id) { this.removeWidget.emit(id); }
sandyc316/redash
client/app/modules/dashboards/dashboards/component/widget.ts
TypeScript
ArrowFunction
() => { performTests(config); }
Hejwo/fablo
e2e/fablo-config-hlf1.4-1org-1chaincode-raft.json.test.ts
TypeScript