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OAAO,UAAU,SAAS,KAAK,GAAG,MAAM,KAAK,GAAG,MAAM,KAAK,GACtE,MAAgB,WAAT,EAAoB,EAAE,YAAY,KAAO,CAClD,CA7EA,OAAO,QAAU","file":"/npm/protocoljs@0.1.0/index.js","sourceRoot":"","sourcesContent":["/**\n * Minified by jsDelivr using Terser v5.37.0.\n * Original file: /npm/protocoljs@0.1.0/index.js\n *\n * Do NOT use SRI with dynamically generated files! More information: https://www.jsdelivr.com/using-sri-with-dynamic-files\n */\n","module.exports = defineProtocol;\n\n/**\n * @param {Function} @optional protocol\n * @param {Object} _interface is an object whose keys are the function names\n * and whose values are an array representing the arguments signature\n */\nfunction defineProtocol (protocol, _interface) {\n  if (arguments.length === 1) {\n    _interface = protocol;\n    var protocol = function (type, implementations) {\n      if (typeof type === 'function') {\n        var typePrototype = type.prototype;\n      }\n      var types = protocol[':types'];\n      var typeStr = typeOf(type && Object.create(typePrototype))\n        , typeFns = types[typeStr];\n\n      if (! typeFns) {\n        var protocolId = typePrototype.protocolId\n          , Other = types.Other;\n        typeFns = Other[protocolId] || (Other[protocolId] = {});\n      }\n      Object.keys(implementations).forEach( function (methodName) {\n        if (! (methodName in protocol)) {\n          throw new Error('This protocol does not include \"' + methodName + '\"');\n        }\n        if (methodName in typeFns) {\n          throw new Error('The type already implements the protocol method ' + methodName);\n        }\n        typeFns[methodName] = implementations[methodName];\n      });\n    }\n    protocol[':interface'] = _interface;\n    protocol[':types'] = {\n      'Arguments': {}\n    , 'Array': {}\n    , 'Boolean': {}\n    , 'Date': {}\n    , 'Function': {}\n    , 'Null': {}\n    , 'Number': {}\n    , 'Other': {}    // For any constructors\n    , 'RegExp': {}\n    , 'String': {}\n    , 'Undefined': {}\n    };\n  } else {\n    for (var k in _interface) {\n      protocol[':interface'][k] = _interface[k];\n    }\n  }\n\n  extendProtocol(protocol, _interface);\n\n  return protocol;\n}\n\nfunction extendProtocol (protocol, _interface) {\n  Object.keys(_interface).forEach( function (methodName) {\n    var index = _interface[methodName].indexOf(defineProtocol)\n      , types = protocol[':types'];\n    protocol[methodName] = function method () {\n      var target  = arguments[index]\n        , typeStr = typeOf(target)\n        , typeFns = types[typeStr]\n        , fn = (typeFns)\n             ? typeFns[methodName]\n             : types.Other[target.protocolId][methodName];\n      return fn.apply(null, arguments);\n    };\n  });\n}\n\nfunction typeOf (x) {\n  var type = Object.prototype.toString.call(x).split(' ')[1].split(']')[0];\n  return type === 'Object' ? x.constructor.name : type;\n}\n"]}