OverviewFilesCommitsIssuesDocsReleasesPeers

holepunchto-kb / skills / fs-native-extensions / api-extract.json

80 lines · json ref:
{
  "repo": "fs-native-extensions",
  "timestamp": "2026-01-16T23:39:42.471Z",
  "entryPoint": "index.js",
  "exports": {
    "packageJson": {
      "main": "index.js"
    }
  },
  "api": {
    "file": "index.js",
    "exports": [],
    "classes": [],
    "functions": [
      {
        "name": "onwork"
      },
      {
        "name": "tryLock"
      },
      {
        "name": "waitForLock"
      },
      {
        "name": "tryDowngradeLock"
      },
      {
        "name": "downgradeLock"
      },
      {
        "name": "tryUpgradeLock"
      },
      {
        "name": "upgradeLock"
      },
      {
        "name": "unlock"
      },
      {
        "name": "trim"
      },
      {
        "name": "sparse"
      },
      {
        "name": "swap"
      },
      {
        "name": "getAttr"
      },
      {
        "name": "setAttr"
      },
      {
        "name": "removeAttr"
      },
      {
        "name": "listAttrs"
      }
    ]
  },
  "readme": {
    "content": "# fs-native-extensions\n\nNative file system extensions for advanced file operations\n\n```\nnpm install fs-native-extensions\n```\n\n## Usage\n\nWrite to a file using an exclusive lock:\n\n```js\nconst { open } = require('fs/promises')\nconst { waitForLock, unlock } = require('fs-native-extensions')\n\nconst file = await open('file.txt', 'a+')\n\nawait waitForLock(file.fd)\n\ntry {\n  await file.write('hello world')\n} finally {\n  unlock(file.fd)\n}\n```\n\n## API\n\n#### `const granted = tryLock(fd[, offset[, length]][, options])`\n\nRequest a lock on a file, returning `true` if the lock was granted or `false` if another file descriptor currently holds the lock.\n\nTo lock only a portion of the file, `offset` and `length` may be passed. A `length` of `0` will request a lock from `offset` to the end of the file.\n\nOn macOS, BSD locks are used and so only locks on the whole file are supported.\n\nNote that the lock is only advisory and there is nothing stopping another process from accessing the file by simply ignoring ",
    "sections": [
      "intro",
      "usage",
      "api",
      "license"
    ],
    "hasApi": true,
    "hasExamples": true,
    "exampleCount": 3,
    "examples": [
      "npm install fs-native-extensions",
      "const { open } = require('fs/promises')\nconst { waitForLock, unlock } = require('fs-native-extensions')\n\nconst file = await open('file.txt', 'a+')\n\nawait waitForLock(file.fd)\n\ntry {\n  await file.write('hello world')\n} finally {\n  unlock(file.fd)\n}",
      "{\n  // If `true`, request a shared lock, i.e. a read lock, on the file. By\n  // default, an exclusive lock, i.e. a write lock, is requested.\n  // Be aware that an exclusive lock can only be granted to files that are\n  // writable!\n  shared: false\n}"
    ]
  },
  "patterns": []
}