type
stringclasses
7 values
content
stringlengths
4
9.55k
repo
stringlengths
7
96
path
stringlengths
4
178
language
stringclasses
1 value
FunctionDeclaration
function Decorator() { const reduxErKlar = useVenterPaRedux(); const valgtEnhet = useAppState(state => state.session.valgtEnhetId); const history = useHistory(); const dispatch = useDispatch(); const queryParams = useQueryParams<{ sokFnr?: string }>(); useHandleGosysUrl(); useOnMount(() => { if (queryParams.sokFnr) { loggEvent('Oppslag', 'Puzzle'); } }); const handleSetEnhet = (enhet: string) => { dispatch(velgEnhetAction(enhet)); }; const config = useCallback(lagConfig, [valgtEnhet, history, handleSetEnhet])(valgtEnhet, history, handleSetEnhet); return ( <StyledNav> {reduxErKlar && ( <> <InternflateDecorator {...config} /> <PersonsokContainer /> <HurtigtastTipsContainer /> <OppdateringsloggContainer /> <DecoratorEasterEgg /> </> )}
navikt/modiapersonoversikt
src/app/internarbeidsflatedecorator/Decorator.tsx
TypeScript
ArrowFunction
() => { setKlar(true); }
navikt/modiapersonoversikt
src/app/internarbeidsflatedecorator/Decorator.tsx
TypeScript
ArrowFunction
state => state.session.valgtEnhetId
navikt/modiapersonoversikt
src/app/internarbeidsflatedecorator/Decorator.tsx
TypeScript
ArrowFunction
() => { if (queryParams.sokFnr) { loggEvent('Oppslag', 'Puzzle'); } }
navikt/modiapersonoversikt
src/app/internarbeidsflatedecorator/Decorator.tsx
TypeScript
ArrowFunction
(enhet: string) => { dispatch(velgEnhetAction(enhet)); }
navikt/modiapersonoversikt
src/app/internarbeidsflatedecorator/Decorator.tsx
TypeScript
MethodDeclaration
onChange(fnr: string | null): void { if (fnr === getFnrFraUrl().pathFnr) { return; } if (fnr && fnr.length > 0) { setNyBrukerIPath(history, fnr); } else { fjernBrukerFraPath(history); } }
navikt/modiapersonoversikt
src/app/internarbeidsflatedecorator/Decorator.tsx
TypeScript
MethodDeclaration
onChange(enhet: string | null): void { if (enhet) { settEnhet(enhet); } }
navikt/modiapersonoversikt
src/app/internarbeidsflatedecorator/Decorator.tsx
TypeScript
ArrowFunction
() => { beforeEach(async(() => { TestBed.configureTestingModule({ imports: [ RouterTestingModule ], declarations: [ AppComponent ], }).compileComponents(); })); it('should create the app', () => { const fixture = TestBed.createComponent(AppComponent); const app = fixture.componentInstance; expect(app).toBeTruthy(); }); it(`should have as title 'dev-todo'`, () => { const fixture = TestBed.createComponent(AppComponent); const app = fixture.componentInstance; expect(app.title).toEqual('dev-todo'); }); it('should render title', () => { const fixture = TestBed.createComponent(AppComponent); fixture.detectChanges(); const compiled = fixture.nativeElement; expect(compiled.querySelector('.content span').textContent).toContain('dev-todo app is running!'); }); }
hadzhiyski/dev-todo
client/src/app/app.component.spec.ts
TypeScript
ArrowFunction
() => { TestBed.configureTestingModule({ imports: [ RouterTestingModule ], declarations: [ AppComponent ], }).compileComponents(); }
hadzhiyski/dev-todo
client/src/app/app.component.spec.ts
TypeScript
ArrowFunction
() => { const fixture = TestBed.createComponent(AppComponent); const app = fixture.componentInstance; expect(app).toBeTruthy(); }
hadzhiyski/dev-todo
client/src/app/app.component.spec.ts
TypeScript
ArrowFunction
() => { const fixture = TestBed.createComponent(AppComponent); const app = fixture.componentInstance; expect(app.title).toEqual('dev-todo'); }
hadzhiyski/dev-todo
client/src/app/app.component.spec.ts
TypeScript
ArrowFunction
() => { const fixture = TestBed.createComponent(AppComponent); fixture.detectChanges(); const compiled = fixture.nativeElement; expect(compiled.querySelector('.content span').textContent).toContain('dev-todo app is running!'); }
hadzhiyski/dev-todo
client/src/app/app.component.spec.ts
TypeScript
ArrowFunction
() => ({ currentUserId: userId, formMode: 'login', // login/regiser formType: '', modalConfirmData: { targetType: null, targetId: null, name: null, }, modalFormData: { name: '', slug: '', url: '', desc: '', tags: [], }, modalFormDataTx: { name: '', }, modalFormMeta: { target: null, // item id: null, // itemid cat_id: null, isEditing: null, }, modalFormMetaTx: { targetTax: null, // cat/tag taxId: null, isEditing: null, }, isModalOpen: false, isModalConfirmOpen: false, isModalAccountOpen: false, })
Uvacoder/bm-vuer
packages/bm-vuer/src/stores/forms.ts
TypeScript
ArrowFunction
(state) => { return state.formType }
Uvacoder/bm-vuer
packages/bm-vuer/src/stores/forms.ts
TypeScript
ArrowFunction
(state) => { return state.formMode }
Uvacoder/bm-vuer
packages/bm-vuer/src/stores/forms.ts
TypeScript
ArrowFunction
(state) => { return state.modalConfirmData }
Uvacoder/bm-vuer
packages/bm-vuer/src/stores/forms.ts
TypeScript
ArrowFunction
(state) => { return state.modalFormData }
Uvacoder/bm-vuer
packages/bm-vuer/src/stores/forms.ts
TypeScript
ArrowFunction
(state) => { return state.modalFormMeta }
Uvacoder/bm-vuer
packages/bm-vuer/src/stores/forms.ts
TypeScript
ArrowFunction
(state) => { return state.modalFormDataTx }
Uvacoder/bm-vuer
packages/bm-vuer/src/stores/forms.ts
TypeScript
ArrowFunction
(state) => { return state.modalFormMetaTx }
Uvacoder/bm-vuer
packages/bm-vuer/src/stores/forms.ts
TypeScript
MethodDeclaration
CRUDHandler(data, isDeleting = false) { if (isDeleting) { const { dataObj } = data const id = dataObj.targetId // COLLECTION ITEMS / TAXONOMY ITEMS return dataObj.targetType === 'item' ? deleteSingleItem(id) : dataObj.targetType === 'cat' ? deleteCatWithAllItems(dataObj) : deleteSingleTag(id) } else { const { dataObj, formId, isEditing } = data // item form if (formId === 'itemForm') { isEditing ? updateCollectionItem(dataObj, userId) : addCollectionItemAndMaybeTags(dataObj, userId) } else { // cat from const tax = formId === 'catForm' ? 'cat' : 'tag' isEditing ? updateTaxonomyItem(dataObj, tax, userId) : addTaxonomyItem(dataObj, tax, userId) } } }
Uvacoder/bm-vuer
packages/bm-vuer/src/stores/forms.ts
TypeScript
MethodDeclaration
openModalTx(targetTax, taxId, name, isEditing) { this.formType = 'taxForm' this.isModalOpen = true this.modalFormMetaTx.isEditing = isEditing this.modalFormMetaTx.targetTax = targetTax this.modalFormMetaTx.taxId = taxId this.modalFormDataTx.name = name }
Uvacoder/bm-vuer
packages/bm-vuer/src/stores/forms.ts
TypeScript
MethodDeclaration
openModal(target, item_id, item, cat_id, isEditing) { this.formType = 'itemForm' this.isModalOpen = true this.modalFormMeta.isEditing = isEditing this.modalFormMeta.target = target this.modalFormMeta.id = item_id this.modalFormMeta.cat_id = cat_id if (item) { // skip for adding new item this.modalFormData.name = item.name this.modalFormData.slug = item.slug this.modalFormData.url = item.url this.modalFormData.desc = item.desc this.modalFormData.tags = item.items_tags } }
Uvacoder/bm-vuer
packages/bm-vuer/src/stores/forms.ts
TypeScript
MethodDeclaration
openModalConfirm(targetType, targetId, name) { this.isModalConfirmOpen = true this.modalConfirmData.targetType = targetType this.modalConfirmData.targetId = targetId this.modalConfirmData.name = name }
Uvacoder/bm-vuer
packages/bm-vuer/src/stores/forms.ts
TypeScript
MethodDeclaration
openModalAccount(targetAction) { this.formType = (targetAction === 'login') ? 'loginForm' : 'registerForm' this.isModalAccountOpen = true }
Uvacoder/bm-vuer
packages/bm-vuer/src/stores/forms.ts
TypeScript
MethodDeclaration
closeModalAccount() { this.isModalAccountOpen = false }
Uvacoder/bm-vuer
packages/bm-vuer/src/stores/forms.ts
TypeScript
MethodDeclaration
closeModalConfirm() { this.isModalConfirmOpen = false }
Uvacoder/bm-vuer
packages/bm-vuer/src/stores/forms.ts
TypeScript
MethodDeclaration
closeModal() { this.isModalOpen = !this.isModalOpen }
Uvacoder/bm-vuer
packages/bm-vuer/src/stores/forms.ts
TypeScript
FunctionDeclaration
/** * write a byte to special address * @param addr eeprom address, eg: 1 * @param dat is the data will be write, eg: 5 */ //% blockId="AT24_WriteByte" block="eeprom address %addr|write byte %dat" //% weight=100 blockGap=8 export function write_byte(addr: number, dat: number): void { let buf = pins.createBuffer(3); buf[0] = addr >> 8; buf[1] = addr; buf[2] = dat; pins.i2cWriteBuffer(AT24_I2C_ADDR, buf) }
STEM-Power/EEPROM_AT24C
AT24CXX.ts
TypeScript
FunctionDeclaration
/** * read a byte from special address * @param addr eeprom address, eg: 1 */ //% blockId="AT24_ReadByte" block="read byte from address %addr" //% weight=99 blockGap=8 export function read_byte(addr: number): number { pins.i2cWriteNumber(AT24_I2C_ADDR, addr, NumberFormat.UInt16BE); return pins.i2cReadNumber(AT24_I2C_ADDR, NumberFormat.UInt8BE); }
STEM-Power/EEPROM_AT24C
AT24CXX.ts
TypeScript
FunctionDeclaration
/** * write a word to special address * @param addr eeprom address, eg: 2 * @param dat is the data will be write, eg: 6 */ //% blockId="AT24_WriteWord" block="eeprom address %addr|write word %dat" //% weight=90 blockGap=8 export function write_word(addr: number, dat: number): void { let buf = pins.createBuffer(4); buf[0] = addr >> 8; buf[1] = addr; buf[2] = dat >> 8; buf[3] = dat; pins.i2cWriteBuffer(AT24_I2C_ADDR, buf) }
STEM-Power/EEPROM_AT24C
AT24CXX.ts
TypeScript
FunctionDeclaration
/** * read a word from special address * @param addr eeprom address, eg: 2 */ //% blockId="AT24_ReadWord" block="read word from address %addr" //% weight=89 blockGap=8 export function read_word(addr: number): number { pins.i2cWriteNumber(AT24_I2C_ADDR, addr, NumberFormat.UInt16BE); return pins.i2cReadNumber(AT24_I2C_ADDR, NumberFormat.UInt16BE); }
STEM-Power/EEPROM_AT24C
AT24CXX.ts
TypeScript
FunctionDeclaration
/** * write a dword to special address * @param addr eeprom address, eg: 4 * @param dat is the data will be write, eg: 7 */ //% blockId="AT24_WriteDWord" block="eeprom address %addr|write dword %dat" //% weight=80 blockGap=8 export function write_dword(addr: number, dat: number): void { let buf = pins.createBuffer(6); buf[0] = addr >> 8; buf[1] = addr; buf[2] = dat >> 24; buf[3] = dat >> 16; buf[4] = dat >> 8; buf[5] = dat; pins.i2cWriteBuffer(AT24_I2C_ADDR, buf) }
STEM-Power/EEPROM_AT24C
AT24CXX.ts
TypeScript
FunctionDeclaration
/** * read a dword from special address * @param addr eeprom address, eg: 4 */ //% blockId="AT24_ReadDWord" block="read dword from address %addr" //% weight=79 blockGap=8 export function read_dword(addr: number): number { pins.i2cWriteNumber(AT24_I2C_ADDR, addr, NumberFormat.UInt16BE); return pins.i2cReadNumber(AT24_I2C_ADDR, NumberFormat.Int32BE); }
STEM-Power/EEPROM_AT24C
AT24CXX.ts
TypeScript
TypeAliasDeclaration
type Network = { rpcUrl: string; explorerUrl: string; explorerApiUrl: string; }
BeanstalkFarms/louper
config/index.ts
TypeScript
FunctionDeclaration
/** * Render text based on stuff * @param {String} text - Nunjucks template in text form * @param {Object} [config] - Config options for rendering * @param {Object} [config.context] - Context to render with * @param {Object} [config.path] - Path to include in the error message * @param {Object} [config.renderMode] - Only render variables (not tags) */ export function render( text: string, config: { context?: Record<string, any>; path?: string; renderMode?: string; } = {}, ) { const context = config.context || {}; // context needs to exist on the root for the old templating syntax, and in _ for the new templating syntax // old: {{ arr[0].prop }} // new: {{ _['arr-name-with-dash'][0].prop }} const templatingContext = { ...context, [NUNJUCKS_TEMPLATE_GLOBAL_PROPERTY_NAME]: context }; const path = config.path || null; const renderMode = config.renderMode || RENDER_ALL; return new Promise<string | null>(async (resolve, reject) => { const nj = await getNunjucks(renderMode); nj?.renderString(text, templatingContext, (err, result) => { if (err) { const sanitizedMsg = err.message .replace(/\(unknown path\)\s/, '') .replace(/\[Line \d+, Column \d*]/, '') .replace(/^\s*Error:\s*/, '') .trim(); const location = err.message.match(/\[Line (\d)+, Column (\d)*]/); const line = location ? parseInt(location[1]) : 1; const column = location ? parseInt(location[2]) : 1; const reason = err.message.includes('attempted to output null or undefined value') ? 'undefined' : 'error'; const newError = new RenderError(sanitizedMsg); newError.path = path || ''; newError.message = sanitizedMsg; newError.location = { line, column, }; newError.type = 'render'; newError.reason = reason; reject(newError); } else { resolve(result); } }); }); }
aeri/insomnia
packages/insomnia-app/app/templating/index.ts
TypeScript
FunctionDeclaration
/** * Reload Nunjucks environments. Useful for if plugins change. */ export function reload() { nunjucksAll = null; nunjucksVariablesOnly = null; nunjucksTagsOnly = null; }
aeri/insomnia
packages/insomnia-app/app/templating/index.ts
TypeScript
FunctionDeclaration
/** * Get definitions of template tags */ export async function getTagDefinitions() { const env = await getNunjucks(RENDER_ALL); // @ts-expect-error -- TSCONVERSION investigate why `extensions` isn't on Environment return Object.keys(env.extensions) // @ts-expect-error -- TSCONVERSION investigate why `extensions` isn't on Environment .map(k => env.extensions[k]) .filter(ext => !ext.isDeprecated()) .sort((a, b) => (a.getPriority() > b.getPriority() ? 1 : -1)) .map<NunjucksParsedTag>(ext => ({ name: ext.getTag(), displayName: ext.getName(), liveDisplayName: ext.getLiveDisplayName(), description: ext.getDescription(), disablePreview: ext.getDisablePreview(), args: ext.getArgs(), actions: ext.getActions(), })); }
aeri/insomnia
packages/insomnia-app/app/templating/index.ts
TypeScript
FunctionDeclaration
async function getNunjucks(renderMode: string) { if (renderMode === RENDER_VARS && nunjucksVariablesOnly) { return nunjucksVariablesOnly; } if (renderMode === RENDER_TAGS && nunjucksTagsOnly) { return nunjucksTagsOnly; } if (renderMode === RENDER_ALL && nunjucksAll) { return nunjucksAll; } // ~~~~~~~~~~~~ // // Setup Config // // ~~~~~~~~~~~~ // const config = { autoescape: false, // Don't escape HTML throwOnUndefined: true, // Strict mode tags: { blockStart: '{%', blockEnd: '%}', variableStart: '{{', variableEnd: '}}', commentStart: '{#', commentEnd: '#}', }, }; if (renderMode === RENDER_VARS) { // Set tag syntax to something that will never happen naturally config.tags.blockStart = '<[{[{[{[{[$%'; config.tags.blockEnd = '%$]}]}]}]}]>'; } if (renderMode === RENDER_TAGS) { // Set tag syntax to something that will never happen naturally config.tags.variableStart = '<[{[{[{[{[$%'; config.tags.variableEnd = '%$]}]}]}]}]>'; } // ~~~~~~~~~~~~~~~~~~~~~~~~~~ // // Create Env with Extensions // // ~~~~~~~~~~~~~~~~~~~~~~~~~~ // const nj = nunjucks.configure(config); let allTemplateTagPlugins: TemplateTag[]; try { plugins.ignorePlugin('insomnia-plugin-kong-bundle'); allTemplateTagPlugins = await plugins.getTemplateTags(); } finally { plugins.clearIgnores(); } const allExtensions = allTemplateTagPlugins; for (let i = 0; i < allExtensions.length; i++) { const { templateTag, plugin } = allExtensions[i]; templateTag.priority = templateTag.priority || i * 100; // @ts-expect-error -- TSCONVERSION const instance = new BaseExtension(templateTag, plugin); // @ts-expect-error -- TSCONVERSION nj.addExtension(instance.getTag(), instance); // Hidden helper filter to debug complicated things // eg. `{{ foo | urlencode | debug | upper }}` nj.addFilter('debug', o => o); } // ~~~~~~~~~~~~~~~~~~~~ // // Cache Env and Return // // ~~~~~~~~~~~~~~~~~~~~ // if (renderMode === RENDER_VARS) { nunjucksVariablesOnly = nj; } else if (renderMode === RENDER_TAGS) { nunjucksTagsOnly = nj; } else { nunjucksAll = nj; } return nj; }
aeri/insomnia
packages/insomnia-app/app/templating/index.ts
TypeScript
ArrowFunction
async (resolve, reject) => { const nj = await getNunjucks(renderMode); nj?.renderString(text, templatingContext, (err, result) => { if (err) { const sanitizedMsg = err.message .replace(/\(unknown path\)\s/, '') .replace(/\[Line \d+, Column \d*]/, '') .replace(/^\s*Error:\s*/, '') .trim(); const location = err.message.match(/\[Line (\d)+, Column (\d)*]/); const line = location ? parseInt(location[1]) : 1; const column = location ? parseInt(location[2]) : 1; const reason = err.message.includes('attempted to output null or undefined value') ? 'undefined' : 'error'; const newError = new RenderError(sanitizedMsg); newError.path = path || ''; newError.message = sanitizedMsg; newError.location = { line, column, }; newError.type = 'render'; newError.reason = reason; reject(newError); } else { resolve(result); } }); }
aeri/insomnia
packages/insomnia-app/app/templating/index.ts
TypeScript
ArrowFunction
(err, result) => { if (err) { const sanitizedMsg = err.message .replace(/\(unknown path\)\s/, '') .replace(/\[Line \d+, Column \d*]/, '') .replace(/^\s*Error:\s*/, '') .trim(); const location = err.message.match(/\[Line (\d)+, Column (\d)*]/); const line = location ? parseInt(location[1]) : 1; const column = location ? parseInt(location[2]) : 1; const reason = err.message.includes('attempted to output null or undefined value') ? 'undefined' : 'error'; const newError = new RenderError(sanitizedMsg); newError.path = path || ''; newError.message = sanitizedMsg; newError.location = { line, column, }; newError.type = 'render'; newError.reason = reason; reject(newError); } else { resolve(result); } }
aeri/insomnia
packages/insomnia-app/app/templating/index.ts
TypeScript
ArrowFunction
k => env.extensions[k]
aeri/insomnia
packages/insomnia-app/app/templating/index.ts
TypeScript
ArrowFunction
ext => !ext.isDeprecated()
aeri/insomnia
packages/insomnia-app/app/templating/index.ts
TypeScript
ArrowFunction
(a, b) => (a.getPriority() > b.getPriority() ? 1 : -1)
aeri/insomnia
packages/insomnia-app/app/templating/index.ts
TypeScript
ArrowFunction
ext => ({ name: ext.getTag(), displayName: ext.getName(), liveDisplayName: ext.getLiveDisplayName(), description: ext.getDescription(), disablePreview: ext.getDisablePreview(), args: ext.getArgs(), actions: ext.getActions(), })
aeri/insomnia
packages/insomnia-app/app/templating/index.ts
TypeScript
ArrowFunction
o => o
aeri/insomnia
packages/insomnia-app/app/templating/index.ts
TypeScript
ClassDeclaration
export class RenderError extends Error { message: string; path: string | null; location: { line: number; column: number; }; type: string; reason: string; }
aeri/insomnia
packages/insomnia-app/app/templating/index.ts
TypeScript
FunctionDeclaration
function keyExists (argv: Arguments, val: any): any { // convert string '1' to number 1 const num = Number(val) val = isNaN(num) ? val : num if (typeof val === 'number') { // check length of argv._ val = argv._.length >= val } else if (val.match(/^--no-.+/)) { // check if key/value doesn't exist val = val.match(/^--no-(.+)/)[1] val = !argv[val] } else { // check if key/value exists val = argv[val] } return val }
jameswomack/yargs
lib/validation.ts
TypeScript
ArrowFunction
(key) => { if (specialKeys.indexOf(key) === -1 && !Object.prototype.hasOwnProperty.call(positionalMap, key) && !Object.prototype.hasOwnProperty.call(yargs._getParseContext(), key) && !self.isValidAndSomeAliasIsNotNew(key, aliases) ) { unknown.push(key) } }
jameswomack/yargs
lib/validation.ts
TypeScript
ArrowFunction
(key) => { if (commandKeys.indexOf('' + key) === -1) { unknown.push('' + key) } }
jameswomack/yargs
lib/validation.ts
TypeScript
ArrowFunction
(key) => { if (specialKeys.indexOf(key) === -1 && Object.prototype.hasOwnProperty.call(options.choices, key)) { [].concat(argv[key]).forEach((value) => { // TODO case-insensitive configurability if (options.choices[key].indexOf(value) === -1 && value !== undefined) { invalid[key] = (invalid[key] || []).concat(value) } }) } }
jameswomack/yargs
lib/validation.ts
TypeScript
ArrowFunction
(value) => { // TODO case-insensitive configurability if (options.choices[key].indexOf(value) === -1 && value !== undefined) { invalid[key] = (invalid[key] || []).concat(value) } }
jameswomack/yargs
lib/validation.ts
TypeScript
ArrowFunction
(key) => { msg += `\n ${__( 'Argument: %s, Given: %s, Choices: %s', key, usage.stringifiedValues(invalid[key]), usage.stringifiedValues(options.choices[key]) )}` }
jameswomack/yargs
lib/validation.ts
TypeScript
ArrowFunction
(k) => { self.implies(k, key[k]) }
jameswomack/yargs
lib/validation.ts
TypeScript
ArrowFunction
(i) => self.implies(key, i)
jameswomack/yargs
lib/validation.ts
TypeScript
ArrowFunction
(key) => { const origKey = key ;(implied[key] || []).forEach((value) => { let key = origKey const origValue = value key = keyExists(argv, key) value = keyExists(argv, value) if (key && !value) { implyFail.push(` ${origKey} -> ${origValue}`) } }) }
jameswomack/yargs
lib/validation.ts
TypeScript
ArrowFunction
(value) => { let key = origKey const origValue = value key = keyExists(argv, key) value = keyExists(argv, value) if (key && !value) { implyFail.push(` ${origKey} -> ${origValue}`) } }
jameswomack/yargs
lib/validation.ts
TypeScript
ArrowFunction
(value) => { msg += (value) }
jameswomack/yargs
lib/validation.ts
TypeScript
ArrowFunction
(k) => { self.conflicts(k, key[k]) }
jameswomack/yargs
lib/validation.ts
TypeScript
ArrowFunction
(i) => self.conflicts(key, i)
jameswomack/yargs
lib/validation.ts
TypeScript
ArrowFunction
() => conflicting
jameswomack/yargs
lib/validation.ts
TypeScript
ArrowFunction
(key) => { if (conflicting[key]) { conflicting[key].forEach((value) => { // we default keys to 'undefined' that have been configured, we should not // apply conflicting check unless they are a value other than 'undefined'. if (value && argv[key] !== undefined && argv[value] !== undefined) { usage.fail(__('Arguments %s and %s are mutually exclusive', key, value)) } }) } }
jameswomack/yargs
lib/validation.ts
TypeScript
ArrowFunction
(value) => { // we default keys to 'undefined' that have been configured, we should not // apply conflicting check unless they are a value other than 'undefined'. if (value && argv[key] !== undefined && argv[value] !== undefined) { usage.fail(__('Arguments %s and %s are mutually exclusive', key, value)) } }
jameswomack/yargs
lib/validation.ts
TypeScript
ArrowFunction
(a, b) => b.length - a.length
jameswomack/yargs
lib/validation.ts
TypeScript
ArrowFunction
k => !localLookup[k]
jameswomack/yargs
lib/validation.ts
TypeScript
ArrowFunction
c => c.global
jameswomack/yargs
lib/validation.ts
TypeScript
InterfaceDeclaration
/** Instance of the validation module. */ export interface ValidationInstance { check(f: CustomCheck['func'], global: boolean): void conflicting(argv: Arguments): void conflicts(key: string | Dictionary<string | string[]>, value?: string | string[]): void customChecks(argv: Arguments, aliases: DetailedArguments['aliases']): void freeze(): void getConflicting(): Dictionary<(string | undefined)[]> getImplied(): Dictionary<KeyOrPos[]> implications(argv: Arguments): void implies(key: string | Dictionary<KeyOrPos | KeyOrPos[]>, value?: KeyOrPos | KeyOrPos[]): void isValidAndSomeAliasIsNotNew(key: string, aliases: DetailedArguments['aliases']): boolean limitedChoices(argv: Arguments): void nonOptionCount(argv: Arguments): void positionalCount(required: number, observed: number): void recommendCommands(cmd: string, potentialCommands: string[]): void requiredArguments(argv: Arguments): void reset(localLookup: Dictionary): ValidationInstance unfreeze(): void unknownArguments( argv: Arguments, aliases: DetailedArguments['aliases'], positionalMap: Dictionary, isDefaultCommand: boolean, checkPositionals?: boolean, ): void unknownCommands(argv: Arguments): boolean }
jameswomack/yargs
lib/validation.ts
TypeScript
InterfaceDeclaration
interface CustomCheck { func: (argv: Arguments, aliases: DetailedArguments['aliases']) => any global: boolean }
jameswomack/yargs
lib/validation.ts
TypeScript
InterfaceDeclaration
interface FrozenValidationInstance { implied: Dictionary<KeyOrPos[]> checks: CustomCheck[] conflicting: Dictionary<(string | undefined)[]> }
jameswomack/yargs
lib/validation.ts
TypeScript
TypeAliasDeclaration
export type KeyOrPos = string | number
jameswomack/yargs
lib/validation.ts
TypeScript
ClassDeclaration
export class Secrets { name !: string; desription !: string; secret !: string; active !: boolean; }
Skatiner/InstantNotificationCenter
src/main/frontend/src/app/dto/Secrets.ts
TypeScript
ArrowFunction
(props: Props) => { const desc = props.message.newDescription.stringValue() return desc ? ( <Kb.Text type="BodySmall" style={styles.text} selectable={true}> changed the channel description to{' '} <Kb.Text type="BodySmallItalic"> {lquote} {desc} {rquote} </Kb.Text> </Kb.Text>
13rac1/keybase-client
shared/chat/conversation/messages/set-description/index.tsx
TypeScript
ArrowFunction
() => ({ text: {flexGrow: 1}, } as const)
13rac1/keybase-client
shared/chat/conversation/messages/set-description/index.tsx
TypeScript
TypeAliasDeclaration
type Props = { message: Types.MessageSetDescription }
13rac1/keybase-client
shared/chat/conversation/messages/set-description/index.tsx
TypeScript
ClassDeclaration
export class Tenant { readonly tenantId: string; constructor(tenantId: Guid) { this.tenantId = tenantId.toString(); } }
dolittle/TheAviator
Source/microservices/configuration/Tenant.ts
TypeScript
InterfaceDeclaration
export interface JSForInStatement extends NodeBaseWithComments { readonly type: "JSForInStatement"; readonly left: JSVariableDeclaration | AnyJSTargetAssignmentPattern; readonly right: AnyJSExpression; readonly body: AnyJSStatement; }
Bradinz/tools
internal/ast/js/statements/JSForInStatement.ts
TypeScript
FunctionDeclaration
function i18nDirectiveFn( i18n: I18nServiceType, $sanitize: (html: string) => string ): IDirective<I18nScope> { return { restrict: 'A', scope: { id: '@i18nId', defaultMessage: '@i18nDefaultMessage', values: '<?i18nValues', }, link($scope, $element) { if ($scope.values) { $scope.$watchCollection('values', () => { setContent($element, $scope, $sanitize, i18n); }); } else { setContent($element, $scope, $sanitize, i18n); } }, }; }
DarshitChanpura/OpenSearch-Dashboards
packages/osd-i18n/src/angular/directive.ts
TypeScript
FunctionDeclaration
function setContent( $element: IRootElementService, $scope: I18nScope, $sanitize: (html: string) => string, i18n: I18nServiceType ) { const originalValues = $scope.values; const valuesWithPlaceholders = {} as Record<string, any>; let hasValuesWithPlaceholders = false; // If we have values with the keys that start with HTML_KEY_PREFIX we should replace // them with special placeholders that later on will be inserted as HTML // into the DOM, the rest of the content will be treated as text. We don't // sanitize values at this stage as some of the values can be excluded from // the translated string (e.g. not used by ICU conditional statements). if (originalValues) { for (const [key, value] of Object.entries(originalValues)) { if (key.startsWith(HTML_KEY_PREFIX)) { valuesWithPlaceholders[ key.slice(HTML_KEY_PREFIX.length) ] = `${PLACEHOLDER_SEPARATOR}${key}${PLACEHOLDER_SEPARATOR}`; hasValuesWithPlaceholders = true; } else { valuesWithPlaceholders[key] = value; } } } const label = i18n($scope.id, { values: valuesWithPlaceholders, defaultMessage: $scope.defaultMessage, }); // If there are no placeholders to replace treat everything as text, otherwise // insert label piece by piece replacing every placeholder with corresponding // sanitized HTML content. if (!hasValuesWithPlaceholders) { $element.text(label); } else { $element.empty(); for (const contentOrPlaceholder of label.split(PLACEHOLDER_SEPARATOR)) { if (!contentOrPlaceholder) { continue; } $element.append( originalValues!.hasOwnProperty(contentOrPlaceholder) ? $sanitize(originalValues![contentOrPlaceholder]) : document.createTextNode(contentOrPlaceholder) ); } } }
DarshitChanpura/OpenSearch-Dashboards
packages/osd-i18n/src/angular/directive.ts
TypeScript
ArrowFunction
() => { setContent($element, $scope, $sanitize, i18n); }
DarshitChanpura/OpenSearch-Dashboards
packages/osd-i18n/src/angular/directive.ts
TypeScript
InterfaceDeclaration
interface I18nScope extends IScope { values?: Record<string, any>; defaultMessage: string; id: string; }
DarshitChanpura/OpenSearch-Dashboards
packages/osd-i18n/src/angular/directive.ts
TypeScript
MethodDeclaration
link($scope, $element) { if ($scope.values) { $scope.$watchCollection('values', () => { setContent($element, $scope, $sanitize, i18n); }); } else { setContent($element, $scope, $sanitize, i18n); } }
DarshitChanpura/OpenSearch-Dashboards
packages/osd-i18n/src/angular/directive.ts
TypeScript
FunctionDeclaration
//const [ strings, setstrings ] = useState( content.settings ) function handleOptionSelection( menuOption: MenuOption ) { if ( typeof menuOption.onOptionPressed === 'function' ) { menuOption.onOptionPressed() } else if ( menuOption.screenName !== undefined ) { navigation.navigate( menuOption.screenName ) } }
thecryptobee/BitHyve-Wallet
src/pages/MoreOptions/MoreOptionsContainerScreen.tsx
TypeScript
ArrowFunction
( item: MenuOption ) => item.title
thecryptobee/BitHyve-Wallet
src/pages/MoreOptions/MoreOptionsContainerScreen.tsx
TypeScript
ArrowFunction
( { navigation }: Props ) => { const { translations, } = useContext( LocalizationContext ) // currencyCode: idx( state, ( _ ) => _.preferences.currencyCode ), const [ isEnabled, setIsEnabled ] = useState( false ) const toggleSwitch = () => setIsEnabled( previousState => !previousState ) const currencyCode = useSelector( ( state ) => state.preferences.currencyCode, ) const strings = translations[ 'settings' ] const common = translations[ 'common' ] const menuOptions: MenuOption[] = [ // { // title: 'Use FaceId', // imageSource: require( '../../assets/images/icons/addressbook.png' ), // subtitle: 'Unlock your wallet using FaceId', // // screenName: 'FriendsAndFamily', // isSwitch: true // }, // { // title: 'Dark Mode', // imageSource: require( '../../assets/images/icons/addressbook.png' ), // subtitle: 'Use dark Mode on your wallet', // // screenName: 'FriendsAndFamily', // isSwitch: true // }, { title: strings.accountManagement, imageSource: require( '../../assets/images/icons/icon_account_management.png' ), subtitle: strings.accountManagementSub, screenName: 'AccountManagement', }, /* Commenting this out as per https://github.com/bithyve/hexa/issues/2560 leaving the option here so that it can be enabled in a future release. { title: 'Friends & Family', imageSource: require( '../../assets/images/icons/addressbook.png' ), subtitle: 'View and manage your contacts', screenName: 'FriendsAndFamily', }, */ { title: strings.node, imageSource: require( '../../assets/images/icons/own-node.png' ), subtitle: strings.nodeSub, screenName: 'NodeSettings', }, /* Commenting this out as per https://github.com/bithyve/hexa/issues/2560 leaving the option here so that it can be enabled in a future release. { title: 'Funding Sources', imageSource: require( '../../assets/images/icons/existing_saving_method.png' ), subtitle: 'Buying methods integrated in your wallet', screenName: 'FundingSources', }, */ // { // title: 'Hexa Community (Telegram)', // imageSource: require( '../../assets/images/icons/telegram.png' ), // subtitle: 'Questions, feedback and more', // onOptionPressed: () => { // Linking.openURL( 'https://t.me/HexaWallet' ) // .then( ( _data ) => { } ) // .catch( ( _error ) => { // alert( 'Make sure Telegram installed on your device' ) // } ) // }, // }, { imageSource: require( '../../assets/images/icons/settings.png' ), subtitle: strings.walletSettingsSub, title: strings.walletSettings, screenName: 'WalletSettings', }, { title: strings.AppInfo, imageSource: require( '../../assets/images/icons/icon_info.png' ), subtitle: strings.AppInfoSub, screenName: 'AppInfo', }, ] const listItemKeyExtractor = ( item: MenuOption ) => item.title //const [ strings, setstrings ] = useState( content.settings ) function handleOptionSelection( menuOption: MenuOption ) { if ( typeof menuOption.onOptionPressed === 'function' ) { menuOption.onOptionPressed() } else if ( menuOption.screenName !== undefined ) { navigation.navigate( menuOption.screenName ) } } const findImage = ( name ) => { switch ( name ){ case strings.accountManagement: return ( <AccManagement /> ) case strings.node: return ( <Node /> ) case strings.walletSettings: return ( <Wallet /> ) case strings.AppInfo: return ( <AppInfo /> ) default: return null } } return ( <View style={{ backgroundColor: Colors.blue }}
thecryptobee/BitHyve-Wallet
src/pages/MoreOptions/MoreOptionsContainerScreen.tsx
TypeScript
ArrowFunction
() => setIsEnabled( previousState => !previousState )
thecryptobee/BitHyve-Wallet
src/pages/MoreOptions/MoreOptionsContainerScreen.tsx
TypeScript
ArrowFunction
previousState => !previousState
thecryptobee/BitHyve-Wallet
src/pages/MoreOptions/MoreOptionsContainerScreen.tsx
TypeScript
ArrowFunction
( state ) => state.preferences.currencyCode
thecryptobee/BitHyve-Wallet
src/pages/MoreOptions/MoreOptionsContainerScreen.tsx
TypeScript
ArrowFunction
( name ) => { switch ( name ){ case strings.accountManagement: return ( <AccManagement /> ) case strings.node: return ( <Node /> ) case strings.walletSettings: return ( <Wallet /> ) case strings.AppInfo: return ( <AppInfo /> ) default: return null } }
thecryptobee/BitHyve-Wallet
src/pages/MoreOptions/MoreOptionsContainerScreen.tsx
TypeScript
ArrowFunction
() => handleOptionSelection( menuOption )
thecryptobee/BitHyve-Wallet
src/pages/MoreOptions/MoreOptionsContainerScreen.tsx
TypeScript
ArrowFunction
( _data ) => { }
thecryptobee/BitHyve-Wallet
src/pages/MoreOptions/MoreOptionsContainerScreen.tsx
TypeScript
ArrowFunction
( _error ) => { }
thecryptobee/BitHyve-Wallet
src/pages/MoreOptions/MoreOptionsContainerScreen.tsx
TypeScript
ArrowFunction
( _error ) => { alert( 'Make sure Telegram installed on your device' ) }
thecryptobee/BitHyve-Wallet
src/pages/MoreOptions/MoreOptionsContainerScreen.tsx
TypeScript
InterfaceDeclaration
interface MenuOption { title: string; subtitle: string; screenName?: string; name ?: string, onOptionPressed?: () => void; // isSwitch: boolean; imageSource: ImageSourcePropType; }
thecryptobee/BitHyve-Wallet
src/pages/MoreOptions/MoreOptionsContainerScreen.tsx
TypeScript
TypeAliasDeclaration
export type Props = { navigation: any; containerStyle: {} };
thecryptobee/BitHyve-Wallet
src/pages/MoreOptions/MoreOptionsContainerScreen.tsx
TypeScript
MethodDeclaration
findImage( menuOption
thecryptobee/BitHyve-Wallet
src/pages/MoreOptions/MoreOptionsContainerScreen.tsx
TypeScript
MethodDeclaration
require( '../../assets/images/icons/icon_arrow.png' )
thecryptobee/BitHyve-Wallet
src/pages/MoreOptions/MoreOptionsContainerScreen.tsx
TypeScript
MethodDeclaration
require( '../../assets/images/icons/link.png' )
thecryptobee/BitHyve-Wallet
src/pages/MoreOptions/MoreOptionsContainerScreen.tsx
TypeScript
FunctionDeclaration
// Instead of `any`, it would make sense here to get a schema-to-dts package and output the // interfaces so you get type-safe options. export default function (options: any): Rule { // The chain rule allows us to chain multiple rules and apply them one after the other. return chain([ (_tree: Tree, context: SchematicContext) => { // Show the options for this Schematics. context.logger.info('-----------------------------------------------'); context.logger.info('--- ** TIBCO CLOUD COMPONENT GENERATOR ** ---'); context.logger.info('--- ** V1.07 ** ---'); context.logger.info('-----------------------------------------------'); context.logger.info('--- ** TYPE: LIVE APPS ** ---'); context.logger.info('-----------------------------------------------'); context.logger.info('Building TIBCO Cloud LiveApps Component, with the following settings: ' + JSON.stringify(options)); }, // The schematic Rule calls the schematic from the same collection, with the options // passed in. Please note that if the schematic has a schema, the options will be // validated and could throw, e.g. if a required option is missing. //schematic('my-other-schematic', { option: true }), (host: Tree, context: SchematicContext) => { context.logger.log('info', "Name: " + options.name); context.logger.info('Adding dependencies...'); const workspace = getWorkspace(host); const project = getProjectFromWorkspace( workspace, // Takes the first project in case it's not provided by CLI options.project ? options.project : Object.keys(workspace['projects'])[0] ); const moduleName = options.name + 'Component'; const sourceLoc = './' + options.name + '/' + options.name + '.component'; context.logger.info('moduleName: ' + moduleName); context.logger.info('sourceLoc: ' + sourceLoc); context.logger.info('Project Root: ' + project.root); //console.log(project); // @ts-ignore addModuleImportToRootModule(host, moduleName, sourceLoc, project); context.logger.info('Installed Dependencies...'); }, // The mergeWith() rule merge two trees; one that's coming from a Source (a Tree with no // base), and the one as input to the rule. You can think of it like rebasing a Source on // top of your current set of changes. In this case, the Source is that apply function. // The apply() source takes a Source, and apply rules to it. In our case, the Source is // url(), which takes an URL and returns a Tree that contains all the files from that URL // in it. In this case, we use the relative path `./files`, and so two files are going to // be created (test1, and __name@dasherize__.md). // We then apply the template() rule, which takes a tree and apply two templates to it: // path templates: this template replaces instances of __X__ in paths with the value of // X from the options passed to template(). If the value of X is a // function, the function will be called. If the X is undefined or it // returns null (not empty string), the file or path will be removed. // content template: this is similar to EJS, but does so in place (there's no special // extension), does not support additional functions if you don't pass // them in, and only work on text files (we use an algorithm to detect // if a file is binary or not). mergeWith(apply(url('./files'), [ template({ ...strings, INDEX: options.index, name: options.name, }), ])), ]); }
TIBCOSoftware/TCSTK-component-schematics
src/comp-liveapps/index.ts
TypeScript
ArrowFunction
(_tree: Tree, context: SchematicContext) => { // Show the options for this Schematics. context.logger.info('-----------------------------------------------'); context.logger.info('--- ** TIBCO CLOUD COMPONENT GENERATOR ** ---'); context.logger.info('--- ** V1.07 ** ---'); context.logger.info('-----------------------------------------------'); context.logger.info('--- ** TYPE: LIVE APPS ** ---'); context.logger.info('-----------------------------------------------'); context.logger.info('Building TIBCO Cloud LiveApps Component, with the following settings: ' + JSON.stringify(options)); }
TIBCOSoftware/TCSTK-component-schematics
src/comp-liveapps/index.ts
TypeScript
ArrowFunction
// The schematic Rule calls the schematic from the same collection, with the options // passed in. Please note that if the schematic has a schema, the options will be // validated and could throw, e.g. if a required option is missing. //schematic('my-other-schematic', { option: true }), (host: Tree, context: SchematicContext) => { context.logger.log('info', "Name: " + options.name); context.logger.info('Adding dependencies...'); const workspace = getWorkspace(host); const project = getProjectFromWorkspace( workspace, // Takes the first project in case it's not provided by CLI options.project ? options.project : Object.keys(workspace['projects'])[0] ); const moduleName = options.name + 'Component'; const sourceLoc = './' + options.name + '/' + options.name + '.component'; context.logger.info('moduleName: ' + moduleName); context.logger.info('sourceLoc: ' + sourceLoc); context.logger.info('Project Root: ' + project.root); //console.log(project); // @ts-ignore addModuleImportToRootModule(host, moduleName, sourceLoc, project); context.logger.info('Installed Dependencies...'); }
TIBCOSoftware/TCSTK-component-schematics
src/comp-liveapps/index.ts
TypeScript