deathcap / nodeachrome

run Node.js scripts in Google Chrome (experimental)
MIT License
2 stars 0 forks source link

Implement fs.read(fd, buffer, offset, length, position, callback) #2

Closed deathcap closed 8 years ago

deathcap commented 8 years ago

Implement the file-descriptor-based read() fs API: https://nodejs.org/api/fs.html#fs_fs_read_fd_buffer_offset_length_position_callback

Currently not implemented, so g.browserify('h.js').bundle().pipe(g.process.stdout) fails:

`` 3extensions::platformApp:17 window.localStorage is not available in packaged apps. Use chrome.storage.local instead.(anonymous function) @ extensions::platformApp:17 fs-static.js:79 readFileSync /node_modules/browser-pack/_prelude.js utf8 prelude2.js:39 require.resolve process/browser.js prelude2.js:39 require.resolve is-buffer prelude2.js:39 require.resolve assert/ prelude2.js:39 require.resolve buffer/ 2prelude2.js:39 require.resolve ./_empty.js prelude2.js:39 require.resolve console-browserify prelude2.js:39 require.resolve constants-browserify prelude2.js:39 require.resolve crypto-browserify 2prelude2.js:39 require.resolve ./_empty.js prelude2.js:39 require.resolve domain-browser prelude2.js:39 require.resolve events/ prelude2.js:39 require.resolve ./_empty.js prelude2.js:39 require.resolve stream-http prelude2.js:39 require.resolve https-browserify 2prelude2.js:39 require.resolve ./_empty.js prelude2.js:39 require.resolve os-browserify/browser.js bundle.js:39 require.resolve path-browserify bundle.js:39 require.resolve punycode/ bundle.js:39 require.resolve querystring-es3/ 2bundle.js:39 require.resolve ./_empty.js bundle.js:39 require.resolve stream-browserify bundle.js:39 require.resolve readable-stream/duplex.js bundle.js:39 require.resolve readable-stream/passthrough.js bundle.js:39 require.resolve readable-stream/readable.js bundle.js:39 require.resolve readable-stream/transform.js bundle.js:39 require.resolve readable-stream/writable.js bundle.js:39 require.resolve string_decoder/ bundle.js:39 require.resolve util/util.js bundle.js:39 require.resolve timers-browserify bundle.js:39 require.resolve ./_empty.js bundle.js:39 require.resolve tty-browserify bundle.js:39 require.resolve url/ bundle.js:39 require.resolve util/util.js bundle.js:39 require.resolve vm-browserify bundle.js:39 require.resolve browserify-zlib bundle.js:39 require.resolve process/browser 2extensions::platformApp:17 window.localStorage is not available in packaged apps. Use chrome.storage.local instead.(anonymous function) @ extensions::platformApp:17 bundle.js:132 readFileSync /node_modules/npm/package.json undefined g.browserify('h.js').bundle().pipe(g.process.stdout) BrowserStdout {_writableState: WritableState, writable: true, _events: Object, _maxListeners: undefined, label: "stdout"} send-native.js:44 sendNative fs.readFile ["/package.json", null] send-native.js:10 decodeResponse Object {result: Object, id: 1} send-native.js:44 sendNative fs.readFile ["/package.json", "utf8"] send-native.js:10 decodeResponse Object {result: "{↵ "name": "test",↵ "version": "1.0.0",↵ "descr…",↵ "license": "ISC",↵ "dependencies": {↵ }↵}↵", id: 2} send-native.js:44 sendNative fs.stat ["/h.js"] send-native.js:10 decodeResponse Object {result: Object, id: 3} send-native.js:44 sendNative fs.realpath ["/h.js"] send-native.js:10 decodeResponse Object {result: "/h.js", id: 4} send-native.js:44 sendNative fs.open ["/h.js", "r", 438] send-native.js:10 decodeResponse Object {result: 14, id: 5} extensions::uncaught_exception_handler:8 Error in event handler for (unknown): TypeError: Cannot read property 'call' of undefined at Object.read (chrome-extension://ldcjdgpgjjhmjomfiekbmeogiamokiec/bundle.js:113838:19) at ReadStream._read (chrome-extension://ldcjdgpgjjhmjomfiekbmeogiamokiec/bundle.js:316:6) at ReadStream. (chrome-extension://ldcjdgpgjjhmjomfiekbmeogiamokiec/bundle.js:287:12) at ReadStream.g (chrome-extension://ldcjdgpgjjhmjomfiekbmeogiamokiec/bundle.js:24990:16) at ReadStream.EventEmitter.emit (chrome-extension://ldcjdgpgjjhmjomfiekbmeogiamokiec/bundle.js:24906:17) at chrome-extension://ldcjdgpgjjhmjomfiekbmeogiamokiec/bundle.js:113538:14 at chrome-extension://ldcjdgpgjjhmjomfiekbmeogiamokiec/bundle.js:113586:16 at decodeResponse (chrome-extension://ldcjdgpgjjhmjomfiekbmeogiamokiec/bundle.js:48225:10) at callbacks.set (chrome-extension://ldcjdgpgjjhmjomfiekbmeogiamokiec/bundle.js:48264:35) at recvIncoming (chrome-extension://ldcjdgpgjjhmjomfiekbmeogiamokiec/bundle.js:48234:3)


compare to (also fd-based): fs.write()