{"version":3,"sources":["../../src/utils/autobind.ts"],"names":["autobind","obj","predefined","proto","Object","getPrototypeOf","propNames","getOwnPropertyNames","object","key","value","find","name","bind"],"mappings":"AAwBA,OAAO,SAASA,QAAT,CAAkBC,GAAlB,EAAmE;AAAA,MAApCC,UAAoC,uEAAvB,CAAC,aAAD,CAAuB;AACxE,QAAMC,KAAK,GAAGC,MAAM,CAACC,cAAP,CAAsBJ,GAAtB,CAAd;AACA,QAAMK,SAAS,GAAGF,MAAM,CAACG,mBAAP,CAA2BJ,KAA3B,CAAlB;AAEA,QAAMK,MAAM,GAAGP,GAAf;;AACA,OAAK,MAAMQ,GAAX,IAAkBH,SAAlB,EAA6B;AAC3B,UAAMI,KAAK,GAAGF,MAAM,CAACC,GAAD,CAApB;;AACA,QAAI,OAAOC,KAAP,KAAiB,UAArB,EAAiC;AAC/B,UAAI,CAACR,UAAU,CAACS,IAAX,CAAgBC,IAAI,IAAIH,GAAG,KAAKG,IAAhC,CAAL,EAA4C;AAC1CJ,QAAAA,MAAM,CAACC,GAAD,CAAN,GAAcC,KAAK,CAACG,IAAN,CAAWZ,GAAX,CAAd;AACD;AACF;AACF;AACF","sourcesContent":["// Copyright (c) 2015 - 2017 Uber Technologies, Inc.\n//\n// Permission is hereby granted, free of charge, to any person obtaining a copy\n// of this software and associated documentation files (the \"Software\"), to deal\n// in the Software without restriction, including without limitation the rights\n// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\n// copies of the Software, and to permit persons to whom the Software is\n// furnished to do so, subject to the following conditions:\n//\n// The above copyright notice and this permission notice shall be included in\n// all copies or substantial portions of the Software.\n//\n// THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN\n// THE SOFTWARE.\n\n/**\n * Binds the \"this\" argument of all functions on a class instance to the instance\n * @param obj - class instance (typically a react component)\n */\nexport function autobind(obj: object, predefined = ['constructor']): void {\n const proto = Object.getPrototypeOf(obj);\n const propNames = Object.getOwnPropertyNames(proto);\n\n const object = obj as Record;\n for (const key of propNames) {\n const value = object[key];\n if (typeof value === 'function') {\n if (!predefined.find(name => key === name)) {\n object[key] = value.bind(obj);\n }\n }\n }\n}\n"],"file":"autobind.js"}