我应该实现方法链吗?

tom*_*ham 6 javascript dsl method-chaining

我正在编写一个javascript DSL,并想知道在实现允许在单个对象上调用多个方法的javascripts时,方法链是否是常见的做法.我来自Ruby背景,使用instance_eval更容易实现DSL,所以我更喜欢以类似的方式实现我的包,但我不想违反惯例.

我的选择是通过例子:

MyObject('test').method1(function() {
  console.log('hi');
}).method2(function() {
  console.log('bye');
});
Run Code Online (Sandbox Code Playgroud)

要么:

MyObject('test', function() {
  this.method1(function() {
    console.log('hi');
  });

  this.method2(function() {
    console.log('bye');
  });
});
Run Code Online (Sandbox Code Playgroud)

我想我会把它抛给JS大师,看看实现它的首选方法是什么.我认为这确实是个人偏好的问题,但可能有一种更为公认的方法.任何想法?