@stdlib/esm
Version:
ES module distribution for Stdlib, a standard library for JavaScript and Node.js.
3 lines • 3.18 kB
JavaScript
// This file is a part of stdlib. License is Apache-2.0: http://www.apache.org/licenses/LICENSE-2.0
import e from"./../../../vendor/events.js";import t from"./../../../vendor/debug.js";import r from"./../../../utils/define-property.js";import n from"./../../../utils/define-read-only-property.js";import i from"./../../../utils/copy.js";import o from"./../../../utils/keys.js";import a from"./../../../assert/is-plain-object.js";import s from"./../../../assert/has-own-property.js";import u from"./../../../assert/is-string.js";import l from"./../../../assert/is-boolean.js";import m from"./../../../vendor/virtual-dom/h.js";var p="",f=!1,d={text:p,autoRender:f},v=u.isPrimitive;function c(e){return v(e)?null:new TypeError("invalid value. `text` must be a string primitive. Value: `"+e+".`")}var h=l.isPrimitive;function g(e){return h(e)?null:new TypeError("invalid value. `autoRender` must be a boolean primitive. Value: `"+e+".`")}var y=c,b=g,w={text:y,autoRender:b},x=o,R=a,j=s,_=w,E=x(_);function N(e,t){var r,n,i,o;if(!R(t))return new TypeError("invalid argument. Options argument must be an object. Value: `"+t+"`.");for(o=0;o<E.length;o++)if(n=E[o],j(t,n)){if(i=t[n],r=_[n](i))return r;e[n]=i}return null}var O="change",V="change",T={text:O,autoRender:V},C=T;function J(e){return C[e]}var P=t,S=J,k=c,A=P("title:set:text"),D=S("text");function G(e){var t=k(e);if(t)throw t;A("Current value: %d.",this._text),this._text=e,A("New Value: %d.",this._text),this.emit(D)}function M(){return this._text}var q=t,z=J,B=g,F=q("title:set:auto-render"),H=z("autoRender");function I(e){var t=B(e);if(t)throw t;F("Current value: %d.",this._autoRender),this._autoRender=e,F("New Value: %d.",this._autoRender),this.emit(H)}function K(){return this._autoRender}var L=t,Q=m,U=L("title:render"),W="text";function X(){var e,t,r;return U("Rendering..."),e={namespace:"http://www.w3.org/2000/svg",property:"title",className:"title noselect",attributes:{x:0,y:0,"text-anchor":"middle"}},r=this.text,U("Title: %s.",r),U("Generating a virtual DOM tree (%s) with properties: %s.",W,JSON.stringify(e)),t=Q(W,e,r),this.emit("_render",t),t}var Y=e.EventEmitter,Z=t,$=r,ee=n,te=i,re=d,ne=N,ie=G,oe=M,ae=I,se=K,ue=X,le=Z("title:main");function me(e){var t,r,n;if(!(this instanceof me))return new me(e);if(t=this,r=te(re),n=ne(r,e))throw n;return le("Creating an instance with the following configuration: %s.",JSON.stringify(r)),Y.call(this),$(this,"_text",{configurable:!1,enumerable:!1,writable:!0,value:r.text}),$(this,"_autoRender",{configurable:!1,enumerable:!1,writable:!0,value:r.autoRender}),this.on("change",(function(){le("Received a change event."),t._autoRender&&t.render()})),this.on("_render",(function(){var e,r;for(le("Received a render event. Re-emitting..."),(e=new Array(arguments.length+1))[0]="render",r=0;r<arguments.length;r++)e[r+1]=arguments[r];t.emit.apply(t,e)})),this}me.prototype=Object.create(Y.prototype),me.prototype.constructor=me,$(me.prototype,"text",{configurable:!1,enumerable:!0,set:ie,get:oe}),$(me.prototype,"autoRender",{configurable:!1,enumerable:!0,set:ae,get:se}),ee(me.prototype,"render",ue);var pe=me;export default pe;
//# sourceMappingURL=title.js.map