Skip to content

Instantly share code, notes, and snippets.

@ajcrites
ajcrites / typedef.ts
Last active September 23, 2024 13:35
interface ItemCalendar {
startDay: number
finishDay: number
itemsPerDay: number
}
function calcItemsUsedBetweenDaysTs({ startDay, finishDay, itemsPerDay }: ItemCalendar) {
return (finishDay - startDay) * itemsPerDay;
}
deleteStaleSpecials() {
return from(this.specials.filter(({ stale }) => stale)).pipe(
mergeMap(special =>
from(this.deleteSpecial(special)).pipe(
catchError(e => of(e))
)
)
);
}
deleteStaleSpecials() {
const specialsDeletionStatus = Promise.allSettled(
this.specials
.filter(({ stale }) => stale)
.map((special) => this.deleteSpecial(special))
);
const rejectedCheckPredicate = ({ status }) => status === 'rejected';
if (specialsDeletionStatus.some(rejectedCheckPredicate) {
export class SpecialsService {
specials: Special[] = [];
...
deleteStaleSpecials() {
return Promise.all(
this.specials.map(async (special) => {
if (special.stale) {
await this.deleteSpecial(special);
}
export class SpecialsService {
specials: [Special] = [{} as Special];
...
async deleteStaleSpecials() {
try {
this.specials.forEach(async (special) => {
if (special.stale) {
await this.deleteSpecial(special);
}
export class ProfilePage {
...
shouldTriggerAppOpen = false;
gameUrl = from(this.userService.getUserId()).pipe(
mergeMap(
({ token: userIdToken } = { token = '' }) =>
this.gameService.buildUrl(userIdToken)
),
@Component(...)
export class ProfilePage {
...
async openGameApp() {
try {
const { token: userIdToken } = { token: '' } = await this.userService.getUserId();
Browser.open(
await lastValueFrom(
export const GAME_FORMAT = '/#{sessionId}/game/format';
export const GAME_WEB_FORMAT_URL = '/#{sessionId}/game/format';
export const GAME_WEB_APP_URL = 'https://qa.game.com';
function validateEmail(email: string) {
- return Promise.resolve(validate(email.trim()));
+ return validate(email.trim());