Skip to content

Commit

Permalink
Update dependencies, fix security alert
Browse files Browse the repository at this point in the history
- Fix eslint/prettier hints
- Fix async Iterator tests according to [email protected] changes

Fixes: #441
PR-URL: #440
  • Loading branch information
tshemsedinov committed Dec 7, 2019
1 parent e87f424 commit 0274e8f
Show file tree
Hide file tree
Showing 7 changed files with 1,327 additions and 1,044 deletions.
2,261 changes: 1,256 additions & 1,005 deletions package-lock.json

Large diffs are not rendered by default.

20 changes: 10 additions & 10 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -51,19 +51,19 @@
"node": ">=8.0.0"
},
"dependencies": {
"@metarhia/common": "^1.4.2"
"@metarhia/common": "^2.1.0"
},
"devDependencies": {
"@babel/cli": "^7.4.3",
"@babel/core": "^7.4.3",
"@babel/preset-env": "^7.4.3",
"@metarhia/doc": "^0.5.3",
"eslint": "^5.16.0",
"@babel/cli": "^7.7.4",
"@babel/core": "^7.7.4",
"@babel/preset-env": "^7.7.4",
"@metarhia/doc": "^0.5.6",
"eslint": "^6.7.2",
"eslint-config-metarhia": "^7.0.0",
"eslint-config-prettier": "^4.1.0",
"eslint-plugin-import": "^2.16.0",
"eslint-config-prettier": "^4.3.0",
"eslint-plugin-import": "^2.18.2",
"eslint-plugin-prettier": "^3.0.1",
"metatests": "^0.6.4",
"prettier": "^1.16.4"
"metatests": "^0.7.1",
"prettier": "^1.19.1"
}
}
8 changes: 7 additions & 1 deletion test/array.every.js
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,13 @@ metatests.test('every with empty array', test =>
);

metatests.test('every with one-element arrays', test =>
fewStrictSameResult([[[false], false], [[true], true]], test)
fewStrictSameResult(
[
[[false], false],
[[true], true],
],
test
)
);

