Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@fastly/performance-observer-polyfill

Package Overview
Dependencies
Maintainers
50
Versions
12
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@fastly/performance-observer-polyfill - npm Package Compare versions

Comparing version 2.0.0-pre-1.1 to 2.0.0-pre-1.2

4

dist/esm/index.js
/**
* Performance Observer Polyfill
* Version: 2.0.0-pre-1.1
* Version: 2.0.0-pre-1.2
* Generated: 2021-02-15

@@ -28,2 +28,2 @@ * https://github.com/fastly/performance-observer-polyfill

class e extends Array{constructor(e){super(...e),this._entries=e}getEntries(){return this._entries}getEntriesByType(e){return this._entries.filter((r=>r.entryType===e))}getEntriesByName(e,r){return this._entries.filter((r=>r.name===e)).filter((e=>!r||e.entryType===r))}}const r=["mark","measure","navigation","resource"],t={"no-entry-types":"Failed to execute 'observe' on 'PerformanceObserver': either an 'entryTypes' or 'type' member must be present.","both-entry-types":"Failed to execute 'observe' on 'PerformanceObserver': either an 'entryTypes' or 'type' member must be present, not both."},s={"no-valid-entry-types":"Aborting 'observe' on 'PerformanceObserver': no valid entry types present in either 'entryTypes' or 'type' member.","entry-types-removed":"Invalid or unsupported entry types provided to 'observe' on 'PerformanceObserver'."},n=e=>r.some((r=>e===r)),i=new class{constructor({registeredObservers:e=new Set,processedEntries:r=new Set,interval:t=100,context:s=self}={}){this.registeredObservers=e,this.processedEntries=r,this.interval=t,this.context=s,this.intervalId=null}getNewEntries(){return this.context.performance.getEntries().filter((e=>!this.processedEntries.has(e)))}getObserversForType(e,r){return Array.from(e).filter((e=>e.entryTypes.some((e=>e===r))))}processBuffer(r){const t=Array.from(r.buffer),s=new e(t);r.buffer.clear(),t.length&&r.callback&&r.callback.call(void 0,s,r)}processEntries(){this.getNewEntries().forEach((e=>{const{entryType:r}=e;this.getObserversForType(this.registeredObservers,r).forEach((r=>{r.buffer.add(e)})),this.processedEntries.add(e)}));const e=()=>this.registeredObservers.forEach(this.processBuffer);"requestAnimationFrame"in this.context?this.context.requestAnimationFrame(e):this.context.setTimeout(e,0)}add(e){this.registeredObservers.add(e),1===this.registeredObservers.size&&this.observe()}remove(e){this.registeredObservers.delete(e),this.registeredObservers.size||this.disconnect()}observe(){this.intervalId=this.context.setInterval(this.processEntries.bind(this),this.interval)}disconnect(){this.intervalId=this.context.clearInterval(this.intervalId)}};class o{constructor(e,r=i){this.entryTypes=[],this.callback=e,this.buffer=new Set,this.taskQueue=r}observe(e){if(!e)throw new Error(t["no-entry-types"]);if(e.entryTypes&&e.type)throw new Error(t["both-entry-types"]);let r;if(e.entryTypes)r=e.entryTypes;else{if(!e.type)throw new Error(t["no-entry-types"]);r=[e.type]}const i=r.filter(n);i.length>0&&i.length!==r.length&&console.warn(s["entry-types-removed"]),i.length?(this.entryTypes=i,this.taskQueue.add(this)):console.warn(s["no-valid-entry-types"])}disconnect(){this.taskQueue.remove(this)}takeRecords(){const r=Array.from(this.buffer);return new e(r)}}o.supportedEntryTypes=r;var a="PerformanceObserver"in self&&"function"==typeof PerformanceObserver?PerformanceObserver:o;export default a;
var e=function(t,r){return(e=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,t){e.__proto__=t}||function(e,t){for(var r in t)Object.prototype.hasOwnProperty.call(t,r)&&(e[r]=t[r])})(t,r)};var t=function(t){function r(e){var r=t.apply(this,e)||this;return r._entries=e,r}return function(t,r){function n(){this.constructor=t}e(t,r),t.prototype=null===r?Object.create(r):(n.prototype=r.prototype,new n)}(r,t),r.prototype.getEntries=function(){return this._entries},r.prototype.getEntriesByType=function(e){return this._entries.filter((function(t){return t.entryType===e}))},r.prototype.getEntriesByName=function(e,t){return this._entries.filter((function(t){return t.name===e})).filter((function(e){return!t||e.entryType===t}))},r}(Array),r=function(){function e(e){var t=void 0===e?{}:e,r=t.registeredObservers,n=void 0===r?new Set:r,o=t.processedEntries,s=void 0===o?new Set:o,i=t.interval,c=void 0===i?100:i,u=t.context,p=void 0===u?self:u;this.registeredObservers=n,this.processedEntries=s,this.interval=c,this.context=p,this.intervalId=null}return e.prototype.getNewEntries=function(){var e=this;return this.context.performance.getEntries().filter((function(t){return!e.processedEntries.has(t)}))},e.prototype.getObserversForType=function(e,t){return Array.from(e).filter((function(e){return e.entryTypes.some((function(e){return e===t}))}))},e.prototype.processBuffer=function(e){var r=Array.from(e.buffer),n=new t(r);e.buffer.clear(),r.length&&e.callback&&e.callback.call(void 0,n,e)},e.prototype.processEntries=function(){var e=this;this.getNewEntries().forEach((function(t){var r=t.entryType;e.getObserversForType(e.registeredObservers,r).forEach((function(e){e.buffer.add(t)})),e.processedEntries.add(t)}));var t=function(){return e.registeredObservers.forEach(e.processBuffer)};"requestAnimationFrame"in this.context?this.context.requestAnimationFrame(t):this.context.setTimeout(t,0)},e.prototype.add=function(e){this.registeredObservers.add(e),1===this.registeredObservers.size&&this.observe()},e.prototype.remove=function(e){this.registeredObservers.delete(e),this.registeredObservers.size||this.disconnect()},e.prototype.observe=function(){this.intervalId=this.context.setInterval(this.processEntries.bind(this),this.interval)},e.prototype.disconnect=function(){this.intervalId=this.context.clearInterval(this.intervalId)},e}(),n=["mark","measure","navigation","resource"],o="Failed to execute 'observe' on 'PerformanceObserver': either an 'entryTypes' or 'type' member must be present.",s="Failed to execute 'observe' on 'PerformanceObserver': either an 'entryTypes' or 'type' member must be present, not both.",i="Aborting 'observe' on 'PerformanceObserver': no valid entry types present in either 'entryTypes' or 'type' member.",c="Invalid or unsupported entry types provided to 'observe' on 'PerformanceObserver'.",u=function(e){return n.some((function(t){return e===t}))},p=new r,f=function(){function e(e,t){void 0===t&&(t=p),this.entryTypes=[],this.callback=e,this.buffer=new Set,this.taskQueue=t}return e.prototype.observe=function(e){if(!e)throw new Error(o);if(e.entryTypes&&e.type)throw new Error(s);var t;if(e.entryTypes)t=e.entryTypes;else{if(!e.type)throw new Error(o);t=[e.type]}var r=t.filter(u);r.length>0&&r.length!==t.length&&console.warn(c),r.length?(this.entryTypes=r,this.taskQueue.add(this)):console.warn(i)},e.prototype.disconnect=function(){this.taskQueue.remove(this)},e.prototype.takeRecords=function(){var e=Array.from(this.buffer);return new t(e)},e.supportedEntryTypes=n,e}(),a="PerformanceObserver"in self&&"function"==typeof PerformanceObserver?PerformanceObserver:f;export default a;
/**
* Performance Observer Polyfill
* Version: 2.0.0-pre-1.1
* Version: 2.0.0-pre-1.2
* Generated: 2021-02-15

@@ -5,0 +5,0 @@ * https://github.com/fastly/performance-observer-polyfill

{
"name": "@fastly/performance-observer-polyfill",
"version": "2.0.0-pre-1.1",
"version": "2.0.0-pre-1.2",
"main": "dist/index.js",

@@ -5,0 +5,0 @@ "module": "dist/esm/index.js",

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