Socket
Socket
Sign inDemoInstall

perf-marks

Package Overview
Dependencies
Maintainers
1
Versions
30
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

perf-marks - npm Package Compare versions

Comparing version 1.8.1 to 1.9.0

dist/cjs/entrypoints/entries.d.ts

12

CHANGELOG.md

@@ -10,2 +10,8 @@ # Change Log

## [1.9.0][] - 2020-07-24
### Added
- Adding support for NodeJS and VanillaJS. Now it runs in frontend and backend 🎉
## [1.8.1][] - 2020-05-13

@@ -222,5 +228,7 @@

[1.8.0]: https://github.com/willmendesneto/perf-marks/tree/v1.8.0
[unreleased]: https://github.com/willmendesneto/perf-marks/compare/v1.8.1...HEAD
[1.8.1]: https://github.com/willmendesneto/perf-marks/tree/v1.8.1
[Unreleased]: https://github.com/willmendesneto/perf-marks/compare/v1.8.1...HEAD
[1.8.1]: https://github.com/willmendesneto/perf-marks/tree/v1.8.1
[Unreleased]: https://github.com/willmendesneto/perf-marks/compare/v1.9.0...HEAD
[1.9.0]: https://github.com/willmendesneto/perf-marks/tree/v1.9.0

4

dist/cjs/entries.js

@@ -5,2 +5,3 @@ "use strict";

