Skip to content

Instantly share code, notes, and snippets.

@agjs
Created April 12, 2017 15:21
Show Gist options
  • Save agjs/7cdede0ce84a2ad52ed7d6d04a386b46 to your computer and use it in GitHub Desktop.
Save agjs/7cdede0ce84a2ad52ed7d6d04a386b46 to your computer and use it in GitHub Desktop.
// Fluent api
function Chai() {}
Chai.prototype.expect = function(number) {
this.number = number;
return this;
};
Chai.prototype.increment = function() {
this.number += 1;
return this;
};
Chai.prototype.decrement = function() {
this.number -= 1;
return this;
};
Chai.prototype.addTo = function(num) {
this.number -= num;
return this;
};
var chai = new Chai(1);
chai.expect(5).increment();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment