JSPM

random-access-open

1.1.0
  • ESM via JSPM
  • ES Module Entrypoint
  • Export Map
  • Keywords
  • License
  • Repository URL
  • TypeScript Types
  • README
  • Created
  • Published
  • Downloads 21
  • Score
    100M100P100Q49325F
  • License MIT

Open a file for random access read / write and create the file if it doesn't exist

Package Exports

  • random-access-open

This package does not declare an exports field, so the exports above have been automatically detected and optimized by JSPM instead. If any package subpath is missing, it is recommended to post an issue to the original package (random-access-open) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.

Readme

random-access-open

Open a file for random access read / write and create the file if it doesn't exist

npm install random-access-open

build status

Usage

var open = require('random-access-open')
var fs = require('fs')

open('hello.txt', function (err, fd) {
  fs.write(fd, new Buffer('hello'), 0, 5, 0, function () {
    fs.write(fd, new Buffer('world'), 0, 5, 0, function () {
      fs.close(fd, function () {
        // prints "world"
        console.log(fs.readFileSync('hello.txt', 'utf-8'))
      })
    })
  })
})

API

open(filename, callback)

Open a file for random access read / writes. Callback is called with (err, fd)

var fd = open.sync(filename)

Same as above but sync

License

MIT