{"_id":"fs-native-extensions","_rev":"237703","name":"fs-native-extensions","description":"Native file system extensions for advanced file operations","dist-tags":{"latest":"1.2.0"},"maintainers":[{"name":"kasperisager","email":""},{"name":"mafintosh","email":""}],"time":{"modified":"2023-03-24T16:40:50.000Z","created":"2022-06-27T08:18:26.622Z","1.2.0":"2022-12-28T13:39:07.581Z","1.1.0":"2022-08-01T16:26:07.207Z","1.0.1":"2022-07-12T23:54:27.736Z","1.0.0":"2022-06-27T08:18:26.622Z"},"users":{},"author":{"name":"Kasper Isager Dalsgarð","email":"kasper@funktionel.co"},"repository":{"type":"git","url":"git+https://github.com/holepunchto/fs-native-extensions.git"},"versions":{"1.2.0":{"name":"fs-native-extensions","version":"1.2.0","description":"Native file system extensions for advanced file operations","main":"index.js","scripts":{"test":"standard && brittle test/*.mjs","prebuild":"prebuildify --napi","install":"node-gyp-build"},"repository":{"type":"git","url":"git+https://github.com/holepunchto/fs-native-extensions.git"},"author":{"name":"Kasper Isager Dalsgarð","email":"kasper@funktionel.co"},"license":"ISC","bugs":{"url":"https://github.com/holepunchto/fs-native-extensions/issues"},"homepage":"https://github.com/holepunchto/fs-native-extensions#readme","dependencies":{"napi-macros":"^2.0.0","node-gyp-build":"^4.2.3","uv-errors":"^1.0.1"},"devDependencies":{"brittle":"^3.1.1","minimist":"^1.2.6","prebuildify":"^5.0.1","standard":"^17.0.0","tempy":"^3.0.0"},"gitHead":"85943e6ec1688ce12e54c6c7058ead478227094c","_id":"fs-native-extensions@1.2.0","_nodeVersion":"16.17.0","_npmVersion":"8.15.0","dist":{"shasum":"1d623a0e692e9255b78c0f69b93bc146131b8cf9","size":91681,"noattachment":false,"key":"/fs-native-extensions/-/fs-native-extensions-1.2.0.tgz","tarball":"http://name.csiicloud.com:7001/fs-native-extensions/download/fs-native-extensions-1.2.0.tgz"},"_npmUser":{"name":"mafintosh","email":"mathiasbuus@gmail.com"},"directories":{},"maintainers":[{"name":"kasperisager","email":""},{"name":"mafintosh","email":""}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/fs-native-extensions_1.2.0_1672234747398_0.37630313115614134"},"_hasShrinkwrap":false,"_cnpmcore_publish_time":"2022-12-28T13:39:11.730Z","hasInstallScript":true,"publish_time":1672234747581,"_cnpm_publish_time":1672234747581},"1.1.0":{"name":"fs-native-extensions","version":"1.1.0","description":"Native file system extensions for advanced file operations","main":"index.js","scripts":{"test":"standard && brittle test/*.mjs","prebuild":"prebuildify --napi","install":"node-gyp-build"},"repository":{"type":"git","url":"git+https://github.com/holepunchto/fs-native-extensions.git"},"author":{"name":"Kasper Isager Dalsgarð","email":"kasper@funktionel.co"},"license":"ISC","bugs":{"url":"https://github.com/holepunchto/fs-native-extensions/issues"},"homepage":"https://github.com/holepunchto/fs-native-extensions#readme","dependencies":{"napi-macros":"^2.0.0","node-gyp-build":"^4.2.3"},"devDependencies":{"brittle":"^2.3.1","minimist":"^1.2.6","prebuildify":"^4.1.2","standard":"^17.0.0","tempy":"^3.0.0"},"gitHead":"ff3c817c428c05b777888c3fc63e2b39e36893ba","_id":"fs-native-extensions@1.1.0","_nodeVersion":"16.15.0","_npmVersion":"8.5.5","dist":{"shasum":"b95ddae49ceb545b84761b9b7d379e88f93adf88","size":91798,"noattachment":false,"key":"/fs-native-extensions/-/fs-native-extensions-1.1.0.tgz","tarball":"http://name.csiicloud.com:7001/fs-native-extensions/download/fs-native-extensions-1.1.0.tgz"},"_npmUser":{"name":"mafintosh","email":"mathiasbuus@gmail.com"},"directories":{},"maintainers":[{"name":"kasperisager","email":""},{"name":"mafintosh","email":""}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/fs-native-extensions_1.1.0_1659371167081_0.7613285450847764"},"_hasShrinkwrap":false,"_cnpmcore_publish_time":"2022-08-01T17:23:29.055Z","hasInstallScript":true,"publish_time":1659371167207,"_cnpm_publish_time":1659371167207},"1.0.1":{"name":"fs-native-extensions","version":"1.0.1","description":"Native file system extensions for advanced file operations","main":"index.js","scripts":{"test":"standard && brittle test/*.mjs","prebuild":"prebuildify --napi","install":"node-gyp-build"},"repository":{"type":"git","url":"git+https://github.com/hypercore-skunkworks/fs-native-extensions.git"},"author":{"name":"Kasper Isager Dalsgarð","email":"kasper@funktionel.co"},"license":"ISC","bugs":{"url":"https://github.com/hypercore-skunkworks/fs-native-extensions/issues"},"homepage":"https://github.com/hypercore-skunkworks/fs-native-extensions#readme","dependencies":{"napi-macros":"^2.0.0","node-gyp-build":"^4.2.3"},"devDependencies":{"brittle":"^2.3.1","minimist":"^1.2.6","prebuildify":"^4.1.2","standard":"^17.0.0","tempy":"^3.0.0"},"gitHead":"dc4c4e0b8cc140e5f9a29ebaa24394aebea55b17","_id":"fs-native-extensions@1.0.1","_nodeVersion":"16.15.0","_npmVersion":"8.5.5","dist":{"shasum":"793f55c01012f6f928e09492c2b708bfab0fa6a0","size":91212,"noattachment":false,"key":"/fs-native-extensions/-/fs-native-extensions-1.0.1.tgz","tarball":"http://name.csiicloud.com:7001/fs-native-extensions/download/fs-native-extensions-1.0.1.tgz"},"_npmUser":{"name":"mafintosh","email":"mathiasbuus@gmail.com"},"directories":{},"maintainers":[{"name":"kasperisager","email":""},{"name":"mafintosh","email":""}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/fs-native-extensions_1.0.1_1657670067253_0.31384203514862463"},"_hasShrinkwrap":false,"_cnpmcore_publish_time":"2022-07-12T23:54:31.435Z","hasInstallScript":true,"publish_time":1657670067736,"_cnpm_publish_time":1657670067736},"1.0.0":{"name":"fs-native-extensions","version":"1.0.0","description":"Native file system extensions for advanced file operations","main":"index.js","scripts":{"test":"standard && brittle test/*.mjs","prebuild":"prebuildify --napi","install":"node-gyp-build"},"repository":{"type":"git","url":"git+https://github.com/hypercore-skunkworks/fs-native-extensions.git"},"author":{"name":"Kasper Isager Dalsgarð","email":"kasper@funktionel.co"},"license":"ISC","bugs":{"url":"https://github.com/hypercore-skunkworks/fs-native-extensions/issues"},"homepage":"https://github.com/hypercore-skunkworks/fs-native-extensions#readme","dependencies":{"napi-macros":"^2.0.0","node-gyp-build":"^4.2.3"},"devDependencies":{"brittle":"^2.3.1","minimist":"^1.2.6","prebuildify":"^4.1.2","standard":"^17.0.0","tempy":"^3.0.0"},"gitHead":"2320b27c145fee869a4d1f1fc40cc6f9da38ad49","_id":"fs-native-extensions@1.0.0","_nodeVersion":"18.0.0","_npmVersion":"8.6.0","dist":{"shasum":"71f018e43f78642b46ce25b2f0a4f7f42cb6401d","size":6582,"noattachment":false,"key":"/fs-native-extensions/-/fs-native-extensions-1.0.0.tgz","tarball":"http://name.csiicloud.com:7001/fs-native-extensions/download/fs-native-extensions-1.0.0.tgz"},"_npmUser":{"name":"kasperisager","email":"kasperisager@hey.com"},"directories":{},"maintainers":[{"name":"kasperisager","email":""},{"name":"mafintosh","email":""}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/fs-native-extensions_1.0.0_1656317906423_0.4451989882095231"},"_hasShrinkwrap":false,"_cnpmcore_publish_time":"2022-06-27T10:28:50.214Z","hasInstallScript":true,"publish_time":1656317906622,"_cnpm_publish_time":1656317906622}},"readme":"# 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 the lock.\n\nOptions include:\n\n```js\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}\n```\n\n#### `await waitForLock(fd[, offset[, length]][, options])`\n\nRequest a lock on a file, resolving when the lock is granted. If another file descriptor holds the lock, the lock will not be granted until the other file descriptor releases the lock.\n\nOptions are the same as `tryLock()`.\n\n#### `const granted = tryDowngradeLock(fd[, offset[, length]])`\n\nRequest a downgrade from an already held exclusive lock to a shared lock, returning `true` if the lock was granted or `false` if another process currently holds the lock. If `false` is returned, the exclusive lock is lost and must be requested again.\n\nOn Windows, the downgrade will happen atomically and be immediately granted.\n\n#### `await waitForDowngradeLock(fd[, offset[, length]])`\n\nRequest a downgrade from an already held exclusive lock to a shared lock.\n\nOn Windows, the downgrade will happen atomically and be immediately granted.\n\n#### `const granted = tryUpgradeLock(fd[, offset[, length]])`\n\nRequest an upgrade from an already held shared lock to an exclusive lock, returning `true` if the lock was granted or `false` if another process currently holds the lock. If `false` is returned, the shared lock is lost and must be requested again.\n\n#### `await waitForUpgradeLock(fd[, offset[, length]])`\n\nRequest an upgrade from an already held shared lock to an exclusive lock.\n\n#### `unlock(fd[, offset[, length]])`\n\nRelease a lock on a file.\n\n#### `await trim(fd, offset, length)`\n\nCreate a hole in a file at `offset` for `length` bytes. On file systems that support sparse files, file blocks wholly covered by a hole will take up no physical space.\n\nOn Windows, the file must first be marked sparse using `sparse(fd)`. Otherwise, zeros will be explicitly written to the hole.\n\n#### `await sparse(fd)`\n\nMark a file as sparse. On Windows, this operation is required before holes can be created in the file. On other systems, this operation has no effect.\n\n#### `await swap(from, to)`\n\nSwap the paths `from` and `to`, making `from` assume the identity of `to` and `to` assume the identity of `from`.\n\nOn Windows, the swap is performed by first moving `to` to a temporary path, then moving `from` to `to`, and finally moving the temporary path to `from`.\n\nOn macOS and Linux, the swap is performed atomically.\n\n## License\n\nISC\n","_attachments":{},"homepage":"https://github.com/holepunchto/fs-native-extensions#readme","bugs":{"url":"https://github.com/holepunchto/fs-native-extensions/issues"},"license":"ISC"}