This guide assumes you've got a project using Detox with Jest, and you want to write your Detox tests in TypeScript.
- Refer to this guide if you need to set up such a project.
We'll be using ts-jest to run Jest tests with TypeScript.
| import requests | |
| import base64 | |
| import secrets | |
| import hashlib | |
| # App's credentials | |
| CLIENT_ID = "top_id" # change this | |
| CLIENT_SECRET = "top_secret" # change this | |
| REDIRECT_URI = "https://ton-design-system-next-typescript.vercel.app/" # change this |
| // A `Fruit` object contains `name` and `color` | |
| class Fruit { | |
| final String name; | |
| final String color; | |
| Fruit( this.name, this.color ); | |
| } | |
| // A `Fruits` collection contains the List of `Fruit` object | |
| // `iterator` getter returns an instance of `FruitsIterator` instance |
| // inspired by: | |
| // https://flaviocopes.com/how-to-get-days-between-dates-javascript/ | |
| // and modified entry data | |
| const getDatesBetweenDates = (startDate, endDate) => { | |
| let dates = []; | |
| //to avoid modifying the original date | |
| const theDate = new Date(startDate); | |
| while (theDate < endDate) { | |
| dates = [...dates, new Date(theDate)]; | |
| theDate.setDate(theDate.getDate() + 1); |
| // src/stores/Counter.ts | |
| import { makeAutoObservable } from 'mobx'; | |
| type State { | |
| counter: number; | |
| }; | |
| type Mutations { | |
| increment(): void; |
This guide assumes you've got a project using Detox with Jest, and you want to write your Detox tests in TypeScript.
We'll be using ts-jest to run Jest tests with TypeScript.
While attempting to explain JavaScript's reduce method on arrays, conceptually, I came up with the following - hopefully it's helpful; happy to tweak it if anyone has suggestions.
JavaScript Arrays have lots of built in methods on their prototype. Some of them mutate - ie, they change the underlying array in-place. Luckily, most of them do not - they instead return an entirely distinct array. Since arrays are conceptually a contiguous list of items, it helps code clarity and maintainability a lot to be able to operate on them in a "functional" way. (I'll also insist on referring to an array as a "list" - although in some languages, List is a native data type, in JS and this post, I'm referring to the concept. Everywhere I use the word "list" you can assume I'm talking about a JS Array) This means, to perform a single operation on the list as a whole ("atomically"), and to return a new list - thus making it much simpler to think about both the old list and the new one, what they contain, and
| # my_frontend/Dockerfile | |
| ### STAGE 1: Build ### | |
| FROM node:latest as build | |
| RUN mkdir /usr/src/app | |
| WORKDIR /usr/src/app | |
| ENV PATH /usr/src/app/node_modules/.bin:$PATH | |
| COPY package.json /usr/src/app/package.json | |
| RUN npm install --silent | |
| COPY . /usr/src/app |
| FROM node:lts-alpine AS build-stage | |
| WORKDIR /app | |
| COPY package*.json ./ | |
| RUN npm install | |
| COPY . . | |
| RUN npm run build | |
| FROM nginx:stable-alpine | |
| COPY --from=build-stage /app/dist /usr/share/nginx/html | |
| # this isn't necessary - you don't have to expose a port here |
| /* eslint-disable no-var,no-console */ | |
| // detect unused CSS selectors | |
| (function() { | |
| var parsedRules = parseCssRules(); | |
| console.log('Parsed CSS rules:', parsedRules); | |
| detectDuplicateSelectors(parsedRules); | |
| var selectorsToTrack = getSelectorsToTrack(parsedRules); | |
| window.selectorStats = { unused: [], added: [], removed: [] }; | |
| console.log('Tracking style usage (inspect window.selectorStats for details)...'); |
| /* eslint-disable no-var,no-console */ | |
| /** | |
| * Проверка на масштабирование изображений в браузере. | |
| * Срабатывает, если натуральный размер изображения намного больше отображаемого на странице, | |
| * то есть браузер грузит большую картинку и масштабирует её до маленькой. | |
| */ | |
| (function() { | |
| if (!window.Promise || !String.prototype.startsWith || window.MSInputMethodContext) { | |
| // Не запускаем проверку в IE11 и браузерах, не поддерживающих нужные API | |
| return; |