UNPKG

react-profiler-table

Version:

React component for printing tables with Profiler API

16 lines (13 loc) 2.42 kB
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("react");function t(e){return e&&"object"==typeof e&&"default"in e?e:{default:e}}var n=t(e),r=function(){return(r=Object.assign||function(e){for(var t,n=1,r=arguments.length;n<r;n++)for(var o in t=arguments[n])Object.prototype.hasOwnProperty.call(t,o)&&(e[o]=t[o]);return e}).apply(this,arguments)},o=function(e,t){void 0===t&&(t=1e3);var n=setTimeout(e,t);return function(){clearTimeout(n)}},i={id:'the "id" prop of the Profiler tree that has just committed',phase:'either "mount" (if the tree just mounted) or "update" (if it re-rendered)',actualDuration:"time spent rendering the committed update",baseDuration:"estimated time to render the entire subtree without memoization",startTime:"when React began rendering this update",commitTime:"when React committed this update",interactions:"the Set of interactions belonging to this update"},a=Object.keys(i),u=[],c=function(e){return function(t,n,o){var i;return r(r({},t),((i={})[n]=e[o],i))}},d=function(){}; /*! ***************************************************************************** Copyright (c) Microsoft Corporation. Permission to use, copy, modify, and/or distribute this software for any purpose with or without fee is hereby granted. THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. ***************************************************************************** */exports.ProfilerTable=function(t){var r,s=t.id,l=t.callback,f=t.children;return n.default.createElement(e.Profiler,{id:s,onRender:(r=l,void 0===r&&(r=function(){console.table(i)}),function(){for(var e=[],t=0;t<arguments.length;t++)e[t]=arguments[t];return d(),d=o(r),u.push(a.reduce(c(e),{})),console.table(u),console.log("\n%cRender count: %c"+u.length+"%c\n"+"_".repeat(28)+"\n\n\n","font-size: 16px; color: #20232a;","padding: 15px; width: 80px; height: 80px; border-radius: 50%; background: #20232a; font-weight: bold; font-size: 20px; color: #61dafb;",""),u})},f)};