random-access-open

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

MIT 3 个版本
安装
npm install random-access-open
yarn add random-access-open
pnpm add random-access-open
bun add random-access-open
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

版本列表
1.1.0 2016-01-23
1.0.1 2016-01-19
1.0.0 2016-01-19