metatests.test('every with two-element arrays', test =>
Expand Down
32 changes: 14 additions & 18 deletions test/fixtures/iterator.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

const path = require('path');
const { fork } = require('child_process');
const { once } = require('events');

const metatests = require('metatests');
const { AsyncIterator, asyncIter } = require('../../');
Expand Down Expand Up @@ -139,18 +140,12 @@ metatests.test(
'AsyncIterator.reduce with no initialValue on consumed iterator',
async test => {
const iterator = asyncIter(array);
iterator
.reduce(() => {})
.then(() => iterator.reduce((acc, current) => acc + current))
.catch(error => {
test.isError(
error,
new TypeError(
'Reduce of consumed async iterator with no initial value'
)
);
test.end();
});
await test.rejects(
iterator
.reduce(() => {})
.then(() => iterator.reduce((acc, current) => acc + current)),
new TypeError('Reduce of consumed async iterator with no initial value')
);
}
);

Expand Down Expand Up @@ -278,7 +273,10 @@ metatests.test('AsyncIterator.zip', async test => {
const iterator = asyncIter(array).take(2);

const zipIter = it.zip(itr, iterator);
test.strictSame(await zipIter.toArray(), [[1, 1, 1], [2, 2, 2]]);
test.strictSame(await zipIter.toArray(), [
[1, 1, 1],
[2, 2, 2],
]);
test.end();
});

Expand Down Expand Up @@ -459,11 +457,9 @@ metatests.test('AsyncIterator.throttle', async test => {
const pathThrottleFile = path.join(__dirname, './throttle.js');
const child = fork(pathThrottleFile);

child.on('message', ({ sum, actualDeviation, ARRAY_SIZE }) => {
test.strictSame(sum, ARRAY_SIZE);
test.assert(actualDeviation <= EXPECTED_DEVIATION);
test.end();
});
const [{ sum, actualDeviation, ARRAY_SIZE }] = await once(child, 'message');
test.strictSame(sum, ARRAY_SIZE);
test.assert(actualDeviation <= EXPECTED_DEVIATION);
});

metatests.testSync('AsyncIterator.enumerate must return tuples', async test => {
Expand Down
15 changes: 12 additions & 3 deletions test/fp.ap.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,23 +10,32 @@ const asyncError = new Error('Async error');
const asyncErrorCb = callback => process.nextTick(() => callback(asyncError));

metatests.test('two successful functions', test => {
metasync.ap(asyncArgs, functionInCallback)((err, res) => {
metasync.ap(
asyncArgs,
functionInCallback
)((err, res) => {
test.error(err);
test.strictSame(res, 9);
test.end();
});
});

metatests.test('first function with error', test => {
metasync.ap(asyncErrorCb, functionInCallback)((err, res) => {
metasync.ap(
asyncErrorCb,
functionInCallback
)((err, res) => {
test.strictSame(err, asyncError);
test.strictSame(res, undefined);
test.end();
});
});

metatests.test('second function with error', test => {
metasync.ap(asyncArgs, asyncErrorCb)((err, res) => {
metasync.ap(
asyncArgs,
asyncErrorCb
)((err, res) => {
test.strictSame(err, asyncError);
test.strictSame(res, undefined);
test.end();
Expand Down
15 changes: 12 additions & 3 deletions test/fp.concat.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,23 +14,32 @@ const asyncTransformErrorCb = (str, callback) =>
process.nextTick(() => callback(asyncError));

metatests.test('two successful functions', test => {
metasync.concat(asyncDataCb, asyncTwice)((err, res) => {
metasync.concat(
asyncDataCb,
asyncTwice
)((err, res) => {
test.error(err);
test.strictSame(res, 'datadata');
test.end();
});
});

metatests.test('first function error', test => {
metasync.concat(asyncErrorCb, asyncTwice)((err, res) => {
metasync.concat(
asyncErrorCb,
asyncTwice
)((err, res) => {
test.strictSame(err, asyncError);
test.strictSame(res, undefined);
test.end();
});
});

metatests.test('second function error', test => {
metasync.concat(asyncDataCb, asyncTransformErrorCb)((err, res) => {
metasync.concat(
asyncDataCb,
asyncTransformErrorCb
)((err, res) => {
test.strictSame(err, asyncError);
test.strictSame(res, undefined);
test.end();
Expand Down
20 changes: 16 additions & 4 deletions test/fp.fmap.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,15 +20,21 @@ const twiceAndColon = str => appendColon(repeatStringTwice(str));

metatests.test('Result transformation', test => {
const expected = 'data:';
metasync.fmap(asyncDataCb, appendColon)((err, res) => {
metasync.fmap(
asyncDataCb,
appendColon
)((err, res) => {
test.error(err);
test.strictSame(expected, res);
test.end();
});
});

metatests.test('Getting asynchronous error', test => {
metasync.fmap(asyncErrorCb, appendColon)((err, res) => {
metasync.fmap(
asyncErrorCb,
appendColon
)((err, res) => {
test.strictSame(err, asyncError);
test.strictSame(res, undefined);
test.end();
Expand All @@ -48,7 +54,10 @@ metatests.test(FP1, test => {
});

metatests.test('functor law I', test => {
metasync.fmap(asyncDataCb, identity)((err, res) => {
metasync.fmap(
asyncDataCb,
identity
)((err, res) => {
test.error(err);
test.strictSame(asyncData, res);
test.end();
Expand All @@ -61,7 +70,10 @@ metatests.test('functor law II', test => {
const asyncTwiceAndColon = fmap(asyncTwice, appendColon);

asyncTwiceAndColon((err1, res1) => {
fmap(asyncDataCb, twiceAndColon)((err2, res2) => {
fmap(
asyncDataCb,
twiceAndColon
)((err2, res2) => {
test.error(err1);
test.error(err2);
test.strictSame(res1, res2);
Expand Down

0 comments on commit 0274e8f

Please sign in to comment.