fs-open-sync

1.0.1 • Public • Published

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

/fs-open-sync/

    Package Sidebar

    Install

    npm i fs-open-sync

    Weekly Downloads

    0

    Version

    1.0.1

    License

    MIT

    Unpacked Size

    388 kB

    Total Files

    11

    Last publish

    Collaborators

    • lpinca