1 | ;
|
2 |
|
3 | Object.defineProperty(exports, '__esModule', {
|
4 | value: true
|
5 | });
|
6 | exports.default = void 0;
|
7 |
|
8 | function _defineProperty(obj, key, value) {
|
9 | if (key in obj) {
|
10 | Object.defineProperty(obj, key, {
|
11 | value: value,
|
12 | enumerable: true,
|
13 | configurable: true,
|
14 | writable: true
|
15 | });
|
16 | } else {
|
17 | obj[key] = value;
|
18 | }
|
19 | return obj;
|
20 | }
|
21 |
|
22 | /**
|
23 | * Copyright (c) Facebook, Inc. and its affiliates. All Rights Reserved.
|
24 | *
|
25 | * This source code is licensed under the MIT license found in the
|
26 | * LICENSE file in the root directory of this source tree.
|
27 | *
|
28 | */
|
29 | // This file is a heavily modified fork of Jasmine. Original license:
|
30 |
|
31 | /*
|
32 | Copyright (c) Facebook, Inc. and its affiliates. All Rights Reserved.
|
33 |
|
34 | Permission is hereby granted, free of charge, to any person obtaining
|
35 | a copy of this software and associated documentation files (the
|
36 | "Software"), to deal in the Software without restriction, including
|
37 | without limitation the rights to use, copy, modify, merge, publish,
|
38 | distribute, sublicense, and/or sell copies of the Software, and to
|
39 | permit persons to whom the Software is furnished to do so, subject to
|
40 | the following conditions:
|
41 |
|
42 | The above copyright notice and this permission notice shall be
|
43 | included in all copies or substantial portions of the Software.
|
44 |
|
45 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
46 | EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
47 | MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
48 | NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
49 | LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
50 | OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
51 | WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
52 | */
|
53 | const defaultNow = (function (Date) {
|
54 | return function () {
|
55 | return new Date().getTime();
|
56 | };
|
57 | })(Date);
|
58 |
|
59 | class Timer {
|
60 | constructor(options) {
|
61 | _defineProperty(this, 'start', void 0);
|
62 |
|
63 | _defineProperty(this, 'elapsed', void 0);
|
64 |
|
65 | options = options || {};
|
66 | const now = options.now || defaultNow;
|
67 | let startTime;
|
68 |
|
69 | this.start = function () {
|
70 | startTime = now();
|
71 | };
|
72 |
|
73 | this.elapsed = function () {
|
74 | return now() - startTime;
|
75 | };
|
76 | }
|
77 | }
|
78 |
|
79 | exports.default = Timer;
|