@tipe/databox-loader
Advanced tools
Comparing version 0.3.6 to 0.3.7
{ | ||
"name": "@tipe/databox-loader", | ||
"version": "0.3.6", | ||
"version": "0.3.7", | ||
"description": "Tipe Databox Loader for talking with Databox", | ||
@@ -5,0 +5,0 @@ "main": "src/index.js", |
@@ -15,20 +15,18 @@ const fetch = require('node-fetch') | ||
function execBatch(url) { | ||
setTimeout(function() { | ||
const _queue = [] | ||
const _defers = [] | ||
exports.queue.forEach(task => { | ||
_queue.push(task.task) | ||
_defers.push(task.deferred) | ||
task.task = null | ||
task.deferred = null | ||
}) | ||
databoxFetch(url, _queue) | ||
exports.queue = [] | ||
exports._defer = defer() | ||
exports._batching = null | ||
exports._timer = null | ||
}, exports.delay) | ||
const _queue = [] | ||
const _defers = [] | ||
exports.queue.forEach(task => { | ||
_queue.push(task.task) | ||
_defers.push(task.deferred) | ||
task.task = null | ||
task.deferred = null | ||
}) | ||
execDataboxFetch(url, _queue, _defers) | ||
exports.queue = [] | ||
exports._defer = defer() | ||
exports._batching = null | ||
exports._timer = null | ||
} | ||
function databoxFetch(url, tasks, promises) { | ||
function execDataboxFetch(url, tasks, promises) { | ||
return fetch(`${url}/batch`, { | ||
@@ -52,4 +50,4 @@ method: 'POST', | ||
function databoxFetch(url, model, action, body, methods = []) { | ||
const task = { model, action, body: {query: body, methods} } | ||
function databoxFetch(url, model, action, query, methods = []) { | ||
const task = { model, action, body: {query, methods} } | ||
const deferred = defer() | ||
@@ -60,3 +58,4 @@ if (exports._batching) { | ||
exports._batching = true | ||
exports._timer = setTimeout(execBatch.bind(null, url)) | ||
exports.queue.push({task: task, deferred: deferred}) | ||
exports._timer = setTimeout(execBatch.bind(null, url), exports.delay) | ||
} | ||
@@ -63,0 +62,0 @@ return deferred.promise |
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
105073
215