Sign Up for Free

RunKit +

Try any Node.js package right in your browser

This is a playground to test code. It runs a full Node.js environment and already has all of npm’s 400,000 packages pre-installed, including open-file with all npm packages installed. Try it out:

var openFile = require("open-file")

This service is provided by RunKit and is not affiliated with npm, Inc or the package authors.

open-file v1.0.0

Open a file with resolving its file descriptor

open-file

NPM version Build Status Coverage Status dependencies Status devDependencies Status

A Node module to open a file with resolving its file descriptor

const openFile = require('open-file');

openFile('file.txt', 'r').then(fileDescriptor => {
  fileDescriptor; //=> 15
});

Installation

Use npm.

npm install open-file

API

openFile = require('open-file');

openFile(filePath, flags [, mode])

filePath: String (a file path to open)
flags: String or Number
mode: Integer
Return: Promise of the file descriptor (Integer)

Almost the same function as fs.open, except:

  • The first argument is restricted to String and doesn't accept Buffer by design.
  • It returns a promise instead of calling a callback function.

License

Copyright (c) 2016 - 2017 Shinnosuke Watanabe

Licensed under the MIT License.

Metadata

RunKit is a free, in-browser JavaScript dev environment for prototyping Node.js code, with every npm package installed. Sign up to share your code.
Sign Up for Free