UNPKG

@helpscout/stats

Version:

Easy performance monitoring for JavaScript / React

40 lines (39 loc) 1.28 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.defaultOptions = { top: 0, left: 'initial', right: 0, bottom: 'initial', opacity: 0.5, position: 'fixed', zIndex: 99999999, }; exports.toPx = function (value) { return (typeof value === 'number' ? value + "px" : value); }; function getTotalNodeCountFromDocument(doc) { if (doc === void 0) { doc = window.document; } if (!doc) return 0; return doc.getElementsByTagName('*').length; } exports.getTotalNodeCountFromDocument = getTotalNodeCountFromDocument; function getTotalNodeCountFromFrames() { var i = 0; var total = 0; var frameNodes = window.document.getElementsByTagName('iframe'); var frames = Array.from(frameNodes); while (i < frames.length) { if (frames[i].contentDocument) { total = total + getTotalNodeCountFromDocument(frames[i].contentDocument); } i++; } return total; } exports.getTotalNodeCountFromFrames = getTotalNodeCountFromFrames; function getTotalNodeCount() { var rootCount = getTotalNodeCountFromDocument(window.document); var frameCount = getTotalNodeCountFromFrames(); return rootCount + frameCount; } exports.getTotalNodeCount = getTotalNodeCount;