type
stringclasses
7 values
content
stringlengths
4
9.55k
repo
stringlengths
7
96
path
stringlengths
4
178
language
stringclasses
1 value
ArrowFunction
t => { const element = ( <span contentEditable> <a contentEditable={false}>Download</a> </span>
TheRealSyler/dom-chef
tests/index.tsx
TypeScript
ArrowFunction
t => { const element = ( // @ts-expect-error <a href={undefined} title={null}> Download </a>
TheRealSyler/dom-chef
tests/index.tsx
TypeScript
ArrowFunction
t => { const element = <a id={'"test"'}>Download</a>; t.is(element.outerHTML, '<a id="&quot;test&quot;">Download</a>'); }
TheRealSyler/dom-chef
tests/index.tsx
TypeScript
ArrowFunction
t => { const element = <div>{'<script>alert();</script>'}</div>; t.is(element.outerHTML, '<div>&lt;script&gt;alert();&lt;/script&gt;</div>'); }
TheRealSyler/dom-chef
tests/index.tsx
TypeScript
ArrowFunction
t => { const element = ( <div dangerouslySetInnerHTML={{__html: '<script>alert();</script>'}}
TheRealSyler/dom-chef
tests/index.tsx
TypeScript
ArrowFunction
t => { const addEventListener = spy(EventTarget.prototype, 'addEventListener'); const handleClick = function () {}; const element = ( <a href="#" onClick={handleClick}> Download </a>
TheRealSyler/dom-chef
tests/index.tsx
TypeScript
ArrowFunction
t => { const addEventListener = spy(EventTarget.prototype, 'addEventListener'); const handler = function () {}; const element = ( <a href="#" onremote-input={handler} on-remote-input={handler}> Download </a>
TheRealSyler/dom-chef
tests/index.tsx
TypeScript
ArrowFunction
t => { const createDocumentFragment = spy(document, 'createDocumentFragment'); const fragment = <>test</>; const fragmentHTML = getFragmentHTML(fragment); t.is(fragmentHTML, 'test'); t.true(createDocumentFragment.calledOnce); t.deepEqual(createDocumentFragment.firstCall.args, []); }
TheRealSyler/dom-chef
tests/index.tsx
TypeScript
ArrowFunction
t => { const fragment = ( <> <h1>test</h1> </> ); const fragmentHTML = getFragmentHTML(fragment); t.is(fragmentHTML, '<h1>test</h1>'); }
TheRealSyler/dom-chef
tests/index.tsx
TypeScript
ArrowFunction
t => { const fragment = ( <> <h1>heading</h1> text </> ); const fragmentHTML = getFragmentHTML(fragment); t.is(fragmentHTML, '<h1>heading</h1> text'); }
TheRealSyler/dom-chef
tests/index.tsx
TypeScript
ArrowFunction
t => { const element = ( <div> <> <h1>heading</h1> text </> <span>outside fragment</span> </div>
TheRealSyler/dom-chef
tests/index.tsx
TypeScript
ArrowFunction
t => { const Icon = () => <i/>; const element = <Icon />; t.is(element.outerHTML, '<i></i>'); }
TheRealSyler/dom-chef
tests/index.tsx
TypeScript
ArrowFunction
() => <i/>;
TheRealSyler/dom-chef
tests/index.tsx
TypeScript
ArrowFunction
t => { const Icon = () => <i className="sweet">Gummy <span>bears</span></i>; const element = <Icon />; t.is(element.outerHTML, '<i class="sweet">Gummy <span>bears</span></i>'); }
TheRealSyler/dom-chef
tests/index.tsx
TypeScript
ArrowFunction
() => <i className
TheRealSyler/dom-chef
tests/index.tsx
TypeScript
ArrowFunction
t => { const Icon = () => <i className="sweet">Gummy <span>bears</span></i>; // @ts-expect-error const element = <Icon className="yellow"> and <b>lollipops</b></Icon>; t.is( element.outerHTML, '<i class="sweet yellow">Gummy <span>bears</span> and <b>lollipops</b></i>' ); }
TheRealSyler/dom-chef
tests/index.tsx
TypeScript
ArrowFunction
n => n.outerHTML || n.textContent
TheRealSyler/dom-chef
tests/index.tsx
TypeScript
ClassDeclaration
export class pairEntityData{ toCurrency: any; pairedCurrency: any; }
templeandaegeandas/bolenum_adminapp
src/app/pages/addNewPair/entity/addNewPair.details.ts
TypeScript
ArrowFunction
(a, b) => a.performanceImpact - b.performanceImpact
iGod42/svl-reservation-rules
src/evaluation/RuleEvaluator.ts
TypeScript
ArrowFunction
(options: RuleEvaluationOptions) => { for (let rule of this.rules) { const message = rule.evaluate(options) if (message) return message } }
iGod42/svl-reservation-rules
src/evaluation/RuleEvaluator.ts
TypeScript
ArrowFunction
(options: BulkRuleEvaluationOptions) => { this.rules.forEach(rule => rule.evaluateBulk(options)) }
iGod42/svl-reservation-rules
src/evaluation/RuleEvaluator.ts
TypeScript
ArrowFunction
rule => rule.evaluateBulk(options)
iGod42/svl-reservation-rules
src/evaluation/RuleEvaluator.ts
TypeScript
ClassDeclaration
export class RuleEvaluator { private readonly rules: Rule[] constructor(rules: RuleDefinition[]) { this.rules = parseRules(rules).sort( (a, b) => a.performanceImpact - b.performanceImpact ) } evaluate = (options: RuleEvaluationOptions) => { for (let rule of this.rules) { const message = rule.evaluate(options) if (message) return message } } bulkEvaluate = (options: BulkRuleEvaluationOptions) => { this.rules.forEach(rule => rule.evaluateBulk(options)) } }
iGod42/svl-reservation-rules
src/evaluation/RuleEvaluator.ts
TypeScript
ArrowFunction
() => { it('should render correctly', () => { const props: Props = { game: testGame }; const component = shallow(<GameInfo {...props} />); expect(component).toMatchSnapshot(); }); }
Archinowsk/konsti-client
src/views/all-games/components/test/GameInfo.test.tsx
TypeScript
ArrowFunction
() => { const props: Props = { game: testGame }; const component = shallow(<GameInfo {...props} />); expect(component).toMatchSnapshot(); }
Archinowsk/konsti-client
src/views/all-games/components/test/GameInfo.test.tsx
TypeScript
FunctionDeclaration
function Sender() { const [emittedPhoton, setEmittedPhoton] = useState<React.ReactNode>(null); const [passingPhoton, setPassingPhoton] = useState<React.ReactNode>(null); const [polarizedPhoton, setPolarizedPhoton] = useState<React.ReactNode>(null); function handlePhotonEmission(photon: React.ReactNode) { setEmittedPhoton(photon); } function handleEmittedPhotonTransported(photon: React.ReactNode) { setEmittedPhoton(null); setPassingPhoton(photon); } function handlePhotonPassed(photon: React.ReactNode) { setPassingPhoton(null); setPolarizedPhoton(photon) } function handlePolarizedPhotonTransported(photon: React.ReactNode) { console.log((photon as any).props.qbit.polarization); setPolarizedPhoton(null); } return ( <div className={ styles.sender }> <div className={ styles.polarizedPhotonOpticalFiberWrapper }> <OpticalFiber pathD="M 0 200 v -200" photon={polarizedPhoton} onAnimationEnd={handlePolarizedPhotonTransported}></OpticalFiber> </div> <div className={ styles.polarizationWheelWrapper }> <PolarizationWheel passingPhoton={passingPhoton} onPhotonPassed={handlePhotonPassed}/> </div> <div className={ styles.emittedPhotonOpticalFiberWrapper }> <OpticalFiber pathD="M 0 200 v -200" photon={emittedPhoton} onAnimationEnd={handleEmittedPhotonTransported}></OpticalFiber> </div> <div className={ styles.photonSourceWrapper }> <PhotonSource onPhotonEmission={handlePhotonEmission} /> </div> </div> ); }
picturestone/qkd-game
qkd-game-client/src/components/game/Sender.tsx
TypeScript
FunctionDeclaration
function handlePhotonEmission(photon: React.ReactNode) { setEmittedPhoton(photon); }
picturestone/qkd-game
qkd-game-client/src/components/game/Sender.tsx
TypeScript
FunctionDeclaration
function handleEmittedPhotonTransported(photon: React.ReactNode) { setEmittedPhoton(null); setPassingPhoton(photon); }
picturestone/qkd-game
qkd-game-client/src/components/game/Sender.tsx
TypeScript
FunctionDeclaration
function handlePhotonPassed(photon: React.ReactNode) { setPassingPhoton(null); setPolarizedPhoton(photon) }
picturestone/qkd-game
qkd-game-client/src/components/game/Sender.tsx
TypeScript
FunctionDeclaration
function handlePolarizedPhotonTransported(photon: React.ReactNode) { console.log((photon as any).props.qbit.polarization); setPolarizedPhoton(null); }
picturestone/qkd-game
qkd-game-client/src/components/game/Sender.tsx
TypeScript
ArrowFunction
(last, current) => last + current.length
emmorts/buffercodec
lib/BufferCodec.ts
TypeScript
ArrowFunction
job => { switch (job.type) { case 'string': this.#offset += this.encodeString(dataView, job); break; case 'float32': this.#offset += this.encodeValue(dataView, dataView.setFloat32, job); break; case 'float64': this.#offset += this.encodeValue(dataView, dataView.setFloat64, job); break; case 'int8': this.#offset += this.encodeValue(dataView, dataView.setInt8, job); break; case 'int16': this.#offset += this.encodeValue(dataView, dataView.setInt16, job); break; case 'int32': this.#offset += this.encodeValue(dataView, dataView.setInt32, job); break; case 'uint8': this.#offset += this.encodeValue(dataView, dataView.setUint8, job); break; case 'uint16': this.#offset += this.encodeValue(dataView, dataView.setUint16, job); break; case 'uint32': this.#offset += this.encodeValue(dataView, dataView.setUint32, job); break; default: throw new Error(`Unrecognized type '${job.type}'`) } }
emmorts/buffercodec
lib/BufferCodec.ts
TypeScript
InterfaceDeclaration
/** @internal */ interface BufferJob { type: BufferContentType, value: number | string, length: number, encoding?: BufferStringEncoding, littleEndian?: boolean }
emmorts/buffercodec
lib/BufferCodec.ts
TypeScript
InterfaceDeclaration
export interface BufferCodecConstructorOptions { buffer?: ArrayBuffer, encoding?: BufferStringEncoding }
emmorts/buffercodec
lib/BufferCodec.ts
TypeScript
MethodDeclaration
/** * Creates a new BufferCodec instance from given buffer * @param {Buffer | ArrayBuffer} buffer Either ArrayBuffer or Buffer * @returns {BufferCodec} A new instance of BufferCodec */ static from(buffer: Buffer | ArrayBuffer): BufferCodec { if (buffer && buffer.byteLength > 0) { if (buffer instanceof ArrayBuffer) { return new BufferCodec({ buffer }); } else { const arrayBuffer = new ArrayBuffer(buffer.length); const view = new Uint8Array(arrayBuffer); for (let i = 0; i < buffer.length; ++i) { view[i] = buffer[i]; } return new BufferCodec({ buffer: arrayBuffer }); } } else { throw new Error("Received malformed data."); } }
emmorts/buffercodec
lib/BufferCodec.ts
TypeScript
MethodDeclaration
/** * Sets string encoding * @param encoding {BufferStringEncoding} String encoding (either 'utf8' or 'utf16') * @returns {BufferCodec} Current instance of BufferCodec */ setEncoding(encoding: BufferStringEncoding): BufferCodec { if (encoding !== 'utf16' && encoding !== 'utf8') { throw new Error(`Unsupported encoding '${encoding}'. Only UTF-8 and UTF-16 are currently supported.`); } this.#encoding = encoding; return this; }
emmorts/buffercodec
lib/BufferCodec.ts
TypeScript
MethodDeclaration
/** * Encode all queued values and return resulting buffer * @returns {ArrayBuffer} Encoded buffer */ result(): ArrayBuffer { this.#offset = 0; const bufferLength = this.#jobs.reduce((last, current) => last + current.length, 0); const buffer = new ArrayBuffer(bufferLength); const dataView = new DataView(buffer); if (this.#jobs.length > 0) { this.#jobs.forEach(job => { switch (job.type) { case 'string': this.#offset += this.encodeString(dataView, job); break; case 'float32': this.#offset += this.encodeValue(dataView, dataView.setFloat32, job); break; case 'float64': this.#offset += this.encodeValue(dataView, dataView.setFloat64, job); break; case 'int8': this.#offset += this.encodeValue(dataView, dataView.setInt8, job); break; case 'int16': this.#offset += this.encodeValue(dataView, dataView.setInt16, job); break; case 'int32': this.#offset += this.encodeValue(dataView, dataView.setInt32, job); break; case 'uint8': this.#offset += this.encodeValue(dataView, dataView.setUint8, job); break; case 'uint16': this.#offset += this.encodeValue(dataView, dataView.setUint16, job); break; case 'uint32': this.#offset += this.encodeValue(dataView, dataView.setUint32, job); break; default: throw new Error(`Unrecognized type '${job.type}'`) } }); } this.#jobs = []; return dataView.buffer; }
emmorts/buffercodec
lib/BufferCodec.ts
TypeScript
MethodDeclaration
/** * Decode a single value from current offset * @param options {BufferTypeOptions} Value decoding options * @returns Decoded value */ decode(options: BufferTypeOptions): any { const dataView = this.#dataView!; let itemValue; switch (options.type) { case 'int8': itemValue = dataView.getInt8(this.#offset); this.#offset += 1; break; case 'uint8': itemValue = dataView.getUint8(this.#offset); this.#offset += 1; break; case 'int16': itemValue = dataView.getInt16(this.#offset, options.littleEndian); this.#offset += 2; break; case 'uint16': itemValue = dataView.getUint16(this.#offset, options.littleEndian); this.#offset += 2; break; case 'int32': itemValue = dataView.getInt32(this.#offset, options.littleEndian); this.#offset += 4; break; case 'uint32': itemValue = dataView.getUint32(this.#offset, options.littleEndian); this.#offset += 4; break; case 'float32': itemValue = dataView.getFloat32(this.#offset, options.littleEndian); this.#offset += 4; break; case 'float64': itemValue = dataView.getFloat64(this.#offset, options.littleEndian); this.#offset += 8; break; case 'string': const [ decodedString, length ] = this.decodeString(dataView, options.encoding || this.#encoding); itemValue = decodedString; this.#offset += length; break; default: throw new Error(`Type '${options.type}' is not supported.`); } return itemValue; }
emmorts/buffercodec
lib/BufferCodec.ts
TypeScript
MethodDeclaration
/** * Decode the whole buffer using provided template * @param template {BufferTemplate | BufferTemplate[]} Template to use for buffer decoding * @returns {any} Decoded object */ parse(template: BufferTemplate | BufferTemplate[]): any { return BufferStrategy.decode(template, this); }
emmorts/buffercodec
lib/BufferCodec.ts
TypeScript
MethodDeclaration
/** * Encodes a string value * @param value {string} String to encode * @param encoding {BufferStringEncoding} String encoding (either 'utf8' or 'utf16'). This parameter takes precedence over the general encoding property set on BufferCodec instance * @returns {BufferCodec} Current instance of BufferCodec */ string(value: string, encoding: BufferStringEncoding = this.#encoding): BufferCodec { this.#jobs.push({ type: 'string', length: (encoding === 'utf16' ? value.length * 2 : value.length) + 1, encoding: encoding, value }); return this; }
emmorts/buffercodec
lib/BufferCodec.ts
TypeScript
MethodDeclaration
/** * Encode a signed 8-bit number * @param value 8-bit numeric value * @returns {BufferCodec} Current instance of BufferCodec */ int8(value: number): BufferCodec { this.#jobs.push({ value, type: 'int8', length: 1 }); return this; }
emmorts/buffercodec
lib/BufferCodec.ts
TypeScript
MethodDeclaration
/** * Encode an unsigned 8-bit number * @param value 8-bit numeric value * @returns {BufferCodec} Current instance of BufferCodec */ uint8(value: number): BufferCodec { this.#jobs.push({ value, type: 'uint8', length: 1 }); return this; }
emmorts/buffercodec
lib/BufferCodec.ts
TypeScript
MethodDeclaration
/** * Encode a signed 16-bit number * @param value 16-bit numeric value * @returns {BufferCodec} Current instance of BufferCodec */ int16(value: number, littleEndian: boolean = false): BufferCodec { this.#jobs.push({ value, type: 'int16', length: 2, littleEndian }); return this; }
emmorts/buffercodec
lib/BufferCodec.ts
TypeScript
MethodDeclaration
/** * Encode an unsigned 16-bit number * @param value 16-bit numeric value * @returns {BufferCodec} Current instance of BufferCodec */ uint16(value: number, littleEndian: boolean = false): BufferCodec { this.#jobs.push({ value, type: 'uint16', length: 2, littleEndian }); return this; }
emmorts/buffercodec
lib/BufferCodec.ts
TypeScript
MethodDeclaration
/** * Encode a signed 32-bit number * @param value 32-bit numeric value * @returns {BufferCodec} Current instance of BufferCodec */ int32(value: number, littleEndian: boolean = false): BufferCodec { this.#jobs.push({ value, type: 'int32', length: 4, littleEndian }); return this; }
emmorts/buffercodec
lib/BufferCodec.ts
TypeScript
MethodDeclaration
/** * Encode an unsigned 32-bit number * @param value 32-bit numeric value * @returns {BufferCodec} Current instance of BufferCodec */ uint32(value: number, littleEndian: boolean = false): BufferCodec { this.#jobs.push({ value, type: 'uint32', length: 4, littleEndian }); return this; }
emmorts/buffercodec
lib/BufferCodec.ts
TypeScript
MethodDeclaration
/** * Encode a 32-bit float * @param value 32-bit numeric value * @returns {BufferCodec} Current instance of BufferCodec */ float32(value: number, littleEndian: boolean = false): BufferCodec { this.#jobs.push({ value, type: 'float32', length: 4, littleEndian }); return this; }
emmorts/buffercodec
lib/BufferCodec.ts
TypeScript
MethodDeclaration
/** * Encode a 64-bit float * @param value 64-bit numeric value * @returns {BufferCodec} Current instance of BufferCodec */ float64(value: number, littleEndian: boolean = false): BufferCodec { this.#jobs.push({ value, type: 'float64', length: 8, littleEndian }); return this; }
emmorts/buffercodec
lib/BufferCodec.ts
TypeScript
MethodDeclaration
private decodeString(dataView: DataView, encoding: BufferStringEncoding): [string, number] { let currentOffset = this.#offset; let result = ''; const contentLength = dataView.getUint8(currentOffset++); if (encoding === 'utf16') { const utf16 = new ArrayBuffer(contentLength * 2); const utf16view = new Uint16Array(utf16); for (let i = 0; i < contentLength; i++ , currentOffset += 2) { utf16view[i] = dataView.getUint8(currentOffset); } result = String.fromCharCode.apply(null, Array.from(utf16view)); } if (encoding === 'utf8') { const utf8 = new ArrayBuffer(contentLength); const utf8view = new Uint8Array(utf8); for (let i = 0; i < contentLength; i++ , currentOffset += 1) { utf8view[i] = dataView.getUint8(currentOffset); } result = String.fromCharCode.apply(null, Array.from(utf8view)); } return [result, currentOffset - this.#offset]; }
emmorts/buffercodec
lib/BufferCodec.ts
TypeScript
MethodDeclaration
private encodeString(dataView: DataView, job: BufferJob): number { const value = job.value as string; const valueLength = value.length; let currentOffset = this.#offset; dataView.setUint8(currentOffset++, valueLength); switch (job.encoding) { case 'utf16': for (let i = 0; i < (job.length - 1) / 2; i++, currentOffset += 2) { dataView.setUint16(currentOffset, value.charCodeAt(i), true); } break; case 'utf8': for (let i = 0; i < (job.length - 1); i++, currentOffset++) { dataView.setUint8(currentOffset, value.charCodeAt(i)); } break; default: throw new Error(`Undefined encoding provided '${this.#encoding}'`) } return currentOffset - this.#offset; }
emmorts/buffercodec
lib/BufferCodec.ts
TypeScript
MethodDeclaration
private encodeValue(dataView: DataView, fn: (...args: any[]) => void, job: BufferJob): number { fn.call(dataView, this.#offset, job.value as number, job.littleEndian); return job.length; }
emmorts/buffercodec
lib/BufferCodec.ts
TypeScript
ArrowFunction
({ onClickOutside }) => { const ref = useRef(null); useOnClickOutside({ ref, handler: onClickOutside }); return ( <> <div ref={ref} data-testid="div-test-id"> test-div </div> <button type="button" data-testid="button-test-id"> test-button </button> </>
ttteam-org/ttteam-vega-ui
packages/hooks/src/use-on-click-outside/use-on-click-outside.test.tsx
TypeScript
ArrowFunction
() => { document.addEventListener = defaultEventListener; }
ttteam-org/ttteam-vega-ui
packages/hooks/src/use-on-click-outside/use-on-click-outside.test.tsx
TypeScript
ArrowFunction
() => { handleClickOutside.mockReset(); }
ttteam-org/ttteam-vega-ui
packages/hooks/src/use-on-click-outside/use-on-click-outside.test.tsx
TypeScript
ArrowFunction
() => { test('коллбек не вызывается, если кликнули на элемент, который обернут в хук', () => { const eventsMap: Record<string, EventListener> = {}; document.addEventListener = jest.fn((event, cb: EventListener) => { eventsMap[event] = cb; }); render(<HookedComponent onClickOutside={handleClickOutside} />); const div = screen.getByTestId('div-test-id'); const event: MouseEvent = new MouseEvent('mousedown'); eventsMap.mousedown({ ...event, target: div }); expect(handleClickOutside).not.toBeCalled(); }); test('коллбек вызывается, если кликнули вне обернутого элемента', () => { const eventsMap: Record<string, EventListener> = {}; document.addEventListener = jest.fn((event, cb: EventListener) => { eventsMap[event] = cb; }); render(<HookedComponent onClickOutside={handleClickOutside} />); const button = screen.getByTestId('button-test-id'); const event: MouseEvent = new MouseEvent('mousedown'); eventsMap.mousedown({ ...event, target: button }); expect(handleClickOutside).toBeCalled(); }); }
ttteam-org/ttteam-vega-ui
packages/hooks/src/use-on-click-outside/use-on-click-outside.test.tsx
TypeScript
ArrowFunction
() => { const eventsMap: Record<string, EventListener> = {}; document.addEventListener = jest.fn((event, cb: EventListener) => { eventsMap[event] = cb; }); render(<HookedComponent onClickOutside={handleClickOutside} />); const div = screen.getByTestId('div-test-id'); const event: MouseEvent = new MouseEvent('mousedown'); eventsMap.mousedown({ ...event, target: div }); expect(handleClickOutside).not.toBeCalled(); }
ttteam-org/ttteam-vega-ui
packages/hooks/src/use-on-click-outside/use-on-click-outside.test.tsx
TypeScript
ArrowFunction
(event, cb: EventListener) => { eventsMap[event] = cb; }
ttteam-org/ttteam-vega-ui
packages/hooks/src/use-on-click-outside/use-on-click-outside.test.tsx
TypeScript
ArrowFunction
() => { const eventsMap: Record<string, EventListener> = {}; document.addEventListener = jest.fn((event, cb: EventListener) => { eventsMap[event] = cb; }); render(<HookedComponent onClickOutside={handleClickOutside} />); const button = screen.getByTestId('button-test-id'); const event: MouseEvent = new MouseEvent('mousedown'); eventsMap.mousedown({ ...event, target: button }); expect(handleClickOutside).toBeCalled(); }
ttteam-org/ttteam-vega-ui
packages/hooks/src/use-on-click-outside/use-on-click-outside.test.tsx
TypeScript
TypeAliasDeclaration
type Props = { onClickOutside: (e: MouseEvent | TouchEvent) => void; };
ttteam-org/ttteam-vega-ui
packages/hooks/src/use-on-click-outside/use-on-click-outside.test.tsx
TypeScript
ClassDeclaration
@NgModule({ imports: [ CommonModule, FormsModule, IonicModule, ClientsPageRoutingModule, SharedModule ], declarations: [ClientsPage] }) export class ClientsPageModule {}
Hamza-IT/Ionic-App
src/app/front_end/doctor_coach/clients/clients.module.ts
TypeScript
ArrowFunction
(unix: string | number): string => { return dayjs.unix(Number(unix) / 1000 / 1000).toISOString() }
10088/supabase
studio/components/interfaces/Settings/Logs/Logs.utils.ts
TypeScript
ArrowFunction
(unix: string | number): boolean => { const digitLength = String(unix).length === 16 const isNum = !Number.isNaN(Number(unix)) return isNum && digitLength }
10088/supabase
studio/components/interfaces/Settings/Logs/Logs.utils.ts
TypeScript
ArrowFunction
(log: LogData) => log && log.timestamp && log.metadata && log.event_message && log.id && Object.keys(log).length === 4
10088/supabase
studio/components/interfaces/Settings/Logs/Logs.utils.ts
TypeScript
ArrowFunction
(obj: { [k: string]: unknown }, parent?: string): string[] => { const keys = Object.keys(obj).filter((k) => obj[k]) return keys.flatMap((k) => { const currKey = parent ? `${parent}.${k}` : k if (typeof obj[k] === 'object') { return getDotKeys(obj[k] as any, currKey) } else { return [currKey] } }) }
10088/supabase
studio/components/interfaces/Settings/Logs/Logs.utils.ts
TypeScript
ArrowFunction
(k) => obj[k]
10088/supabase
studio/components/interfaces/Settings/Logs/Logs.utils.ts
TypeScript
ArrowFunction
(k) => { const currKey = parent ? `${parent}.${k}` : k if (typeof obj[k] === 'object') { return getDotKeys(obj[k] as any, currKey) } else { return [currKey] } }
10088/supabase
studio/components/interfaces/Settings/Logs/Logs.utils.ts
TypeScript
ArrowFunction
(table: LogsTableName, filters: Filters) => { const keys = Object.keys(filters) const filterTemplates = SQL_FILTER_TEMPLATES[table] const _resolveTemplateToStatement = (dotKey: string): string | null => { const template = filterTemplates[dotKey] const value = get(filters, dotKey) if (value !== undefined && typeof template === 'function') { return template(value) } else if (template === undefined) { // resolve unknwon filters (possibly from filter overrides) // no template, set a default if (typeof value === 'string') { return `${dotKey} = '${value}'` } else { return `${dotKey} = ${value}` } } else if (value === undefined && typeof template === 'function') { return null } else if (template && value === false) { // template present, but value is false return null } else { return template } } const statement = keys .map((rootKey) => { if (typeof filters[rootKey] === 'object') { // join all statements with an OR const nestedStatements = getDotKeys(filters[rootKey] as Filters, rootKey) .map(_resolveTemplateToStatement) .filter(Boolean) if (nestedStatements.length > 0) { return `(${nestedStatements.join(' or ')})` } else { return null } } else { const nestedStatement = _resolveTemplateToStatement(rootKey) if (nestedStatement === null) return null return `(${nestedStatement})` } }) .filter(Boolean) // join all root statements with AND .join(' and ') if (statement) { return 'where ' + statement } else { return '' } }
10088/supabase
studio/components/interfaces/Settings/Logs/Logs.utils.ts
TypeScript
ArrowFunction
(dotKey: string): string | null => { const template = filterTemplates[dotKey] const value = get(filters, dotKey) if (value !== undefined && typeof template === 'function') { return template(value) } else if (template === undefined) { // resolve unknwon filters (possibly from filter overrides) // no template, set a default if (typeof value === 'string') { return `${dotKey} = '${value}'` } else { return `${dotKey} = ${value}` } } else if (value === undefined && typeof template === 'function') { return null } else if (template && value === false) { // template present, but value is false return null } else { return template } }
10088/supabase
studio/components/interfaces/Settings/Logs/Logs.utils.ts
TypeScript
ArrowFunction
(rootKey) => { if (typeof filters[rootKey] === 'object') { // join all statements with an OR const nestedStatements = getDotKeys(filters[rootKey] as Filters, rootKey) .map(_resolveTemplateToStatement) .filter(Boolean) if (nestedStatements.length > 0) { return `(${nestedStatements.join(' or ')})` } else { return null } } else { const nestedStatement = _resolveTemplateToStatement(rootKey) if (nestedStatement === null) return null return `(${nestedStatement})` } }
10088/supabase
studio/components/interfaces/Settings/Logs/Logs.utils.ts
TypeScript
ArrowFunction
(table: LogsTableName, filters: Filters) => { const where = _genWhereStatement(table, filters) switch (table) { case 'edge_logs': return `select id, timestamp, event_message, metadata, request, response, request.method, request.path, response.status_code from ${table} cross join unnest(metadata) as m cross join unnest(m.request) as request cross join unnest(m.response) as response ${where} limit 100 ` break case 'postgres_logs': return `select postgres_logs.timestamp, id, event_message, metadata, metadataparsed.error_severity from ${table} cross join unnest(metadata) as m cross join unnest(m.parsed) as metadataparsed ${where} limit 100 ` break case 'function_logs': return `select id, ${table}.timestamp, event_message, metadata.event_type, metadata.function_id, metadata.level, metadata from ${table} cross join unnest(metadata) as metadata ${where} limit 100 ` break case 'function_edge_logs': return `select id, ${table}.timestamp, event_message, response.status_code, response, request, request.method, m.function_id, m.execution_time_ms, m.deployment_id, m.version from ${table} cross join unnest(metadata) as m cross join unnest(m.response) as response cross join unnest(m.request) as request ${where} limit 100 ` default: return `select id, ${table}.timestamp, event_message, metadata from ${table} ${where} limit 100 ` break } }
10088/supabase
studio/components/interfaces/Settings/Logs/Logs.utils.ts
TypeScript
ArrowFunction
(resolve, reject) => { let id = route.paramMap.get('id'); this.firebaseService.getRoutineDetails(id).then(routine => { routine.subscribe( data => { data.id = id; resolve(data); }) }) }
m3yevn/beabuddhist
src/app/pages/view/view-routine/view-routine.resolver.ts
TypeScript
ArrowFunction
routine => { routine.subscribe( data => { data.id = id; resolve(data); }) }
m3yevn/beabuddhist
src/app/pages/view/view-routine/view-routine.resolver.ts
TypeScript
ArrowFunction
data => { data.id = id; resolve(data); }
m3yevn/beabuddhist
src/app/pages/view/view-routine/view-routine.resolver.ts
TypeScript
ArrowFunction
(resolve, reject) => { let id = route.paramMap.get('id'); this.firebaseService.getRoutineTasks(id).then(routine => { routine.subscribe( data => { resolve(data); }) }) }
m3yevn/beabuddhist
src/app/pages/view/view-routine/view-routine.resolver.ts
TypeScript
ArrowFunction
routine => { routine.subscribe( data => { resolve(data); }) }
m3yevn/beabuddhist
src/app/pages/view/view-routine/view-routine.resolver.ts
TypeScript
ArrowFunction
data => { resolve(data); }
m3yevn/beabuddhist
src/app/pages/view/view-routine/view-routine.resolver.ts
TypeScript
ClassDeclaration
@Injectable() export class ViewRoutineResolver implements Resolve<any> { constructor(public firebaseService: FirebaseService,) { } resolve(route: ActivatedRouteSnapshot) { return new Promise((resolve, reject) => { let id = route.paramMap.get('id'); this.firebaseService.getRoutineDetails(id).then(routine => { routine.subscribe( data => { data.id = id; resolve(data); }) }) }) } }
m3yevn/beabuddhist
src/app/pages/view/view-routine/view-routine.resolver.ts
TypeScript
ClassDeclaration
@Injectable() export class TasksResolver implements Resolve<any> { constructor(public firebaseService: FirebaseService,) { } resolve(route: ActivatedRouteSnapshot) { return new Promise((resolve, reject) => { let id = route.paramMap.get('id'); this.firebaseService.getRoutineTasks(id).then(routine => { routine.subscribe( data => { resolve(data); }) }) }) } }
m3yevn/beabuddhist
src/app/pages/view/view-routine/view-routine.resolver.ts
TypeScript
MethodDeclaration
resolve(route: ActivatedRouteSnapshot) { return new Promise((resolve, reject) => { let id = route.paramMap.get('id'); this.firebaseService.getRoutineDetails(id).then(routine => { routine.subscribe( data => { data.id = id; resolve(data); }) }) }) }
m3yevn/beabuddhist
src/app/pages/view/view-routine/view-routine.resolver.ts
TypeScript
MethodDeclaration
resolve(route: ActivatedRouteSnapshot) { return new Promise((resolve, reject) => { let id = route.paramMap.get('id'); this.firebaseService.getRoutineTasks(id).then(routine => { routine.subscribe( data => { resolve(data); }) }) }) }
m3yevn/beabuddhist
src/app/pages/view/view-routine/view-routine.resolver.ts
TypeScript
FunctionDeclaration
export function MultiSelect<T>(props: MultiSelectProps<T>) { const { ariaDescribedBy, components: customComponents, errorMessage, hasError, helperMessage, inputStyle, isLabelVisuallyHidden, innerRef, itemToString, items, labelPosition, labelStyle, labelText, disabled, isInverse, itemListMaxHeight, menuStyle, messageStyle, onBlur, onFocus, onKeyDown, onKeyPress, onKeyUp, onRemoveSelectedItem, placeholder, } = props; function checkSelectedItemValidity(itemToCheck: T) { return ( items.findIndex(i => itemToString(i) === itemToString(itemToCheck)) !== -1 ); } const { getSelectedItemProps, getDropdownProps, addSelectedItem, removeSelectedItem, selectedItems, setActiveIndex, } = useMultipleSelection<T>({ ...props, ...(props.initialSelectedItems && { initialSelectedItems: props.initialSelectedItems.filter( checkSelectedItemValidity ), }), ...(props.selectedItems && { selectedItems: props.selectedItems.filter(checkSelectedItemValidity), }), }); function getFilteredItems(unfilteredItems) { return unfilteredItems.filter( item => selectedItems.findIndex( selectedItem => itemToString(selectedItem) === itemToString(item) ) < 0 ); } const { stateReducer: passedInStateReducer, onStateChange, ...selectProps } = props; function stateReducer(state, actionAndChanges) { const { type, changes } = actionAndChanges; switch (type) { case useSelect.stateChangeTypes.ToggleButtonKeyDownCharacter: return { ...changes, selectedItem: state.selectedItem, }; default: return changes; } } const { isOpen, getToggleButtonProps, getLabelProps, getMenuProps, highlightedIndex, getItemProps, selectItem, openMenu, } = useSelect({ ...selectProps, items: getFilteredItems(items), onSelectedItemChange: defaultOnSelectedItemChange, stateReducer, }); function defaultOnSelectedItemChange(changes) { const { selectedItem: newSelectedItem } = changes; if (newSelectedItem) { addSelectedItem(newSelectedItem); selectItem(null); } } function handleRemoveSelectedItem(event: React.SyntheticEvent, selectedItem) { event.stopPropagation(); onRemoveSelectedItem && typeof onRemoveSelectedItem === 'function' ? onRemoveSelectedItem(selectedItem) : removeSelectedItem(selectedItem); } const theme = React.useContext(ThemeContext); const i18n = React.useContext(I18nContext); const toggleButtonProps = getToggleButtonProps({ ...getDropdownProps({ onBlur, onKeyDown: event => { if ( document.activeElement.tagName.toLowerCase() === 'button' && (event.key === 'Backspace' || event.key === 'Delete' || event.key === 'ArrowLeft') ) { event.nativeEvent.preventDownshiftDefault = true; } if (event.key === 'Enter' || event.key === ' ') { event.preventDefault(); openMenu(); } onKeyDown && typeof onKeyDown === 'function' && onKeyDown(event); }, onKeyPress, onKeyUp, onFocus, preventKeyAction: isOpen, ...(innerRef && { ref: innerRef }), }), disabled: disabled, }); return ( <SelectContainer descriptionId={ariaDescribedBy} errorMessage={errorMessage} getLabelProps={getLabelProps} helperMessage={helperMessage} isLabelVisuallyHidden={isLabelVisuallyHidden} labelPosition={labelPosition} labelStyle={labelStyle} labelText={labelText} isInverse={isInverse} messageStyle={messageStyle} > <SelectTriggerButton ariaDescribedBy={ariaDescribedBy} toggleButtonProps={toggleButtonProps} hasError={hasError} disabled={disabled} isInverse={isInverse} style={inputStyle} > {selectedItems && selectedItems.length > 0 ? selectedItems.map((multiSelectedItem, index) => { const multiSelectedItemString = itemToString(multiSelectedItem); return ( <SelectedItemButton aria-label={i18n.multiSelect.selectedItemButtonAriaLabel.replace( /\{selectedItem\}/g, multiSelectedItemString )} key={`selected-item-${index}`} {...getSelectedItemProps({ selectedItem: multiSelectedItem, index, })} onClick={event => handleRemoveSelectedItem(event, multiSelectedItem) } onFocus={() => setActiveIndex(index)}
Malgalad/react-magma
packages/react-magma-dom/src/components/Select/MultiSelect.tsx
TypeScript
FunctionDeclaration
function checkSelectedItemValidity(itemToCheck: T) { return ( items.findIndex(i => itemToString(i) === itemToString(itemToCheck)) !== -1 ); }
Malgalad/react-magma
packages/react-magma-dom/src/components/Select/MultiSelect.tsx
TypeScript
FunctionDeclaration
function getFilteredItems(unfilteredItems) { return unfilteredItems.filter( item => selectedItems.findIndex( selectedItem => itemToString(selectedItem) === itemToString(item) ) < 0 ); }
Malgalad/react-magma
packages/react-magma-dom/src/components/Select/MultiSelect.tsx
TypeScript
FunctionDeclaration
function stateReducer(state, actionAndChanges) { const { type, changes } = actionAndChanges; switch (type) { case useSelect.stateChangeTypes.ToggleButtonKeyDownCharacter: return { ...changes, selectedItem: state.selectedItem, }; default: return changes; } }
Malgalad/react-magma
packages/react-magma-dom/src/components/Select/MultiSelect.tsx
TypeScript
FunctionDeclaration
function defaultOnSelectedItemChange(changes) { const { selectedItem: newSelectedItem } = changes; if (newSelectedItem) { addSelectedItem(newSelectedItem); selectItem(null); } }
Malgalad/react-magma
packages/react-magma-dom/src/components/Select/MultiSelect.tsx
TypeScript
FunctionDeclaration
function handleRemoveSelectedItem(event: React.SyntheticEvent, selectedItem) { event.stopPropagation(); onRemoveSelectedItem && typeof onRemoveSelectedItem === 'function' ? onRemoveSelectedItem(selectedItem) : removeSelectedItem(selectedItem); }
Malgalad/react-magma
packages/react-magma-dom/src/components/Select/MultiSelect.tsx
TypeScript
ArrowFunction
i => itemToString(i) === itemToString(itemToCheck)
Malgalad/react-magma
packages/react-magma-dom/src/components/Select/MultiSelect.tsx
TypeScript
ArrowFunction
item => selectedItems.findIndex( selectedItem => itemToString(selectedItem) === itemToString(item) ) < 0
Malgalad/react-magma
packages/react-magma-dom/src/components/Select/MultiSelect.tsx
TypeScript
ArrowFunction
selectedItem => itemToString(selectedItem) === itemToString(item)
Malgalad/react-magma
packages/react-magma-dom/src/components/Select/MultiSelect.tsx
TypeScript
ArrowFunction
event => { if ( document.activeElement.tagName.toLowerCase() === 'button' && (event.key === 'Backspace' || event.key === 'Delete' || event.key === 'ArrowLeft') ) { event.nativeEvent.preventDownshiftDefault = true; } if (event.key === 'Enter' || event.key === ' ') { event.preventDefault(); openMenu(); } onKeyDown && typeof onKeyDown === 'function' && onKeyDown(event); }
Malgalad/react-magma
packages/react-magma-dom/src/components/Select/MultiSelect.tsx
TypeScript
ArrowFunction
(multiSelectedItem, index) => { const multiSelectedItemString = itemToString(multiSelectedItem); return ( <SelectedItemButton aria-label={i18n.multiSelect.selectedItemButtonAriaLabel.replace( /\{selectedItem\}/g, multiSelectedItemString )} key={`selected-item-${index}`}
Malgalad/react-magma
packages/react-magma-dom/src/components/Select/MultiSelect.tsx
TypeScript
MethodDeclaration
handleRemoveSelectedItem(event, multiSelectedItem)
Malgalad/react-magma
packages/react-magma-dom/src/components/Select/MultiSelect.tsx
TypeScript
MethodDeclaration
getFilteredItems(items)
Malgalad/react-magma
packages/react-magma-dom/src/components/Select/MultiSelect.tsx
TypeScript
ArrowFunction
(format: StyleResourcesFileFormat): StyleResourcesLoaderOptions => ({ patterns: `./${format}/resources.${format}`, })
VisonM/style-resources-loader
test/options/string-pattern.ts
TypeScript
InterfaceDeclaration
export interface Props { block?: boolean; children?: ReactNode; className?: string; disabled?: boolean; size?: 'large' | 'regular' | 'small' | 'x-small' | 'custom'; theme?: 'default' | 'primary'; variant?: 'contained' | 'outlined' | 'link' | 'text'; }
MilanBariya/OpenMetadata
openmetadata-ui/src/main/resources/ui/src/components/buttons/Button/Button.interface.ts
TypeScript
InterfaceDeclaration
export interface ButtonAsButtonProps extends Props, React.ButtonHTMLAttributes<HTMLButtonElement> { /** * The element that should be rendered as a button */ tag?: 'button'; /** * The native HTML button type */ type?: 'button' | 'submit' | 'reset'; }
MilanBariya/OpenMetadata
openmetadata-ui/src/main/resources/ui/src/components/buttons/Button/Button.interface.ts
TypeScript
InterfaceDeclaration
export interface ButtonAsAnchorProps extends Props, React.AnchorHTMLAttributes<HTMLAnchorElement> { tag?: 'a'; }
MilanBariya/OpenMetadata
openmetadata-ui/src/main/resources/ui/src/components/buttons/Button/Button.interface.ts
TypeScript
InterfaceDeclaration
export interface ButtonAsOtherProps extends Props, React.AnchorHTMLAttributes<HTMLAnchorElement> { tag?: string; }
MilanBariya/OpenMetadata
openmetadata-ui/src/main/resources/ui/src/components/buttons/Button/Button.interface.ts
TypeScript
TypeAliasDeclaration
export type ButtonProps = | ButtonAsButtonProps | ButtonAsAnchorProps | ButtonAsOtherProps;
MilanBariya/OpenMetadata
openmetadata-ui/src/main/resources/ui/src/components/buttons/Button/Button.interface.ts
TypeScript
TypeAliasDeclaration
export type Ref = ReactNode | HTMLElement | string;
MilanBariya/OpenMetadata
openmetadata-ui/src/main/resources/ui/src/components/buttons/Button/Button.interface.ts
TypeScript