type
stringclasses
7 values
content
stringlengths
4
9.55k
repo
stringlengths
7
96
path
stringlengths
4
178
language
stringclasses
1 value
ArrowFunction
(_bytesWritten: number, totalBytesWritten: number, totalBytesExpectedToWrite: number) => { const percent = Number((100 * (totalBytesWritten / totalBytesExpectedToWrite)).toFixed(2)); progress({ total: totalBytesExpectedToWrite, loaded: totalBytesWritten, percent }); }
Bernard-Cloutier/imodeljs
core/backend/src/MobileDevice.ts
TypeScript
ArrowFunction
(_downloadUrl: string, _downloadFileUrl: string, cancelled: boolean, err?: string) => { if (cancelled) reject(new UserCancelledError(BriefcaseStatus.DownloadCancelled, "User cancelled download", Logger.logWarning)); else if (err) reject(new DownloadFailed(400, "Download failed")); else resolve(); }
Bernard-Cloutier/imodeljs
core/backend/src/MobileDevice.ts
TypeScript
ArrowFunction
() => { return this._impl.cancelDownloadTask!(requestId); }
Bernard-Cloutier/imodeljs
core/backend/src/MobileDevice.ts
TypeScript
ArrowFunction
(accessToken?: string, err?: string) => { if (accessToken) { // Patch user info const tmp = JSON.parse(accessToken); if (typeof tmp._userInfo === undefined) { tmp._userInfo = {}; } accessToken = JSON.stringify(tmp); } this.onUserStateChanged.raiseEvent(accessToken, err); }
Bernard-Cloutier/imodeljs
core/backend/src/MobileDevice.ts
TypeScript
ArrowFunction
(resolve, reject) => { this._impl.authInit!(ctx, settings, (err?: string) => { if (!err) { this._authInitialized = true; resolve(); } else { this._authInitialized = false; reject(new Error(err)); } }); }
Bernard-Cloutier/imodeljs
core/backend/src/MobileDevice.ts
TypeScript
ArrowFunction
(err?: string) => { if (!err) { this._authInitialized = true; resolve(); } else { this._authInitialized = false; reject(new Error(err)); } }
Bernard-Cloutier/imodeljs
core/backend/src/MobileDevice.ts
TypeScript
ArrowFunction
(resolve, reject) => { this._impl.authSignIn!(ctx, (err?: string) => { if (!err) { resolve(); } else { reject(new Error(err)); } }); }
Bernard-Cloutier/imodeljs
core/backend/src/MobileDevice.ts
TypeScript
ArrowFunction
(err?: string) => { if (!err) { resolve(); } else { reject(new Error(err)); } }
Bernard-Cloutier/imodeljs
core/backend/src/MobileDevice.ts
TypeScript
ArrowFunction
(resolve, reject) => { this._impl.authSignOut!(ctx, (err?: string) => { if (!err) { resolve(); } else { reject(new Error(err)); } }); }
Bernard-Cloutier/imodeljs
core/backend/src/MobileDevice.ts
TypeScript
ArrowFunction
(resolve, reject) => { this._impl.authGetAccessToken!(ctx, (accessToken?: string, err?: string) => { if (!err) { resolve(AccessToken.fromJson(accessToken)); } else { reject(new Error(err)); } }); }
Bernard-Cloutier/imodeljs
core/backend/src/MobileDevice.ts
TypeScript
ArrowFunction
(accessToken?: string, err?: string) => { if (!err) { resolve(AccessToken.fromJson(accessToken)); } else { reject(new Error(err)); } }
Bernard-Cloutier/imodeljs
core/backend/src/MobileDevice.ts
TypeScript
ClassDeclaration
class MobileDeviceRpcImpl { public emit(eventName: DeviceEvents, ...args: any[]) { MobileDevice.currentDevice.emit(eventName, ...args); } public getOrientation?: () => Orientation; public getBatteryState?: () => BatteryState; public getBatteryLevel?: () => number; public createDownloadTask?: (downloadUrl: string, isBackground: boolean, downloadTo: string, completion: MobileCompletionCallback, progress?: MobileProgressCallback) => number; public cancelDownloadTask?: (cancelId: number) => boolean; public getDownloadTasks?: () => DownloadTask[]; public resumeDownloadInForeground?: (requestId: number) => boolean; public resumeDownloadInBackground?: (requestId: number) => boolean; public reconnect?: (connection: number) => void; public authSignIn?: (ctx: ClientRequestContext, callback: (err?: string) => void) => void; public authSignOut?: (ctx: ClientRequestContext, callback: (err?: string) => void) => void; public authGetAccessToken?: (ctx: ClientRequestContext, callback: (accessToken?: string, err?: string) => void) => void; public authInit?: (ctx: ClientRequestContext, settings: MobileDeviceAuthSettings, callback: (err?: string) => void) => void; public authStateChanged?: (accessToken?: string, err?: string) => void; }
Bernard-Cloutier/imodeljs
core/backend/src/MobileDevice.ts
TypeScript
ClassDeclaration
export class MobileDevice { private get _impl(): MobileDeviceRpcImpl { const client = (global as any).MobileDeviceRpcImpl as MobileDeviceRpcImpl; if (!client) { throw new Error("MobileDeviceRpcImpl is not registered."); } return client; } private _authInitialized: boolean = false; public readonly onMemoryWarning = new BeEvent(); public readonly onOrientationChanged = new BeEvent(); public readonly onEnterForeground = new BeEvent(); public readonly onEnterBackground = new BeEvent(); public readonly onWillTerminate = new BeEvent(); public readonly onUserStateChanged = new BeEvent<(accessToken?: string, err?: string) => void>(); /** * Download file * @internal */ public async downloadFile(downloadUrl: string, downloadTo: string, progress?: ProgressCallback, cancelRequest?: CancelRequest): Promise<void> { return new Promise<void>((resolve, reject) => { if (!this._impl.createDownloadTask) { throw new Error("Native backend did not registered downloadFile() functions"); } let progressCb: MobileProgressCallback | undefined; if (progress) { progressCb = (_bytesWritten: number, totalBytesWritten: number, totalBytesExpectedToWrite: number) => { const percent = Number((100 * (totalBytesWritten / totalBytesExpectedToWrite)).toFixed(2)); progress({ total: totalBytesExpectedToWrite, loaded: totalBytesWritten, percent }); }; } const requestId = this._impl.createDownloadTask(downloadUrl, false, downloadTo, (_downloadUrl: string, _downloadFileUrl: string, cancelled: boolean, err?: string) => { if (cancelled) reject(new UserCancelledError(BriefcaseStatus.DownloadCancelled, "User cancelled download", Logger.logWarning)); else if (err) reject(new DownloadFailed(400, "Download failed")); else resolve(); }, progressCb); if (cancelRequest) { // eslint-disable-next-line @typescript-eslint/unbound-method cancelRequest.cancel = () => { return this._impl.cancelDownloadTask!(requestId); } } }); } /** * Reconnect app * @internal */ public reconnect(connection: number) { if (!this._impl.reconnect) { throw new Error("Native backend did not registered reconnect() functions"); } this._impl.reconnect(connection); } public emit(eventName: DeviceEvents, ...args: any[]) { switch (eventName) { case DeviceEvents.MemoryWarning: this.onMemoryWarning.raiseEvent(...args); break; case DeviceEvents.OrientationChanged: this.onOrientationChanged.raiseEvent(...args); break; case DeviceEvents.EnterForeground: this.onEnterForeground.raiseEvent(...args); break; case DeviceEvents.EnterBackground: this.onEnterBackground.raiseEvent(...args); break; case DeviceEvents.WillTerminate: this.onWillTerminate.raiseEvent(...args); break; } } public get hasAuthClient(): boolean { return !(!this._impl.authSignIn || !this._impl.authSignOut || !this._impl.authInit || !this._impl.authGetAccessToken); } public async authInit(ctx: ClientRequestContext, settings: MobileDeviceAuthSettings) { if (!this.hasAuthClient) { throw new Error("App did not registered any native auth client or implement all required functions"); } if (this._authInitialized) { return; } // Set callback for ios this._impl.authStateChanged = (accessToken?: string, err?: string) => { if (accessToken) { // Patch user info const tmp = JSON.parse(accessToken); if (typeof tmp._userInfo === undefined) { tmp._userInfo = {}; } accessToken = JSON.stringify(tmp); } this.onUserStateChanged.raiseEvent(accessToken, err); }; return new Promise<void>((resolve, reject) => { this._impl.authInit!(ctx, settings, (err?: string) => { if (!err) { this._authInitialized = true; resolve(); } else { this._authInitialized = false; reject(new Error(err)); } }); }); } public async signIn(ctx: ClientRequestContext): Promise<void> { // eslint-disable-next-line no-console console.log("signIn() ", JSON.stringify(ctx)); if (!this.hasAuthClient) { throw new Error("App did not registered any native auth client or implement all required functions"); } return new Promise<void>((resolve, reject) => { this._impl.authSignIn!(ctx, (err?: string) => { if (!err) { resolve(); } else { reject(new Error(err)); } }); }); } public async signOut(ctx: ClientRequestContext): Promise<void> { if (!this.hasAuthClient) { throw new Error("App did not registered any native auth client or implement all required functions"); } return new Promise<void>((resolve, reject) => { this._impl.authSignOut!(ctx, (err?: string) => { if (!err) { resolve(); } else { reject(new Error(err)); } }); }); } public async getAccessToken(ctx: ClientRequestContext): Promise<AccessToken> { if (!this.hasAuthClient) { throw new Error("App did not registered any native auth client or implement all required functions"); } return new Promise<AccessToken>((resolve, reject) => { this._impl.authGetAccessToken!(ctx, (accessToken?: string, err?: string) => { if (!err) { resolve(AccessToken.fromJson(accessToken)); } else { reject(new Error(err)); } }); }); } public static readonly currentDevice = new MobileDevice(); }
Bernard-Cloutier/imodeljs
core/backend/src/MobileDevice.ts
TypeScript
InterfaceDeclaration
export interface MobileDeviceAuthSettings { issuerUrl: string; clientId: string; redirectUrl: string; scope: string; stateKey?: string; }
Bernard-Cloutier/imodeljs
core/backend/src/MobileDevice.ts
TypeScript
InterfaceDeclaration
export interface DownloadTask { url: string; downloadPath: string; isDetached: boolean; isRunning: boolean; totalBytes?: number; doneBytes?: number; cancelId?: number; isBackground?: boolean; cancel?: MobileCancelCallback; toBackground: () => boolean; toForeground: () => boolean; }
Bernard-Cloutier/imodeljs
core/backend/src/MobileDevice.ts
TypeScript
EnumDeclaration
export enum Orientation { Unknown = 0, Portrait = 0x1, PortraitUpsideDown = 0x2, LandscapeLeft = 0x4, LandscapeRight = 0x8, FaceUp = 0x10, FaceDown = 0x20, }
Bernard-Cloutier/imodeljs
core/backend/src/MobileDevice.ts
TypeScript
EnumDeclaration
export enum BatteryState { Unknown = 0, Unplugged = 1, Charging = 2, Full = 3, }
Bernard-Cloutier/imodeljs
core/backend/src/MobileDevice.ts
TypeScript
EnumDeclaration
export enum DeviceEvents { MemoryWarning = "memoryWarning", OrientationChanged = "orientationChanged", EnterForeground = "enterForeground", EnterBackground = "enterBackground", WillTerminate = "willTerminate", }
Bernard-Cloutier/imodeljs
core/backend/src/MobileDevice.ts
TypeScript
TypeAliasDeclaration
export type MobileCompletionCallback = (downloadUrl: string, downloadFileUrl: string, cancelled: boolean, err?: string) => void;
Bernard-Cloutier/imodeljs
core/backend/src/MobileDevice.ts
TypeScript
TypeAliasDeclaration
export type MobileProgressCallback = (bytesWritten: number, totalBytesWritten: number, totalBytesExpectedToWrite: number) => void;
Bernard-Cloutier/imodeljs
core/backend/src/MobileDevice.ts
TypeScript
TypeAliasDeclaration
export type MobileCancelCallback = () => boolean;
Bernard-Cloutier/imodeljs
core/backend/src/MobileDevice.ts
TypeScript
MethodDeclaration
public emit(eventName: DeviceEvents, ...args: any[]) { MobileDevice.currentDevice.emit(eventName, ...args); }
Bernard-Cloutier/imodeljs
core/backend/src/MobileDevice.ts
TypeScript
MethodDeclaration
/** * Download file * @internal */ public async downloadFile(downloadUrl: string, downloadTo: string, progress?: ProgressCallback, cancelRequest?: CancelRequest): Promise<void> { return new Promise<void>((resolve, reject) => { if (!this._impl.createDownloadTask) { throw new Error("Native backend did not registered downloadFile() functions"); } let progressCb: MobileProgressCallback | undefined; if (progress) { progressCb = (_bytesWritten: number, totalBytesWritten: number, totalBytesExpectedToWrite: number) => { const percent = Number((100 * (totalBytesWritten / totalBytesExpectedToWrite)).toFixed(2)); progress({ total: totalBytesExpectedToWrite, loaded: totalBytesWritten, percent }); }; } const requestId = this._impl.createDownloadTask(downloadUrl, false, downloadTo, (_downloadUrl: string, _downloadFileUrl: string, cancelled: boolean, err?: string) => { if (cancelled) reject(new UserCancelledError(BriefcaseStatus.DownloadCancelled, "User cancelled download", Logger.logWarning)); else if (err) reject(new DownloadFailed(400, "Download failed")); else resolve(); }, progressCb); if (cancelRequest) { // eslint-disable-next-line @typescript-eslint/unbound-method cancelRequest.cancel = () => { return this._impl.cancelDownloadTask!(requestId); } } }); }
Bernard-Cloutier/imodeljs
core/backend/src/MobileDevice.ts
TypeScript
MethodDeclaration
/** * Reconnect app * @internal */ public reconnect(connection: number) { if (!this._impl.reconnect) { throw new Error("Native backend did not registered reconnect() functions"); } this._impl.reconnect(connection); }
Bernard-Cloutier/imodeljs
core/backend/src/MobileDevice.ts
TypeScript
MethodDeclaration
public emit(eventName: DeviceEvents, ...args: any[]) { switch (eventName) { case DeviceEvents.MemoryWarning: this.onMemoryWarning.raiseEvent(...args); break; case DeviceEvents.OrientationChanged: this.onOrientationChanged.raiseEvent(...args); break; case DeviceEvents.EnterForeground: this.onEnterForeground.raiseEvent(...args); break; case DeviceEvents.EnterBackground: this.onEnterBackground.raiseEvent(...args); break; case DeviceEvents.WillTerminate: this.onWillTerminate.raiseEvent(...args); break; } }
Bernard-Cloutier/imodeljs
core/backend/src/MobileDevice.ts
TypeScript
MethodDeclaration
public async authInit(ctx: ClientRequestContext, settings: MobileDeviceAuthSettings) { if (!this.hasAuthClient) { throw new Error("App did not registered any native auth client or implement all required functions"); } if (this._authInitialized) { return; } // Set callback for ios this._impl.authStateChanged = (accessToken?: string, err?: string) => { if (accessToken) { // Patch user info const tmp = JSON.parse(accessToken); if (typeof tmp._userInfo === undefined) { tmp._userInfo = {}; } accessToken = JSON.stringify(tmp); } this.onUserStateChanged.raiseEvent(accessToken, err); }; return new Promise<void>((resolve, reject) => { this._impl.authInit!(ctx, settings, (err?: string) => { if (!err) { this._authInitialized = true; resolve(); } else { this._authInitialized = false; reject(new Error(err)); } }); }); }
Bernard-Cloutier/imodeljs
core/backend/src/MobileDevice.ts
TypeScript
MethodDeclaration
public async signIn(ctx: ClientRequestContext): Promise<void> { // eslint-disable-next-line no-console console.log("signIn() ", JSON.stringify(ctx)); if (!this.hasAuthClient) { throw new Error("App did not registered any native auth client or implement all required functions"); } return new Promise<void>((resolve, reject) => { this._impl.authSignIn!(ctx, (err?: string) => { if (!err) { resolve(); } else { reject(new Error(err)); } }); }); }
Bernard-Cloutier/imodeljs
core/backend/src/MobileDevice.ts
TypeScript
MethodDeclaration
public async signOut(ctx: ClientRequestContext): Promise<void> { if (!this.hasAuthClient) { throw new Error("App did not registered any native auth client or implement all required functions"); } return new Promise<void>((resolve, reject) => { this._impl.authSignOut!(ctx, (err?: string) => { if (!err) { resolve(); } else { reject(new Error(err)); } }); }); }
Bernard-Cloutier/imodeljs
core/backend/src/MobileDevice.ts
TypeScript
MethodDeclaration
public async getAccessToken(ctx: ClientRequestContext): Promise<AccessToken> { if (!this.hasAuthClient) { throw new Error("App did not registered any native auth client or implement all required functions"); } return new Promise<AccessToken>((resolve, reject) => { this._impl.authGetAccessToken!(ctx, (accessToken?: string, err?: string) => { if (!err) { resolve(AccessToken.fromJson(accessToken)); } else { reject(new Error(err)); } }); }); }
Bernard-Cloutier/imodeljs
core/backend/src/MobileDevice.ts
TypeScript
FunctionDeclaration
function ChallengeBox() { const { activeChallenge, resetChallenge, completeChallenge } = useContext(ChallengesContext); const { resetCountdown } = useContext(CountdownContext); function handleChallengeSucceeded() { completeChallenge(); resetCountdown(); } function handleChallengeFailed() { resetChallenge(); resetCountdown(); } return ( <div className={styles.challengeBoxContainer}> {activeChallenge ? ( <div className={styles.challengeActive}> <header>Ganhe {activeChallenge.amount}xp</header> <main> <img src={`icons/${activeChallenge.type}.svg`} alt="" /> <strong>Novo desafio</strong> <p>{activeChallenge.description}</p> </main> <footer> <button type="button" className={styles.challengeFailedButton} onClick={handleChallengeFailed} > Falhei </button> <button type="button" className={styles.challengeSucceedButton} onClick={handleChallengeSucceeded} > Completei </button> </footer> </div> ) : ( <div className={styles.challengeNotActive}> <strong> Inicie um ciclo para receber desafios a serem completados </strong> <p> <img src="icons/level-up.svg" alt="Level Up" /> Complete-os e ganhe experiência para avançar para o próximo nível </p> </div> )}
martinsgabriel1956/moveit_nlw4
src/components/ChallengeBox/index.tsx
TypeScript
FunctionDeclaration
function handleChallengeSucceeded() { completeChallenge(); resetCountdown(); }
martinsgabriel1956/moveit_nlw4
src/components/ChallengeBox/index.tsx
TypeScript
FunctionDeclaration
function handleChallengeFailed() { resetChallenge(); resetCountdown(); }
martinsgabriel1956/moveit_nlw4
src/components/ChallengeBox/index.tsx
TypeScript
MethodDeclaration
activeChallenge ? ( <div className={styles.challengeActive}> <header>Ganhe {activeChallenge
martinsgabriel1956/moveit_nlw4
src/components/ChallengeBox/index.tsx
TypeScript
ClassDeclaration
export declare class Info extends MenuItem { constructor(vditor: IVditor, menuItem: IMenuItem); }
lbb4511/storyhub
static/vditor/ts/toolbar/Info.d.ts
TypeScript
ClassDeclaration
/** * 连线 [v.1.0.0] * 将该对象 放置到 两个节点之间,形成连线, 可以无视节点关系 */ @ccclass @menu("添加特殊行为/General/Line (连线)") @disallowMultiple export default class BhvLine extends cc.Component { @property(cc.Node) startNode: cc.Node = null; @property(cc.Node) endNode: cc.Node = null; // LIFE-CYCLE CALLBACKS: start() { if (this.startNode && this.endNode) { this.setLine(this.startNode, this.endNode); } } /**设置这条线 与 两个节点 动态连接起来 */ setLine(nodeStart: cc.Node, nodeEnd: cc.Node) { if (!this.startNode || !this.endNode) return; this.node.anchorX = 0; this.node.anchorY = 0.5; this.startNode = nodeStart; this.endNode = nodeEnd; } update() { if (!this.startNode || !this.endNode) return; var startPos: cc.Vec2 = this.startNode.convertToWorldSpaceAR(cc.Vec2.ZERO); var endPos: cc.Vec2 = this.endNode.convertToWorldSpaceAR(cc.Vec2.ZERO); var distance: number = startPos.sub(endPos).mag(); var angle: number = Math.atan2(endPos.y - startPos.y, endPos.x - startPos.x); this.node.position = this.node.getParent().convertToNodeSpaceAR(startPos); this.node.width = distance; this.node.rotation = cc.misc.radiansToDegrees(angle) * -1; } }
wsssheep/cc_easy_script
assets/Behavior/general/BhvLine.ts
TypeScript
MethodDeclaration
// LIFE-CYCLE CALLBACKS: start() { if (this.startNode && this.endNode) { this.setLine(this.startNode, this.endNode); } }
wsssheep/cc_easy_script
assets/Behavior/general/BhvLine.ts
TypeScript
MethodDeclaration
/**设置这条线 与 两个节点 动态连接起来 */ setLine(nodeStart: cc.Node, nodeEnd: cc.Node) { if (!this.startNode || !this.endNode) return; this.node.anchorX = 0; this.node.anchorY = 0.5; this.startNode = nodeStart; this.endNode = nodeEnd; }
wsssheep/cc_easy_script
assets/Behavior/general/BhvLine.ts
TypeScript
MethodDeclaration
update() { if (!this.startNode || !this.endNode) return; var startPos: cc.Vec2 = this.startNode.convertToWorldSpaceAR(cc.Vec2.ZERO); var endPos: cc.Vec2 = this.endNode.convertToWorldSpaceAR(cc.Vec2.ZERO); var distance: number = startPos.sub(endPos).mag(); var angle: number = Math.atan2(endPos.y - startPos.y, endPos.x - startPos.x); this.node.position = this.node.getParent().convertToNodeSpaceAR(startPos); this.node.width = distance; this.node.rotation = cc.misc.radiansToDegrees(angle) * -1; }
wsssheep/cc_easy_script
assets/Behavior/general/BhvLine.ts
TypeScript
FunctionDeclaration
/** * https://simplestatistics.org/docs/#sample */ declare function sample<T extends any>( x: T[], n: number, randomSource: () => number ): T[];
angelyaaaaa/simple-statistics
src/sample.d.ts
TypeScript
ClassDeclaration
export declare class CHTMLmunder<N, T, D> extends CHTMLmunder_base { static kind: string; static styles: StyleList; toCHTML(parent: N): void; }
NishadPatilMuzero/react-native-math-view-customize
node_modules/mathjax-full/js/output/chtml/Wrappers/munderover.d.ts
TypeScript
ClassDeclaration
export declare class CHTMLmover<N, T, D> extends CHTMLmover_base { static kind: string; static styles: StyleList; toCHTML(parent: N): void; }
NishadPatilMuzero/react-native-math-view-customize
node_modules/mathjax-full/js/output/chtml/Wrappers/munderover.d.ts
TypeScript
ClassDeclaration
export declare class CHTMLmunderover<N, T, D> extends CHTMLmunderover_base { static kind: string; static styles: StyleList; toCHTML(parent: N): void; }
NishadPatilMuzero/react-native-math-view-customize
node_modules/mathjax-full/js/output/chtml/Wrappers/munderover.d.ts
TypeScript
MethodDeclaration
toCHTML(parent: N): void;
NishadPatilMuzero/react-native-math-view-customize
node_modules/mathjax-full/js/output/chtml/Wrappers/munderover.d.ts
TypeScript
InterfaceDeclaration
//Components export interface IChatItemProps { data:{ users:string[]|[], room:string, messages:{ mess:string, name:string }[]|[] }, chatGo:Function, userInf:{ id:string, name?:string, email:string, nickname?:string, family_name?:string, isAuth:boolean }, userAll:{ email: string, family_name?: string, name?: string, nickname?: string, __v: number, _id: string }[]|[], notification:({ [key:string]:number })[] }
YuriiDubnytskyi/practick
client/my-app/src/interfaces/IProps.ts
TypeScript
ArrowFunction
(props) => { const { intl } = props const { exchange, wallet, createWallet, history } = messages const { exchange: exchangeLink, quickSwap, createWallet: create, // farm, history: historyLink, home, } = links const itemsWithWallet = [ { title: intl.formatMessage(wallet), link: home, exact: true, currentPageFlag: true, }, { title: intl.formatMessage(history), link: historyLink, exact: true, currentPageFlag: true, }, !externalConfig.opts.exchangeDisabled && { title: intl.formatMessage(exchange), link: quickSwap, exact: false, currentPageFlag: true, }, ] const itemsWithoutWallet = [ { title: intl.formatMessage(createWallet), link: create, exact: true, currentPageFlag: true, }, !externalConfig.opts.exchangeDisabled && { title: intl.formatMessage(exchange), link: exchangeLink, exact: false, currentPageFlag: true, }, ] // Marketmaker pages ******** if (!isWidgetBuild) { const marketmakerItem = { title: intl.formatMessage(messages.marketmaker), link: !isChromeExtension ? `${links.marketmaker}/` : `${links.marketmaker}/{MATIC}WBTC`, exact: true, currentPageFlag: true, } itemsWithWallet.push(marketmakerItem) itemsWithoutWallet.push(marketmakerItem) } // temporarily hidden // Farm ************************ // if (!isWidgetBuild) { // const farmItem = { // title: intl.formatMessage(messages.farm), // link: farm, // isExternal: true, // exact: true, // currentPageFlag: true, // } // itemsWithWallet.push(farmItem) // itemsWithoutWallet.push(farmItem) // } return localStorage.getItem('isWalletCreate') === 'true' || externalConfig && externalConfig.isWidget ? itemsWithWallet : itemsWithoutWallet }
AAH20/MultiCurrencyWallet
src/front/shared/components/Header/config.tsx
TypeScript
ArrowFunction
(props, isWalletCreate, dinamicPath) => { const { intl } = props const { exchange, wallet, createWallet, history } = messages const { exchange: exchangeLink, quickSwap, // farm, history: historyLink, } = links const mobileItemsWithWallet = [ { title: intl.formatMessage(isWalletCreate ? wallet : createWallet), link: dinamicPath, exact: true, icon: <i className="fa fa-home" aria-hidden="true" />, }, { title: props.intl.formatMessage(history), link: historyLink, displayNone: !isWalletCreate, icon: <i className="fas fa-exchange-alt" aria-hidden="true" />, }, !externalConfig.opts.exchangeDisabled && { title: intl.formatMessage(exchange), link: quickSwap, exact: false, icon: <i className="fas fa-sync-alt" aria-hidden="true" />, }, ] const mobileItemsWithoutWallet = [ { title: intl.formatMessage(createWallet), link: dinamicPath, exact: true, icon: <i className="fa fa-home" aria-hidden="true" />, }, !externalConfig.opts.exchangeDisabled && { title: intl.formatMessage(exchange), link: exchangeLink, exact: false, icon: <i className="fas fa-sync-alt" aria-hidden="true" />, }, ] // temporarily hidden // Farm ************************ // if (externalConfig.entry === 'testnet' && !isWidgetBuild) { // const farmItem = { // title: props.intl.formatMessage(messages.farm), // link: farm, // isExternal: true, // exact: true, // icon: <i className="fas fa-coins" aria-hidden="true" />, // } // mobileItemsWithWallet.push(farmItem) // mobileItemsWithoutWallet.push(farmItem) // } return localStorage.getItem('isWalletCreate') === 'true' ? mobileItemsWithWallet : mobileItemsWithoutWallet }
AAH20/MultiCurrencyWallet
src/front/shared/components/Header/config.tsx
TypeScript
ArrowFunction
(event: MessageEventInit) => event.data.message.toUpperCase()
mprobber/anansi
examples/typescript/src/pages/Home/my.worker.ts
TypeScript
ArrowFunction
() => MultipleGameAdditionModelService
Spielekreis-Darmstadt/lending
lending-admin-frontend/src/app/add-multiple/add-multiple-games/add-multiple-games.component.ts
TypeScript
ClassDeclaration
/** * A component used to add a list of games at once. * This list needs to be provided as a table file, e.g. as an xls or csv file */ @Component({ selector: 'lending-add-multiple-games', templateUrl: './add-multiple-games.component.html', styleUrls: ['./add-multiple-games.component.css'], providers: [{provide: MultipleAdditionModel, useExisting: forwardRef(() => MultipleGameAdditionModelService)}] }) export class AddMultipleGamesComponent { constructor() { } }
Spielekreis-Darmstadt/lending
lending-admin-frontend/src/app/add-multiple/add-multiple-games/add-multiple-games.component.ts
TypeScript
ClassDeclaration
@Component({ selector: 'gb-pedigree-constraint', templateUrl: './gb-pedigree-constraint.component.html', styleUrls: ['./gb-pedigree-constraint.component.css', '../gb-constraint/gb-constraint.component.css'] }) export class GbPedigreeConstraintComponent extends GbConstraintComponent implements OnInit { selectedPedigreeType: string; pedigreeTypes: SelectItem[]; triStateOptions: object[]; private _rightHandSideConstraint: Constraint; ngOnInit() { this.pedigreeTypes = []; this.triStateOptions = [ {label: 'both', value: undefined}, {label: 'yes', value: true}, {label: 'no', value: false} ]; const relationType = (<PedigreeConstraint>this.constraint).relationType; for (let typeObj of this.constraintService.validPedigreeTypes) { let ptype: SelectItem = { label: typeObj['text'], value: typeObj['type'] }; this.pedigreeTypes.push(ptype); if (relationType === typeObj['type']) { this.selectedPedigreeType = ptype.value; } } this.rightHandSideConstraint = (<PedigreeConstraint>this.constraint).rightHandSideConstraint; } updateRelationType(event) { (<PedigreeConstraint>this.constraint).relationType = event.value; this.update(); } get rightHandSideConstraint(): Constraint { return this._rightHandSideConstraint; } set rightHandSideConstraint(value: Constraint) { this._rightHandSideConstraint = value; } get biological(): TriState { return (<PedigreeConstraint>this.constraint).biological; } set biological(value: TriState) { (<PedigreeConstraint>this.constraint).biological = value; this.update(); } get shareHousehold(): TriState { return (<PedigreeConstraint>this.constraint).shareHousehold; } set shareHousehold(value: TriState) { (<PedigreeConstraint>this.constraint).shareHousehold = value; this.update(); } }
thehyve/glowing-bear
src/app/modules/gb-cohort-selection-module/constraint-components/gb-pedigree-constraint/gb-pedigree-constraint.component.ts
TypeScript
TypeAliasDeclaration
type TriState = true | false | undefined;
thehyve/glowing-bear
src/app/modules/gb-cohort-selection-module/constraint-components/gb-pedigree-constraint/gb-pedigree-constraint.component.ts
TypeScript
MethodDeclaration
ngOnInit() { this.pedigreeTypes = []; this.triStateOptions = [ {label: 'both', value: undefined}, {label: 'yes', value: true}, {label: 'no', value: false} ]; const relationType = (<PedigreeConstraint>this.constraint).relationType; for (let typeObj of this.constraintService.validPedigreeTypes) { let ptype: SelectItem = { label: typeObj['text'], value: typeObj['type'] }; this.pedigreeTypes.push(ptype); if (relationType === typeObj['type']) { this.selectedPedigreeType = ptype.value; } } this.rightHandSideConstraint = (<PedigreeConstraint>this.constraint).rightHandSideConstraint; }
thehyve/glowing-bear
src/app/modules/gb-cohort-selection-module/constraint-components/gb-pedigree-constraint/gb-pedigree-constraint.component.ts
TypeScript
MethodDeclaration
updateRelationType(event) { (<PedigreeConstraint>this.constraint).relationType = event.value; this.update(); }
thehyve/glowing-bear
src/app/modules/gb-cohort-selection-module/constraint-components/gb-pedigree-constraint/gb-pedigree-constraint.component.ts
TypeScript
FunctionDeclaration
/** * Creates a span using the global tracer. * @param name The name of the operation being performed. * @param tracingOptions The tracingOptions for the underlying http request. */ export function createSpan( operationName: string, tracingOptions: OperationTracingOptions = {} ): { span: Span; spanOptions: SpanOptions } { const tracer = getTracer(); const spanOptions: SpanOptions = { ...tracingOptions.spanOptions, kind: SpanKind.INTERNAL }; const span = tracer.startSpan(`Azure.Storage.File.${operationName}`, spanOptions); let newOptions = tracingOptions.spanOptions || {}; if (span.isRecording()) { newOptions = { ...tracingOptions, parent: span }; } return { span, spanOptions: newOptions }; }
burkeholland/azure-sdk-for-js
sdk/storage/storage-file-share/src/utils/tracing.ts
TypeScript
TypeAliasDeclaration
export declare type AppProps = { children: React.ReactNode; iconsSprite: string | null; };
nevendyulgerov/react-fidelity-ui
dist/components/App.d.ts
TypeScript
ClassDeclaration
@Bean('selectionHandleFactory') export class SelectionHandleFactory extends BeanStub implements ISelectionHandleFactory { public createSelectionHandle(type: SelectionHandleType): ISelectionHandle { return this.createBean(type === SelectionHandleType.RANGE ? new RangeHandle() : new FillHandle()); } }
39155319/ag-grid
enterprise-modules/range-selection/src/rangeSelection/selectionHandleFactory.ts
TypeScript
MethodDeclaration
public createSelectionHandle(type: SelectionHandleType): ISelectionHandle { return this.createBean(type === SelectionHandleType.RANGE ? new RangeHandle() : new FillHandle()); }
39155319/ag-grid
enterprise-modules/range-selection/src/rangeSelection/selectionHandleFactory.ts
TypeScript
EnumDeclaration
export enum EFGSignificanceType { Creature, AudioVolume, GenericTickHelper, ConveyorBelt, Factory, LowDistanceGainSignificance, MidDistanceGainSignificance, HighDistanceGainSignificance, AmbientSoundSpline, CustomDistanceGainSignificance, ParticleSignificance, TrainSignificance, PipelineSignificance, MAX, }
ficsit/data-landing
interfaces/enums/EFGSignificanceType.ts
TypeScript
FunctionDeclaration
/** * Not undefined type guard * @internal * @param x */ function notUndefined<T>(x: T | undefined): x is T { return x !== undefined; }
jexia/jexia-sdk-js
src/api/core/tokenManager.ts
TypeScript
ArrowFunction
(accessToken: string): Observable<string> => { const aliases: string[] = this.storage.getTokenAliases(accessToken); return of(accessToken).pipe( tap(currentAccessToken => this.removeRefreshDigest(currentAccessToken)), switchMap(() => this.refresh(aliases)), map(({ access_token }: Tokens): string => access_token), tap(newAccessToken => this.startRefreshDigest(aliases, newAccessToken)), ); }
jexia/jexia-sdk-js
src/api/core/tokenManager.ts
TypeScript
ArrowFunction
currentAccessToken => this.removeRefreshDigest(currentAccessToken)
jexia/jexia-sdk-js
src/api/core/tokenManager.ts
TypeScript
ArrowFunction
() => this.refresh(aliases)
jexia/jexia-sdk-js
src/api/core/tokenManager.ts
TypeScript
ArrowFunction
({ access_token }: Tokens): string => access_token
jexia/jexia-sdk-js
src/api/core/tokenManager.ts
TypeScript
ArrowFunction
newAccessToken => this.startRefreshDigest(aliases, newAccessToken)
jexia/jexia-sdk-js
src/api/core/tokenManager.ts
TypeScript
ArrowFunction
() => { const tokens = this.storage.getTokens(auth); if (!tokens) { throw new Error(MESSAGE.TOKEN_MANAGER.TOKEN_NOT_AVAILABLE); } return tokens.access_token; }
jexia/jexia-sdk-js
src/api/core/tokenManager.ts
TypeScript
ArrowFunction
(accessToken: string) => iif( () => isTokenExpired(accessToken), $refresh(accessToken), of(accessToken))
jexia/jexia-sdk-js
src/api/core/tokenManager.ts
TypeScript
ArrowFunction
() => isTokenExpired(accessToken)
jexia/jexia-sdk-js
src/api/core/tokenManager.ts
TypeScript
ArrowFunction
() => this.login(opts).toPromise()
jexia/jexia-sdk-js
src/api/core/tokenManager.ts
TypeScript
ArrowFunction
() => this
jexia/jexia-sdk-js
src/api/core/tokenManager.ts
TypeScript
ArrowFunction
timeout => clearTimeout(timeout)
jexia/jexia-sdk-js
src/api/core/tokenManager.ts
TypeScript
ArrowFunction
(alias, index) => { this.storage.setTokens(alias, tokens, !index && defaults); }
jexia/jexia-sdk-js
src/api/core/tokenManager.ts
TypeScript
ArrowFunction
() => { this.logger.debug("tokenManager", `refresh ${aliases[0]} token`); this.refresh(aliases) .pipe( finalize(() => this.removeRefreshDigest(accessToken)), ) .subscribe( ({ access_token }: Tokens) => this.startRefreshDigest(aliases, access_token), // start a digest for the new token () => this.terminate(), // TODO: send an event out, so the user can act on that ); }
jexia/jexia-sdk-js
src/api/core/tokenManager.ts
TypeScript
ArrowFunction
() => this.removeRefreshDigest(accessToken)
jexia/jexia-sdk-js
src/api/core/tokenManager.ts
TypeScript
ArrowFunction
({ access_token }: Tokens) => this.startRefreshDigest(aliases, access_token)
jexia/jexia-sdk-js
src/api/core/tokenManager.ts
TypeScript
ArrowFunction
() => this.terminate()
jexia/jexia-sdk-js
src/api/core/tokenManager.ts
TypeScript
ArrowFunction
(tokens: Tokens) => this.addTokens([auth], tokens, true)
jexia/jexia-sdk-js
src/api/core/tokenManager.ts
TypeScript
ArrowFunction
() => this.dispatcher.emit(DispatchEvents.TOKEN_LOGIN)
jexia/jexia-sdk-js
src/api/core/tokenManager.ts
TypeScript
ArrowFunction
(refreshedTokens: Tokens) => [auth, ...restAliases].forEach((alias) => this.storage.setTokens(alias, refreshedTokens))
jexia/jexia-sdk-js
src/api/core/tokenManager.ts
TypeScript
ArrowFunction
(alias) => this.storage.setTokens(alias, refreshedTokens)
jexia/jexia-sdk-js
src/api/core/tokenManager.ts
TypeScript
ArrowFunction
() => this.dispatcher.emit(DispatchEvents.TOKEN_REFRESH)
jexia/jexia-sdk-js
src/api/core/tokenManager.ts
TypeScript
ArrowFunction
() => { this.dispatcher.emit(DispatchEvents.TOKEN_REFRESH_FAILED); throw new Error("Refreshing token failed"); }
jexia/jexia-sdk-js
src/api/core/tokenManager.ts
TypeScript
ArrowFunction
(r) => resolve = r
jexia/jexia-sdk-js
src/api/core/tokenManager.ts
TypeScript
ArrowFunction
(refreshedTokens: Tokens) => resolve(refreshedTokens.access_token)
jexia/jexia-sdk-js
src/api/core/tokenManager.ts
TypeScript
ArrowFunction
(error: IRequestError) => { delete this.defers[auth]; throw { httpStatus: error.httpStatus, message: this.getErrorMessage(error), }; }
jexia/jexia-sdk-js
src/api/core/tokenManager.ts
TypeScript
InterfaceDeclaration
/** * Authorization options of the project */ export interface IAuthOptions { /** * Project ID */ readonly projectID?: string | null; /** * Project Zone */ readonly zone?: string | null; /** * Project URL (using this field overrides zone and projectID when composing the project url) */ readonly projectURL?: string | null; /** * Authorization alias. Used for multiple authorization methods at the same time * by default used 'apikey' */ auth?: string; /** * Project Key */ readonly key?: string; /** * Project Password */ readonly secret?: string; /** * Token refresh interval */ readonly refreshInterval?: number; /** * Remember user flag */ readonly remember?: boolean; }
jexia/jexia-sdk-js
src/api/core/tokenManager.ts
TypeScript
TypeAliasDeclaration
/** * API interface of the authorization token */ export type Tokens = { /** * JSON web token */ access_token: string, /** * Refresh token */ refresh_token: string, };
jexia/jexia-sdk-js
src/api/core/tokenManager.ts
TypeScript
MethodDeclaration
/** * Get access token for the specific authentication alias (APK by default) * When a token is expired, try to refresh the token * @param {string} auth Authentication alias */ public token(auth?: string): Observable<string> { // refreshing a token means: cancel current digest for expired token, fetch new token, start new digest with new token // due the digest, we are sure that it will not come to this, but to be 100% sure, its required deal with this const $refresh = (accessToken: string): Observable<string> => { const aliases: string[] = this.storage.getTokenAliases(accessToken); return of(accessToken).pipe( tap(currentAccessToken => this.removeRefreshDigest(currentAccessToken)), switchMap(() => this.refresh(aliases)), map(({ access_token }: Tokens): string => access_token), tap(newAccessToken => this.startRefreshDigest(aliases, newAccessToken)), ); }; return from(this.resolved).pipe( map(() => { const tokens = this.storage.getTokens(auth); if (!tokens) { throw new Error(MESSAGE.TOKEN_MANAGER.TOKEN_NOT_AVAILABLE); } return tokens.access_token; }), // check if the token is expired, if so, refresh the token and assign it to the storage switchMap((accessToken: string) => iif( () => isTokenExpired(accessToken), $refresh(accessToken), of(accessToken)), ), ); }
jexia/jexia-sdk-js
src/api/core/tokenManager.ts
TypeScript
MethodDeclaration
private validateAuthOptions({ projectID, projectURL }: IAuthOptions): void { if (!projectID && !projectURL) { throw this.authOptionsError; } }
jexia/jexia-sdk-js
src/api/core/tokenManager.ts
TypeScript
MethodDeclaration
/** * Initialize Token Manager * should be always initialized with projectID * ApiKey auth is optional * @param {IAuthOptions} opts Initialize options */ public init(opts: IAuthOptions): Promise<TokenManager> { this.validateAuthOptions(opts); this.config = opts; this.initPromise = Promise.resolve(this); /* if auth is provided */ if (opts.key && opts.secret) { this.initPromise = this.initPromise .then(() => this.login(opts).toPromise()) .then(() => this); } return this.initPromise; }
jexia/jexia-sdk-js
src/api/core/tokenManager.ts
TypeScript
MethodDeclaration
/** Terminate token manager and clear all tokens */ public terminate(): void { this.storage.clear(); this.refreshes.forEach(timeout => clearTimeout(timeout)); this.refreshes.clear(); }
jexia/jexia-sdk-js
src/api/core/tokenManager.ts
TypeScript
MethodDeclaration
/** * Set specific token to use by default * @param {string} auth authentication alias */ public setDefault(auth: string): void { this.storage.setDefault(auth); }
jexia/jexia-sdk-js
src/api/core/tokenManager.ts
TypeScript
MethodDeclaration
/** * Switch back to apikey token */ public resetDefault(): void { this.storage.setDefault(APIKEY_DEFAULT_ALIAS); }
jexia/jexia-sdk-js
src/api/core/tokenManager.ts
TypeScript
MethodDeclaration
/** * Add new token pair and run refresh digest * @param {Array<string | undefined>} aliases an array of authenticate aliases * @param {Tokens} tokens Token pair * @param {boolean} defaults Whether to use this token by default */ public addTokens(aliases: Array<string | undefined>, tokens: Tokens, defaults?: boolean) { const definedAliases: string[] = aliases.filter(notUndefined); /* Store token pairs for each alias but make default the first one only */ definedAliases.forEach((alias, index) => { this.storage.setTokens(alias, tokens, !index && defaults); }); this.startRefreshDigest(definedAliases, tokens.access_token); }
jexia/jexia-sdk-js
src/api/core/tokenManager.ts
TypeScript
MethodDeclaration
/** * Remove a token based on the name of the key * * @param {string} alias The key to identify the token */ public removeTokens(alias: string): void { this.storage.removeTokens(alias); }
jexia/jexia-sdk-js
src/api/core/tokenManager.ts
TypeScript
MethodDeclaration
/** * Start refreshing digest for the specific auth based on the exp value from the token * @ignore */ private startRefreshDigest(aliases: string[], accessToken: string) { const delay = delayTokenRefresh(accessToken); const timer = setTimeout(() => { this.logger.debug("tokenManager", `refresh ${aliases[0]} token`); this.refresh(aliases) .pipe( finalize(() => this.removeRefreshDigest(accessToken)), ) .subscribe( ({ access_token }: Tokens) => this.startRefreshDigest(aliases, access_token), // start a digest for the new token () => this.terminate(), // TODO: send an event out, so the user can act on that ); }, delay); // save the timeout ref, and ref it to the accessToken key this.refreshes.set(accessToken, timer); }
jexia/jexia-sdk-js
src/api/core/tokenManager.ts
TypeScript
MethodDeclaration
/** * Stop a refreshing digest * @ignore */ private removeRefreshDigest(currentAccessToken: string): void { if(this.refreshes.has(currentAccessToken)) { const timer = this.refreshes.get(currentAccessToken); clearTimeout(timer); this.refreshes.delete(currentAccessToken); } }
jexia/jexia-sdk-js
src/api/core/tokenManager.ts
TypeScript
MethodDeclaration
/** * Login to the project using APK method * @ignore */ private login({auth = APIKEY_DEFAULT_ALIAS, key, secret}: IAuthOptions): Observable<Tokens> { return this.obtainTokens(auth, this.authUrl, { method: "apk", key, secret }).pipe( tap((tokens: Tokens) => this.addTokens([auth], tokens, true)), tap(() => this.dispatcher.emit(DispatchEvents.TOKEN_LOGIN)), ); }
jexia/jexia-sdk-js
src/api/core/tokenManager.ts
TypeScript
MethodDeclaration
/** * Refresh the token * @ignore */ private refresh([auth, ...restAliases]: string[] = []): Observable<Tokens> { const tokens = this.storage.getTokens(auth); if (!tokens || !tokens.refresh_token) { throw new Error(`There is no refresh token for ${auth}`); } return this.obtainTokens(auth, this.refreshUrl, { refresh_token: tokens.refresh_token }).pipe( tap((refreshedTokens: Tokens) => [auth, ...restAliases].forEach((alias) => this.storage.setTokens(alias, refreshedTokens)), ), tap(() => this.dispatcher.emit(DispatchEvents.TOKEN_REFRESH)), catchError(() => { this.dispatcher.emit(DispatchEvents.TOKEN_REFRESH_FAILED); throw new Error("Refreshing token failed"); }), ); }
jexia/jexia-sdk-js
src/api/core/tokenManager.ts
TypeScript
MethodDeclaration
/** * Get tokens from the project * @ignore */ private obtainTokens(auth: string, url: string, body: object): Observable<Tokens> { let resolve: (value?: any) => void; this.defers[auth] = new Promise((r) => resolve = r); return this.requestAdapter.execute(url, { body, method: RequestMethod.POST, }).pipe( tap((refreshedTokens: Tokens) => resolve(refreshedTokens.access_token)), catchError((error: IRequestError) => { delete this.defers[auth]; throw { httpStatus: error.httpStatus, message: this.getErrorMessage(error), }; }), ); }
jexia/jexia-sdk-js
src/api/core/tokenManager.ts
TypeScript
MethodDeclaration
public getErrorMessage({ httpStatus: { code, status } }: IRequestError): string { if (code === 404) { return `Authorization failed: project ${getProjectId(this.config)} not found.`; } return `Authorization failed: ${code} ${status}`; }
jexia/jexia-sdk-js
src/api/core/tokenManager.ts
TypeScript