perf-marks
Advanced tools
Comparing version 1.2.1 to 1.3.0
@@ -10,2 +10,19 @@ # Change Log | ||
### Fixed | ||
- Adding `UMD` bundle as main entry for the package | ||
### Updated | ||
- Removing `tslib` for Stackblitz examples | ||
- Updated entrypoints logic to remove files after `yarn bundlesize` command | ||
### Added | ||
- Adding different bundles for `CommonJS`, `UMD`, `ESM` and `ES2015` | ||
- Using `ESM` definition for entry points for better tree shaking | ||
- Exposing new methods in entry points | ||
- Adding docs for entry points | ||
- Adding docs yarn usage and installation | ||
## [1.2.1][] - 2019-10-22 | ||
@@ -78,5 +95,3 @@ | ||
[1.2.0]: https://github.com/willmendesneto/perf-marks/tree/v1.2.0 | ||
[Unreleased]: https://github.com/willmendesneto/perf-marks/compare/v1.2.1...HEAD | ||
[1.2.1]: https://github.com/willmendesneto/perf-marks/tree/v1.2.1 | ||
[unreleased]: https://github.com/willmendesneto/perf-marks/compare/v1.2.1...HEAD | ||
[1.2.1]: https://github.com/willmendesneto/perf-marks/tree/v1.2.1 |
@@ -1,4 +0,24 @@ | ||
declare const getNavigationMarker: () => PerformanceNavigationTiming | { | ||
/** | ||
* Response type of `PerfMarks.getNavigationMarker()` and `Perf.getEntriesByType()` methods | ||
* | ||
*/ | ||
export declare type PerfMarksPerformanceNavigationTiming = PerformanceNavigationTiming | { | ||
[key: string]: any; | ||
}; | ||
export { getNavigationMarker }; | ||
/** | ||
* Gets the result for all marks that matches with the given mark name | ||
* | ||
* @param markName - Performance marker to be checked | ||
* | ||
* @returns PerfMarksPerformanceNavigationTiming[] | ||
* | ||
*/ | ||
declare const getEntriesByType: (entryName: string) => PerfMarksPerformanceNavigationTiming[]; | ||
/** | ||
* Gets the marks for `navigation` loaded mark | ||
* | ||
* @returns PerfMarksPerformanceNavigationTiming[] | ||
* | ||
*/ | ||
declare const getNavigationMarker: () => PerfMarksPerformanceNavigationTiming; | ||
export { getNavigationMarker, getEntriesByType }; |
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
var is_user_timing_api_supported_1 = require("./is-user-timing-api-supported"); | ||
/** | ||
* Gets the result for all marks that matches with the given mark name | ||
* | ||
* @param markName - Performance marker to be checked | ||
* | ||
* @returns PerfMarksPerformanceNavigationTiming[] | ||
* | ||
*/ | ||
var getEntriesByType = function (entryName) { | ||
@@ -10,5 +18,10 @@ if (!is_user_timing_api_supported_1.isUserTimingAPISupported) { | ||
}; | ||
var getNavigationMarker = function () { | ||
return getEntriesByType('navigation').pop() || {}; | ||
}; | ||
exports.getEntriesByType = getEntriesByType; | ||
/** | ||
* Gets the marks for `navigation` loaded mark | ||
* | ||
* @returns PerfMarksPerformanceNavigationTiming[] | ||
* | ||
*/ | ||
var getNavigationMarker = function () { return getEntriesByType('navigation').pop() || {}; }; | ||
exports.getNavigationMarker = getNavigationMarker; |
@@ -1,4 +0,24 @@ | ||
declare const getNavigationMarker: () => PerformanceNavigationTiming | { | ||
/** | ||
* Response type of `PerfMarks.getNavigationMarker()` and `Perf.getEntriesByType()` methods | ||
* | ||
*/ | ||
export declare type PerfMarksPerformanceNavigationTiming = PerformanceNavigationTiming | { | ||
[key: string]: any; | ||
}; | ||
export { getNavigationMarker }; | ||
/** | ||
* Gets the result for all marks that matches with the given mark name | ||
* | ||
* @param markName - Performance marker to be checked | ||
* | ||
* @returns PerfMarksPerformanceNavigationTiming[] | ||
* | ||
*/ | ||
declare const getEntriesByType: (entryName: string) => PerfMarksPerformanceNavigationTiming[]; | ||
/** | ||
* Gets the marks for `navigation` loaded mark | ||
* | ||
* @returns PerfMarksPerformanceNavigationTiming[] | ||
* | ||
*/ | ||
declare const getNavigationMarker: () => PerfMarksPerformanceNavigationTiming; | ||
export { getNavigationMarker, getEntriesByType }; |
import { isUserTimingAPISupported } from './is-user-timing-api-supported'; | ||
/** | ||
* Gets the result for all marks that matches with the given mark name | ||
* | ||
* @param markName - Performance marker to be checked | ||
* | ||
* @returns PerfMarksPerformanceNavigationTiming[] | ||
* | ||
*/ | ||
const getEntriesByType = (entryName) => { | ||
@@ -8,3 +16,9 @@ if (!isUserTimingAPISupported) { | ||
}; | ||
/** | ||
* Gets the marks for `navigation` loaded mark | ||
* | ||
* @returns PerfMarksPerformanceNavigationTiming[] | ||
* | ||
*/ | ||
const getNavigationMarker = () => getEntriesByType('navigation').pop() || {}; | ||
export { getNavigationMarker }; | ||
export { getNavigationMarker, getEntriesByType }; |
@@ -1,4 +0,24 @@ | ||
declare const getNavigationMarker: () => PerformanceNavigationTiming | { | ||
/** | ||
* Response type of `PerfMarks.getNavigationMarker()` and `Perf.getEntriesByType()` methods | ||
* | ||
*/ | ||
export declare type PerfMarksPerformanceNavigationTiming = PerformanceNavigationTiming | { | ||
[key: string]: any; | ||
}; | ||
export { getNavigationMarker }; | ||
/** | ||
* Gets the result for all marks that matches with the given mark name | ||
* | ||
* @param markName - Performance marker to be checked | ||
* | ||
* @returns PerfMarksPerformanceNavigationTiming[] | ||
* | ||
*/ | ||
declare const getEntriesByType: (entryName: string) => PerfMarksPerformanceNavigationTiming[]; | ||
/** | ||
* Gets the marks for `navigation` loaded mark | ||
* | ||
* @returns PerfMarksPerformanceNavigationTiming[] | ||
* | ||
*/ | ||
declare const getNavigationMarker: () => PerfMarksPerformanceNavigationTiming; | ||
export { getNavigationMarker, getEntriesByType }; |
import { isUserTimingAPISupported } from './is-user-timing-api-supported'; | ||
/** | ||
* Gets the result for all marks that matches with the given mark name | ||
* | ||
* @param markName - Performance marker to be checked | ||
* | ||
* @returns PerfMarksPerformanceNavigationTiming[] | ||
* | ||
*/ | ||
const getEntriesByType = (entryName) => { | ||
@@ -8,3 +16,9 @@ if (!isUserTimingAPISupported) { | ||
}; | ||
/** | ||
* Gets the marks for `navigation` loaded mark | ||
* | ||
* @returns PerfMarksPerformanceNavigationTiming[] | ||
* | ||
*/ | ||
const getNavigationMarker = () => getEntriesByType('navigation').pop() || {}; | ||
export { getNavigationMarker }; | ||
export { getNavigationMarker, getEntriesByType }; |
{ | ||
"name": "perf-marks", | ||
"version": "1.2.1", | ||
"version": "1.3.0", | ||
"author": "Will Mendes <willmendesneto@gmail.com>", | ||
@@ -11,6 +11,7 @@ "description": "The simplest and lightweight solution for User Timing API in Javascript.", | ||
"license": "MIT", | ||
"main": "dist/es5/index.js", | ||
"main": "dist/umd/index.js", | ||
"jsnext:main": "dist/es2015/index.js", | ||
"module": "dist/es2015/index.js", | ||
"types": "dist/es5/index.d.ts", | ||
"cjs": "dist/cjs/index.js", | ||
"types": "dist/umd/index.d.ts", | ||
"keywords": [ | ||
@@ -27,2 +28,3 @@ "perf-marks", | ||
"@babel/core": "^7.6.4", | ||
"@babel/plugin-transform-modules-umd": "^7.2.0", | ||
"@babel/preset-env": "^7.6.3", | ||
@@ -61,7 +63,9 @@ "@types/jest": "^24.0.18", | ||
"clean": "rm -rf ./dist ./.jest ./coverage ./lib ./marks.* ./entries.*", | ||
"build": "yarn build:es2015 && yarn build:cjs && yarn build:esm", | ||
"clean:entrypoints": "rm -rf ./marks.* ./entries.*", | ||
"build": "yarn build:es2015 && yarn build:cjs && yarn build:esm && yarn build:umd", | ||
"build:umd": "tsc --module esnext --target ES5 --outDir dist/umd && babel dist/umd --out-dir dist/umd", | ||
"build:es2015": "tsc --module es2015 --target es2015 --outDir dist/es2015", | ||
"build:esm": "tsc --module esnext --target esnext --outDir dist/esm && yarn build:entrypoints:clean && yarn build:entrypoints", | ||
"build:cjs": "tsc --module commonjs --target es5 --outDir dist/cjs", | ||
"build:entrypoints:clean": "rm -rf ./dist/cjs/entrypoints ./dist/es2015/entrypoints", | ||
"build:entrypoints:clean": "rm -rf ./dist/umd/entrypoints ./dist/cjs/entrypoints ./dist/es2015/entrypoints", | ||
"build:entrypoints": "node ./scripts/build-entrypoints.js", | ||
@@ -72,8 +76,5 @@ "test": "jest", | ||
"check-coverage": "cat ./coverage/lcov.info | ./node_modules/.bin/coveralls && rm -rf coverage", | ||
"prepublish": "yarn build", | ||
"generate-banner": "node ./scripts/generate-banner.js", | ||
"bundlesize": "bundlesize", | ||
"bundlesize": "bundlesize && yarn clean:entrypoints", | ||
"lint": "eslint '{scripts,src}/**/*.[tj]s'", | ||
"lint:fix": "prettier --no-editorconfig --write", | ||
"version": "version-changelog CHANGELOG.md && changelog-verify CHANGELOG.md && git add CHANGELOG.md" | ||
"lint:fix": "prettier --no-editorconfig --write" | ||
}, | ||
@@ -92,2 +93,6 @@ "bundlesize": [ | ||
"maxSize": "178B" | ||
}, | ||
{ | ||
"path": "./dist/umd/index.js", | ||
"maxSize": "305B" | ||
} | ||
@@ -94,0 +99,0 @@ ], |
118
README.md
@@ -35,3 +35,2 @@ # Perf-marks | ||
$ nvm use $(cat .nvmrc); # use nodejs version | ||
$ npm install | ||
``` | ||
@@ -46,3 +45,2 @@ | ||
$ nvm use $(cat .nvmrc); # use nodejs version | ||
$ npm install | ||
``` | ||
@@ -56,2 +54,14 @@ | ||
### Install yarn | ||
We use `yarn` as our package manager instead of `npm` | ||
[Install it following these steps](https://yarnpkg.com/lang/en/docs/install/#mac-tab) | ||
After that, just navigate to your local repository and run | ||
```bash | ||
$ yarn install | ||
``` | ||
## Demo | ||
@@ -66,3 +76,3 @@ | ||
```bash | ||
$ npm start | ||
$ yarn start | ||
``` | ||
@@ -73,3 +83,3 @@ | ||
```bash | ||
$ npm test # run the tests | ||
$ yarn test # run the tests | ||
``` | ||
@@ -80,3 +90,3 @@ | ||
```bash | ||
$ npm run build # run the tests | ||
$ yarn build # run the tests | ||
``` | ||
@@ -92,2 +102,10 @@ | ||
```js | ||
import * as PerfMarks from 'perf-marks'; | ||
... | ||
PerfMarks.start('name-of-your-mark'); | ||
... | ||
``` | ||
### `PerfMarks.end(markName)` | ||
@@ -97,2 +115,11 @@ | ||
```js | ||
import * as PerfMarks from 'perf-marks'; | ||
... | ||
PerfMarks.start('name-of-your-mark'); | ||
... | ||
const markResults: PerfMarks.PerfMarksPerformanceEntry = PerfMarks.end('name-of-your-mark'); | ||
``` | ||
### `PerfMarks.clear(markName)` | ||
@@ -102,2 +129,12 @@ | ||
```js | ||
import * as PerfMarks from 'perf-marks'; | ||
... | ||
PerfMarks.start('name-of-your-mark'); | ||
... | ||
PerfMarks.clear('name-of-your-mark'); | ||
... | ||
``` | ||
### `PerfMarks.clearAll()` | ||
@@ -107,2 +144,73 @@ | ||
```js | ||
import * as PerfMarks from 'perf-marks'; | ||
... | ||
PerfMarks.start('name-of-your-mark'); | ||
... | ||
PerfMarks.clearAll(); | ||
... | ||
``` | ||
### `PerfMarks.getNavigationMarker()` | ||
Gets the marks for `navigation` loaded | ||
```js | ||
import * as PerfMarks from 'perf-marks'; | ||
... | ||
const markResults: PerfMarksPerformanceNavigationTiming = PerfMarks.getNavigationMarker(); | ||
... | ||
``` | ||
### `PerfMarks.getEntriesByType(markName)` | ||
Gets the result for all marks that matches with the given mark name | ||
```js | ||
import * as PerfMarks from 'perf-marks'; | ||
... | ||
PerfMarks.start('name-of-your-mark'); | ||
PerfMarks.start('another-name-of-your-mark'); | ||
... | ||
// 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'); | ||
... | ||
``` | ||
### `PerfMarks.isUserTimingAPISupported` | ||
Boolean with the result of the check if User Timing API is supported for the current browser/NodeJS version | ||
```js | ||
import * as PerfMarks from 'perf-marks'; | ||
... | ||
PerfMarks.start('name-of-your-mark'); | ||
PerfMarks.start('another-name-of-your-mark'); | ||
... | ||
// 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'); | ||
... | ||
``` | ||
## Entrypoints | ||
These are entrypoints for specific components to be used carefully by the consumers. If you're using one of these entrypoints we are assuming you know what you are doing. So it means that code-splitting and tree-shaking should be done on the consumer/product side. | ||
### Exposed entrypoints | ||
- `perf-marks/marks`: it has all the methods for marks | ||
- `start` | ||
- `end` | ||
- `clear` | ||
- `clearAll` | ||
- `perf-marks/entries`: it has all the methods to get entries | ||
- `getNavigationMarker` | ||
- `getEntriesByType` | ||
## Publish | ||
@@ -109,0 +217,0 @@ |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
43026
42
978
218
29