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

async-test-util

Package Overview
Dependencies
Maintainers
1
Versions
25
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

async-test-util - npm Package Compare versions

Comparing version 1.7.3 to 2.0.0

.github/workflows/main.yml

45

dist/es/wait-until.js

@@ -16,26 +16,37 @@ import wait from './wait';

if (timeout !== 0) wait(timeout).then(function () {
return timedOut = true;
});
if (timeout !== 0) {
wait(timeout).then(function () {
return timedOut = true;
});
}
return new Promise(function (resolve, reject) {
var runLoop = function runLoop() {
/**
* @recursive
* @return {Promise<void>}
*/
function runLoopOnce() {
if (ok) {
resolve();
return;
}
if (timedOut) {
} else if (timedOut) {
reject(new Error('AsyncTestUtil.waitUntil(): reached timeout of ' + timeout + 'ms'));
return;
} else {
return wait(interval).then(function () {
return promisify(fun());
})
/**
* Propagate errors of the fun function
* upwards.
*/
['catch'](function (err) {
return reject(err);
}).then(function (value) {
ok = value;
return runLoopOnce();
});
}
wait(interval).then(function () {
var value = promisify(fun());
value.then(function (val) {
ok = val;
runLoop();
});
});
};
runLoop();
}
runLoopOnce();
});
}

@@ -30,26 +30,37 @@ 'use strict';

if (timeout !== 0) (0, _wait2['default'])(timeout).then(function () {
return timedOut = true;
});
if (timeout !== 0) {
(0, _wait2['default'])(timeout).then(function () {
return timedOut = true;
});
}
return new Promise(function (resolve, reject) {
var runLoop = function runLoop() {
/**
* @recursive
* @return {Promise<void>}
*/
function runLoopOnce() {
if (ok) {
resolve();
return;
}
if (timedOut) {
} else if (timedOut) {
reject(new Error('AsyncTestUtil.waitUntil(): reached timeout of ' + timeout + 'ms'));
return;
} else {
return (0, _wait2['default'])(interval).then(function () {
return (0, _promisify2['default'])(fun());
})
/**
* Propagate errors of the fun function
* upwards.
*/
['catch'](function (err) {
return reject(err);
}).then(function (value) {
ok = value;
return runLoopOnce();
});
}
(0, _wait2['default'])(interval).then(function () {
var value = (0, _promisify2['default'])(fun());
value.then(function (val) {
ok = val;
runLoop();
});
});
};
runLoop();
}
runLoopOnce();
});
}
{
"name": "async-test-util",
"version": "1.7.3",
"version": "2.0.0",
"description": "Util-functions that are be useful in async tests",

@@ -5,0 +5,0 @@ "keywords": [

@@ -117,3 +117,3 @@ # async-test-util

Async-Form of [assert.throws](https://nodejs.org/api/assert.html#assert_assert_throws_block_error_message). Asserts that the given function throws with the defined error, throws if not.
Async-Form of [assert.throws](https://nodejs.org/api/assert.html#assert_assert_throws_fn_error_message). Asserts that the given function throws with the defined error, throws if not.

@@ -120,0 +120,0 @@ ```javascript

@@ -13,25 +13,34 @@ import wait from './wait';

if (timeout !== 0)
if (timeout !== 0) {
wait(timeout).then(() => timedOut = true);
}
return new Promise((resolve, reject) => {
const runLoop = () => {
/**
* @recursive
* @return {Promise<void>}
*/
function runLoopOnce() {
if (ok) {
resolve();
return;
}
if (timedOut) {
} else if (timedOut) {
reject(new Error('AsyncTestUtil.waitUntil(): reached timeout of ' + timeout + 'ms'));
return;
} else {
return wait(interval)
.then(() => promisify(fun()))
/**
* Propagate errors of the fun function
* upwards.
*/
.catch(err => reject(err))
.then(value => {
ok = value;
return runLoopOnce();
});
}
wait(interval).then(() => {
const value = promisify(fun());
value.then(val => {
ok = val;
runLoop();
});
});
};
runLoop();
}
runLoopOnce();
});
}
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