Created
April 30, 2020 21:07
-
-
Save Vzor-/97d95a1953ec2e0b31caec943ae4b4a8 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
function createDataChain(targetFunction, deviceInfo, data, chunkLength) { | |
var chain = Promise.resolve(); | |
for (var i = 0; i < data.length; i += chunkLength) { | |
deviceInfo.data = data.substring(i, Math.min(i + chunkLength, data.length)); | |
chain = chain.then(()=>targetFunction(deviceInfo)); | |
} | |
return chain; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment