perf-marks
Advanced tools
Comparing version 1.6.0 to 1.7.0
@@ -10,2 +10,10 @@ # Change Log | ||
## [1.7.0][] - 2020-01-18 | ||
### Updated | ||
- Updating `README.md` docs with latest changes | ||
- Decreasing bundle size of the package to `176B` 🎉 | ||
- Updating NodeJS Version to 12.14.1 | ||
## [1.6.0][] - 2019-11-14 | ||
@@ -161,5 +169,7 @@ | ||
[1.5.1]: https://github.com/willmendesneto/perf-marks/tree/v1.5.1 | ||
[unreleased]: https://github.com/willmendesneto/perf-marks/compare/v1.6.0...HEAD | ||
[1.6.0]: https://github.com/willmendesneto/perf-marks/tree/v1.6.0 | ||
[Unreleased]: https://github.com/willmendesneto/perf-marks/compare/v1.6.0...HEAD | ||
[1.6.0]: https://github.com/willmendesneto/perf-marks/tree/v1.6.0 | ||
[Unreleased]: https://github.com/willmendesneto/perf-marks/compare/v1.7.0...HEAD | ||
[1.7.0]: https://github.com/willmendesneto/perf-marks/tree/v1.7.0 |
@@ -17,3 +17,3 @@ "use strict"; | ||
} | ||
return Date.now ? Date.now() : +new Date(); | ||
return Date.now(); | ||
}; | ||
@@ -70,6 +70,3 @@ /** | ||
var entry = performance.getEntriesByName(markName).pop(); | ||
if (entry) { | ||
return entry; | ||
} | ||
return {}; | ||
return entry || {}; | ||
} | ||
@@ -76,0 +73,0 @@ catch (e) { |
@@ -14,3 +14,3 @@ import { isUserTimingAPISupported } from './is-user-timing-api-supported'; | ||
} | ||
return Date.now ? Date.now() : +new Date(); | ||
return Date.now(); | ||
}; | ||
@@ -65,6 +65,3 @@ /** | ||
const entry = performance.getEntriesByName(markName).pop(); | ||
if (entry) { | ||
return entry; | ||
} | ||
return {}; | ||
return entry || {}; | ||
} | ||
@@ -71,0 +68,0 @@ catch (e) { |
@@ -14,3 +14,3 @@ import { isUserTimingAPISupported } from './is-user-timing-api-supported'; | ||
} | ||
return Date.now ? Date.now() : +new Date(); | ||
return Date.now(); | ||
}; | ||
@@ -65,6 +65,3 @@ /** | ||
var entry = performance.getEntriesByName(markName).pop(); | ||
if (entry) { | ||
return entry; | ||
} | ||
return {}; | ||
return entry || {}; | ||
} | ||
@@ -71,0 +68,0 @@ catch (e) { |
@@ -33,3 +33,3 @@ (function (global, factory) { | ||
} | ||
return Date.now ? Date.now() : +new Date(); | ||
return Date.now(); | ||
}; | ||
@@ -84,6 +84,3 @@ /** | ||
var entry = performance.getEntriesByName(markName).pop(); | ||
if (entry) { | ||
return entry; | ||
} | ||
return {}; | ||
return entry || {}; | ||
} | ||
@@ -90,0 +87,0 @@ catch (e) { |
@@ -1,1 +0,1 @@ | ||
!function(e,r){"object"==typeof exports&&"undefined"!=typeof module?r(exports):"function"==typeof define&&define.amd?define(["exports"],r):r((e=e||self).PerfMarks={})}(this,function(e){"use strict";function t(){return f?performance.now():Date.now?Date.now():+new Date}function a(e){c[e]=void 0,f&&(performance.clearMeasures(e),performance.clearMarks(e))}function r(e){return f&&performance.getEntriesByType(e)||[]}var f="undefined"!=typeof performance&&void 0!==performance.now&&"function"==typeof performance.mark&&"function"==typeof performance.clearMarks&&"function"==typeof performance.measure&&"function"==typeof performance.clearMeasures,c={};e.clear=a,e.clearAll=function(){c={},f&&(performance.clearMeasures(),performance.clearMarks())},e.end=function(e,r){try{var n=c[e];if(!f)return n?{duration:t()-n,startTime:n}:{};performance.measure(e,e,r||void 0);var o=performance.getEntriesByName(e).pop();return o||{}}catch(e){return{}}finally{a(e)}},e.getEntriesByType=r,e.getNavigationMarker=function(){return r("navigation").pop()||{}},e.isUserTimingAPISupported=f,e.start=function(e){f&&performance.mark(e),c[e]=t()},Object.defineProperty(e,"__esModule",{value:!0})}); | ||
!function(e,r){"object"==typeof exports&&"undefined"!=typeof module?r(exports):"function"==typeof define&&define.amd?define(["exports"],r):r((e=e||self).PerfMarks={})}(this,function(e){"use strict";function o(){return a?performance.now():Date.now()}function t(e){f[e]=void 0,a&&(performance.clearMeasures(e),performance.clearMarks(e))}function r(e){return a&&performance.getEntriesByType(e)||[]}var a="undefined"!=typeof performance&&void 0!==performance.now&&"function"==typeof performance.mark&&"function"==typeof performance.clearMarks&&"function"==typeof performance.measure&&"function"==typeof performance.clearMeasures,f={};e.clear=t,e.clearAll=function(){f={},a&&(performance.clearMeasures(),performance.clearMarks())},e.end=function(e,r){try{var n=f[e];return a?(performance.measure(e,e,r||void 0),performance.getEntriesByName(e).pop()||{}):n?{duration:o()-n,startTime:n}:{}}catch(e){return{}}finally{t(e)}},e.getEntriesByType=r,e.getNavigationMarker=function(){return r("navigation").pop()||{}},e.isUserTimingAPISupported=a,e.start=function(e){a&&performance.mark(e),f[e]=o()},Object.defineProperty(e,"__esModule",{value:!0})}); |
{ | ||
"name": "perf-marks", | ||
"version": "1.6.0", | ||
"version": "1.7.0", | ||
"author": "Will Mendes <willmendesneto@gmail.com>", | ||
@@ -31,3 +31,3 @@ "description": "The simplest and lightweight solution for User Timing API in Javascript.", | ||
"@types/jest": "^24.0.18", | ||
"@types/node": "^12.0.10", | ||
"@types/node": "^13.1.0", | ||
"@typescript-eslint/eslint-plugin": "^2.3.3", | ||
@@ -44,3 +44,3 @@ "@typescript-eslint/parser": "^2.3.3", | ||
"glob": "^7.1.4", | ||
"husky": "^3.0.9", | ||
"husky": "^4.0.2", | ||
"jest": "^24.9.0", | ||
@@ -83,19 +83,19 @@ "jsdom": "^15.2.0", | ||
"path": "./dist/esm/index.js", | ||
"maxSize": "89B" | ||
"maxSize": "84B" | ||
}, | ||
{ | ||
"path": "./dist/es2015/index.js", | ||
"maxSize": "89B" | ||
"maxSize": "84B" | ||
}, | ||
{ | ||
"path": "./dist/cjs/index.js", | ||
"maxSize": "178B" | ||
"maxSize": "176B" | ||
}, | ||
{ | ||
"path": "./dist/umd/perf-marks.js", | ||
"maxSize": "1.21KB" | ||
"maxSize": "1.19KB" | ||
}, | ||
{ | ||
"path": "./dist/umd/perf-marks.min.js", | ||
"maxSize": "530B" | ||
"maxSize": "508B" | ||
} | ||
@@ -102,0 +102,0 @@ ], |
@@ -70,20 +70,26 @@ # Perf-marks | ||
## Run the app | ||
### Run the tests | ||
```bash | ||
$ yarn start | ||
$ yarn test # run the tests | ||
``` | ||
## Run the tests | ||
### Run the build | ||
```bash | ||
$ yarn test # run the tests | ||
$ yarn build # run the tests | ||
``` | ||
## Run the build | ||
### Run the bundlesize check | ||
```bash | ||
$ yarn build # run the tests | ||
$ yarn bundlesize # run the tests | ||
``` | ||
### Run the code lint | ||
```bash | ||
$ yarn lint # run the tests | ||
``` | ||
## `PerfMarks` | ||
@@ -107,4 +113,6 @@ | ||
Returns the results for the specified marker | ||
Returns the results for the specified marker. | ||
> `PerfMarks.end(markName)` calls `PerfMarks.clear(markName)` after return the mark values | ||
```js | ||
@@ -142,2 +150,3 @@ import * as PerfMarks from 'perf-marks'; | ||
PerfMarks.start('name-of-your-mark'); | ||
PerfMarks.start('another-name-of-your-mark'); | ||
... | ||
@@ -179,4 +188,6 @@ PerfMarks.clearAll(); | ||
Boolean with the result of the check if User Timing API is supported for the current browser/NodeJS version | ||
Boolean with the result of the check if User Timing API is supported for the current browser/NodeJS version. | ||
> `PerfMarks` already have a fallback in case user timing is not supported. This boolean is exposed in case the app needs to check the case to use any other mechanism. | ||
```js | ||
@@ -186,9 +197,6 @@ import * as PerfMarks from 'perf-marks'; | ||
... | ||
PerfMarks.start('name-of-your-mark'); | ||
PerfMarks.start('another-name-of-your-mark'); | ||
if (PerfMarks.isUserTimingAPISupported) { | ||
// ... Do something | ||
} | ||
... | ||
// It will return results for all the marks that matches with `name-of-your-mark` | ||
// In this case, `name-of-your-mark` and `another-name-of-your-mark` | ||
const markResult: PerfMarksPerformanceNavigationTiming[] = PerfMarks.getEntriesByType('name-of-your-mark'); | ||
... | ||
``` | ||
@@ -200,2 +208,4 @@ | ||
By definition it will use CJS as the main distribution entrypoint used in the app. However, this can be changed in the consumer's bundle step. This is the built-in scenario if the consumer uses toolings such as `Webpack`, `Rollup`, or `Parcel`. | ||
### Exposed entrypoints | ||
@@ -208,2 +218,3 @@ | ||
- `clearAll` | ||
- `isUserTimingAPISupported` | ||
- `perf-marks/entries`: it has all the methods to get entries | ||
@@ -210,0 +221,0 @@ - `getNavigationMarker` |
Sorry, the diff of this file is not supported yet
55688
290
1219