aurelia-task-queue
Advanced tools
Comparing version 1.3.0 to 1.3.1
{ | ||
"name": "aurelia-task-queue", | ||
"version": "1.3.0", | ||
"version": "1.3.1", | ||
"description": "A simple task queue for the browser that enables the queuing of both standard tasks and micro tasks.", | ||
@@ -5,0 +5,0 @@ "keywords": [ |
@@ -21,9 +21,11 @@ define(['exports', 'aurelia-pal'], function (exports, _aureliaPal) { | ||
function makeRequestFlushFromMutationObserver(flush) { | ||
var toggle = 1; | ||
var observer = _aureliaPal.DOM.createMutationObserver(flush); | ||
var node = _aureliaPal.DOM.createTextNode(''); | ||
var val = 'a'; | ||
var node = _aureliaPal.DOM.createTextNode('a'); | ||
var values = Object.create(null); | ||
values.a = 'b'; | ||
values.b = 'a'; | ||
observer.observe(node, { characterData: true }); | ||
return function requestFlush() { | ||
toggle = -toggle; | ||
node.data = toggle; | ||
node.data = val = values[val]; | ||
}; | ||
@@ -30,0 +32,0 @@ } |
@@ -7,9 +7,11 @@ import {DOM,FEATURE} from 'aurelia-pal'; | ||
function makeRequestFlushFromMutationObserver(flush) { | ||
let toggle = 1; | ||
let observer = DOM.createMutationObserver(flush); | ||
let node = DOM.createTextNode(''); | ||
let val = 'a'; | ||
let node = DOM.createTextNode('a'); | ||
let values = Object.create(null); | ||
values.a = 'b'; | ||
values.b = 'a'; | ||
observer.observe(node, {characterData: true}); | ||
return function requestFlush() { | ||
toggle = -toggle; | ||
node.data = toggle; | ||
node.data = val = values[val]; | ||
}; | ||
@@ -16,0 +18,0 @@ } |
@@ -18,9 +18,11 @@ 'use strict'; | ||
function makeRequestFlushFromMutationObserver(flush) { | ||
var toggle = 1; | ||
var observer = _aureliaPal.DOM.createMutationObserver(flush); | ||
var node = _aureliaPal.DOM.createTextNode(''); | ||
var val = 'a'; | ||
var node = _aureliaPal.DOM.createTextNode('a'); | ||
var values = Object.create(null); | ||
values.a = 'b'; | ||
values.b = 'a'; | ||
observer.observe(node, { characterData: true }); | ||
return function requestFlush() { | ||
toggle = -toggle; | ||
node.data = toggle; | ||
node.data = val = values[val]; | ||
}; | ||
@@ -27,0 +29,0 @@ } |
@@ -7,9 +7,11 @@ import { DOM, FEATURE } from 'aurelia-pal'; | ||
function makeRequestFlushFromMutationObserver(flush) { | ||
let toggle = 1; | ||
let observer = DOM.createMutationObserver(flush); | ||
let node = DOM.createTextNode(''); | ||
let val = 'a'; | ||
let node = DOM.createTextNode('a'); | ||
let values = Object.create(null); | ||
values.a = 'b'; | ||
values.b = 'a'; | ||
observer.observe(node, { characterData: true }); | ||
return function requestFlush() { | ||
toggle = -toggle; | ||
node.data = toggle; | ||
node.data = val = values[val]; | ||
}; | ||
@@ -16,0 +18,0 @@ } |
@@ -11,9 +11,11 @@ var _typeof = typeof Symbol === "function" && typeof Symbol.iterator === "symbol" ? function (obj) { return typeof obj; } : function (obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; | ||
function makeRequestFlushFromMutationObserver(flush) { | ||
var toggle = 1; | ||
var observer = DOM.createMutationObserver(flush); | ||
var node = DOM.createTextNode(''); | ||
var val = 'a'; | ||
var node = DOM.createTextNode('a'); | ||
var values = Object.create(null); | ||
values.a = 'b'; | ||
values.b = 'a'; | ||
observer.observe(node, { characterData: true }); | ||
return function requestFlush() { | ||
toggle = -toggle; | ||
node.data = toggle; | ||
node.data = val = values[val]; | ||
}; | ||
@@ -20,0 +22,0 @@ } |
@@ -11,9 +11,11 @@ 'use strict'; | ||
function makeRequestFlushFromMutationObserver(flush) { | ||
var toggle = 1; | ||
var observer = DOM.createMutationObserver(flush); | ||
var node = DOM.createTextNode(''); | ||
var val = 'a'; | ||
var node = DOM.createTextNode('a'); | ||
var values = Object.create(null); | ||
values.a = 'b'; | ||
values.b = 'a'; | ||
observer.observe(node, { characterData: true }); | ||
return function requestFlush() { | ||
toggle = -toggle; | ||
node.data = toggle; | ||
node.data = val = values[val]; | ||
}; | ||
@@ -20,0 +22,0 @@ } |
@@ -0,1 +1,8 @@ | ||
<a name="1.3.1"></a> | ||
## [1.3.1](https://github.com/aurelia/task-queue/compare/1.3.0...1.3.1) (2018-06-18) | ||
### Performance Improvements | ||
* Improved internal micro task queue flush initiation. | ||
<a name="1.3.0"></a> | ||
@@ -2,0 +9,0 @@ # [1.3.0](https://github.com/aurelia/task-queue/compare/1.2.1...1.3.0) (2018-05-08) |
{ | ||
"name": "aurelia-task-queue", | ||
"version": "1.3.0", | ||
"version": "1.3.1", | ||
"description": "A simple task queue for the browser that enables the queuing of both standard tasks and micro tasks.", | ||
@@ -5,0 +5,0 @@ "keywords": [ |
@@ -7,9 +7,11 @@ import {DOM, FEATURE} from 'aurelia-pal'; | ||
function makeRequestFlushFromMutationObserver(flush) { | ||
let toggle = 1; | ||
let observer = DOM.createMutationObserver(flush); | ||
let node = DOM.createTextNode(''); | ||
let val = 'a'; | ||
let node = DOM.createTextNode('a'); | ||
let values = Object.create(null); | ||
values.a = 'b'; | ||
values.b = 'a'; | ||
observer.observe(node, {characterData: true}); | ||
return function requestFlush() { | ||
toggle = -toggle; | ||
node.data = toggle; | ||
node.data = val = values[val]; | ||
}; | ||
@@ -16,0 +18,0 @@ } |
import {TaskQueue} from '../src/index'; | ||
import {initialize} from 'aurelia-pal-browser'; | ||
describe('task queue', () => { | ||
describe('TaskQueue', () => { | ||
let sut; | ||
beforeAll(() => initialize()); | ||
it("does not provide immediate execution", () => { | ||
beforeEach(() => { | ||
sut = new TaskQueue(); | ||
}); | ||
it('queueTask does not provide immediate execution', () => { | ||
let count = 0; | ||
let task = () => count += 1; | ||
let task = () => (count += 1); | ||
let queue = new TaskQueue(); | ||
queue.queueTask(task); | ||
queue.queueTask(task); | ||
sut.queueTask(task); | ||
sut.queueTask(task); | ||
expect(count).toBe(0); | ||
}); | ||
it('flushTaskQueue provides immediate execution', () => { | ||
let count = 0; | ||
let task = () => (count += 1); | ||
sut.queueTask(task); | ||
sut.flushTaskQueue(); | ||
expect(count).toBe(1); | ||
}); | ||
it("will execute tasks in the correct order", done => { | ||
let queue = new TaskQueue(); | ||
it('flushTaskQueue does not affect microTaskQueue', () => { | ||
let count = 0; | ||
let task = () => (count += 1); | ||
sut.queueMicroTask(task); | ||
sut.queueMicroTask(task); | ||
sut.flushTaskQueue(); | ||
expect(count).toBe(0); | ||
}); | ||
it('queueMicroTask does not provide immediate execution', () => { | ||
let count = 0; | ||
let task = () => (count += 1); | ||
sut.queueMicroTask(task); | ||
sut.queueMicroTask(task); | ||
expect(count).toBe(0); | ||
}); | ||
it('flushMicroTaskQueue provides immediate execution', () => { | ||
let count = 0; | ||
let task = () => (count += 1); | ||
sut.queueMicroTask(task); | ||
sut.flushMicroTaskQueue(); | ||
expect(count).toBe(1); | ||
}); | ||
it('flushMicroTaskQueue does not affect taskQueue', () => { | ||
let count = 0; | ||
let task = () => (count += 1); | ||
sut.queueTask(task); | ||
sut.queueTask(task); | ||
sut.flushMicroTaskQueue(); | ||
expect(count).toBe(0); | ||
}); | ||
it('will execute tasks in the correct order', done => { | ||
let task1HasRun = false; | ||
let task1 = () => { | ||
expect(queue.flushing).toBe(true); | ||
expect(sut.flushing).toBe(true); | ||
task1HasRun = true; | ||
}; | ||
let task2 = () => { | ||
expect(queue.flushing).toBe(true); | ||
expect(task1HasRun).toEqual(true); | ||
expect(sut.flushing).toBe(true); | ||
expect(task1HasRun).toBe(true); | ||
setTimeout(() => { | ||
expect(queue.flushing).toBe(false); | ||
expect(sut.flushing).toBe(false); | ||
done(); | ||
@@ -37,19 +90,17 @@ }); | ||
expect(queue.flushing).toBe(false); | ||
queue.queueTask(task1); | ||
queue.queueTask(task2); | ||
expect(sut.flushing).toBe(false); | ||
sut.queueTask(task1); | ||
sut.queueTask(task2); | ||
}); | ||
it("will use an onError handler on a task", done => { | ||
let queue = new TaskQueue(); | ||
let count = 0; | ||
it('will use an onError handler on a task', done => { | ||
let task = () => { | ||
expect(queue.flushing).toBe(true); | ||
throw new Error("oops"); | ||
expect(sut.flushing).toBe(true); | ||
throw new Error('oops'); | ||
}; | ||
task.onError = (ex) => { | ||
expect(ex.message).toBe("oops"); | ||
task.onError = ex => { | ||
expect(ex.message).toBe('oops'); | ||
setTimeout(() => { | ||
expect(queue.flushing).toBe(false); | ||
expect(sut.flushing).toBe(false); | ||
done(); | ||
@@ -59,5 +110,5 @@ }); | ||
expect(queue.flushing).toBe(false); | ||
queue.queueTask(task); | ||
expect(sut.flushing).toBe(false); | ||
sut.queueTask(task); | ||
}); | ||
}); |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
143995
2266