After understanding how Box is, then we are going to see how to use Box to refacotr code, to un-nested expression. For example, we have code: const moneyToFloat = str => { const cost = str.replace(/\$/g, ''); return parseFloat(cost); } const percentT…
We refactor a function that uses try/catch to a single composed expression using Either. We then introduce the chain function to deal with nested Eithers resulting from two try/catch calls. For example we have this code using try & catch: const getPo…
本文转自:https://code.visualstudio.com/docs/nodejs/nodejs-tutorial Node.js tutorial in Visual Studio Code Node.js is a platform for building fast and scalable server applications using JavaScript. Node.js is the runtime and NPM is the Package Manager for…
今天在使用bootstrap的时候引入的js文件出现错误Syntax error on token "Invalid Regular Expression Options", no accurate correc: 大概意思就是无效的表达式什么的,具体解决方法如下: 1.选中报错的js文件或报错内容.2.右键选择 MyEclipse-->Exclude From Validation .3.再右键选择 MyEclipse-->Run Validation 即可. 本文参照h…
We define the Either type and see how it works. Then try it out to enforce a null check and branch our code. Now, we try to make Box more useful. We want to do a force null check by define "Right" and "Left" tow boxes. What "Right…
For if..else: const showPage() { if(current_user) { return renderPage(current_user); } else { return showLogin(); } } const showPage() { fromNullable(current_user) .fold(showLogin, renderPage) } const getPrefs = user => { if(user.premium) { return lo…
Object-Oriented Code 1. var Person = function (name) { this.name = name; }; Person.prototype.say = function (words) { alert(this.name + ' says "' + words + '"'); }; var tom = new Person("tom"); tom.say("Hello"); 2.Inheritance…
CentOs 6.5 using root acount, I have a working Node.js Express app: root@vps [/home/test/node]# npm start app.js > test@0.0.1 start /home/test/node > node ./bin/www app.js The app can be seen working on the internet browser. I stop the app and try t…
When we start to accumulate functions that all work on a given datatype, we end up creating a bunch of boilerplate code in almost every function to handle the changes we need to make to our records’ values. This can lead to not only undesirable boile…
We'll examine how to unnest function calls, capture assignment, and create a linear data flow with a type we call Box. This is our introduction to working with the various container-style types. At first, might not be comforable with 'Box' or 'Contai…