Skip to content

Commit 272bc3b

Browse files
authored
Use a multi-line JS string in library_noderawfs.js. NFC (#16122)
IMHO this makes the code actually readable.
1 parent 38e4d71 commit 272bc3b

File tree

1 file changed

+21
-6
lines changed

1 file changed

+21
-6
lines changed

src/library_noderawfs.js

Lines changed: 21 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -6,12 +6,27 @@
66

77
mergeInto(LibraryManager.library, {
88
$NODERAWFS__deps: ['$ERRNO_CODES', '$FS', '$NODEFS', '$mmapAlloc'],
9-
$NODERAWFS__postset: 'if (ENVIRONMENT_IS_NODE) {' +
10-
'var _wrapNodeError = function(func) { return function() { try { return func.apply(this, arguments) } catch (e) { if (!e.code) throw e; throw new FS.ErrnoError(ERRNO_CODES[e.code]); } } };' +
11-
'var VFS = Object.assign({}, FS);' +
12-
'for (var _key in NODERAWFS) FS[_key] = _wrapNodeError(NODERAWFS[_key]);' +
13-
'}' +
14-
'else { throw new Error("NODERAWFS is currently only supported on Node.js environment.") }',
9+
$NODERAWFS__postset: `
10+
if (ENVIRONMENT_IS_NODE) {
11+
var _wrapNodeError = function(func) {
12+
return function() {
13+
try {
14+
return func.apply(this, arguments)
15+
} catch (e) {
16+
if (e.code) {
17+
throw new FS.ErrnoError(ERRNO_CODES[e.code]);
18+
}
19+
throw e;
20+
}
21+
}
22+
};
23+
var VFS = Object.assign({}, FS);
24+
for (var _key in NODERAWFS) {
25+
FS[_key] = _wrapNodeError(NODERAWFS[_key]);
26+
}
27+
} else {
28+
throw new Error("NODERAWFS is currently only supported on Node.js environment.")
29+
}`,
1530
$NODERAWFS: {
1631
lookup: function(parent, name) {
1732
return FS.lookupPath(parent.path + '/' + name).node;

0 commit comments

Comments
 (0)