This file contains hidden or 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 { Helper } from './helper' | |
| import { Observable, combineLatest, Subject } from 'rxjs' | |
| import { | |
| refCount, | |
| scan, | |
| startWith, | |
| switchMapTo, | |
| takeUntil, | |
| publishBehavior, | |
| } from 'rxjs/operators' |
This file contains hidden or 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 interface IGameState { | |
| id: string | |
| status: GameStatus | |
| selectedLetters: string[] | |
| lifeLeft: number | |
| secretWordLength: number | |
| knownSecretWord: string | |
| timeLeft: number | |
| } |
This file contains hidden or 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 { GameStatus } from './hangman/model' | |
| import { Helper } from './hangman/helper' | |
| import { timer, Subject } from 'rxjs' | |
| import express from 'express' | |
| import { reactiveHangman } from './hangman/reactive-hangman' | |
| import { StateManager } from './hangman/state-manager' | |
| import { take, distinctUntilKeyChanged } from 'rxjs/operators' | |
| const app = express() | |
| const port = 3000 |
This file contains hidden or 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 { Observable, BehaviorSubject, Subject } from 'rxjs' | |
| import { withLatestFrom } from 'rxjs/operators' | |
| import { deepEqual } from 'assert' | |
| interface IGameState { | |
| status: GameStatus | |
| selectedLetters: string[] | |
| lifeLeft: number | |
| secretWordLength: number | |
| knownSecretWord: string |
This file contains hidden or 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 hangman2(secretWords: string, ...letters: string[]) { | |
| return [...secretWords].every(char => letters.includes(char)) | |
| } |
This file contains hidden or 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 hangman(secretWords: string, ...letters: string[]) { | |
| return ( | |
| secretWords | |
| .split('') | |
| .sort() | |
| .join() === | |
| letters | |
| .filter(letter => secretWords.includes(letter)) | |
| .sort() | |
| .join() |
This file contains hidden or 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 R = require('ramda') | |
| const customers = [ | |
| { id: 1, name: 'Bill', age: 45, title: 'MR.', email: 'bill@email.com', phoneNumber: 01, company: 'ABC Comp' }, | |
| { id: 2, name: 'Diane', age: 59, email: 'diane@email.com', phoneNumber: 02 }, | |
| { id: 3, name: 'Krish', age: 26, title: 'MR.', phoneNumber: 03, company: 'Apricot' } | |
| ] | |
| // const titleProp = R.prop('title') | |
| // const nameProp = R.prop('name') |
This file contains hidden or 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 R = require('ramda') | |
| const products = [...] | |
| const unitCostLens = R.lensProp('unit_cost') | |
| const dollarToNumber = R.pipe(R.tail, Number) | |
| const unitCostDollarToNumber = R.over(unitCostLens, dollarToNumber) | |
| const mapUnitCostDollarToNumber = R.map(unitCostDollarToNumber) | |
| const result = mapUnitCostDollarToNumber(products) | |
| cconsole.log(result) |
This file contains hidden or 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 R = require('ramda') | |
| const products = [...] | |
| // R.map | |
| const productNameProp = R.prop('product_name') | |
| const getProductNameList = R.map(productNameProp) | |
| const mapResult = getProductNameList(products) | |
| // console.log(mapResult) |
This file contains hidden or 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
| [ | |
| { | |
| "id": "5968dd23fc13ae04d9000001", | |
| "product_name": "sildenafil citrate", | |
| "supplier": "Wisozk Inc", | |
| "quantity": 261, | |
| "unit_cost": "$10.47" | |
| }, { | |
| "id": "5968dd23fc13ae04d9000002", | |
| "product_name": "Mountain Juniperus ashei", |