Skip to content

Commit 9d48ab6

Browse files
authored
Merge pull request #2665 from yne/patch-1
Add File.read support to QuickJS
2 parents 5aec39c + 9ebe258 commit 9d48ab6

File tree

1 file changed

+11
-0
lines changed

1 file changed

+11
-0
lines changed

stdlib/quickjs/file.rb

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
class File
2+
def self.read(path)
3+
%x{
4+
const body = std.loadFile(path);
5+
if (body === null) {
6+
throw new Error(`Unable to read "${path}"`);
7+
}
8+
return body;
9+
}
10+
end
11+
end

0 commit comments

Comments
 (0)