{"version":3,"sources":["https://lively-kernel.org/lively4/BP2019RH1/scratch/venn-source/getSet.js"],"names":["getSet","option","component","_","arguments","length","applier","options","key","binder","bind"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;;;;;;;;;;AAUA,qBAASA,MAAT,CAAgBC,MAAhB,EAAwBC,SAAxB,EAAmC;AACjC,uBAAO,UAASC,CAAT,EAAY;AACjB,wBAAI,CAAEC,UAAUC,MAAhB,EAAwB;AACtB,+BAAO,KAAKJ,MAAL,CAAP;AACD;;AAED,yBAAKA,MAAL,IAAeE,CAAf;;AAEA,2BAAOD,SAAP;AACD,iBARD;AASD;;AAED,qBAASI,OAAT,CAAiBJ,SAAjB,EAA4BK,OAA5B,EAAqC;AACpC,qBAAK,IAAIC,GAAT,IAAgBD,OAAhB,EAAyB;AAClB,wBAAGL,UAAUM,GAAV,KAAmB,OAAON,UAAUM,GAAV,CAAP,IAAyB,UAA/C,EAA4D;AACxDN,kCAAUM,GAAV,EAAeD,QAAQC,GAAR,CAAf;AACH;AACJ;AACD,uBAAON,SAAP;AACH;;AAED,qBAASO,MAAT,CAAgBP,SAAhB,EAA2BK,OAA3B,EAAoC;AACnC,qBAAK,IAAIC,GAAT,IAAgBD,OAAhB,EAAyB;AAClB,wBAAG,CAACL,UAAUM,GAAV,CAAJ,EAAoB;AAChBN,kCAAUM,GAAV,IAAiBR,OAAOQ,GAAP,EAAYN,SAAZ,EAAuBQ,IAAvB,CAA4BH,OAA5B,CAAjB;AACH;AACJ;AACJ;;;;;;8BAEOE,M;;+BAAQH,O","file":"getSet.js","sourcesContent":["/**\n * getSet creates a getter/setter function for a re-usable D3.js component. \n *\n * @method getSet\n * @param  {string}   option    - the name of the object in the string you want agetter/setter for.\n * @param  {function} component - the D3 component this getter/setter relates to.\n *\n * @return {mixed} The value of the option or the component.\n */\n\nfunction getSet(option, component) {\n  return function(_) {\n    if (! arguments.length) {\n      return this[option];\n    }\n\n    this[option] = _;\n\n    return component;\n  };\n}\n\nfunction applier(component, options) {\n\tfor (var key in options) {\n        if(component[key] && (typeof component[key] == \"function\")) {\n            component[key](options[key]);\n        }\n    }\n    return component;\n}\n\nfunction binder(component, options) {\n\tfor (var key in options) {\n        if(!component[key]) {\n            component[key] = getSet(key, component).bind(options);\n        }\n    }\n}\n\nexport {binder, applier};"]}