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 fs = require('fs') | |
const R = require('ramda') | |
const parseJSONFromFile = R.compose(JSON.parse, fs.readFileSync) | |
const products = parseJSONFromFile('../products.json') | |
console.log(products) |
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 fs = require('fs') | |
const R = require('ramda') | |
const parseJSONFromFile = R.pipe(fs.readFileSync, JSON.parse) | |
const products = parseJSONFromFile('../products.json') | |
console.log(products) |
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 fs = require('fs') | |
const R = require('ramda') | |
// Utils | |
const log = R.tap(console.log) | |
const emptyArray = () => [] | |
// getObjectFromFile | |
const parseJSONFromFile = R.compose(JSON.parse, fs.readFileSync) | |
const handleError = R.compose(emptyArray, log) |
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
[ | |
{ | |
"id": "5968dd23fc13ae04d9000001", | |
"product_name": "sildenafil citrate", | |
"supplier": "Wisozk Inc", | |
"quantity": 261, | |
"unit_cost": "$10.47" | |
}, { | |
"id": "5968dd23fc13ae04d9000002", | |
"product_name": "Mountain Juniperus ashei", |
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 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 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 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 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 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 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 |
OlderNewer