1 line
17 KiB
JSON
1 line
17 KiB
JSON
{"id":"Kt0u","dependencies":[{"name":"/Users/philkunz/gitlab/pushrocks_meta/webdetector/node_modules/@pushrocks/smarttime/ts/smarttime.classes.timer.ts","includedInParent":true,"mtime":499162500000},{"name":"/Users/philkunz/gitlab/pushrocks_meta/webdetector/package.json","includedInParent":true,"mtime":1545395749058},{"name":"/Users/philkunz/gitlab/pushrocks_meta/webdetector/node_modules/@pushrocks/smarttime/package.json","includedInParent":true,"mtime":1545395356342},{"name":"./smarttime.plugins","loc":{"line":3,"column":24},"parent":"/Users/philkunz/gitlab/pushrocks_meta/webdetector/node_modules/@pushrocks/smarttime/dist/smarttime.classes.timer.js","resolved":"/Users/philkunz/gitlab/pushrocks_meta/webdetector/node_modules/@pushrocks/smarttime/dist/smarttime.plugins.js"},{"name":"./smarttime.classes.timestamp","loc":{"line":4,"column":46},"parent":"/Users/philkunz/gitlab/pushrocks_meta/webdetector/node_modules/@pushrocks/smarttime/dist/smarttime.classes.timer.js","resolved":"/Users/philkunz/gitlab/pushrocks_meta/webdetector/node_modules/@pushrocks/smarttime/dist/smarttime.classes.timestamp.js"}],"generated":{"js":"\"use strict\";Object.defineProperty(exports,\"__esModule\",{value:!0});const e=require(\"./smarttime.plugins\"),t=require(\"./smarttime.classes.timestamp\");class s{constructor(t){this.state=\"initiated\",this.completedDeferred=e.smartpromise.defer(),this.timeInMilliseconds=t,this.completed=this.completedDeferred.promise}get timeLeft(){return this.timeInMilliseconds-this.pausedAt.change}start(){if(this.startedAt)throw new Error(\"timer has been started before. Please use resume instead\");this.currentTimeout=setTimeout(()=>{this.completedDeferred.resolve()},this.timeInMilliseconds),this.startedAt=new t.TimeStamp}pause(){this.startedAt&&(clearTimeout(this.currentTimeout),this.currentTimeout=null,this.pausedAt=t.TimeStamp.fromTimeStamp(this.startedAt))}resume(){if(!this.startedAt)throw new Error(\"timer has NOT been started before. Please use .start() instead\");this.currentTimeout=setTimeout(()=>{this.completedDeferred.resolve()},this.timeLeft)}reset(){this.pause(),this.startedAt=null,this.pausedAt=null}}exports.Timer=s;","map":{"mappings":[{"source":"../ts/smarttime.classes.timer.ts","name":null,"original":{"line":1,"column":0},"generated":{"line":1,"column":68}},{"source":"../ts/smarttime.classes.timer.ts","name":null,"original":{"line":1,"column":0},"generated":{"line":1,"column":74}},{"source":"../ts/smarttime.classes.timer.ts","name":null,"original":{"line":1,"column":0},"generated":{"line":1,"column":76}},{"source":"../ts/smarttime.classes.timer.ts","name":null,"original":{"line":1,"column":0},"generated":{"line":1,"column":84}},{"source":"../ts/smarttime.classes.timer.ts","name":null,"original":{"line":3,"column":0},"generated":{"line":1,"column":107}},{"source":"../ts/smarttime.classes.timer.ts","name":null,"original":{"line":3,"column":0},"generated":{"line":1,"column":109}},{"source":"../ts/smarttime.classes.timer.ts","name":null,"original":{"line":3,"column":0},"generated":{"line":1,"column":117}},{"source":"../ts/smarttime.classes.timer.ts","name":null,"original":{"line":7,"column":0},"generated":{"line":1,"column":150}},{"source":"../ts/smarttime.classes.timer.ts","name":null,"original":{"line":7,"column":13},"generated":{"line":1,"column":156}},{"source":"../ts/smarttime.classes.timer.ts","name":null,"original":{"line":44,"column":2},"generated":{"line":1,"column":158}},{"source":"../ts/smarttime.classes.timer.ts","name":null,"original":{"line":44,"column":14},"generated":{"line":1,"column":170}},{"source":"../ts/smarttime.classes.timer.ts","name":null,"original":{"line":16,"column":9},"generated":{"line":1,"column":173}},{"source":"../ts/smarttime.classes.timer.ts","name":null,"original":{"line":16,"column":9},"generated":{"line":1,"column":178}},{"source":"../ts/smarttime.classes.timer.ts","name":null,"original":{"line":16,"column":29},"generated":{"line":1,"column":184}},{"source":"../ts/smarttime.classes.timer.ts","name":null,"original":{"line":42,"column":10},"generated":{"line":1,"column":196}},{"source":"../ts/smarttime.classes.timer.ts","name":null,"original":{"line":42,"column":10},"generated":{"line":1,"column":201}},{"source":"../ts/smarttime.classes.timer.ts","name":null,"original":{"line":42,"column":30},"generated":{"line":1,"column":219}},{"source":"../ts/smarttime.classes.timer.ts","name":null,"original":{"line":42,"column":38},"generated":{"line":1,"column":221}},{"source":"../ts/smarttime.classes.timer.ts","name":null,"original":{"line":42,"column":51},"generated":{"line":1,"column":234}},{"source":"../ts/smarttime.classes.timer.ts","name":null,"original":{"line":45,"column":4},"generated":{"line":1,"column":242}},{"source":"../ts/smarttime.classes.timer.ts","name":null,"original":{"line":45,"column":9},"generated":{"line":1,"column":247}},{"source":"../ts/smarttime.classes.timer.ts","name":null,"original":{"line":45,"column":30},"generated":{"line":1,"column":266}},{"source":"../ts/smarttime.classes.timer.ts","name":null,"original":{"line":46,"column":4},"generated":{"line":1,"column":268}},{"source":"../ts/smarttime.classes.timer.ts","name":null,"original":{"line":46,"column":9},"generated":{"line":1,"column":273}},{"source":"../ts/smarttime.classes.timer.ts","name":null,"original":{"line":46,"column":21},"generated":{"line":1,"column":283}},{"source":"../ts/smarttime.classes.timer.ts","name":null,"original":{"line":46,"column":26},"generated":{"line":1,"column":288}},{"source":"../ts/smarttime.classes.timer.ts","name":null,"original":{"line":46,"column":44},"generated":{"line":1,"column":306}},{"source":"../ts/smarttime.classes.timer.ts","name":null,"original":{"line":33,"column":2},"generated":{"line":1,"column":314}},{"source":"../ts/smarttime.classes.timer.ts","name":null,"original":{"line":34,"column":4},"generated":{"line":1,"column":329}},{"source":"../ts/smarttime.classes.timer.ts","name":null,"original":{"line":34,"column":11},"generated":{"line":1,"column":336}},{"source":"../ts/smarttime.classes.timer.ts","name":null,"original":{"line":34,"column":16},"generated":{"line":1,"column":341}},{"source":"../ts/smarttime.classes.timer.ts","name":null,"original":{"line":34,"column":37},"generated":{"line":1,"column":360}},{"source":"../ts/smarttime.classes.timer.ts","name":null,"original":{"line":34,"column":42},"generated":{"line":1,"column":365}},{"source":"../ts/smarttime.classes.timer.ts","name":null,"original":{"line":34,"column":51},"generated":{"line":1,"column":374}},{"source":"../ts/smarttime.classes.timer.ts","name":null,"original":{"line":52,"column":9},"generated":{"line":1,"column":381}},{"source":"../ts/smarttime.classes.timer.ts","name":null,"original":{"line":53,"column":4},"generated":{"line":1,"column":389}},{"source":"../ts/smarttime.classes.timer.ts","name":null,"original":{"line":53,"column":9},"generated":{"line":1,"column":392}},{"source":"../ts/smarttime.classes.timer.ts","name":null,"original":{"line":53,"column":14},"generated":{"line":1,"column":397}},{"source":"../ts/smarttime.classes.timer.ts","name":null,"original":{"line":59,"column":6},"generated":{"line":1,"column":407}},{"source":"../ts/smarttime.classes.timer.ts","name":null,"original":{"line":59,"column":12},"generated":{"line":1,"column":413}},{"source":"../ts/smarttime.classes.timer.ts","name":null,"original":{"line":59,"column":16},"generated":{"line":1,"column":417}},{"source":"../ts/smarttime.classes.timer.ts","name":null,"original":{"line":59,"column":22},"generated":{"line":1,"column":423}},{"source":"../ts/smarttime.classes.timer.ts","name":null,"original":{"line":54,"column":6},"generated":{"line":1,"column":483}},{"source":"../ts/smarttime.classes.timer.ts","name":null,"original":{"line":54,"column":11},"generated":{"line":1,"column":488}},{"source":"../ts/smarttime.classes.timer.ts","name":null,"original":{"line":54,"column":28},"generated":{"line":1,"column":503}},{"source":"../ts/smarttime.classes.timer.ts","name":null,"original":{"line":54,"column":39},"generated":{"line":1,"column":514}},{"source":"../ts/smarttime.classes.timer.ts","name":null,"original":{"line":55,"column":8},"generated":{"line":1,"column":519}},{"source":"../ts/smarttime.classes.timer.ts","name":null,"original":{"line":55,"column":13},"generated":{"line":1,"column":524}},{"source":"../ts/smarttime.classes.timer.ts","name":null,"original":{"line":55,"column":31},"generated":{"line":1,"column":542}},{"source":"../ts/smarttime.classes.timer.ts","name":null,"original":{"line":56,"column":9},"generated":{"line":1,"column":553}},{"source":"../ts/smarttime.classes.timer.ts","name":null,"original":{"line":56,"column":14},"generated":{"line":1,"column":558}},{"source":"../ts/smarttime.classes.timer.ts","name":null,"original":{"line":57,"column":6},"generated":{"line":1,"column":578}},{"source":"../ts/smarttime.classes.timer.ts","name":null,"original":{"line":57,"column":11},"generated":{"line":1,"column":583}},{"source":"../ts/smarttime.classes.timer.ts","name":null,"original":{"line":57,"column":23},"generated":{"line":1,"column":593}},{"source":"../ts/smarttime.classes.timer.ts","name":null,"original":{"line":57,"column":27},"generated":{"line":1,"column":597}},{"source":"../ts/smarttime.classes.timer.ts","name":null,"original":{"line":57,"column":27},"generated":{"line":1,"column":599}},{"source":"../ts/smarttime.classes.timer.ts","name":null,"original":{"line":63,"column":9},"generated":{"line":1,"column":609}},{"source":"../ts/smarttime.classes.timer.ts","name":null,"original":{"line":64,"column":8},"generated":{"line":1,"column":617}},{"source":"../ts/smarttime.classes.timer.ts","name":null,"original":{"line":64,"column":13},"generated":{"line":1,"column":622}},{"source":"../ts/smarttime.classes.timer.ts","name":null,"original":{"line":65,"column":6},"generated":{"line":1,"column":634}},{"source":"../ts/smarttime.classes.timer.ts","name":null,"original":{"line":65,"column":19},"generated":{"line":1,"column":647}},{"source":"../ts/smarttime.classes.timer.ts","name":null,"original":{"line":65,"column":24},"generated":{"line":1,"column":652}},{"source":"../ts/smarttime.classes.timer.ts","name":null,"original":{"line":66,"column":6},"generated":{"line":1,"column":668}},{"source":"../ts/smarttime.classes.timer.ts","name":null,"original":{"line":66,"column":11},"generated":{"line":1,"column":673}},{"source":"../ts/smarttime.classes.timer.ts","name":null,"original":{"line":66,"column":28},"generated":{"line":1,"column":688}},{"source":"../ts/smarttime.classes.timer.ts","name":null,"original":{"line":67,"column":6},"generated":{"line":1,"column":693}},{"source":"../ts/smarttime.classes.timer.ts","name":null,"original":{"line":67,"column":11},"generated":{"line":1,"column":698}},{"source":"../ts/smarttime.classes.timer.ts","name":null,"original":{"line":67,"column":22},"generated":{"line":1,"column":707}},{"source":"../ts/smarttime.classes.timer.ts","name":null,"original":{"line":67,"column":22},"generated":{"line":1,"column":709}},{"source":"../ts/smarttime.classes.timer.ts","name":null,"original":{"line":67,"column":32},"generated":{"line":1,"column":719}},{"source":"../ts/smarttime.classes.timer.ts","name":null,"original":{"line":67,"column":46},"generated":{"line":1,"column":733}},{"source":"../ts/smarttime.classes.timer.ts","name":null,"original":{"line":67,"column":51},"generated":{"line":1,"column":738}},{"source":"../ts/smarttime.classes.timer.ts","name":null,"original":{"line":71,"column":9},"generated":{"line":1,"column":750}},{"source":"../ts/smarttime.classes.timer.ts","name":null,"original":{"line":72,"column":4},"generated":{"line":1,"column":759}},{"source":"../ts/smarttime.classes.timer.ts","name":null,"original":{"line":72,"column":8},"generated":{"line":1,"column":763}},{"source":"../ts/smarttime.classes.timer.ts","name":null,"original":{"line":72,"column":13},"generated":{"line":1,"column":768}},{"source":"../ts/smarttime.classes.timer.ts","name":null,"original":{"line":77,"column":6},"generated":{"line":1,"column":778}},{"source":"../ts/smarttime.classes.timer.ts","name":null,"original":{"line":77,"column":12},"generated":{"line":1,"column":784}},{"source":"../ts/smarttime.classes.timer.ts","name":null,"original":{"line":77,"column":16},"generated":{"line":1,"column":788}},{"source":"../ts/smarttime.classes.timer.ts","name":null,"original":{"line":77,"column":22},"generated":{"line":1,"column":794}},{"source":"../ts/smarttime.classes.timer.ts","name":null,"original":{"line":73,"column":6},"generated":{"line":1,"column":860}},{"source":"../ts/smarttime.classes.timer.ts","name":null,"original":{"line":73,"column":11},"generated":{"line":1,"column":865}},{"source":"../ts/smarttime.classes.timer.ts","name":null,"original":{"line":73,"column":28},"generated":{"line":1,"column":880}},{"source":"../ts/smarttime.classes.timer.ts","name":null,"original":{"line":73,"column":39},"generated":{"line":1,"column":891}},{"source":"../ts/smarttime.classes.timer.ts","name":null,"original":{"line":74,"column":8},"generated":{"line":1,"column":896}},{"source":"../ts/smarttime.classes.timer.ts","name":null,"original":{"line":74,"column":13},"generated":{"line":1,"column":901}},{"source":"../ts/smarttime.classes.timer.ts","name":null,"original":{"line":74,"column":31},"generated":{"line":1,"column":919}},{"source":"../ts/smarttime.classes.timer.ts","name":null,"original":{"line":75,"column":9},"generated":{"line":1,"column":930}},{"source":"../ts/smarttime.classes.timer.ts","name":null,"original":{"line":75,"column":14},"generated":{"line":1,"column":935}},{"source":"../ts/smarttime.classes.timer.ts","name":null,"original":{"line":81,"column":9},"generated":{"line":1,"column":945}},{"source":"../ts/smarttime.classes.timer.ts","name":null,"original":{"line":82,"column":4},"generated":{"line":1,"column":953}},{"source":"../ts/smarttime.classes.timer.ts","name":null,"original":{"line":82,"column":9},"generated":{"line":1,"column":958}},{"source":"../ts/smarttime.classes.timer.ts","name":null,"original":{"line":83,"column":4},"generated":{"line":1,"column":966}},{"source":"../ts/smarttime.classes.timer.ts","name":null,"original":{"line":83,"column":9},"generated":{"line":1,"column":971}},{"source":"../ts/smarttime.classes.timer.ts","name":null,"original":{"line":83,"column":21},"generated":{"line":1,"column":981}},{"source":"../ts/smarttime.classes.timer.ts","name":null,"original":{"line":84,"column":4},"generated":{"line":1,"column":986}},{"source":"../ts/smarttime.classes.timer.ts","name":null,"original":{"line":84,"column":9},"generated":{"line":1,"column":991}},{"source":"../ts/smarttime.classes.timer.ts","name":null,"original":{"line":84,"column":20},"generated":{"line":1,"column":1000}},{"source":"../ts/smarttime.classes.timer.ts","name":null,"original":{"line":7,"column":0},"generated":{"line":1,"column":1006}},{"source":"../ts/smarttime.classes.timer.ts","name":null,"original":{"line":7,"column":0},"generated":{"line":1,"column":1014}},{"source":"../ts/smarttime.classes.timer.ts","name":null,"original":{"line":7,"column":0},"generated":{"line":1,"column":1020}}],"sources":{"../ts/smarttime.classes.timer.ts":"import * as plugins from './smarttime.plugins';\n\nimport { TimeStamp } from './smarttime.classes.timestamp';\n\nexport type TimerState = 'initiated' | 'started' | 'paused' | 'completed';\n\nexport class Timer {\n /**\n * the original amount of milliseconds for this Timer\n */\n public timeInMilliseconds: number;\n\n /**\n * the state of the timer\n */\n public state: TimerState = 'initiated';\n\n /**\n * completed Promise\n */\n public completed: Promise<void>;\n\n /**\n * a reference to when the Timeout started\n */\n public startedAt: TimeStamp;\n\n /**\n * a reference to when a Timer has been potentially paused\n */\n public pausedAt: TimeStamp;\n\n get timeLeft(): number {\n return this.timeInMilliseconds - this.pausedAt.change;\n }\n /**\n * the current timeout the needs to be canceled when this Timer is stopped\n */\n private currentTimeout: NodeJS.Timer;\n\n // a deferred triggeted when Timer has completed\n private completedDeferred = plugins.smartpromise.defer<void>();\n\n constructor(timeInMillisecondsArg: number) {\n this.timeInMilliseconds = timeInMillisecondsArg;\n this.completed = this.completedDeferred.promise;\n }\n\n /**\n * starts the timer\n */\n public start() {\n if (!this.startedAt) {\n this.currentTimeout = setTimeout(() => {\n this.completedDeferred.resolve();\n }, this.timeInMilliseconds);\n this.startedAt = new TimeStamp();\n } else {\n throw new Error('timer has been started before. Please use resume instead');\n }\n }\n\n public pause() {\n if (this.startedAt) {\n clearTimeout(this.currentTimeout);\n this.currentTimeout = null;\n this.pausedAt = TimeStamp.fromTimeStamp(this.startedAt);\n }\n }\n\n public resume() {\n if (this.startedAt) {\n this.currentTimeout = setTimeout(() => {\n this.completedDeferred.resolve();\n }, this.timeLeft);\n } else {\n throw new Error('timer has NOT been started before. Please use .start() instead');\n }\n }\n\n public reset() {\n this.pause();\n this.startedAt = null;\n this.pausedAt = null;\n }\n}\n"},"lineCount":null}},"hash":"5cff019270d410b451d16e4e6573ff6d","cacheData":{"env":{}}} |