The "branded type" approach fixes the following problem:
type UserId = string;
type GroupId = string;
const myUserId: UserId = '1';
const myGroupId: GroupId = '2';
const getUser = (userId: UserId) => {/*stuff*/};
// **NOTE** this doens't even get to the prompt yet, only setup that I think is correct. | |
'use strict'; | |
process.stdin.resume(); | |
process.stdin.setEncoding('utf-8'); | |
let inputString: string = ''; | |
let inputLines: string[] = []; | |
let currentLine: number = 0; | |
process.stdin.on('data', function(inputStdin: string): void { | |
inputString += inputStdin; |
(ns wonderland | |
(:require [clojure.set :as s])) | |
(defn common-fav-foods | |
[foods1 foods2] | |
(let [food-set1 (set foods1) | |
food-set2 (set foods2) | |
common-foods (s/intersection foods-set1 foods-set2)] | |
(str "Common Foods: " common-foods))) | |
;; TODO: add execution call examples. |
;; reverses a list of words, from codewars challenge, solution provided from @alpox on Discord | |
;; https://www.codewars.com/kata/51c8991dee245d7ddf00000e/train/clojure | |
(defn reverse-words [words] | |
(-> words | |
(clojure.string/split #" ") | |
(reverse) | |
(->> (clojure.string/join " "))) |
{ | |
"[javascript]": { | |
"editor.defaultFormatter": "esbenp.prettier-vscode" | |
}, | |
"[typescript]": { | |
"editor.defaultFormatter": "esbenp.prettier-vscode", | |
// fix for copilot | |
"editor.autoClosingBrackets": "languageDefined" | |
}, | |
"[html]": { |
// returns the parent-index, will return -1 if no parent | |
const getParentIndex = i => Math.floor((i - 1) / 2); | |
// returns the left-child index. | |
const getLeftChild = i => i * 2 + 1; | |
// returns the right-child index | |
const getRightChild = i => i * 2 + 2; |
/** | |
* Heapify function example copied directly from: | |
* https://dandkim.com/js-heap-implementation/#minheapify | |
* | |
* credit goes to https://www.linkedin.com/in/dougouk | |
* | |
*/ | |
function minHeapify (array, index) { | |
const temp = array[index] | |
let childIndex |
/* | |
* | |
* Complete the 'matchingStrings' function below. | |
* | |
* The function is expected to return an INTEGER_ARRAY. | |
* The function accepts following parameters: | |
* 1. STRING_ARRAY strings | |
* 2. STRING_ARRAY queries | |
* | |
* @param strings {string[]} array of strings to compare against |
The "branded type" approach fixes the following problem:
type UserId = string;
type GroupId = string;
const myUserId: UserId = '1';
const myGroupId: GroupId = '2';
const getUser = (userId: UserId) => {/*stuff*/};
const sortStringsByVowels = (strings) => | |
strings | |
.map((word) => ({ | |
value: word.split("").reduce( | |
({ longest, current }, char) => | |
"aeiouAEIOU".split("").includes(char) | |
? (current += 1) && { | |
longest: Math.max(longest, current), | |
current, | |
} |
import { Observable, defer } from 'rxjs'; | |
interface QueueItem { | |
req: string; | |
resolve: (req: string) => void; | |
} | |
const requestQueue: QueueItem[] = []; | |
const DELAY = 800; |