Skip to content

Commit 824399c

Browse files
committed
[jslib] Add forgotten File.readLinesAsync() proxy.
1 parent 7e4ade9 commit 824399c

File tree

2 files changed

+18
-1
lines changed

2 files changed

+18
-1
lines changed

src/resources/scripts/io.js

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,23 @@ if (!File.readAsync) {
3232
}
3333
}
3434

35+
if (!File.readLinesAsync) {
36+
File.readLinesAsync = function(file, maxLines, fromLine, trimTrailing, cb) {
37+
if (typeof cb === 'function')
38+
return File.readLinesAsyncCb(file, maxLines, fromLine, trimTrailing, cb);
39+
if (typeof trimTrailing === 'function')
40+
return File.readLinesAsyncCb(file, maxLines, fromLine, trimTrailing);
41+
if (typeof fromLine === 'function')
42+
return File.readLinesAsyncCb(file, maxLines, fromLine);
43+
return new Promise((resolve, reject) => {
44+
File.readLinesAsyncCb(file, maxLines, fromLine, trimTrailing, (err, data) => {
45+
if (err) reject(err);
46+
else resolve(data);
47+
});
48+
});
49+
}
50+
}
51+
3552
if (!File.writeAsync) {
3653
File.writeAsync = function(file, data, mode, cb) {
3754
if (typeof cb === 'function' || typeof mode === 'function')

src/resources/scripts/jslib.min.js

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)