Launch Week Day 5: Introducing Reachability for PHP.Learn More
Socket
Book a DemoSign in
Socket

on-performance

Package Overview
Dependencies
Maintainers
26
Versions
6
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

on-performance - npm Package Compare versions

Comparing version
1.2.1
to
1.2.2
+39
test/browser.js
var nanotiming = require('nanotiming')
var tape = require('tape')
var onPerformance = require('../browser')
tape('should flush already buffered events', function (assert) {
var startLength = window.performance.getEntries().length
var i = 0
var stop = onPerformance(function (entry) {
assert.ok(entry, 'entry passed')
i++
endMaybe()
})
endMaybe() // call once at the start to if startLength === 0
function endMaybe () {
assert.pass('endMaybe called')
if (i < startLength) return
if (stop) stop()
assert.end()
}
})
tape('should capture performance measures', function (assert) {
assert.plan(2)
var startLength = window.performance.getEntries().length
var stop = onPerformance(function (entry) {
if (entry.entryType !== 'measure') return
assert.ok(entry, 'entry was passed')
var newLength = window.performance.getEntries().length
assert.equal(startLength, newLength, 'entries are cleared')
stop()
})
nanotiming('test')()
})
var nanotiming = require('nanotiming')
var tape = require('tape')
var onPerformance = require('../')
var hasPerfHooks = (function () {
try {
require('perf_hooks')
return true
} catch (err) {
return false
}
}())
tape('should capture performance measures', { skip: !hasPerfHooks }, function (assert) {
assert.plan(1)
var stop = onPerformance(function (entry) {
if (entry.entryType !== 'measure') return
assert.ok(entry, 'entry was passed')
stop()
})
nanotiming('test')()
})
+3
-3
node_js:
- "7"
- "8"
- "9"
- "10"
- "8"
- "6"
sudo: false

@@ -6,0 +6,0 @@ language: node_js

@@ -35,6 +35,11 @@ var assert = require('assert')

var observer = new PerformanceObserver(parseEntries)
setTimeout(function () {
parseEntries(performance)
// Only necessary in Node >=8.5 <10, Node 10+ doesn't have a global buffer
if (performance.getEntries) {
setTimeout(function () {
parseEntries(performance)
observer.observe({ entryTypes: entryTypes })
}, 0)
} else {
observer.observe({ entryTypes: entryTypes })
}, 0)
}

@@ -58,6 +63,6 @@ return stop

var type = entry.entryType
if (type === 'measure') performance.clearMeasures(entry.name)
else if (type === 'mark') performance.clearMarks(entry.name)
else if (type === 'function') performance.clearFunctions(entry.name)
// Only necessary in Node >=8.5 <10, Node 10+ doesn't have a global buffer
if (type === 'measure' && performance.clearMeasures) performance.clearMeasures(entry.name)
else if (type === 'function' && performance.clearFunctions) performance.clearFunctions(entry.name)
}
}

@@ -10,6 +10,6 @@ {

},
"version": "1.2.1",
"version": "1.2.2",
"scripts": {
"start": "bankai start test.js",
"test": "standard && browserify test | tape-run"
"start": "bankai start test/browser.js",
"test": "standard && node test && browserify test/browser | tape-run"
},

@@ -21,9 +21,9 @@ "dependencies": {

"devDependencies": {
"bankai": "^8.0.0",
"browserify": "^14.4.0",
"dependency-check": "^2.8.0",
"nanotiming": "^5.2.1",
"standard": "^10.0.2",
"tape": "^4.6.3",
"tape-run": "^3.0.0"
"bankai": "^9.12.0",
"browserify": "^16.2.2",
"dependency-check": "^3.1.0",
"nanotiming": "^7.3.1",
"standard": "^11.0.1",
"tape": "^4.9.0",
"tape-run": "^4.0.0"
},

@@ -30,0 +30,0 @@ "keywords": [

var nanotiming = require('nanotiming')
var tape = require('tape')
var onPerformance = require('./browser')
tape('should flush already buffered events', function (assert) {
var startLength = window.performance.getEntries().length
var i = 0
var stop = onPerformance(function (entry) {
assert.ok(entry, 'entry passed')
i++
endMaybe()
})
endMaybe() // call once at the start to if startLength === 0
function endMaybe () {
assert.pass('endMaybe called')
if (i < startLength) return
if (stop) stop()
assert.end()
}
})
tape('should capture performance measures', function (assert) {
assert.plan(2)
var startLength = window.performance.getEntries().length
var stop = onPerformance(function (entry) {
if (entry.entryType !== 'measure') return
assert.ok(entry, 'entry was passed')
var newLength = window.performance.getEntries().length
assert.equal(startLength, newLength, 'entries are cleared')
stop()
})
nanotiming('test')()
})