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

pure-canvas

Package Overview
Dependencies
Maintainers
1
Versions
62
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

pure-canvas - npm Package Compare versions

Comparing version 0.5.2 to 0.5.3

27

lib/Stage.js

@@ -76,2 +76,29 @@ "use strict";

};
Stage.prototype.renderAsynchronous = function (index, maxBatchTime) {
var _this = this;
if (index === void 0) { index = true; }
if (maxBatchTime === void 0) { maxBatchTime = 10; }
var _a = this.renderDeferred(), steps = _a.steps, commit = _a.commit;
if (this.nonBlockingTimeoutId) {
window.clearTimeout(this.nonBlockingTimeoutId);
}
var i = 0;
var repeat = function () {
_this.nonBlockingTimeoutId = window.setTimeout(batch, 0);
};
var batch = function () {
var deadline = Date.now() + maxBatchTime;
while (i < steps.length && Date.now() < deadline) {
steps[i++]();
}
commit(false);
if (i < steps.length) {
repeat();
}
else {
commit(index);
}
};
repeat();
};
Stage.prototype.renderDeferred = function () {

@@ -78,0 +105,0 @@ var _this = this;

2

package.json
{
"name": "pure-canvas",
"version": "0.5.2",
"version": "0.5.3",
"description": "TODO",

@@ -5,0 +5,0 @@ "main": "lib/index.js",

@@ -17,2 +17,4 @@ import {EventEmitter} from 'eventemitter3';

private nonBlockingTimeoutId?: number;
constructor(canvas: HTMLCanvasElement) {

@@ -75,2 +77,3 @@ super();

const {steps, commit} = this.renderDeferred();
for (const step of steps) {

@@ -80,2 +83,3 @@ step();

commit(index);
// this.context.clearRect(0, 0, this.canvas.width, this.canvas.height);

@@ -86,2 +90,28 @@ // this.internalLayer.draw(this.context);

renderAsynchronous(index: boolean = true, maxBatchTime: number = 10): void {
const {steps, commit} = this.renderDeferred();
if (this.nonBlockingTimeoutId) {
window.clearTimeout(this.nonBlockingTimeoutId);
}
let i = 0;
const repeat = () => {
this.nonBlockingTimeoutId = window.setTimeout(batch, 0);
};
const batch = () => {
const deadline = Date.now() + maxBatchTime;
while (i < steps.length && Date.now() < deadline) {
steps[i++]();
}
commit(false);
if (i < steps.length) {
repeat();
} else {
commit(index);
}
};
repeat();
}
renderDeferred(): {steps: Array<() => void>, commit: (index: boolean) => void} {

@@ -88,0 +118,0 @@ const stepAccumulator: Array<() => void> = [];

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

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