This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function arrow(number) { | |
const isEven = number % 2 == 0; | |
const middles = isEven ? [Math.floor(number / 2) - 1, Math.floor(number / 2)] : [Math.floor(number / 2)] | |
const middle = middles[0] | |
new Array(number).fill(1).forEach((_, idx) => { | |
let indent = 0; | |
if (middles.includes(idx)) { | |
indent = middle | |
} else if (idx < middle) { | |
indent = idx |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@Post('money/transfer') | |
async transferMoney(@Body() dto: TransferMoneyDto) { | |
// Start session using mongo connection | |
const session = await this.mongoConnection.startSession(); | |
// Start transaction using the session | |
session.startTransaction(); | |
try { | |
// This method will do a few mongo db operations | |
const result = await this.transferMoneyService.transfer(dto, session); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import { Injectable } from '@nestjs/common'; | |
import { ReceiveMode, ServiceBusClient } from '@azure/service-bus'; | |
@Injectable() | |
export class ServiceBusService { | |
constructor() { | |
this.init(); | |
} | |
async init() { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import { createSlice, PayloadAction } from '@reduxjs/toolkit'; | |
import { UserProfileApi, UserSettingsApi } from '@selfplat/api-model'; | |
import { AppThunk } from '../root.store'; | |
import { ProfileService } from './profile.service'; | |
export interface UserState { | |
profile: UserProfileApi; | |
settings: UserSettingsApi; | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const theme = { | |
breakpoints: ['30em', '48em', '62em', '80em'], | |
zIndices: { | |
hide: -1, | |
auto: 'auto', | |
base: 0, | |
docked: 10, | |
dropdown: 1000, | |
sticky: 1100, | |
banner: 1200, |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//Make the following test cases pass | |
function isPalindrome(phrase) { | |
const SPACE = " "; | |
const lowerCharsInPhrase = phrase | |
.toLowerCase() | |
.split("") | |
.filter(char => char !== SPACE); | |
return lowerCharsInPhrase.join() === lowerCharsInPhrase.reverse().join(); | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const maybePerson = getPerson(); | |
console.log(maybePerson?.name); | |
console.log(maybePerson?.name?.firstName); | |
console.log(maybePerson?.name?.lastName); | |
console.log(maybePerson?.name?.getFullName?.()); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const maybePerson = getPerson(); | |
if (maybePerson) { | |
console.log(maybePerson.name); | |
} | |
if (maybePerson && maybePerson.name) { | |
console.log(maybePerson.name.firstName); | |
console.log(maybePerson.name.lastName); | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function getRandomNumber() { | |
return Math.floor(Math.random() * 100); | |
} | |
function isEvenNumber(number: number) { | |
return number % 2 == 0; | |
} | |
function getPerson() { | |
if (isEvenNumber(getRandomNumber())) { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
export class AppComponent implements OnInit, OnDestroy { | |
@Selector(CustomersState.SelectedCustomer) | |
private selectedCustomer$: Observable<Customer>; | |
@Selector(OrdersState.NewOrder) | |
private newOrder$: Observable<Order>; | |
private onComponentDestroy$: Subject<void>; | |
constructor() { |
NewerOlder