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
case class JsonableEither[+L, +R](left: Option[L] = None, right: Option[R] = None) { | |
require(left == None && right != None || | |
left != None && right == None) | |
} |
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
console.log(stringToArray('Robin H😀😀d')); |
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
console.log(stringToArray('Robin Hoווd')); |
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 stringToArray(s) { | |
const retVal = []; | |
for (let i = 0; i < s.length; ++i) { | |
retVal.push(s[i]); | |
} | |
return retVal; | |
} |
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 str = 'H😀😀d'; | |
const iterator = str[Symbol.iterator](); // get the iterator from string | |
iterator.next(); // skip over the 'H' | |
console.log(iterator.next().value); // get the first emoji |
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 stringToArray(s) { | |
const retVal = []; | |
for (const ch of s) { | |
retVal.push(ch); | |
} | |
return retVal; | |
} |
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
console.log(Array.from('Robin H😀😀d').map(ch => ch == '😀' ? '🙃' : ch)); |
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
console.log(Array.from('Robin H😀😀d').map(ch => ch == '😀' ? '🙃' : ch).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
exports.writeSumToFile = (a, b, fileSumWriter) => { | |
const sum = a + b | |
fileSumWriter(sum) | |
} |
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 {describe, it} = require('mocha') | |
const {expect} = require('chai') | |
const calculator = require('../../lib/calculator') | |
describe('calculator', function () { | |
const stream = (characters, calculatorState = calculator.initialState) => | |
!characters | |
? calculatorState | |
: stream(characters.slice(1), | |
calculator.nextState(calculatorState, characters[0])) |
OlderNewer