luijar / functional-programming-js Goto Github PK
View Code? Open in Web Editor NEWCode Samples Functional Programming in JavaScript, Manning 2016
Code Samples Functional Programming in JavaScript, Manning 2016
Hi Luis,
First of all, thanks for writing this book, I have really enjoyed it.
I have some problems with some tests. (ch06 and ch08).
I see qunitjs 2.x is installed as a dep for qunit 1.x and there are changes on how you call expect (it is assert.expect now).
Also I have a little recommendation on the map of IO monad: just use an arrow function to keep the context of the method.
I'm using Qunit v1.0.0. All the test codes fail to run with following error:
stack: ReferenceError: assert is not defined
Thus, we have to inject "the assert" into each test code.
For example, the test code of 1.4 will become:
QUnit.test("Listing 1.4 Decomposing the showStudent program", function (assert) {... <- put assert here
I'm not shure but I think there is a faulty implementation in Listing 8.9. Asynchronous version of showStudent.
The implementation of then
only pay attention for Promises. But what if when we have a Nothing
container which comes from map or lift.
I've identified a few changes in the code which can lead to unexpected errors.
Missing from Person.js
set address(addr){ this._address = addr; }
Person.js param order changed from:
class Person { constructor(ssn,firstname, lastname, birthYear = null, address = null) {
To:
class Person { constructor(firstname, lastname, ssn){
Student.js param order changed from:
class Student extends Person { constructor(ssn, firstname, lastname, school, birthYear = null, address = null) {
To:
class Student extends Person { constructor(firstname, lastname, ssn, school) {
Hi Luis,
Just wondering what your thoughts were on getting onto mocha/istanbul test stack rather than QUnit/Blanket? I've forked and created a branch here to illustrate with Chapters 3 and 4.
Some advantages to this are:
Running all unit tests in one command as well as individual chapters.
Test coverage across all unit tests.
watch
mechanism built in for instant feedback while working with code.
mocha
/istanbul
are ubiquitous now for unit testing in nodejs
.
Here's sample output:
$ npm test [ 2:29PM Mon Jul 31 ]
[email protected] test /Users/aperkin/prj/functional-programming-js
mocha src/**/ch*-tests.js
Chapter 3
✓ Understanding reduce
✓ Combining map and reduce
✓ Combining map and reduce with lenses
✓ Valid or not valid
✓ Introducing filter
✓ People born in 1903
✓ Array processing with Lodash
✓ Gather stats
✓ Lazy function chains
✓ SQL-like JavaScript
✓ Recursive addition
✓ Recursive addition 2
✓ Tree navigation
Chapter 4
✓ Chaining methods together
✓ Check Type tests
✓ Tuple test
✓ Extending the core language
✓ Compsition
✓ More compsition
✓ Composition with functional libraries
✓ Composition as point-free functions
✓ Show student program with currying and composition
✓ More point-free coding
23 passing (24ms)
$ npm run ch04 [ 2:29PM Mon Jul 31 ]
[email protected] ch04 /Users/aperkin/prj/functional-programming-js
mocha src/ch04/ch04-tests.js
Chapter 4
✓ Chaining methods together
✓ Check Type tests
✓ Tuple test
✓ Extending the core language
✓ Compsition
✓ More compsition
✓ Composition with functional libraries
✓ Composition as point-free functions
✓ Show student program with currying and composition
✓ More point-free coding
10 passing (16ms)
$ npm run cover
[email protected] cover /Users/aperkin/prj/functional-programming-js
istanbul cover node_modules/.bin/_mocha src/**/ch*-tests.js
Chapter 3
✓ Understanding reduce
✓ Combining map and reduce
✓ Combining map and reduce with lenses
✓ Valid or not valid
✓ Introducing filter
✓ People born in 1903
✓ Array processing with Lodash
✓ Gather stats
✓ Lazy function chains
✓ SQL-like JavaScript
✓ Recursive addition
✓ Recursive addition 2
✓ Tree navigation
Chapter 4
✓ Chaining methods together
✓ Check Type tests
✓ Tuple test
✓ Extending the core language
✓ Compsition
✓ More compsition
✓ Composition with functional libraries
✓ Composition as point-free functions
✓ Show student program with currying and composition
✓ More point-free coding
23 passing (42ms)
=============================================================================
Writing coverage object [/Users/aperkin/prj/functional-programming-js/coverage/coverage.json]
Writing coverage reports at [/Users/aperkin/prj/functional-programming-js/coverage]
=============================================================================
=============================== Coverage summary ===============================
Statements : 95.82% ( 321/335 )
Branches : 88.46% ( 46/52 )
Functions : 87.69% ( 57/65 )
Lines : 96.08% ( 294/306 )
================================================================================
Just some thoughts...
Hello @luijar, I' reading your book (very instructive, I ❤️ it), but I can't find the ES2015 samples like class Maybe
.
I found on the book Listing 4.7 Implementation of partial:
...
let position = 0, length = args.length;
...
I think that length should be length = boundArgs.length
, isn't it?
To fix had to yarn add -D babel-preset-es2015-node5
cant find code samples
Hi,
Love the book but as others have mentioned in other issues and on the Manning forums, this repo is disappointing given it is part of a book that costs roughly $50. If you are too busy to update the code, why not ask for help from the community here?
Thanks,
Peter
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.