
function Collection (type) {
  var _this = this
  for (const f in type.prototype) {
    (function (fn) {
      _this[fn] = function () {
        if (_this.length) {
          var results = []
          var sameResult = true
          for (var i = 0, l = _this.length; i < l; i++) {
            var result = _this[i][fn].apply(_this[i], arguments)
            results.push(result)
            sameResult &= (result === _this[i])
          }
          return sameResult ? _this : results
        } else {
          return null
        }
      }
    })(f)
  }
}

Collection.prototype = []
Collection.constructor = Collection
export default Collection
