Sha256: 08fa0fea759ac1f088d9633888f5f94c56de792297ace99c0e1242fa73f1bb3d
Contents?: true
Size: 891 Bytes
Versions: 6
Compression:
Stored size: 891 Bytes
Contents
# backtick_javascript: true require 'nodejs/file' %x{ function executeIOAction(action) { try { return action(); } catch (error) { if (error.code === 'EACCES' || error.code === 'EISDIR' || error.code === 'EMFILE' || error.code === 'ENOENT' || error.code === 'EPERM') { throw Opal.IOError.$new(error.message) } throw error; } } } `var __fs__ = require('fs')` class IO @__fs__ = `__fs__` attr_reader :lineno alias initialize_before_node_io initialize def initialize(fd, flags = 'r') @lineno = 0 initialize_before_node_io(fd, flags) end def self.write(path, data) File.write(path, data) end def self.read(path) File.read(path) end def self.binread(path) `return executeIOAction(function(){return __fs__.readFileSync(#{path}).toString('binary')})` end end
Version data entries
6 entries across 6 versions & 1 rubygems