daniellmb/MemSnap

View on GitHub
memSnap.min.js

Summary

Maintainability
A
3 hrs
Test Coverage
(function (window, factory) {
  'use strict';
  if (typeof define === 'function' && define.amd) {
    // AMD
    define('MemSnap', [], factory);
  } else {
    // Browser
    window.memSnap = factory();
  }
}(this, function factory() {
  // public API
  return function memSnap(e,m,o,r){var t=e.performance;if(t&&t.memory){var n,a,c=/\{lbl\}/,i=/\{lmt\}/,p=/\{tot\}/,l=/\{use\}/;o=o||{"0s":0,"5m":3e5,"10m":6e5,"15m":9e5,"30m":18e5,"1h":36e5,"3h":108e5,"6h":216e5,"12h":432e5,"24h":864e5,"48h":1728e5},n=function(o,n){e.setTimeout(function(){r&&r(o,t.memory),e.document.createElement("img").src=m.replace(c,e.encodeURIComponent(o)).replace(i,t.memory.jsHeapSizeLimit).replace(p,t.memory.totalJSHeapSize).replace(l,t.memory.usedJSHeapSize)},n)};for(a in o)o.hasOwnProperty(a)&&n(a,o[a])}};
}));