Created
December 16, 2019 18:35
-
-
Save Streeterxs/f609acd2e3a6a3b5d4bb8fdf71841726 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/// <reference lib="webworker" /> | |
addEventListener('message', ({ data }) => { | |
const response = `worker response to ${data.lista}`; | |
const objMessageReturn = { | |
value: data.lista[0], | |
halfDown: null, | |
halfUp: null | |
}; | |
if (data.lista.length > 1) { | |
data.lista.splice(0, 1); | |
const halfLength = Math.ceil(data.lista.length / 2); | |
if (data.lista.length > 1) { | |
const halfDown = data.lista.slice(0, halfLength); | |
const halfUp = data.lista.slice(halfLength, data.lista.length); | |
objMessageReturn.halfDown = halfDown; | |
objMessageReturn.halfUp = halfUp; | |
} else { | |
data.halfDown = data.lista; | |
} | |
} | |
postMessage(objMessageReturn); | |
}); | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment