1.0.2 • Published 7 months ago

fs-open-sync v1.0.2

Weekly downloads
-
License
MIT
Repository
github
Last release
7 months ago

fs-open-sync

Version npm Build Status Coverage Status

Like fs.openSync() but does not interfere with the provided pathname. Useful to open special files like CONOUT$, \\.\nul, etc.

Install

npm install --save fs-open-sync

API

This module exports a single function that works like fs.openSync().

open(path[, flags[, mode]])

Arguments

  • path {Buffer|string} The file pathname.
  • flags {number|string} The access mode. Defaults to 'r'.
  • mode {number|string} The file mode bits to be applied when a new file is created. Defaults to 0o666.

Return value

An integer representing the file descriptor.

Exceptions

Throws a RangeError or TypeError if an argument in not valid or an Error if the file cannot be opened.

Example

import open from 'fs-open-sync'; // Also available as a named export.
import { fileURLToPath } from 'node:url';
import { ok } from 'node:assert';

const __filename = fileURLToPath(import.meta.url);
const fd = open(__filename);

ok(fd > 0);

License

MIT

1.0.2

7 months ago

1.0.1

12 months ago

1.0.0

12 months ago