@danielkalen/simplybind
Version:
Magically simple, framework-less one-way/two-way data binding for frontend/backend in ~5kb.
41 lines (40 loc) • 20.2 kB
JavaScript
(function(){var A,m,n,B,v,r,u,C,D,O,E,F,G,H,p,I,q,P,J,K,L,h,w,x,y,M,z,N,l,t;K=function(a){return a instanceof NodeList||a instanceof HTMLCollection||"undefined"!==typeof jQuery&&null!==jQuery&&a instanceof jQuery};G=function(a){var b;if(1<a.length){if("radio"===a[0].type||"checkbox"===a[0].type){var c,d,e;e=[];c=0;for(d=a.length;c<d;c++)b=a[c],e.push(b);return e}t("onlyOneDOMElement")}return a[0]};C=function(){var a;a=document.createEvent("Event");a.initEvent("change",!0,!1);a._sb=!0;return a};v=
"push pop shift unshift splice reverse sort".split(" ");H=function(){return"sb_"+Math.floor(1E12*(1+Math.random())).toString(16)};p=function(){return Object.create(null)};J=function(a){return a instanceof m};y=function(a,b,c){var d,e;for(d in b)e=b[d],null!=q[d]&&(a.options[d]=e);if(c)return a.makePropertyLive()};u={textNodes:{},object:{set:function(a){var b,c;c=a.selector||a.property;if(a.object._sb_map)return a.object._sb_map[c]=a.ID;b={};b[c]=a.ID;return Object.defineProperty(a.object,"_sb_map",
{configurable:!0,value:b})},get:function(a,b){if(a._sb_map&&a._sb_map[b])return r[a._sb_map[b]]}},simpleObject:{set:function(a){return Object.defineProperty(a.object,"_sb_ID",{configurable:!0,value:a.ID})},get:function(a){return r[a._sb_ID]}}};F=/[.*+?^${}()|[\]\\]/g;x=w=null;M=function(){var a,b,c;c=q.placeholderStart.replace(F,"\\$&");a=q.placeholderEnd.replace(F,"\\$&");b="[^"+a+"]+";w=new RegExp(c+"("+b+")"+a,"g");return x=new RegExp(""+c+b+a,"g")};B=function(a,b,c){var d,e,f,g,k;k="";f=e=0;for(g=
a.length;e<g;f=++e)d=a[f],k+=d,c[f]&&(k+=b[c[f]]);return k};z=function(a,b){var c;c=I();throw Error("SimplyBind: "+((b?a:E[a])+("\n\nCall Source:\n"+c)));};t=function(a){var b;if(!q.silent)return b=I(),a=E[a],console.log("SimplyBind: "+(a+("\n\nCall Source:\n"+b)))};l=function(a){return z("You can't use/invoke ."+a+"() at this stage",!0)};N=function(a,b){return z("Invalid argument/s ("+b+") passed to ."+a+"()",!0)};I=function(){return Error().stack.split("\n").slice(3,10).map(function(a){return a.replace(O,
function(a,c,d){return"@ "+d})}).join("\n")};O=/[@(?:\wat\s)](.*)\/(.+)$/;Error.prototype.stack="\n\n\n";E={invalidParamName:"SimplyBind() and .to() only accept a function, an array, a bound object, a string, or a number.",fnOnly:"Only functions are allowed for .transform/.condition/All()",badEventArg:"Invalid argument number in .ofEvent()",onlyOneDOMElement:"You can only pass 1 DOM element to SimplyBind unless it's a collection of radio/checkbox inputs",emptyElList:"You can't bind an empty element list to anything..."};
r={};q={silent:!1,liveProps:!0,dispatchEvents:!1,updateEvenIfUndefined:!1,updateEvenIfSame:!1,updateOnBind:!0,mutateInherited:!1,trackArrayChildren:!1,simpleSelector:!1,promiseTransforms:!1,placeholderStart:"{{",placeholderEnd:"}}"};M();n=function(a,b,c){if(!a&&0!==a||"string"!==typeof a&&"number"!==typeof a&&"function"!==typeof a&&!(a instanceof Array))J(a)||z("invalidParamName");return"object"!==typeof a||a instanceof Array?new m(null,0,null,a,c,b):new m(a._,1)};A=function(a,b,c,d,e,f,g,k){var h,
l;for(h in g)l=g[h],this[h]=l;this.options=f;this.type=a;this.ID=H();this.property=c;this.selector=b;this.object=d;this.objects=e;this.value=this.valueOriginal=null;this.deps=[];this.depsMap={1:p(),2:p()};this.depsPholders=p();this.myPholders=p();this.transforms=p();this.conditions=p();this.attachedEvents=[];"Event"!==this.type&&(a=this.fetchDirectValue(null,k),"undefined"===typeof a&&"ObjectProp"===this.type&&(this.object[this.property]=a=null),this.value=this.valueOriginal=a,this.placeholder&&!this.pholderValues&&
this.scanForPholders());this.makePropertyLive();this.attachEvents();this.object instanceof Array&&"Array"!==this.type&&(this.arrayBinding=a=u.simpleObject.get(this.object))&&a.options.trackArrayChildren&&-1===a.trackedChildren.indexOf(this.property)&&(a.trackedChildren.push(this.property),n(this.property).of(this.object).to(a.updateSelf));return r[this.ID]=this};m=function(a,b,c,d,e,f){var g,k;this.stage=b||0;b=c||{};for(g in b)c=b[g],this[g]=c;this.proxies=this.proxies&&this.proxies.length?this.proxies:
this.proxied?[this.proxied]:[];null==this.state&&(this.state={});switch(this.stage){case 0:this.optionsPassed=f||(f={});this.options={};for(g in q)this.options[g]=null!=f[g]?f[g]:q[g];"function"===typeof d?(a=this.setObject(d,"Func",!0,e),this.stage=1):d instanceof Array?(a=this.setObject(d,"Array",!0),this.stage=1):("number"===typeof d&&(d=d.toString()),this.selector=this.property=d,this.options.simpleSelector||(-1!==this.selector.indexOf(":")&&(k=this.property.split(":"),this.descriptor=k[0],this.property=
k[1]),-1!==this.selector.indexOf(".")&&(k=this.property.split("."),this.property=k[0],this.placeholder=k.slice(1).join(".")),this.selector=this.property));break;case 1:if(!a){if(K(d)){d=G(d);if(!d)return t("emptyElList");b=this.objects=[].concat(d);d=0;for(f=b.length;d<f;d++)g=b[d],g.checked&&(k=g);d=k||(k=this.objects[0]);1<this.objects.length||delete this.objects}k=d;if(this.isDom=k.nodeName&&1===k.nodeType)d=this.objects?this.objects[0].nodeName.toUpperCase():k.nodeName.toUpperCase(),this.isDomInput=
"INPUT"===d||"TEXTAREA"===d||"SELECT"===d;d=function(){switch(!1){case !this.state.hasEventName:return"Event";case !(this.isDomInput&&"value"===this.property):return"DOMValue";case !(this.isDom&&"textContent"===this.property):return"DOMText";case "attr"!==this.descriptor:return"DOMAttr";default:return"ObjectProp"}}.call(this);a=this.setObject(k,d)}}Object.defineProperties(this,{_:{value:a},ID:{get:function(){return a.ID}},value:{get:function(){return a.value}},original:{get:function(){return a.objects||
a.object}},dependents:{get:function(){return a.deps.slice().map(function(a){return a.object})}},"new":{value:function(b,c){return new m(a,b,this.getState(),c,e)}}});return this};A.prototype={makePropertyLive:function(a){var b,c,d,e,f,g,k,h;if(this.options.liveProps)if(b=this,"ObjectProp"===this.type){if(f=Object.getOwnPropertyDescriptor(this.object,this.property),(h=(h=this.options.mutateInherited||f&&f.configurable)&&this.object.constructor!==CSSStyleDeclaration)&&!this.isLiveProp||a)return this.isLiveProp=
!0,d=(null!=f?null!=(g=f.get)?g.bind(this.object):void 0:void 0)||function(){return b.value},e=(null!=f?null!=(k=f.set)?k.bind(this.object):void 0:void 0)||function(){},Object.defineProperty(this.object,this.property,{configurable:!0,enumerable:null!=f?f.enumerable:void 0,get:function(){return d()},set:function(a){b.setValue(a);return e(a)}})}else if("Array"===this.type&&(this.isLiveProp||(this.isLiveProp=!0,v.forEach(function(a){return Object.defineProperty(b.value,a,{configurable:!0,value:function(){var c;
c=Array.prototype[a].apply(b.value,arguments);b.updateAllDeps();return c}})})),this.options.trackArrayChildren&&!this.trackedChildren))return this.trackedChildren=[],this.updateSelf=function(){return b.updateAllDeps()},c={updateOnBind:!1},this.value.forEach(function(a,d){b.trackedChildren.push(""+d);return n(d,c).of(b.value).to(b.updateSelf)})},addDep:function(a,b,c){this.depsMap[1][a.ID]||(this.depsMap[1][a.ID]=a._,this.deps.push(a._));b.placeholder?this.myPholders[a.ID]=b.placeholder:this.myPholders[a.ID]&&
delete this.myPholders[a.ID];a.placeholder&&(this.depsPholders[a.ID]=a.placeholder);c?this.depsMap[2][a.ID]=a._:a._.depsMap[1][this.ID]&&(a._.addDep(b,a,!0),this.addDep(a,b,!0));return this},removeDep:function(a,b){this.depsMap[1][a.ID]&&(this.deps.splice(this.deps.indexOf(a),1),delete this.depsMap[1][a.ID],delete this.depsPholders[a.ID]);if(b)return a.removeDep(this),delete this.depsMap[2][a.ID]},removeAllDeps:function(a){var b,c,d,e;e=this.deps.slice();c=0;for(d=e.length;c<d;c++)b=e[c],this.removeDep(b,
a);if(a||0===Object.keys(this.depsMap[2]).length)return this.destroy()},destroy:function(){var a,b,c,d;delete r[this.ID];if("ObjectProp"===this.type||"DOMText"===this.type)Object.defineProperty(this.object,this.property,{value:this.value,writable:!0}),delete this.object._sb_map,delete this.object._sb_ID;else if("Event"===this.type){d=this.attachedEvents;b=0;for(c=d.length;b<c;b++)a=d[b],this.unRegisterEvent(a,this.customEventMethod.remove);delete this.object._sb_map}else if("Array"===this.type)for(delete this.object._sb_ID,
a=0,b=v.length;a<b;a++)c=v[a],delete this.object[c];else"Func"===this.type&&delete this.object._sb_ID},fetchDirectValue:function(a,b){null==a&&(a=this.type);switch(a){case "Func":if(!b)return this.object();break;case "Array":return this.object;case "DOMAttr":return this.object.getAttribute(this.property)||"";default:return this.object[this.property]}},setValue:function(a,b,c,d){var e,f,g,k;null==c&&(c=this);e=b?this.pholderValues[b]:this.value;this.selfTransform&&(a=this.selfTransform(a));e=a!==e||
this.options.updateEvenIfSame;g="undefined"!==typeof a||this.options.updateEvenIfUndefined;if((e&&g||this.isEvent)&&"Array"!==this.type){b?(this.pholderValues[b]=f=a,this.value=a=B(this.pholderContexts,this.pholderValues,this.pholderIndexMap)):this.value=a;switch(this.type){case "ObjectProp":this.isLiveProp||(this.object[this.property]=a);break;case "Func":b=this.valuePassed;this.valuePassed=a;this.value=this.object(a,b);break;case "Event":d||(this.emitCauser=c,this.emitEvent(a),this.emitCauser=null);
break;case "DOMValue":if(this.objects)for(k=this.objects,f=0,e=k.length;f<e;f++)g=k[f],b=g.checked=g.value===a,this.options.dispatchEvents&&b&&g.dispatchEvent(C());else this.object.value!==this.value&&(this.object.value=this.value,this.options.dispatchEvents&&this.object.dispatchEvent(C()));break;case "DOMAttr":this.object.setAttribute(this.property,this.value);break;case "DOMText":this.applyTextContentReplace(this.object,b,f)}d&&this.emitCauser||this.updateAllDeps(c)}},updateAllDeps:function(a){var b,
c,d,e;if(this.deps.length){if(this.throttleRate){if(+new Date-this.lastUpdate<this.throttleRate)return clearTimeout(this.throttleTimeout),this.throttleTimeout=setTimeout(function(b){return function(){return b.updateAllDeps(a)}}(this),this.throttleRate);this.lastUpdate=+new Date}e=this.deps;c=0;for(d=e.length;c<d;c++)b=e[c],this.updateDep(b,a)}},updateDep:function(a,b){var c,d,e,f;c=null===this.value&&"Event"===this.type;if(!(b&&(b===a||b!==this&&b.depsMap[1][a.ID])||c)&&(b||(b=this),c=(c=this.myPholders[a.ID])?
this.pholderValues[c]:this.value,e=(d=this.depsPholders[a.ID])?a.pholderValues[d]:a.value,f=c,f=this.applyTransform(a,d,c,e),this.checkCondition(a,d,c,e)))return this.options.promiseTransforms&&null!=f&&"function"===typeof f.then?f.then(function(c){return function(c){return a.setValue(c,d,b)}}(this)):a.setValue(f,d,b)},processTransform:function(a,b){var c,d,e,f;if("function"!==typeof a)return t("fnOnly");c=0;for(d=b.length;c<d;c++)e=b[c],f=e.ID,f+=e.placeholder?"."+e.placeholder:"",this.addTransform(f,
a),e=e._,this.depsMap[2][e.ID]&&e.addTransform(this.ID,a),(this.options.updateOnBind||"Func"===this.type)&&this.updateDep(e);return!0},applyTransform:function(a,b,c,d){return this.hasTransforms?(a=a.ID,b&&(a+="."+b),this.transforms[a]?this.transforms[a](c,d):c):c},addTransform:function(a,b){this.hasTransforms=!0;return this.transforms[a]=b},processCondition:function(a,b){var c,d,e,f;if("function"!==typeof a)return t("fnOnly");c=0;for(d=b.length;c<d;c++)e=b[c],f=e.ID,f+=e.placeholder?"."+e.placeholder:
"",this.addCondition(f,a),e=e._,this.depsMap[2][e.ID]&&e.addCondition(this.ID,a);return!0},checkCondition:function(a,b,c,d){return this.hasConditions?(a=a.ID,b&&(a+="."+b),this.conditions[a]?this.conditions[a](c,d):!0):!0},addCondition:function(a,b){this.hasConditions=!0;return this.conditions[a]=b},scanForPholders:function(){var a;this.pholderValues=p();this.pholderIndexMap=p();this.pholderContexts=[];"string"===typeof this.valueOriginal&&(this.pholderContexts=this.valueOriginal.split(x),a=0,this.value=
this.valueOriginal.replace(w,function(b){return function(c,d){b.pholderIndexMap[a++]=d;return b.pholderValues[d]=d}}(this)));if(this.isDom&&"textContent"===this.property)return this.scanTextNodesPlaceholders()},scanTextNodesPlaceholders:function(a){var b,c,d,e,f,g,k,h,l,m;null==a&&(a=this.object);l=a.childNodes;c=0;for(f=l.length;c<f;c++)g=l[c],3!==g.nodeType?this.scanTextNodesPlaceholders(g):(k=H(),h=g.textContent,b=!1,m=p(),e=p(),a=h.split(x),d=0,h.replace(w,function(a){return function(c,f){b=!0;
e[d++]=f;return m[f]=a.pholderValues[f]}}(this)),b||(m=null),Object.defineProperty(g,"_sb_ID",{configurable:!0,value:k}),u.textNodes[k]=[h,a,m,e])},getNodeFullValue:function(a,b,c){var d;return(a=u.textNodes[a._sb_ID])?(d=a[2])?(d[b]=c,B(a[1],a[2],a[3])):a[0]:!1},applyTextContentReplace:function(a,b,c){var d,e,f,g;if(this.placeholder)for(g=a.childNodes,a=0,d=g.length;a<d;a++)if(f=g[a],3!==f.nodeType)this.applyTextContentReplace(f,b,c);else{if(e=this.getNodeFullValue(f,b,c))f.textContent=e}else a.textContent=
this.value},addPollInterval:function(a){this.removePollInterval();return this.pollInterval=setInterval(function(a){return function(){var c;c=a.fetchDirectValue();return a.setValue(c)}}(this),a)},removePollInterval:function(){clearInterval(this.pollInterval);return this.pollInterval=null},attachEvents:function(){var a,b;if("Event"===this.type)return this.registerEvent(this.eventName,this.customEventMethod["in"]);if("DOMValue"===this.type||"DOMText"===this.type)if(a=this,b=function(b){if(!b._sb)return a.setValue(b.target.value)},
this.isDomInput){if("radio"===this.object.type||"checkbox"===this.object.type)return this.objects.forEach(function(a){return a.addEventListener("change",b,!1)});this.object.addEventListener("input",b,!1);return this.object.addEventListener("change",b,!1)}},registerEvent:function(a,b){if(-1===this.attachedEvents.indexOf(a))return this.attachedEvents.push(a),this.invokeEventMethod(a,b||"addEventListener","addEventListener")},unRegisterEvent:function(a,b){var c;c=this.attachedEvents.indexOf(a);if(-1!==
c)return this.attachedEvents.splice(c,1),this.invokeEventMethod(a,b||"removeEventListener","removeEventListener")},invokeEventMethod:function(a,b,c){var d;d=this.object;if(this.isDom&&"undefined"!==typeof jQuery&&null!==jQuery&&"on"===b||"off"===b)d=jQuery(this.object);d[b]||(b=c);this.eventHandler||(this.eventHandler=P.bind(this));return"function"===typeof d[b]?d[b](a,this.eventHandler):void 0},emitEvent:function(a){var b,c;c=this.object;b=this.customEventMethod.out||"dispatchEvent";this.isDom&&
"undefined"!==typeof jQuery&&null!==jQuery&&"trigger"===b&&(c=jQuery(this.object));c[b]||(b="dispatchEvent");return"dispatchEvent"===b?(this.eventObject||(this.eventObject=document.createEvent("Event"),this.eventObject.initEvent(this.eventName,!0,!0)),this.eventObject.boundData=a,c[b](this.eventObject)):c[b](this.eventName,a)}};P=function(){var a;a="Event"===this.type?arguments[this.property]:this.fetchDirectValue();return this.setValue(a,null,this.emitCauser,!0)};m.prototype={of:function(a){var b;
0!==this.stage&&2!==this.stage&&l(h[0]);"object"!==typeof a&&"function"!==typeof a&&N(h[0],a);J(a)&&(a=a.object);2===this.stage&&(b=this.proxies.indexOf(this.proxied),this.proxied=this.proxied.of(a),this.proxies[b]=this.proxied,this.state.hasInitialBinding=!0,this.state.hasTransform=!1,this._.addDep(this.proxied,this),L(this._,this.proxied._));return this["new"](this.stage+1,a)},ofEvent:function(a,b,c){0!==this.stage||this.state.hasEventName?l(h[1]):a&&"string"===typeof a?isNaN(parseInt(this.property))&&
t("badEventArg"):N(h[1],a);this.state.hasEventName=!0;this.eventName=a;this.selector=this.property+"#"+this.eventName;this.customEventMethod={"in":b,out:c};return this},to:function(a,b){var c;(1!==this.stage||this.state.hasInitialBinding)&&l(h[2]);this.proxied=D(this,a,b);0===this.proxied.stage?c=2:(c=3,this.state.hasInitialBinding=!0);return this["new"](c)},and:function(a,b){var c;3===this.stage&&this.state.hasInitialBinding&&!this.state.hasMultiTransform||l(h[3]);this.proxied=D(this,a,b);this.proxies=
this.proxies.concat(this.proxied);0===this.proxied.stage?c=2:(c=3,this.state.hasTransform=!1);return this["new"](c)},toEvent:function(a,b,c,d){1!==this.stage&&l(h[4]);this.proxied=n(0,d).ofEvent(a,c,b);return this["new"](2)},chainTo:function(a,b){3!==this.stage&&l(h[5]);return n(this.proxied).to(a,b)},set:function(a){0!==this.stage&&2!==this.stage||l(h[6]);this._.setValue(a,this.placeholder);return this},get:function(){0!==this.stage&&2!==this.stage||l(h[7]);return this.placeholder?this._.pholderValues[this.placeholder]:
this._.value},transformSelf:function(a){(1!==this.stage||1===this.stage&&"Array"===this._.type)&&l(h[8]);"function"!==typeof a?t("fnOnly"):(this._.selfTransform=a,this._.options.updateOnBind&&this.set(this.value));return this},transform:function(a){(3!==this.stage||this.state.hasTransform||this.state.hasMultiTransform)&&l(h[9]);this.state.hasTransform=this._.processTransform(a,[this.proxied])||!1;return this["new"](3)},transformAll:function(a){(3!==this.stage||this.state.hasTransform||this.state.hasMultiTransform)&&
l(h[10]);this.state.hasMultiTransform=this._.processTransform(a,this.proxies)||!1;return this["new"](3)},condition:function(a){3!==this.stage&&l(h[11]);this._.processCondition(a,[this.proxied]);return this["new"](3)},conditionAll:function(a){3!==this.stage&&l(h[12]);this._.processCondition(a,this.proxies);return this["new"](3)},bothWays:function(a){var b,c,d;(3!==this.stage||this.state.hasMultiTransform)&&l(h[13]);b=this.proxied._.addDep(this,this.proxied,!0);d=this._.transforms[this.proxied.ID];
c=this._.conditions[this.proxied.ID];(d||a)&&(d="function"===typeof a?a:d)&&!1!==a&&b.addTransform(this.ID,d);c&&b.addCondition(this.ID,c);this._.addDep(this.proxied,this,!0);return this},unBind:function(a){var b,c,d,e;3!==this.stage&&l(h[14]);e=this.proxies;b=0;for(c=e.length;b<c;b++)d=e[b],this._.removeDep(d._,a);return this},pollEvery:function(a){3===this.stage&&"Event"!==this._.type||l(h[15]);this._.addPollInterval(a);return this},stopPolling:function(){3!==this.stage&&l(h[16]);this._.removePollInterval();
return this},updateDepsOnEvent:function(a,b){3!==this.stage&&l(h[17]);this._.registerEvent(a,b);return this},removeEvent:function(a,b){3!==this.stage&&l(h[18]);this._.unRegisterEvent(a,b);return this},throttle:function(a){1!==this.stage&&3!==this.stage&&l(h[19]);"number"===typeof a&&a?this._.throttleRate=a:!1===a&&delete this._.throttleRate;return this},setOption:function(a,b){var c,d,e,f,g;e=(c={},c[""+a]=b,c);y(this._,e,!0);g=this.proxies;c=0;for(d=g.length;c<d;c++)f=g[c],y(f._,e,!0);return this}};
m.prototype.update=m.prototype.set;m.prototype.twoWay=m.prototype.bothWays;m.prototype.pipe=m.prototype.chainTo;h=Object.keys(m.prototype);D=function(a,b,c){null==c&&(c={});a.proxied=b=n(b,c,!0);0!==b.stage&&(a._.addDep(b,a),L(a._,b._));return b};L=function(a,b){if(a.options.updateOnBind||"Func"===a.type)return a.updateDep(b)};Object.defineProperties(m.prototype,{setObject:{value:function(a,b,c,d){var e;this.object=a;c=c?"simpleObject":"object";if(e=u[c].get(a,this.selector))return this.placeholder&&
!e.pholderValues&&(e.valueOriginal=e.fetchDirectValue(),e.scanForPholders()),"ObjectProp"!==e.type||this.property in a||e.makePropertyLive(!0),y(e,this.options,!0),e;a=new A(b,this.selector,this.property,this.object,this.objects,this.options,{isDom:this.isDom,isDomInput:this.isDomInput,placeholder:this.placeholder,eventName:this.eventName,customEventMethod:this.customEventMethod,isEvent:this.state.hasEventName},d);u[c].set(a);return a}},getState:{value:function(){return{options:this.options,selector:this.selector,
object:this.object,property:this.property,descriptor:this.descriptor,placeholder:this.placeholder,eventName:this.eventName,customEventMethod:this.customEventMethod,proxied:this.proxied,proxies:this.proxies,state:this.state}}}});Object.defineProperties(n,{version:{value:"1.2.0"},options:{get:function(){var a,b,c;a={};for(b in q)c=q[b],a[b]=c;return a}}});n.setOption=function(a,b){if(null!=q[a]&&(q[a]=b,-1!==a.indexOf("place")))return M()};n.setOptions=function(a){var b,c;for(b in a)c=a[b],n.setOption(b,
c)};n.unBindAll=function(a,b){var c,d,e;if(a&&("object"===typeof a||"function"===typeof a)&&(K(a)&&(a=G(a)),e=a._sb_map,a._sb_ID&&r[a._sb_ID].removeAllDeps(b),e))for(d in e)c=e[d],r[c].removeAllDeps(b)};return window.SimplyBind=n})();