Thanks to visit codestin.com
Credit goes to github.com

Skip to content
Closed
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion lib/internal/fs/utils.js
Original file line number Diff line number Diff line change
Expand Up @@ -153,7 +153,7 @@ function lazyLoadFs() {
function assertEncoding(encoding) {
if (encoding && !Buffer.isEncoding(encoding)) {
const reason = 'is invalid encoding';
throw new ERR_INVALID_ARG_VALUE(encoding, 'encoding', reason);
throw new ERR_INVALID_ARG_VALUE('encoding', encoding, reason);
}
}

Expand Down
15 changes: 15 additions & 0 deletions test/parallel/test-fs-internal-assertencoding.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
'use strict';

// Tests to verify that a correctly formatted invalid encoding error
// is thrown. Originally the internal assertEncoding utility was
// reversing the arguments when constructing the ERR_INVALID_ARG_VALUE
// error.

require('../common');
const { opendirSync } = require('node:fs');
const { throws } = require('node:assert');

throws(() => opendirSync('.', { encoding: 'no' }), {
code: 'ERR_INVALID_ARG_VALUE',
message: 'The argument \'encoding\' is invalid encoding. Received \'no\'',
});