type
stringclasses
7 values
content
stringlengths
4
9.55k
repo
stringlengths
7
96
path
stringlengths
4
178
language
stringclasses
1 value
ArrowFunction
(partial: Partial<RulerAlertingRuleDTO> = {}): RulerAlertingRuleDTO => ({ alert: 'alert1', expr: 'up = 1', labels: { severity: 'warning', }, annotations: { summary: 'test alert', }, })
JiayuanZHOU/grafana
public/app/features/alerting/unified/mocks.ts
TypeScript
ArrowFunction
(partial: Partial<RulerRuleGroupDTO> = {}): RulerRuleGroupDTO => ({ name: 'group1', rules: [mockRulerAlertingRule()], ...partial, })
JiayuanZHOU/grafana
public/app/features/alerting/unified/mocks.ts
TypeScript
ArrowFunction
(partial: Partial<AlertingRule> = {}): AlertingRule => { return { type: PromRuleType.Alerting, alerts: [mockPromAlert()], name: 'myalert', query: 'foo > 1', lastEvaluation: '2021-03-23T08:19:05.049595312Z', evaluationTime: 0.000395601, annotations: { message: 'alert with severity "{{.warning}}}"', }, labels: { severity: 'warning', }, state: PromAlertingRuleState.Firing, health: 'OK', ...partial, }; }
JiayuanZHOU/grafana
public/app/features/alerting/unified/mocks.ts
TypeScript
ArrowFunction
(partial: Partial<RecordingRule> = {}): RecordingRule => { return { type: PromRuleType.Recording, query: 'bar < 3', labels: { cluster: 'eu-central', }, health: 'OK', name: 'myrecordingrule', lastEvaluation: '2021-03-23T08:19:05.049595312Z', evaluationTime: 0.000395601, ...partial, }; }
JiayuanZHOU/grafana
public/app/features/alerting/unified/mocks.ts
TypeScript
ArrowFunction
(partial: Partial<RuleGroup> = {}): RuleGroup => { return { name: 'mygroup', interval: 60, rules: [mockPromAlertingRule()], ...partial, }; }
JiayuanZHOU/grafana
public/app/features/alerting/unified/mocks.ts
TypeScript
ArrowFunction
(partial: Partial<RuleNamespace> = {}): RuleNamespace => { return { dataSourceName: 'Prometheus-1', name: 'default', groups: [mockPromRuleGroup()], ...partial, }; }
JiayuanZHOU/grafana
public/app/features/alerting/unified/mocks.ts
TypeScript
ArrowFunction
(partial: Partial<AlertmanagerAlert> = {}): AlertmanagerAlert => { return { annotations: { summary: 'US-Central region is on fire', }, endsAt: '2021-06-22T21:49:28.562Z', fingerprint: '88e013643c3df34ac3', receivers: [{ name: 'pagerduty' }], startsAt: '2021-06-21T17:25:28.562Z', status: { inhibitedBy: [], silencedBy: [], state: AlertState.Active }, updatedAt: '2021-06-22T21:45:28.564Z', generatorURL: 'https://play.grafana.com/explore', labels: { severity: 'warning', region: 'US-Central' }, ...partial, }; }
JiayuanZHOU/grafana
public/app/features/alerting/unified/mocks.ts
TypeScript
ArrowFunction
(partial: Partial<AlertmanagerGroup> = {}): AlertmanagerGroup => { return { labels: { severity: 'warning', region: 'US-Central', }, receiver: { name: 'pagerduty', }, alerts: [ mockAlertmanagerAlert(), mockAlertmanagerAlert({ status: { state: AlertState.Suppressed, silencedBy: ['123456abcdef'], inhibitedBy: [] }, labels: { severity: 'warning', region: 'US-Central', foo: 'bar', ...partial.labels }, }), ], ...partial, }; }
JiayuanZHOU/grafana
public/app/features/alerting/unified/mocks.ts
TypeScript
ArrowFunction
(partial: Partial<Silence> = {}): Silence => { return { id: '1a2b3c4d5e6f', matchers: [{ name: 'foo', value: 'bar', isEqual: true, isRegex: false }], startsAt: new Date().toISOString(), endsAt: new Date(Date.now() + 60 * 60 * 1000).toISOString(), updatedAt: new Date().toISOString(), createdBy: config.bootData.user.name || 'admin', comment: 'Silence noisy alerts', status: { state: SilenceState.Active, }, ...partial, }; }
JiayuanZHOU/grafana
public/app/features/alerting/unified/mocks.ts
TypeScript
ArrowFunction
() => []
JiayuanZHOU/grafana
public/app/features/alerting/unified/mocks.ts
TypeScript
ArrowFunction
(name: any) => name
JiayuanZHOU/grafana
public/app/features/alerting/unified/mocks.ts
TypeScript
ArrowFunction
(acc, ds) => { acc[ds.name] = ds; return acc; }
JiayuanZHOU/grafana
public/app/features/alerting/unified/mocks.ts
TypeScript
ArrowFunction
( type: string, overrides: Partial<GrafanaManagedReceiverConfig> = {} ): GrafanaManagedReceiverConfig => ({ type: type, name: type, disableResolveMessage: false, settings: {}, ...overrides, })
JiayuanZHOU/grafana
public/app/features/alerting/unified/mocks.ts
TypeScript
ArrowFunction
(dataSourceName = 'Prometheus'): RuleNamespace[] => [ { dataSourceName, name: 'namespace1', groups: [ mockPromRuleGroup({ name: 'group1', rules: [mockPromAlertingRule({ name: 'alert1' })] }), mockPromRuleGroup({ name: 'group2', rules: [mockPromAlertingRule({ name: 'alert2' })] }), ], }, { dataSourceName, name: 'namespace2', groups: [mockPromRuleGroup({ name: 'group3', rules: [mockPromAlertingRule({ name: 'alert3' })] })], }, ]
JiayuanZHOU/grafana
public/app/features/alerting/unified/mocks.ts
TypeScript
ClassDeclaration
export class MockDataSourceSrv implements DataSourceSrv { datasources: Record<string, DataSourceApi> = {}; // @ts-ignore private settingsMapByName: Record<string, DataSourceInstanceSettings> = {}; private settingsMapByUid: Record<string, DataSourceInstanceSettings> = {}; private settingsMapById: Record<string, DataSourceInstanceSettings> = {}; // @ts-ignore private templateSrv = { getVariables: () => [], replace: (name: any) => name, }; defaultName = ''; constructor(datasources: Record<string, DataSourceInstanceSettings>) { this.datasources = {}; this.settingsMapByName = Object.values(datasources).reduce<Record<string, DataSourceInstanceSettings>>( (acc, ds) => { acc[ds.name] = ds; return acc; }, {} ); for (const dsSettings of Object.values(this.settingsMapByName)) { this.settingsMapByUid[dsSettings.uid] = dsSettings; this.settingsMapById[dsSettings.id] = dsSettings; if (dsSettings.isDefault) { this.defaultName = dsSettings.name; } } } get(name?: string | null | DataSourceRef, scopedVars?: ScopedVars): Promise<DataSourceApi> { return DatasourceSrv.prototype.get.call(this, name, scopedVars); //return Promise.reject(new Error('not implemented')); } /** * Get a list of data sources */ getList(filters?: GetDataSourceListFilters): DataSourceInstanceSettings[] { return DatasourceSrv.prototype.getList.call(this, filters); } /** * Get settings and plugin metadata by name or uid */ getInstanceSettings(nameOrUid: string | null | undefined): DataSourceInstanceSettings | undefined { return ( DatasourceSrv.prototype.getInstanceSettings.call(this, nameOrUid) || (({ meta: { info: { logos: {} } } } as unknown) as DataSourceInstanceSettings) ); } async loadDatasource(name: string): Promise<DataSourceApi<any, any>> { return DatasourceSrv.prototype.loadDatasource.call(this, name); } }
JiayuanZHOU/grafana
public/app/features/alerting/unified/mocks.ts
TypeScript
MethodDeclaration
get(name?: string | null | DataSourceRef, scopedVars?: ScopedVars): Promise<DataSourceApi> { return DatasourceSrv.prototype.get.call(this, name, scopedVars); //return Promise.reject(new Error('not implemented')); }
JiayuanZHOU/grafana
public/app/features/alerting/unified/mocks.ts
TypeScript
MethodDeclaration
/** * Get a list of data sources */ getList(filters?: GetDataSourceListFilters): DataSourceInstanceSettings[] { return DatasourceSrv.prototype.getList.call(this, filters); }
JiayuanZHOU/grafana
public/app/features/alerting/unified/mocks.ts
TypeScript
MethodDeclaration
/** * Get settings and plugin metadata by name or uid */ getInstanceSettings(nameOrUid: string | null | undefined): DataSourceInstanceSettings | undefined { return ( DatasourceSrv.prototype.getInstanceSettings.call(this, nameOrUid) || (({ meta: { info: { logos: {} } } } as unknown) as DataSourceInstanceSettings) ); }
JiayuanZHOU/grafana
public/app/features/alerting/unified/mocks.ts
TypeScript
MethodDeclaration
async loadDatasource(name: string): Promise<DataSourceApi<any, any>> { return DatasourceSrv.prototype.loadDatasource.call(this, name); }
JiayuanZHOU/grafana
public/app/features/alerting/unified/mocks.ts
TypeScript
ArrowFunction
(value: string) => R.map(Number.parseInt, R.split(',', value))
sprengerjo/katas_js
src/gol.ts
TypeScript
ArrowFunction
(key: any, value: any) => { return GameOfLife.isAlive(value, R.contains(destructIdentity(key), cells)); }
sprengerjo/katas_js
src/gol.ts
TypeScript
ArrowFunction
cs => GameOfLife.filterWithKeys(fn, cs)
sprengerjo/katas_js
src/gol.ts
TypeScript
ArrowFunction
(cell: Number) => R.identity(cell.toString())
sprengerjo/katas_js
src/gol.ts
TypeScript
ArrowFunction
(val: any) => R.apply(pred, val)
sprengerjo/katas_js
src/gol.ts
TypeScript
ClassDeclaration
export default class GameOfLife { static nextGeneration(cells: [number[]]) { const destructIdentity = (value: string) => R.map(Number.parseInt, R.split(',', value)); const fn = (key: any, value: any) => { return GameOfLife.isAlive(value, R.contains(destructIdentity(key), cells)); }; const nextGen = R.compose( R.map(destructIdentity), R.keys, cs => GameOfLife.filterWithKeys(fn, cs), R.countBy((cell: Number) => R.identity(cell.toString())), R.chain(GameOfLife.getNeighbours) )(cells); return nextGen; } public static getNeighbours(cell: number []): any [] { const neighbours = []; if (GameOfLife.isValid(cell)) { const d = [1, 0, -1]; for (let i in d) { for (let j in d) { if (d[i] === 0 && d[j] === 0) { continue; } const c = [cell[0] - d[i], cell[1] - d[j]]; neighbours.push(c); } } } return neighbours; } public static isAlive(number: number, alive: boolean) { return number === 3 || number === 2 && alive; } private static isValid(cell: number []): boolean { return cell !== undefined && cell !== null && cell.length > 0; } private static filterWithKeys(pred: any, obj: any) { return R.pipe( R.toPairs, R.filter((val: any) => R.apply(pred, val)), R.fromPairs )(obj); } }
sprengerjo/katas_js
src/gol.ts
TypeScript
MethodDeclaration
static nextGeneration(cells: [number[]]) { const destructIdentity = (value: string) => R.map(Number.parseInt, R.split(',', value)); const fn = (key: any, value: any) => { return GameOfLife.isAlive(value, R.contains(destructIdentity(key), cells)); }; const nextGen = R.compose( R.map(destructIdentity), R.keys, cs => GameOfLife.filterWithKeys(fn, cs), R.countBy((cell: Number) => R.identity(cell.toString())), R.chain(GameOfLife.getNeighbours) )(cells); return nextGen; }
sprengerjo/katas_js
src/gol.ts
TypeScript
MethodDeclaration
public static getNeighbours(cell: number []): any [] { const neighbours = []; if (GameOfLife.isValid(cell)) { const d = [1, 0, -1]; for (let i in d) { for (let j in d) { if (d[i] === 0 && d[j] === 0) { continue; } const c = [cell[0] - d[i], cell[1] - d[j]]; neighbours.push(c); } } } return neighbours; }
sprengerjo/katas_js
src/gol.ts
TypeScript
MethodDeclaration
public static isAlive(number: number, alive: boolean) { return number === 3 || number === 2 && alive; }
sprengerjo/katas_js
src/gol.ts
TypeScript
MethodDeclaration
private static isValid(cell: number []): boolean { return cell !== undefined && cell !== null && cell.length > 0; }
sprengerjo/katas_js
src/gol.ts
TypeScript
MethodDeclaration
private static filterWithKeys(pred: any, obj: any) { return R.pipe( R.toPairs, R.filter((val: any) => R.apply(pred, val)), R.fromPairs )(obj); }
sprengerjo/katas_js
src/gol.ts
TypeScript
ArrowFunction
() => { const { ratings } = Redux( (state: AppReduxState) => ({ ratings: state.ratings, }), shallow ); const [sortConfig, setSortConfig] = useState<SortConfig>({ column: 'rating', order: 1, }); const [activePage, setActivePage] = useState(1); const getData = useMemo( () => ratings.slice().sort((a, b) => { let cmp = 0; const { column, order } = sortConfig; const { rating: ratingA, time: timeA, course: courseA, sentiment: sentimentA, } = a; const { rating: ratingB, time: timeB, course: courseB, sentiment: sentimentB, } = b; switch (column) { case TIME_ID: if (timeA < timeB) { cmp = -1; } else if (timeA > timeB) { cmp = 1; } return order * cmp; case COURSE_ID: return order * courseA.localeCompare(courseB); case SENTIMENT_ID: const sentimentANum = sentimentA ?? 0; const sentimentBNum = sentimentB ?? 0; if (sentimentANum < sentimentBNum) { cmp = -1; } else if (sentimentANum > sentimentBNum) { cmp = 1; } return order * cmp; default: if (ratingA < ratingB) { cmp = -1; } else if (ratingA > ratingB) { cmp = 1; } return order * cmp; } }), [sortConfig, ratings] ); const handleSortClick = useCallback( (event: React.MouseEvent<HTMLTableHeaderCellElement, MouseEvent>) => { const { id: clickedHeader } = event.currentTarget; const { column, order } = sortConfig; setActivePage(1); if (column === clickedHeader) { setSortConfig({ column, order: order * -1, }); } else { setSortConfig({ column: clickedHeader, order: 1, }); } }, [sortConfig, setSortConfig] ); if (ratings.length === 0) return null; const avg = ratings.length === 0 ? 0 : ratings.reduce((acc, rating) => acc + rating.rating, 0) / ratings.length; const { column, order } = sortConfig; const [firstRating, ...rest] = ratings; const firstCourse = firstRating.course ?? null; const isMultiCourseLA = rest.length > 0 && !rest.every((r) => r.course === firstCourse); return ( <> <Table hover style={{ width: '100%', cursor: 'default' }}
hbiede/LA-Feedback-System
src/components/AdminComponents/LADetailTable.tsx
TypeScript
ArrowFunction
(state: AppReduxState) => ({ ratings: state.ratings, })
hbiede/LA-Feedback-System
src/components/AdminComponents/LADetailTable.tsx
TypeScript
ArrowFunction
() => ratings.slice().sort((a, b) => { let cmp = 0; const { column, order } = sortConfig; const { rating: ratingA, time: timeA, course: courseA, sentiment: sentimentA, } = a; const { rating: ratingB, time: timeB, course: courseB, sentiment: sentimentB, } = b; switch (column) { case TIME_ID: if (timeA < timeB) { cmp = -1; } else if (timeA > timeB) { cmp = 1; } return order * cmp; case COURSE_ID: return order * courseA.localeCompare(courseB); case SENTIMENT_ID: const sentimentANum = sentimentA ?? 0; const sentimentBNum = sentimentB ?? 0; if (sentimentANum < sentimentBNum) { cmp = -1; } else if (sentimentANum > sentimentBNum) { cmp = 1; } return order * cmp; default: if (ratingA < ratingB) { cmp = -1; } else if (ratingA > ratingB) { cmp = 1; } return order * cmp; } })
hbiede/LA-Feedback-System
src/components/AdminComponents/LADetailTable.tsx
TypeScript
ArrowFunction
(a, b) => { let cmp = 0; const { column, order } = sortConfig; const { rating: ratingA, time: timeA, course: courseA, sentiment: sentimentA, } = a; const { rating: ratingB, time: timeB, course: courseB, sentiment: sentimentB, } = b; switch (column) { case TIME_ID: if (timeA < timeB) { cmp = -1; } else if (timeA > timeB) { cmp = 1; } return order * cmp; case COURSE_ID: return order * courseA.localeCompare(courseB); case SENTIMENT_ID: const sentimentANum = sentimentA ?? 0; const sentimentBNum = sentimentB ?? 0; if (sentimentANum < sentimentBNum) { cmp = -1; } else if (sentimentANum > sentimentBNum) { cmp = 1; } return order * cmp; default: if (ratingA < ratingB) { cmp = -1; } else if (ratingA > ratingB) { cmp = 1; } return order * cmp; } }
hbiede/LA-Feedback-System
src/components/AdminComponents/LADetailTable.tsx
TypeScript
ArrowFunction
(event: React.MouseEvent<HTMLTableHeaderCellElement, MouseEvent>) => { const { id: clickedHeader } = event.currentTarget; const { column, order } = sortConfig; setActivePage(1); if (column === clickedHeader) { setSortConfig({ column, order: order * -1, }); } else { setSortConfig({ column: clickedHeader, order: 1, }); } }
hbiede/LA-Feedback-System
src/components/AdminComponents/LADetailTable.tsx
TypeScript
ArrowFunction
(acc, rating) => acc + rating.rating
hbiede/LA-Feedback-System
src/components/AdminComponents/LADetailTable.tsx
TypeScript
ArrowFunction
(r) => r.course === firstCourse
hbiede/LA-Feedback-System
src/components/AdminComponents/LADetailTable.tsx
TypeScript
ArrowFunction
(row) => ( <tr className={getRowClass(row.rating
hbiede/LA-Feedback-System
src/components/AdminComponents/LADetailTable.tsx
TypeScript
MethodDeclaration
getRowClass(row
hbiede/LA-Feedback-System
src/components/AdminComponents/LADetailTable.tsx
TypeScript
FunctionDeclaration
/** * Downloads the data at the object's location. Returns an error if the object * is not found. * * To use this functionality, you have to whitelist your app's origin in your * Cloud Storage bucket. See also * https://cloud.google.com/storage/docs/configuring-cors * * This API is not available in Node. * * @public * @param ref - StorageReference where data should be downloaded. * @param maxDownloadSizeBytes - If set, the maximum allowed size in bytes to * retrieve. * @returns A Promise that resolves with a Blob containing the object's bytes */ // eslint-disable-next-line @typescript-eslint/no-unused-vars export function getBlob( ref: StorageReference, maxDownloadSizeBytes?: number ): Promise<Blob> { throw new Error('getBlob() is only available in Browser-like environments'); }
BearerPipelineTest/firebase-js-sdk
packages/storage/src/api.node.ts
TypeScript
FunctionDeclaration
/** * Downloads the data at the object's location. Raises an error event if the * object is not found. * * This API is only available in Node. * * @public * @param ref - StorageReference where data should be downloaded. * @param maxDownloadSizeBytes - If set, the maximum allowed size in bytes to * retrieve. * @returns A stream with the object's data as bytes */ export function getStream( ref: StorageReference, maxDownloadSizeBytes?: number ): NodeJS.ReadableStream { ref = getModularInstance(ref); return getStreamInternal(ref as Reference, maxDownloadSizeBytes); }
BearerPipelineTest/firebase-js-sdk
packages/storage/src/api.node.ts
TypeScript
FunctionDeclaration
export default function(theme: string | ThemeDef, opts: Partial<IOptions> = {}) { const { cwd = process.cwd() } = opts; if (!theme) { return {}; } if (typeof theme === 'string') { const themePath = isAbsolute(theme) ? theme : resolve(cwd, theme); if (existsSync(themePath)) { try { const themeConfig = require(themePath); // eslint-disable-line if (typeof themeConfig === 'function') { return themeConfig(); } else { return themeConfig; } } catch (e) { return {}; } } else { throw new Error(`theme file don't exists`); } } return theme; }
FringeY/alibabacloud-console-toolkit
packages/plugin-react/src/webpack/rules/style/normalizeTheme.ts
TypeScript
InterfaceDeclaration
interface IOptions { cwd: string; }
FringeY/alibabacloud-console-toolkit
packages/plugin-react/src/webpack/rules/style/normalizeTheme.ts
TypeScript
ClassDeclaration
@Injectable() export class AuthRequiredGuard implements CanActivate { canActivate(context: ExecutionContext) { const req = context.switchToHttp().getRequest(); return !!req.user; } }
dailydismay/calm-waters-api
src/auth/guards/auth.guard.ts
TypeScript
MethodDeclaration
canActivate(context: ExecutionContext) { const req = context.switchToHttp().getRequest(); return !!req.user; }
dailydismay/calm-waters-api
src/auth/guards/auth.guard.ts
TypeScript
ClassDeclaration
export class GetByEmailAccountsValidationResult implements IValidationResult { public isValid: boolean; public errors: string[] = []; }
adico1/clean-on-nest
libs/bootcamp-businesslogic/src/lib/accounts/get-by-email/get-by-email.accounts.validation-result.ts
TypeScript
FunctionDeclaration
/** * Ensure branch integrity - GitHub and RTD urls, and workflow target branches * * @returns An array of messages for changes. */ function ensureBranch(): string[] { const messages: string[] = []; const { source, target, rtdVersion } = URL_CONFIG; // Handle the github_version in conf.py const confPath = 'docs/source/conf.py'; const oldConfData = fs.readFileSync(confPath, 'utf-8'); const confTest = new RegExp('"github_version": "(.*)"'); const newConfData = oldConfData.replace( confTest, `"github_version": "${target}"` ); if (newConfData !== oldConfData) { messages.push(`Overwriting ${confPath}`); fs.writeFileSync(confPath, newConfData, 'utf-8'); } // Handle urls in files // Get all files matching the desired file types const fileTypes = ['.json', '.md', '.rst', '.yml', '.ts', '.tsx', '.py']; let files = execSync('git ls-tree -r HEAD --name-only') .toString() .trim() .split(/\r?\n/); files = files.filter(filePath => { return fileTypes.indexOf(path.extname(filePath)) !== -1; }); // Set up string replacements const base = '/jupyterlab/jupyterlab'; const rtdString = `jupyterlab.readthedocs.io/en/${rtdVersion}/`; const urlMap = [ [`\/jupyterlab\/jupyterlab\/${source}\/`, `${base}/${target}/`], [`\/jupyterlab\/jupyterlab\/blob\/${source}\/`, `${base}/blob/${target}/`], [`\/jupyterlab\/jupyterlab\/tree\/${source}\/`, `${base}/tree/${target}/`], [`jupyterlab.readthedocs.io\/en\/.*?\/`, rtdString] ]; // Make the string replacements files.forEach(filePath => { if (path.basename(filePath) === 'ensure-repo.ts') { return; } const oldData = fs.readFileSync(filePath, 'utf-8'); let newData = oldData; urlMap.forEach(section => { const test = new RegExp(section[0], 'g'); const replacer = section[1]; if (newData.match(test)) { newData = newData.replace(test, replacer); } }); // Make sure the root RTD links point to stable const badgeLink = '(http://jupyterlab.readthedocs.io/en/stable/)'; const toReplace = badgeLink.replace('stable', rtdVersion); if (badgeLink !== toReplace) { while (newData.indexOf(toReplace) !== -1) { newData = newData.replace(toReplace, badgeLink); } } if (newData !== oldData) { messages.push(`Overwriting ${filePath}`); fs.writeFileSync(filePath, newData, 'utf-8'); } }); // Handle workflow file target branches const workflows = glob.sync(path.join('.github', 'workflows', '*.yml')); workflows.forEach(filePath => { let workflowData = fs.readFileSync(filePath, 'utf-8'); const test = new RegExp(`\\[${source}\\]`, 'g'); if (workflowData.match(test)) { if (workflowData.match(test)![1] !== `[${target}]`) { messages.push(`Overwriting ${filePath}`); workflowData = workflowData.replace(test, `[${target}]`); fs.writeFileSync(filePath, workflowData, 'utf-8'); } } }); return messages; }
Refinitiv/jupyterlab
buildutils/src/ensure-repo.ts
TypeScript
FunctionDeclaration
/** * Ensure the metapackage package. * * @returns An array of messages for changes. */ function ensureMetaPackage(): string[] { const basePath = path.resolve('.'); const mpPath = path.join(basePath, 'packages', 'metapackage'); const mpJson = path.join(mpPath, 'package.json'); const mpData = utils.readJSONFile(mpJson); const messages: string[] = []; const seen: Dict<boolean> = {}; utils.getCorePaths().forEach(pkgPath => { if (path.resolve(pkgPath) === path.resolve(mpPath)) { return; } const name = pkgNames[pkgPath]; if (!name) { return; } seen[name] = true; const data = pkgData[name]; let valid = true; // Ensure it is a dependency. if (!mpData.dependencies[name]) { valid = false; mpData.dependencies[name] = '^' + data.version; } if (!valid) { messages.push(`Updated: ${name}`); } }); // Make sure there are no extra deps. Object.keys(mpData.dependencies).forEach(name => { if (!(name in seen)) { messages.push(`Removing dependency: ${name}`); delete mpData.dependencies[name]; } }); // Write the files. if (messages.length > 0) { utils.writePackageData(mpJson, mpData); } // Update the global data. pkgData[mpData.name] = mpData; return messages; }
Refinitiv/jupyterlab
buildutils/src/ensure-repo.ts
TypeScript
FunctionDeclaration
/** * Ensure the jupyterlab application package. */ function ensureJupyterlab(): string[] { const basePath = path.resolve('.'); const corePath = path.join(basePath, 'dev_mode', 'package.json'); const corePackage = utils.readJSONFile(corePath); corePackage.jupyterlab.extensions = {}; corePackage.jupyterlab.mimeExtensions = {}; corePackage.jupyterlab.linkedPackages = {}; // start with known external dependencies corePackage.dependencies = Object.assign( {}, corePackage.jupyterlab.externalExtensions ); corePackage.resolutions = {}; const singletonPackages: string[] = corePackage.jupyterlab.singletonPackages; const coreData = new Map<string, any>(); utils.getCorePaths().forEach(pkgPath => { const dataPath = path.join(pkgPath, 'package.json'); let data: any; try { data = utils.readJSONFile(dataPath); } catch (e) { return; } coreData.set(data.name, data); // If the package has a tokens.ts file, make sure it is noted as a singleton if ( fs.existsSync(path.join(pkgPath, 'src', 'tokens.ts')) && !singletonPackages.includes(data.name) ) { singletonPackages.push(data.name); } }); // These are not sorted when writing out by default singletonPackages.sort(); // Populate the yarn resolutions. First we make sure direct packages have // resolutions. coreData.forEach((data, name) => { // Insist on a restricted version in the yarn resolution. corePackage.resolutions[name] = `~${data.version}`; }); // Then fill in any missing packages that should be singletons from the direct // package dependencies. coreData.forEach(data => { if (data.dependencies) { Object.entries(data.dependencies).forEach(([dep, version]) => { if ( singletonPackages.includes(dep) && !(dep in corePackage.resolutions) ) { corePackage.resolutions[dep] = version; } }); } }); // At this point, each singleton should have a resolution. Check this. const unresolvedSingletons = singletonPackages.filter( pkg => !(pkg in corePackage.resolutions) ); if (unresolvedSingletons.length > 0) { throw new Error( `Singleton packages must have a resolved version number; these do not: ${unresolvedSingletons.join( ', ' )}` ); } coreData.forEach((data, name) => { // Determine if the package wishes to be included in the top-level // dependencies. const meta = data.jupyterlab; const keep = !!( meta && (meta.coreDependency || meta.extension || meta.mimeExtension) ); if (!keep) { return; } // Make sure it is included as a dependency. corePackage.dependencies[data.name] = `~${data.version}`; // Handle extensions. ['extension', 'mimeExtension'].forEach(item => { let ext = meta[item]; if (ext === true) { ext = ''; } if (typeof ext !== 'string') { return; } corePackage.jupyterlab[`${item}s`][name] = ext; }); }); utils.getLernaPaths().forEach(pkgPath => { const dataPath = path.join(pkgPath, 'package.json'); let data: any; try { data = utils.readJSONFile(dataPath); } catch (e) { return; } // Skip private packages. if (data.private === true) { return; } // watch all src, build, and test files in the Jupyterlab project const relativePath = utils.ensureUnixPathSep( path.join('..', path.relative(basePath, pkgPath)) ); corePackage.jupyterlab.linkedPackages[data.name] = relativePath; }); // Update the dev mode version. const curr = utils.getPythonVersion(); corePackage.jupyterlab.version = curr; // Write the package.json back to disk. if (utils.writePackageData(corePath, corePackage)) { return ['Updated dev mode']; } return []; }
Refinitiv/jupyterlab
buildutils/src/ensure-repo.ts
TypeScript
FunctionDeclaration
/** * Ensure buildutils and builder bin files are symlinked */ function ensureBuildUtils() { const basePath = path.resolve('.'); ['builder', 'buildutils'].forEach(packageName => { const utilsPackage = path.join(basePath, packageName, 'package.json'); const utilsData = utils.readJSONFile(utilsPackage); for (const name in utilsData.bin) { const src = path.join(basePath, packageName, utilsData.bin[name]); const dest = path.join(basePath, 'node_modules', '.bin', name); try { fs.lstatSync(dest); fs.removeSync(dest); } catch (e) { // no-op } fs.symlinkSync(src, dest, 'file'); fs.chmodSync(dest, 0o777); } }); }
Refinitiv/jupyterlab
buildutils/src/ensure-repo.ts
TypeScript
FunctionDeclaration
/** * Ensure the repo integrity. */ export async function ensureIntegrity(): Promise<boolean> { const messages: Dict<string[]> = {}; if (process.env.SKIP_INTEGRITY_CHECK === 'true') { console.log('Skipping integrity check'); return true; } // Handle branch integrity const branchMessages = ensureBranch(); if (branchMessages.length > 0) { messages['branch'] = branchMessages; } // Pick up all the package versions. const paths = utils.getLernaPaths(); // This package is not part of the workspaces but should be kept in sync. paths.push('./jupyterlab/tests/mock_packages/mimeextension'); const cssImports: Dict<string[]> = {}; const cssModuleImports: Dict<string[]> = {}; // Get the package graph. const graph = utils.getPackageGraph(); // Gather all of our package data and other metadata. paths.forEach(pkgPath => { // Read in the package.json. let data: any; try { data = utils.readJSONFile(path.join(pkgPath, 'package.json')); } catch (e) { console.error(e); return; } pkgData[data.name] = data; pkgPaths[data.name] = pkgPath; pkgNames[pkgPath] = data.name; locals[data.name] = pkgPath; }); // Build up an ordered list of CSS imports for each local package. Object.keys(locals).forEach(name => { const data = pkgData[name]; const deps: Dict<string> = data.dependencies || {}; const skip = SKIP_CSS[name] || []; // Initialize cssData with explicit css imports if available const cssData: Dict<string[]> = { ...(data.jupyterlab && data.jupyterlab.extraStyles) }; const cssModuleData: Dict<string[]> = { ...(data.jupyterlab && data.jupyterlab.extraStyles) }; // Add automatic dependency css Object.keys(deps).forEach(depName => { // Bail for skipped imports and known extra styles. if (skip.includes(depName) || depName in cssData) { return; } const depData = graph.getNodeData(depName) as any; if (typeof depData.style === 'string') { cssData[depName] = [depData.style]; } if (typeof depData.styleModule === 'string') { cssModuleData[depName] = [depData.styleModule]; } else if (typeof depData.style === 'string') { cssModuleData[depName] = [depData.style]; } }); // Get our CSS imports in dependency order. cssImports[name] = []; cssModuleImports[name] = []; graph.dependenciesOf(name).forEach(depName => { if (depName in cssData) { cssData[depName].forEach(cssPath => { cssImports[name].push(`${depName}/${cssPath}`); }); } if (depName in cssModuleData) { cssModuleData[depName].forEach(cssModulePath => { cssModuleImports[name].push(`${depName}/${cssModulePath}`); }); } }); }); // Update the metapackage. let pkgMessages = ensureMetaPackage(); if (pkgMessages.length > 0) { const pkgName = '@jupyterlab/metapackage'; if (!messages[pkgName]) { messages[pkgName] = []; } messages[pkgName] = messages[pkgName].concat(pkgMessages); } // Validate each package. for (const name in locals) { // application-top is handled elsewhere if (name === '@jupyterlab/application-top') { continue; } const unused = UNUSED[name] || []; // Allow jest-junit to be unused in the test suite. if (name.indexOf('@jupyterlab/test-') === 0) { unused.push('jest-junit'); } const options: IEnsurePackageOptions = { pkgPath: pkgPaths[name], data: pkgData[name], depCache, missing: MISSING[name], unused, locals, cssImports: cssImports[name], cssModuleImports: cssModuleImports[name], differentVersions: DIFFERENT_VERSIONS }; if (name === '@jupyterlab/metapackage') { options.noUnused = false; } const pkgMessages = await ensurePackage(options); if (pkgMessages.length > 0) { messages[name] = pkgMessages; } } // ensure the icon svg imports pkgMessages = await ensureUiComponents(pkgPaths['@jupyterlab/ui-components']); if (pkgMessages.length > 0) { const pkgName = '@jupyterlab/ui-components'; if (!messages[pkgName]) { messages[pkgName] = []; } messages[pkgName] = messages[pkgName].concat(pkgMessages); } // Handle the top level package. const corePath = path.resolve('.', 'package.json'); const coreData: any = utils.readJSONFile(corePath); if (utils.writePackageData(corePath, coreData)) { messages['top'] = ['Update package.json']; } // Handle the refs in the top level tsconfigdoc.json const tsConfigDocExclude = [ 'application-extension', 'metapackage', 'nbconvert-css' ]; const tsConfigdocPath = path.resolve('.', 'tsconfigdoc.json'); const tsConfigdocData = utils.readJSONFile(tsConfigdocPath); tsConfigdocData.references = utils .getCorePaths() .filter(pth => !tsConfigDocExclude.some(pkg => pth.includes(pkg))) .map(pth => { return { path: './' + path.relative('.', pth) }; }); utils.writeJSONFile(tsConfigdocPath, tsConfigdocData); // Handle buildutils ensureBuildUtils(); // Handle the JupyterLab application top package. pkgMessages = ensureJupyterlab(); if (pkgMessages.length > 0) { messages['@application/top'] = pkgMessages; } // Handle any messages. if (Object.keys(messages).length > 0) { console.debug(JSON.stringify(messages, null, 2)); if (process.argv.indexOf('--force') !== -1) { console.debug( '\n\nPlease run `jlpm run integrity` locally and commit the changes' ); process.exit(1); } utils.run('jlpm install'); console.debug('\n\nMade integrity changes!'); console.debug('Please commit the changes by running:'); console.debug('git commit -a -m "Package integrity updates"'); return false; } console.debug('Repo integrity verified!'); return true; }
Refinitiv/jupyterlab
buildutils/src/ensure-repo.ts
TypeScript
ArrowFunction
filePath => { return fileTypes.indexOf(path.extname(filePath)) !== -1; }
Refinitiv/jupyterlab
buildutils/src/ensure-repo.ts
TypeScript
ArrowFunction
filePath => { if (path.basename(filePath) === 'ensure-repo.ts') { return; } const oldData = fs.readFileSync(filePath, 'utf-8'); let newData = oldData; urlMap.forEach(section => { const test = new RegExp(section[0], 'g'); const replacer = section[1]; if (newData.match(test)) { newData = newData.replace(test, replacer); } }); // Make sure the root RTD links point to stable const badgeLink = '(http://jupyterlab.readthedocs.io/en/stable/)'; const toReplace = badgeLink.replace('stable', rtdVersion); if (badgeLink !== toReplace) { while (newData.indexOf(toReplace) !== -1) { newData = newData.replace(toReplace, badgeLink); } } if (newData !== oldData) { messages.push(`Overwriting ${filePath}`); fs.writeFileSync(filePath, newData, 'utf-8'); } }
Refinitiv/jupyterlab
buildutils/src/ensure-repo.ts
TypeScript
ArrowFunction
section => { const test = new RegExp(section[0], 'g'); const replacer = section[1]; if (newData.match(test)) { newData = newData.replace(test, replacer); } }
Refinitiv/jupyterlab
buildutils/src/ensure-repo.ts
TypeScript
ArrowFunction
filePath => { let workflowData = fs.readFileSync(filePath, 'utf-8'); const test = new RegExp(`\\[${source}\\]`, 'g'); if (workflowData.match(test)) { if (workflowData.match(test)![1] !== `[${target}]`) { messages.push(`Overwriting ${filePath}`); workflowData = workflowData.replace(test, `[${target}]`); fs.writeFileSync(filePath, workflowData, 'utf-8'); } } }
Refinitiv/jupyterlab
buildutils/src/ensure-repo.ts
TypeScript
ArrowFunction
pkgPath => { if (path.resolve(pkgPath) === path.resolve(mpPath)) { return; } const name = pkgNames[pkgPath]; if (!name) { return; } seen[name] = true; const data = pkgData[name]; let valid = true; // Ensure it is a dependency. if (!mpData.dependencies[name]) { valid = false; mpData.dependencies[name] = '^' + data.version; } if (!valid) { messages.push(`Updated: ${name}`); } }
Refinitiv/jupyterlab
buildutils/src/ensure-repo.ts
TypeScript
ArrowFunction
name => { if (!(name in seen)) { messages.push(`Removing dependency: ${name}`); delete mpData.dependencies[name]; } }
Refinitiv/jupyterlab
buildutils/src/ensure-repo.ts
TypeScript
ArrowFunction
pkgPath => { const dataPath = path.join(pkgPath, 'package.json'); let data: any; try { data = utils.readJSONFile(dataPath); } catch (e) { return; } coreData.set(data.name, data); // If the package has a tokens.ts file, make sure it is noted as a singleton if ( fs.existsSync(path.join(pkgPath, 'src', 'tokens.ts')) && !singletonPackages.includes(data.name) ) { singletonPackages.push(data.name); } }
Refinitiv/jupyterlab
buildutils/src/ensure-repo.ts
TypeScript
ArrowFunction
(data, name) => { // Insist on a restricted version in the yarn resolution. corePackage.resolutions[name] = `~${data.version}`; }
Refinitiv/jupyterlab
buildutils/src/ensure-repo.ts
TypeScript
ArrowFunction
data => { if (data.dependencies) { Object.entries(data.dependencies).forEach(([dep, version]) => { if ( singletonPackages.includes(dep) && !(dep in corePackage.resolutions) ) { corePackage.resolutions[dep] = version; } }); } }
Refinitiv/jupyterlab
buildutils/src/ensure-repo.ts
TypeScript
ArrowFunction
([dep, version]) => { if ( singletonPackages.includes(dep) && !(dep in corePackage.resolutions) ) { corePackage.resolutions[dep] = version; } }
Refinitiv/jupyterlab
buildutils/src/ensure-repo.ts
TypeScript
ArrowFunction
pkg => !(pkg in corePackage.resolutions)
Refinitiv/jupyterlab
buildutils/src/ensure-repo.ts
TypeScript
ArrowFunction
(data, name) => { // Determine if the package wishes to be included in the top-level // dependencies. const meta = data.jupyterlab; const keep = !!( meta && (meta.coreDependency || meta.extension || meta.mimeExtension) ); if (!keep) { return; } // Make sure it is included as a dependency. corePackage.dependencies[data.name] = `~${data.version}`; // Handle extensions. ['extension', 'mimeExtension'].forEach(item => { let ext = meta[item]; if (ext === true) { ext = ''; } if (typeof ext !== 'string') { return; } corePackage.jupyterlab[`${item}s`][name] = ext; }); }
Refinitiv/jupyterlab
buildutils/src/ensure-repo.ts
TypeScript
ArrowFunction
item => { let ext = meta[item]; if (ext === true) { ext = ''; } if (typeof ext !== 'string') { return; } corePackage.jupyterlab[`${item}s`][name] = ext; }
Refinitiv/jupyterlab
buildutils/src/ensure-repo.ts
TypeScript
ArrowFunction
pkgPath => { const dataPath = path.join(pkgPath, 'package.json'); let data: any; try { data = utils.readJSONFile(dataPath); } catch (e) { return; } // Skip private packages. if (data.private === true) { return; } // watch all src, build, and test files in the Jupyterlab project const relativePath = utils.ensureUnixPathSep( path.join('..', path.relative(basePath, pkgPath)) ); corePackage.jupyterlab.linkedPackages[data.name] = relativePath; }
Refinitiv/jupyterlab
buildutils/src/ensure-repo.ts
TypeScript
ArrowFunction
packageName => { const utilsPackage = path.join(basePath, packageName, 'package.json'); const utilsData = utils.readJSONFile(utilsPackage); for (const name in utilsData.bin) { const src = path.join(basePath, packageName, utilsData.bin[name]); const dest = path.join(basePath, 'node_modules', '.bin', name); try { fs.lstatSync(dest); fs.removeSync(dest); } catch (e) { // no-op } fs.symlinkSync(src, dest, 'file'); fs.chmodSync(dest, 0o777); } }
Refinitiv/jupyterlab
buildutils/src/ensure-repo.ts
TypeScript
ArrowFunction
pkgPath => { // Read in the package.json. let data: any; try { data = utils.readJSONFile(path.join(pkgPath, 'package.json')); } catch (e) { console.error(e); return; } pkgData[data.name] = data; pkgPaths[data.name] = pkgPath; pkgNames[pkgPath] = data.name; locals[data.name] = pkgPath; }
Refinitiv/jupyterlab
buildutils/src/ensure-repo.ts
TypeScript
ArrowFunction
name => { const data = pkgData[name]; const deps: Dict<string> = data.dependencies || {}; const skip = SKIP_CSS[name] || []; // Initialize cssData with explicit css imports if available const cssData: Dict<string[]> = { ...(data.jupyterlab && data.jupyterlab.extraStyles) }; const cssModuleData: Dict<string[]> = { ...(data.jupyterlab && data.jupyterlab.extraStyles) }; // Add automatic dependency css Object.keys(deps).forEach(depName => { // Bail for skipped imports and known extra styles. if (skip.includes(depName) || depName in cssData) { return; } const depData = graph.getNodeData(depName) as any; if (typeof depData.style === 'string') { cssData[depName] = [depData.style]; } if (typeof depData.styleModule === 'string') { cssModuleData[depName] = [depData.styleModule]; } else if (typeof depData.style === 'string') { cssModuleData[depName] = [depData.style]; } }); // Get our CSS imports in dependency order. cssImports[name] = []; cssModuleImports[name] = []; graph.dependenciesOf(name).forEach(depName => { if (depName in cssData) { cssData[depName].forEach(cssPath => { cssImports[name].push(`${depName}/${cssPath}`); }); } if (depName in cssModuleData) { cssModuleData[depName].forEach(cssModulePath => { cssModuleImports[name].push(`${depName}/${cssModulePath}`); }); } }); }
Refinitiv/jupyterlab
buildutils/src/ensure-repo.ts
TypeScript
ArrowFunction
depName => { // Bail for skipped imports and known extra styles. if (skip.includes(depName) || depName in cssData) { return; } const depData = graph.getNodeData(depName) as any; if (typeof depData.style === 'string') { cssData[depName] = [depData.style]; } if (typeof depData.styleModule === 'string') { cssModuleData[depName] = [depData.styleModule]; } else if (typeof depData.style === 'string') { cssModuleData[depName] = [depData.style]; } }
Refinitiv/jupyterlab
buildutils/src/ensure-repo.ts
TypeScript
ArrowFunction
depName => { if (depName in cssData) { cssData[depName].forEach(cssPath => { cssImports[name].push(`${depName}/${cssPath}`); }); } if (depName in cssModuleData) { cssModuleData[depName].forEach(cssModulePath => { cssModuleImports[name].push(`${depName}/${cssModulePath}`); }); } }
Refinitiv/jupyterlab
buildutils/src/ensure-repo.ts
TypeScript
ArrowFunction
cssPath => { cssImports[name].push(`${depName}/${cssPath}`); }
Refinitiv/jupyterlab
buildutils/src/ensure-repo.ts
TypeScript
ArrowFunction
cssModulePath => { cssModuleImports[name].push(`${depName}/${cssModulePath}`); }
Refinitiv/jupyterlab
buildutils/src/ensure-repo.ts
TypeScript
ArrowFunction
pth => !tsConfigDocExclude.some(pkg => pth.includes(pkg))
Refinitiv/jupyterlab
buildutils/src/ensure-repo.ts
TypeScript
ArrowFunction
pkg => pth.includes(pkg)
Refinitiv/jupyterlab
buildutils/src/ensure-repo.ts
TypeScript
ArrowFunction
pth => { return { path: './' + path.relative('.', pth) }; }
Refinitiv/jupyterlab
buildutils/src/ensure-repo.ts
TypeScript
TypeAliasDeclaration
type Dict<T> = { [key: string]: T };
Refinitiv/jupyterlab
buildutils/src/ensure-repo.ts
TypeScript
InterfaceDeclaration
export interface IPayloadParselizer { parse(buffer: Buffer): PayloadType | null; serialize(payload: Exclude<PayloadType, null>): Buffer | null; }
bghtrbb/metekcity
packages/esn00-packet/src/lib/payloads/index.ts
TypeScript
TypeAliasDeclaration
export type PayloadType = Exclude<number | boolean | IMeasurement, null>;
bghtrbb/metekcity
packages/esn00-packet/src/lib/payloads/index.ts
TypeScript
ArrowFunction
(request: FinalizeHandlerArguments<any>) => requestHandler.handle(request.request as __HttpRequest, options || {})
Sordie/aws-sdk-js-v3
clients/client-lightsail/src/commands/GetInstancePortStatesCommand.ts
TypeScript
ClassDeclaration
/** * <p>Returns the firewall port states for a specific Amazon Lightsail instance, the IP addresses * allowed to connect to the instance through the ports, and the protocol.</p> * @example * Use a bare-bones client and the command you need to make an API call. * ```javascript * import { LightsailClient, GetInstancePortStatesCommand } from "@aws-sdk/client-lightsail"; // ES Modules import * // const { LightsailClient, GetInstancePortStatesCommand } = require("@aws-sdk/client-lightsail"); // CommonJS import * const client = new LightsailClient(config); * const command = new GetInstancePortStatesCommand(input); * const response = await client.send(command); * ``` * * @see {@link GetInstancePortStatesCommandInput} for command's `input` shape. * @see {@link GetInstancePortStatesCommandOutput} for command's `response` shape. * @see {@link LightsailClientResolvedConfig | config} for command's `input` shape. * */ export class GetInstancePortStatesCommand extends $Command< GetInstancePortStatesCommandInput, GetInstancePortStatesCommandOutput, LightsailClientResolvedConfig > { // Start section: command_properties // End section: command_properties constructor(readonly input: GetInstancePortStatesCommandInput) { // Start section: command_constructor super(); // End section: command_constructor } /** * @internal */ resolveMiddleware( clientStack: MiddlewareStack<ServiceInputTypes, ServiceOutputTypes>, configuration: LightsailClientResolvedConfig, options?: __HttpHandlerOptions ): Handler<GetInstancePortStatesCommandInput, GetInstancePortStatesCommandOutput> { this.middlewareStack.use(getSerdePlugin(configuration, this.serialize, this.deserialize)); const stack = clientStack.concat(this.middlewareStack); const { logger } = configuration; const clientName = "LightsailClient"; const commandName = "GetInstancePortStatesCommand"; const handlerExecutionContext: HandlerExecutionContext = { logger, clientName, commandName, inputFilterSensitiveLog: GetInstancePortStatesRequest.filterSensitiveLog, outputFilterSensitiveLog: GetInstancePortStatesResult.filterSensitiveLog, }; const { requestHandler } = configuration; return stack.resolve( (request: FinalizeHandlerArguments<any>) => requestHandler.handle(request.request as __HttpRequest, options || {}), handlerExecutionContext ); } private serialize(input: GetInstancePortStatesCommandInput, context: __SerdeContext): Promise<__HttpRequest> { return serializeAws_json1_1GetInstancePortStatesCommand(input, context); } private deserialize(output: __HttpResponse, context: __SerdeContext): Promise<GetInstancePortStatesCommandOutput> { return deserializeAws_json1_1GetInstancePortStatesCommand(output, context); } // Start section: command_body_extra // End section: command_body_extra }
Sordie/aws-sdk-js-v3
clients/client-lightsail/src/commands/GetInstancePortStatesCommand.ts
TypeScript
InterfaceDeclaration
export interface GetInstancePortStatesCommandInput extends GetInstancePortStatesRequest {}
Sordie/aws-sdk-js-v3
clients/client-lightsail/src/commands/GetInstancePortStatesCommand.ts
TypeScript
InterfaceDeclaration
export interface GetInstancePortStatesCommandOutput extends GetInstancePortStatesResult, __MetadataBearer {}
Sordie/aws-sdk-js-v3
clients/client-lightsail/src/commands/GetInstancePortStatesCommand.ts
TypeScript
MethodDeclaration
/** * @internal */ resolveMiddleware( clientStack: MiddlewareStack<ServiceInputTypes, ServiceOutputTypes>, configuration: LightsailClientResolvedConfig, options?: __HttpHandlerOptions ): Handler<GetInstancePortStatesCommandInput, GetInstancePortStatesCommandOutput> { this.middlewareStack.use(getSerdePlugin(configuration, this.serialize, this.deserialize)); const stack = clientStack.concat(this.middlewareStack); const { logger } = configuration; const clientName = "LightsailClient"; const commandName = "GetInstancePortStatesCommand"; const handlerExecutionContext: HandlerExecutionContext = { logger, clientName, commandName, inputFilterSensitiveLog: GetInstancePortStatesRequest.filterSensitiveLog, outputFilterSensitiveLog: GetInstancePortStatesResult.filterSensitiveLog, }; const { requestHandler } = configuration; return stack.resolve( (request: FinalizeHandlerArguments<any>) => requestHandler.handle(request.request as __HttpRequest, options || {}), handlerExecutionContext ); }
Sordie/aws-sdk-js-v3
clients/client-lightsail/src/commands/GetInstancePortStatesCommand.ts
TypeScript
MethodDeclaration
private serialize(input: GetInstancePortStatesCommandInput, context: __SerdeContext): Promise<__HttpRequest> { return serializeAws_json1_1GetInstancePortStatesCommand(input, context); }
Sordie/aws-sdk-js-v3
clients/client-lightsail/src/commands/GetInstancePortStatesCommand.ts
TypeScript
MethodDeclaration
private deserialize(output: __HttpResponse, context: __SerdeContext): Promise<GetInstancePortStatesCommandOutput> { return deserializeAws_json1_1GetInstancePortStatesCommand(output, context); }
Sordie/aws-sdk-js-v3
clients/client-lightsail/src/commands/GetInstancePortStatesCommand.ts
TypeScript
ArrowFunction
(req, res) => { res.send({"username":"admin","locale":"en"}) }
Haulmont/jmix-frontend
packages/jmix-server-mock/src/rest.ts
TypeScript
ArrowFunction
(req, res) => { res.send({ "entities": [], "entityAttributes": [], "specifics": [{"target": "rest.fileDownload.enabled", "value": 1}, { "target": "rest.fileUpload.enabled", "value": 1 }] }) }
Haulmont/jmix-frontend
packages/jmix-server-mock/src/rest.ts
TypeScript
ArrowFunction
(req, res) => { res.send({}) }
Haulmont/jmix-frontend
packages/jmix-server-mock/src/rest.ts
TypeScript
ArrowFunction
res => { if (res) { this.flashMessage.showFlashMessage({ messages: ['Your account successfully created, Let\'s get logged in!'], dismissible: true, timeout: 4000, type: 'success' }); this.router.navigate(['login']); form.resetForm(); return true; } else { this.flashMessage.showFlashMessage({ messages: ['Something went wrong!'], dismissible: true, timeout: 4000, type: 'danger' }); this.router.navigate(['dashboard']); return false; } }
b-lor/B2BCustomerPortal
.history/Portal/src/app/user/sign-up/sign-up.component_20190220111918.ts
TypeScript
ClassDeclaration
@Component({ selector: 'app-sign-up', templateUrl: './sign-up.component.html', styleUrls: ['./sign-up.component.css'] }) export class SignUpComponent implements OnInit { // tslint:disable-next-line:max-line-length emailRegex = /^(([^<>()\[\]\\.,;:\s@"]+(\.[^<>()\[\]\\.,;:\s@"]+)*)|(".+"))@((\[[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\])|(([a-zA-Z\-0-9]+\.)+[a-zA-Z]{2,}))$/; showSuccessMessage: boolean; serverErrorMessages: string; constructor(private userService: UserService, private validateService: ValidateService, private flashMessage: NgFlashMessageService, private router: Router) {} ngOnInit() {} onHandleSubmit(form: NgForm) { const user = { email: form.value.email, username: form.value.username, password: form.value.password, password2: form.value.password2 }; if (!this.validateService.validateEmail(user.email)) { this.flashMessage.showFlashMessage({ messages: ['Invalid Email Id!'], dismissible: true, timeout: 4000, type: 'danger' }); return false; } if (!this.validateService.validateUsername(user.username)) { this.flashMessage.showFlashMessage({ messages: ['Invalid Username!'], dismissible: true, timeout: 4000, type: 'danger' }); return false; } if (!this.validateService.validatePassword(user.password, user.password2)) { this.flashMessage.showFlashMessage({ messages: ['Password not matched!'], dismissible: true, timeout: 4000, type: 'danger' }); return false; } this.userService.postUser(form.value).subscribe(res => { if (res) { this.flashMessage.showFlashMessage({ messages: ['Your account successfully created, Let\'s get logged in!'], dismissible: true, timeout: 4000, type: 'success' }); this.router.navigate(['login']); form.resetForm(); return true; } else { this.flashMessage.showFlashMessage({ messages: ['Something went wrong!'], dismissible: true, timeout: 4000, type: 'danger' }); this.router.navigate(['dashboard']); return false; } }); // onSubmit(form: NgForm) { // this.userService.postUser(form.value).subscribe( // res => { // this.showSuccessMessage = true; // setTimeout(() => (this.showSuccessMessage = false), 4000); // this.resetForm(form); // }, // err => { // if (err.status === 422) { // this.serverErrorMessages = err.error.join('<br/>'); // } else { // this.serverErrorMessages = // 'Something went wrong. Please contact the Admin.'; // } // } // ); // } // resetForm(form: NgForm) { // this.userService.selectedUser = { // _id: '', // email: '', // password: '' // }; // form.resetForm(); // this.serverErrorMessages = ''; // } } }
b-lor/B2BCustomerPortal
.history/Portal/src/app/user/sign-up/sign-up.component_20190220111918.ts
TypeScript
MethodDeclaration
ngOnInit() {}
b-lor/B2BCustomerPortal
.history/Portal/src/app/user/sign-up/sign-up.component_20190220111918.ts
TypeScript
MethodDeclaration
onHandleSubmit(form: NgForm) { const user = { email: form.value.email, username: form.value.username, password: form.value.password, password2: form.value.password2 }; if (!this.validateService.validateEmail(user.email)) { this.flashMessage.showFlashMessage({ messages: ['Invalid Email Id!'], dismissible: true, timeout: 4000, type: 'danger' }); return false; } if (!this.validateService.validateUsername(user.username)) { this.flashMessage.showFlashMessage({ messages: ['Invalid Username!'], dismissible: true, timeout: 4000, type: 'danger' }); return false; } if (!this.validateService.validatePassword(user.password, user.password2)) { this.flashMessage.showFlashMessage({ messages: ['Password not matched!'], dismissible: true, timeout: 4000, type: 'danger' }); return false; } this.userService.postUser(form.value).subscribe(res => { if (res) { this.flashMessage.showFlashMessage({ messages: ['Your account successfully created, Let\'s get logged in!'], dismissible: true, timeout: 4000, type: 'success' }); this.router.navigate(['login']); form.resetForm(); return true; } else { this.flashMessage.showFlashMessage({ messages: ['Something went wrong!'], dismissible: true, timeout: 4000, type: 'danger' }); this.router.navigate(['dashboard']); return false; } }); // onSubmit(form: NgForm) { // this.userService.postUser(form.value).subscribe( // res => { // this.showSuccessMessage = true; // setTimeout(() => (this.showSuccessMessage = false), 4000); // this.resetForm(form); // }, // err => { // if (err.status === 422) { // this.serverErrorMessages = err.error.join('<br/>'); // } else { // this.serverErrorMessages = // 'Something went wrong. Please contact the Admin.'; // } // } // ); // } // resetForm(form: NgForm) { // this.userService.selectedUser = { // _id: '', // email: '', // password: '' // }; // form.resetForm(); // this.serverErrorMessages = ''; // } }
b-lor/B2BCustomerPortal
.history/Portal/src/app/user/sign-up/sign-up.component_20190220111918.ts
TypeScript
ClassDeclaration
export default class TestAnimation extends ThreeAnimation { vShader = ` precision mediump float; precision mediump int; uniform mat4 modelViewMatrix; // optional uniform mat4 projectionMatrix; // optional attribute vec3 position; varying vec3 vPosition; void main() { vPosition = position; gl_Position = projectionMatrix * modelViewMatrix * vec4( position, 1.0 ); }` fShader = ` precision mediump float; precision mediump int; uniform float time; varying vec3 vPosition; void main() { vec4 color = vec4( vPosition, 1.0); color.r += sin( time * 0.01 ) * 0.5; gl_FragColor = color; }` material : THREE.RawShaderMaterial = new THREE.RawShaderMaterial( { uniforms: { time: { value: this.currentTime } }, vertexShader: this.vShader, fragmentShader: this.fShader, side: THREE.DoubleSide, transparent: true } ); constructor(element : HTMLElement) { super(element); // nr of triangles with 3 vertices per triangle const vertexCount = 200 * 3; const geometry = new THREE.BufferGeometry(); const positions = []; for ( let i = 0; i < vertexCount; i ++ ) { // adding x,y,z positions.push( Math.random() - 0.5 ); positions.push( Math.random() - 0.5 ); positions.push( Math.random() - 0.5 ); } const positionAttribute = new THREE.Float32BufferAttribute( positions, 3 ); geometry.setAttribute( 'position', positionAttribute ); const mesh = new THREE.Mesh( geometry, this.material ); this.scene.add(mesh); } update(_ : number) : void { this.material.uniforms.time.value = this.currentTime; } }
JRoper18/channels
src/animations/testanimation.ts
TypeScript
MethodDeclaration
update(_ : number) : void { this.material.uniforms.time.value = this.currentTime; }
JRoper18/channels
src/animations/testanimation.ts
TypeScript
ArrowFunction
() => { it('happy', () => { const result = renameProps(rules, input) result // $ExpectType object }) it('curried', () => { const result = renameProps(rules)(input) result // $ExpectType object }) }
Paqmind/rambda
source/renameProps-spec.ts
TypeScript
ArrowFunction
() => { const result = renameProps(rules, input) result // $ExpectType object }
Paqmind/rambda
source/renameProps-spec.ts
TypeScript
ArrowFunction
() => { const result = renameProps(rules)(input) result // $ExpectType object }
Paqmind/rambda
source/renameProps-spec.ts
TypeScript
ArrowFunction
() => { interface Output { foo: number, bar: number, } it('happy', () => { const result = renameProps<Output>(rules, input) result // $ExpectType Output }) it('curried', () => { const result = renameProps<Output>(rules)(input) result // $ExpectType Output }) }
Paqmind/rambda
source/renameProps-spec.ts
TypeScript
ArrowFunction
() => { const result = renameProps<Output>(rules, input) result // $ExpectType Output }
Paqmind/rambda
source/renameProps-spec.ts
TypeScript
ArrowFunction
() => { const result = renameProps<Output>(rules)(input) result // $ExpectType Output }
Paqmind/rambda
source/renameProps-spec.ts
TypeScript