UNPKG

@joergmittaglawo/dmvconfig

Version:

DMV Configuration scripts for Lawo V__matrix Distributed Multiviewers.

1 lines 2.66 kB
Object.defineProperty(exports,"__esModule",{value:!0}),exports.Timestamp=exports.Seconds=exports.Nanoseconds=exports.Duration=void 0;class t{}exports.Duration=t;class s extends t{constructor(t){super(),this.ns=t}static make_of(t){return new s("number"==typeof t?t:t.as_ns())}plus(t){return new s(this.ns+t.as_ns())}minus(t){return new s(this.ns-t.as_ns())}times(t){return new s(this.ns*t)}divide_by(t){return new s(this.ns/t)}as_ns(){return this.ns}as_s(){return this.ns/1e9}toString(){return this.ns+" ns"}equal(t){const s=Math.max(Math.abs(this.as_ns()),Math.abs(t.as_ns()))*Math.pow(2,-50);return Math.abs(t.as_ns()-this.as_ns())<=s}}exports.Nanoseconds=s;class a extends t{constructor(t){super(),this.s=t}static make_of(t){return new s("number"==typeof t?t:t.as_s())}plus(t){return new s(this.s+t.as_s())}minus(t){return new s(this.s-t.as_s())}times(t){return new s(this.s*t)}divide_by(t){return new s(this.s/t)}as_ns(){return 1e9*this.s}as_s(){return this.s}toString(){return this.s+" s"}equal(t){const s=Math.max(Math.abs(this.as_s()),Math.abs(t.as_s()))*Math.pow(2,-50);return Math.abs(t.as_s()-this.as_s())<=s}}exports.Seconds=a;class e{constructor(t){this.data=t}nanoseconds(){if("number"==typeof this.data)return Math.round(this.data%1*1e9);{const t=this.data.indexOf(".");return-1===t?0:parseInt(this.data.substr(t+1).padEnd(9,"0"))}}seconds(){if("number"==typeof this.data)return Math.floor(this.data);{const t=this.data.indexOf(".");return-1===t?parseInt(this.data):parseInt(this.data.substr(0,t))}}parts(){if("number"==typeof this.data)return[Math.floor(this.data),this.data%1];{const t=this.data.indexOf(".");return-1===t?[parseInt(this.data),0]:[parseInt(this.data.substr(0,t)),parseInt(this.data.substr(t+1).padEnd(9,"0"))]}}distance_from(t){const[r,n]=this.parts(),[i,o]=t.parts();let h=i-r,u=o-n;return u<0?(u+=1e9,h-=1):u>=1e9&&(u-=1e9,h+=1),h>e.MAX_SAFE_SECONDS?new a(h+1e-9*u):new s(Math.round(1e9*h+u))}distance_to(t){return t.distance_from(this)}plus(t){const s=t.as_ns(),a=Math.floor(s/1e9),r=s%1e9,[n,i]=this.parts();let o=n+a,h=i+r;return h<0?(h+=1e9,o-=1):h>=1e9&&(h-=1e9,o+=1),"number"==typeof this.data?new e(o+1e-9*h):new e(`${o}.${h.toString().padStart(9,"0")}`)}minus(t){return this.plus(t.times(-1))}toString(){return"number"==typeof this.data?""+this.data.toFixed(9):this.data}toNumber(){return"number"==typeof this.data?this.data:parseFloat(this.data)}equal(t){if("string"==typeof t.data&&"string"==typeof this.data)return t.data===this.data;{const s=this.toNumber(),a=t.toNumber(),e=Math.max(Math.abs(s),Math.abs(a))*Math.pow(2,-50);return Math.abs(s-a)<=e}}}exports.Timestamp=e,e.MAX_SAFE_SECONDS=Number.MAX_SAFE_INTEGER/1e9;