var is_user_timing_api_supported_1 = require("./is-user-timing-api-supported");
var is_nodejs_env_1 = require("./is-nodejs-env");
/**

@@ -15,3 +16,4 @@ * Gets the result for all marks that matches with the given mark name

var getEntriesByType = function (entryName) {
if (!is_user_timing_api_supported_1.isUserTimingAPISupported) {
// NodeJS doesn't have support for getEntriesByType
if (!is_user_timing_api_supported_1.isUserTimingAPISupported || is_nodejs_env_1.isNodeJSEnv) {
return [];

@@ -18,0 +20,0 @@ }

@@ -0,1 +1,2 @@

import './user-timing-api-resolver';
export * from './marks';

@@ -2,0 +3,0 @@ export * from './entries';

"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
var tslib_1 = require("tslib");
require("./user-timing-api-resolver");
tslib_1.__exportStar(require("./marks"), exports);

@@ -5,0 +6,0 @@ tslib_1.__exportStar(require("./entries"), exports);

@@ -14,5 +14,4 @@ "use strict";

typeof performance.mark === 'function' &&
typeof performance.clearMarks === 'function' &&
typeof performance.measure === 'function' &&
typeof performance.clearMeasures === 'function';
(typeof performance.clearMarks === 'function' || typeof performance.clearMeasures === 'function');
exports.isUserTimingAPISupported = isUserTimingAPISupported;

@@ -28,2 +28,4 @@ import { isUserTimingAPISupported } from './is-user-timing-api-supported';

startTime?: number;
name?: string;
entryType?: string;
};

@@ -30,0 +32,0 @@ /**

@@ -8,2 +8,3 @@ "use strict";

Object.defineProperty(exports, "isPerformanceObservableSupported", { enumerable: true, get: function () { return is_performance_observable_supported_1.isPerformanceObservableSupported; } });
var is_nodejs_env_1 = require("./is-nodejs-env");
// Map() is not used in order to decrease the bundle

@@ -36,3 +37,6 @@ var marksMap = {};

}
performance.clearMeasures(markName);
// Some versions of NodeJS doesn't support this method
if (!is_nodejs_env_1.isNodeJSEnv) {
performance.clearMeasures(markName);
}
performance.clearMarks(markName);

@@ -69,4 +73,7 @@ };

var startTime = marksMap[markName];
if (!is_user_timing_api_supported_1.isUserTimingAPISupported) {
return startTime ? { duration: getTimeNow() - startTime, startTime: startTime } : {};
// NodeJS is not using performance api directly from them for now
if (!is_user_timing_api_supported_1.isUserTimingAPISupported || is_nodejs_env_1.isNodeJSEnv) {
return startTime
? { duration: getTimeNow() - startTime, startTime: startTime, entryType: 'measure', name: markName }
: {};
}

@@ -101,5 +108,8 @@ performance.measure(markName, markName, markNameToCompare || undefined);

}
performance.clearMeasures();
// Some versions of NodeJS doesn't support this method
if (!is_nodejs_env_1.isNodeJSEnv) {
performance.clearMeasures();
}
performance.clearMarks();
};
exports.clearAll = clearAll;
import { isUserTimingAPISupported } from './is-user-timing-api-supported';
import { isNodeJSEnv } from './is-nodejs-env';
/**

@@ -11,3 +12,4 @@ * Gets the result for all marks that matches with the given mark name

const getEntriesByType = (entryName) => {
if (!isUserTimingAPISupported) {
// NodeJS doesn't have support for getEntriesByType
if (!isUserTimingAPISupported || isNodeJSEnv) {
return [];

@@ -14,0 +16,0 @@ }

@@ -0,1 +1,2 @@

import './user-timing-api-resolver';
export * from './marks';

@@ -2,0 +3,0 @@ export * from './entries';

@@ -0,1 +1,2 @@

import './user-timing-api-resolver';
export * from './marks';

@@ -2,0 +3,0 @@ export * from './entries';

@@ -11,5 +11,4 @@ /**

typeof performance.mark === 'function' &&
typeof performance.clearMarks === 'function' &&
typeof performance.measure === 'function' &&
typeof performance.clearMeasures === 'function';
(typeof performance.clearMarks === 'function' || typeof performance.clearMeasures === 'function');
export { isUserTimingAPISupported };

@@ -28,2 +28,4 @@ import { isUserTimingAPISupported } from './is-user-timing-api-supported';

startTime?: number;
name?: string;
entryType?: string;
};

@@ -30,0 +32,0 @@ /**

import { isUserTimingAPISupported } from './is-user-timing-api-supported';
import { isPerformanceObservableSupported } from './is-performance-observable-supported';
import { isNodeJSEnv } from './is-nodejs-env';
// Map() is not used in order to decrease the bundle

@@ -30,3 +31,6 @@ let marksMap = {};

}
performance.clearMeasures(markName);
// Some versions of NodeJS doesn't support this method
if (!isNodeJSEnv) {
performance.clearMeasures(markName);
}
performance.clearMarks(markName);

@@ -61,4 +65,7 @@ };

const startTime = marksMap[markName];
if (!isUserTimingAPISupported) {
return startTime ? { duration: getTimeNow() - startTime, startTime } : {};
// NodeJS is not using performance api directly from them for now
if (!isUserTimingAPISupported || isNodeJSEnv) {
return startTime
? { duration: getTimeNow() - startTime, startTime, entryType: 'measure', name: markName }
: {};
}

@@ -92,5 +99,8 @@ performance.measure(markName, markName, markNameToCompare || undefined);

}
performance.clearMeasures();
// Some versions of NodeJS doesn't support this method
if (!isNodeJSEnv) {
performance.clearMeasures();
}
performance.clearMarks();
};
export { start, end, clear, clearAll, isUserTimingAPISupported, isPerformanceObservableSupported };
import { isUserTimingAPISupported } from './is-user-timing-api-supported';
import { isNodeJSEnv } from './is-nodejs-env';
/**

@@ -11,3 +12,4 @@ * Gets the result for all marks that matches with the given mark name

var getEntriesByType = function (entryName) {
if (!isUserTimingAPISupported) {
// NodeJS doesn't have support for getEntriesByType
if (!isUserTimingAPISupported || isNodeJSEnv) {
return [];

@@ -14,0 +16,0 @@ }

@@ -0,1 +1,2 @@

import './user-timing-api-resolver';
export * from './marks';

@@ -2,0 +3,0 @@ export * from './entries';

@@ -0,1 +1,2 @@

import './user-timing-api-resolver';
export * from './marks';

@@ -2,0 +3,0 @@ export * from './entries';

@@ -11,5 +11,4 @@ /**

typeof performance.mark === 'function' &&
typeof performance.clearMarks === 'function' &&
typeof performance.measure === 'function' &&
typeof performance.clearMeasures === 'function';
(typeof performance.clearMarks === 'function' || typeof performance.clearMeasures === 'function');
export { isUserTimingAPISupported };

@@ -28,2 +28,4 @@ import { isUserTimingAPISupported } from './is-user-timing-api-supported';

startTime?: number;
name?: string;
entryType?: string;
};

@@ -30,0 +32,0 @@ /**

import { isUserTimingAPISupported } from './is-user-timing-api-supported';
import { isPerformanceObservableSupported } from './is-performance-observable-supported';
import { isNodeJSEnv } from './is-nodejs-env';
// Map() is not used in order to decrease the bundle

@@ -30,3 +31,6 @@ var marksMap = {};

}
performance.clearMeasures(markName);
// Some versions of NodeJS doesn't support this method
if (!isNodeJSEnv) {
performance.clearMeasures(markName);
}
performance.clearMarks(markName);

@@ -61,4 +65,7 @@ };

var startTime = marksMap[markName];
if (!isUserTimingAPISupported) {
return startTime ? { duration: getTimeNow() - startTime, startTime: startTime } : {};
// NodeJS is not using performance api directly from them for now
if (!isUserTimingAPISupported || isNodeJSEnv) {
return startTime
? { duration: getTimeNow() - startTime, startTime: startTime, entryType: 'measure', name: markName }
: {};
}

@@ -92,5 +99,8 @@ performance.measure(markName, markName, markNameToCompare || undefined);

}
performance.clearMeasures();
// Some versions of NodeJS doesn't support this method
if (!isNodeJSEnv) {
performance.clearMeasures();
}
performance.clearMarks();
};
export { start, end, clear, clearAll, isUserTimingAPISupported, isPerformanceObservableSupported };

@@ -8,2 +8,23 @@ (function (global, factory) {

/**
* Boolean with the result of the check if package
* is running on the browser or in a NodeJS environment
*
* @returns boolean
*
*/
var isNodeJSEnv = typeof process !== 'undefined';
if (isNodeJSEnv && !global.PerformanceObserver && !global.performance) {
try {
// eslint-disable-next-line @typescript-eslint/no-var-requires
var _a = require('perf_hooks'), PerformanceObserver_1 = _a.PerformanceObserver, performance_1 = _a.performance;
global.PerformanceObserver = PerformanceObserver_1;
global.performance = performance_1;
}
catch (error) {
throw new Error("Your NodeJS application doesn't support perf_hooks. " + error);
}
}
/**
* Boolean with the result of the check if User Timing API

@@ -18,5 +39,4 @@ * is supported for the current browser/NodeJS version

typeof performance.mark === 'function' &&
typeof performance.clearMarks === 'function' &&
typeof performance.measure === 'function' &&
typeof performance.clearMeasures === 'function';
(typeof performance.clearMarks === 'function' || typeof performance.clearMeasures === 'function');

@@ -61,3 +81,6 @@ /**

}
performance.clearMeasures(markName);
// Some versions of NodeJS doesn't support this method
if (!isNodeJSEnv) {
performance.clearMeasures(markName);
}
performance.clearMarks(markName);

@@ -92,4 +115,7 @@ };

var startTime = marksMap[markName];
if (!isUserTimingAPISupported) {
return startTime ? { duration: getTimeNow() - startTime, startTime: startTime } : {};
// NodeJS is not using performance api directly from them for now
if (!isUserTimingAPISupported || isNodeJSEnv) {
return startTime
? { duration: getTimeNow() - startTime, startTime: startTime, entryType: 'measure', name: markName }
: {};
}

@@ -123,3 +149,6 @@ performance.measure(markName, markName, markNameToCompare || undefined);

}
performance.clearMeasures();
// Some versions of NodeJS doesn't support this method
if (!isNodeJSEnv) {
performance.clearMeasures();
}
performance.clearMarks();

@@ -137,3 +166,4 @@ };

var getEntriesByType = function (entryName) {
if (!isUserTimingAPISupported) {
// NodeJS doesn't have support for getEntriesByType
if (!isUserTimingAPISupported || isNodeJSEnv) {
return [];

@@ -140,0 +170,0 @@ }

@@ -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 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,n="undefined"!=typeof PerformanceObserver&&void 0!==PerformanceObserver.prototype&&"function"==typeof PerformanceObserver.prototype.constructor,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.isPerformanceObservableSupported=n,e.isUserTimingAPISupported=a,e.start=function(e){a&&performance.mark(e),f[e]=o()},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";var n="undefined"!=typeof process;if(n&&!global.PerformanceObserver&&!global.performance)try{var r=require("perf_hooks"),o=r.PerformanceObserver,a=r.performance;global.PerformanceObserver=o,global.performance=a}catch(e){throw new Error("Your NodeJS application doesn't support perf_hooks. "+e)}function t(){return p?performance.now():Date.now()}function f(e){s[e]=void 0,p&&(n||performance.clearMeasures(e),performance.clearMarks(e))}function c(e){return p&&!n&&performance.getEntriesByType(e)||[]}var p="undefined"!=typeof performance&&void 0!==performance.now&&"function"==typeof performance.mark&&"function"==typeof performance.measure&&("function"==typeof performance.clearMarks||"function"==typeof performance.clearMeasures),i="undefined"!=typeof PerformanceObserver&&void 0!==PerformanceObserver.prototype&&"function"==typeof PerformanceObserver.prototype.constructor,s={};e.clear=f,e.clearAll=function(){s={},p&&(n||performance.clearMeasures(),performance.clearMarks())},e.end=function(e,r){try{var o=s[e];return!p||n?o?{duration:t()-o,startTime:o,entryType:"measure",name:e}:{}:(performance.measure(e,e,r||void 0),performance.getEntriesByName(e).pop()||{})}catch(e){return{}}finally{f(e)}},e.getEntriesByType=c,e.getNavigationMarker=function(){return c("navigation").pop()||{}},e.isPerformanceObservableSupported=i,e.isUserTimingAPISupported=p,e.start=function(e){p&&performance.mark(e),s[e]=t()},Object.defineProperty(e,"__esModule",{value:!0})});
{
"name": "perf-marks/entries",
"private": true,
"main": "../dist/cjs/entries.js",
"module": "../dist/esm/entries.js"
"main": "../dist/cjs/entrypoints/entries.js",
"module": "../dist/esm/entrypoints/entries.js"
}
{
"name": "perf-marks/marks",
"private": true,
"main": "../dist/cjs/marks.js",
"module": "../dist/esm/marks.js"
"main": "../dist/cjs/entrypoints/marks.js",
"module": "../dist/esm/entrypoints/marks.js"
}
{
"name": "perf-marks",
"version": "1.8.1",
"version": "1.9.0",
"author": "Will Mendes <willmendesneto@gmail.com>",

@@ -18,3 +18,3 @@ "description": "The simplest and lightweight solution for User Timing API in Javascript.",

"cjs": "dist/cjs/index.js",
"types": "dist/umd/index.d.ts",
"types": "dist/cjs/index.d.ts",
"keywords": [

@@ -28,3 +28,3 @@ "perf-marks",

"dependencies": {
"tslib": "^1.12.0"
"tslib": "^2.0.0"
},

@@ -34,4 +34,4 @@ "devDependencies": {

"@types/node": "^14.0.0",
"@typescript-eslint/eslint-plugin": "^2.33.0",
"@typescript-eslint/parser": "^2.33.0",
"@typescript-eslint/eslint-plugin": "^3.0.1",
"@typescript-eslint/parser": "^3.0.0",
"bundlesize": "^0.18.0",

@@ -52,3 +52,3 @@ "changelog-verify": "^1.1.0",

"rollup": "^2.9.1",
"ts-jest": "^25.5.1",
"ts-jest": "^26.0.0",
"ts-node": "^8.10.1",

@@ -85,19 +85,19 @@ "typescript": "^3.9.2",

"path": "./dist/esm/index.js",
"maxSize": "104B"
"maxSize": "118B"
},
{
"path": "./dist/es2015/index.js",
"maxSize": "104B"
"maxSize": "118B"
},
{
"path": "./dist/cjs/index.js",
"maxSize": "193B"
"maxSize": "208B"
},
{
"path": "./dist/umd/perf-marks.js",
"maxSize": "1.24KB"
"maxSize": "1.56KB"
},
{
"path": "./dist/umd/perf-marks.min.js",
"maxSize": "554B"
"maxSize": "698B"
}

@@ -104,0 +104,0 @@ ],

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc