Skip to content

Instantly share code, notes, and snippets.

@ourmaninamsterdam
Last active August 29, 2015 14:05
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ourmaninamsterdam/80fdb88e16a324c0c598 to your computer and use it in GitHub Desktop.
Save ourmaninamsterdam/80fdb88e16a324c0c598 to your computer and use it in GitHub Desktop.
Method chaining with arguments - demonstrating a simple conversion pipeline utility
var Editor = function(){};
Editor.prototype.convert = {};
Editor.prototype.convert.from = function(type) {
this.fromType = type;
return this;
};
Editor.prototype.convert.to = function(type) {
this.toType = type;
this.parse(this.fromType, this.toType);
return this;
};
Editor.prototype.convert.parse = function(from, to) {
// Do some parsing
return this;
};
var editor = new Editor();
editor.convert.from('html').to('markdown');
@ourmaninamsterdam
Copy link
Author

convert.from('html').to('markdown');

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment