@visulima/fs 5.0.0-alpha.3 → 5.0.0-alpha.30

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (223) hide show
  1. package/CHANGELOG.md +371 -0
  2. package/LICENSE.md +208 -131
  3. package/dist/eol.d.ts +31 -30
  4. package/dist/eol.js +3 -26
  5. package/dist/error.d.ts +273 -7
  6. package/dist/error.js +1 -7
  7. package/dist/glob-parent.d.ts +35 -0
  8. package/dist/glob-parent.js +1 -0
  9. package/dist/glob.d.ts +4 -0
  10. package/dist/glob.js +1 -0
  11. package/dist/index.d.ts +857 -36
  12. package/dist/index.js +1 -33
  13. package/dist/ini.d.ts +70 -0
  14. package/dist/ini.js +1 -0
  15. package/dist/is-glob.d.ts +34 -0
  16. package/dist/is-glob.js +1 -0
  17. package/dist/json5.d.ts +36 -0
  18. package/dist/json5.js +1 -0
  19. package/dist/jsonc.d.ts +65 -0
  20. package/dist/jsonc.js +1 -0
  21. package/dist/match.d.ts +80 -0
  22. package/dist/match.js +1 -0
  23. package/dist/packem_shared/AlreadyExistsError-CEu6_Tjb.js +1 -0
  24. package/dist/packem_shared/DirectoryError-ddlbUV8C.js +1 -0
  25. package/dist/packem_shared/F_OK-CAwY1qU7.js +1 -0
  26. package/dist/packem_shared/JSONError-D7h6PNWc.js +4 -0
  27. package/dist/packem_shared/NotEmptyError-DMh1o7UL.js +1 -0
  28. package/dist/packem_shared/NotFoundError-BPiW0icm.js +1 -0
  29. package/dist/packem_shared/PermissionError-B1Emi5a9.js +1 -0
  30. package/dist/packem_shared/WalkError-Olmh4908.js +1 -0
  31. package/dist/packem_shared/_commonjsHelpers-D6W6KoPK.js +1 -0
  32. package/dist/packem_shared/assertValidFileContents-BZFnXa7K.js +1 -0
  33. package/dist/packem_shared/assertValidFileOrDirectoryPath-DgPIPmZT.js +1 -0
  34. package/dist/packem_shared/build-rm-options-C1R4reBu.js +1 -0
  35. package/dist/packem_shared/collect-BuI4N8Cb.js +1 -0
  36. package/dist/packem_shared/collectSync-xeb7vY2J.js +1 -0
  37. package/dist/packem_shared/emptyDir-8utO028L.js +1 -0
  38. package/dist/packem_shared/emptyDirSync-Bk5fUX73.js +1 -0
  39. package/dist/packem_shared/ensureDir-CZ4oUFuo.js +1 -0
  40. package/dist/packem_shared/ensureDirSync-CoPWhbjM.js +1 -0
  41. package/dist/packem_shared/ensureFile-CF1cAAyh.js +1 -0
  42. package/dist/packem_shared/ensureFileSync-C3qR6naU.js +1 -0
  43. package/dist/packem_shared/ensureLink-LLLxlGHn.js +1 -0
  44. package/dist/packem_shared/ensureLinkSync-Dh_GtT8F.js +1 -0
  45. package/dist/packem_shared/ensureSymlink-bcGk7tvJ.js +1 -0
  46. package/dist/packem_shared/ensureSymlinkSync-BbVDPvI4.js +1 -0
  47. package/dist/packem_shared/findUp-CZow0UvS.js +1 -0
  48. package/dist/packem_shared/findUpSync-BOMeyfWY.js +1 -0
  49. package/dist/packem_shared/get-file-info-type-CaWGXRjY.js +1 -0
  50. package/dist/packem_shared/glob-MHJQjR39.js +1 -0
  51. package/dist/packem_shared/glob-sync.d-BgJM6l8W.d.ts +54 -0
  52. package/dist/packem_shared/globSync-CwzlELgS.js +1 -0
  53. package/dist/packem_shared/index-CYIVJA0W.js +1 -0
  54. package/dist/packem_shared/index-DrapuBsB.js +1 -0
  55. package/dist/packem_shared/index-K-NNTkpb.js +11 -0
  56. package/dist/packem_shared/index-yGx8uzZs.js +1 -0
  57. package/dist/packem_shared/indexToLineColumn-BRSZFC6I-zN_sCTx7.js +6 -0
  58. package/dist/packem_shared/ini-preserve-CXc_xkpG.js +4 -0
  59. package/dist/packem_shared/is-stats-identical-CohsLtWy.js +1 -0
  60. package/dist/packem_shared/isAccessible-CDFxsAAo.js +1 -0
  61. package/dist/packem_shared/isAccessibleSync-5nzZWgin.js +1 -0
  62. package/dist/packem_shared/isFsCaseSensitive-CMZVY1A2.js +1 -0
  63. package/dist/packem_shared/json-error.d-DVILOyHc.d.ts +52 -0
  64. package/dist/packem_shared/jsonc-merge-CQMjx3Vw.js +2 -0
  65. package/dist/packem_shared/move-LmP6P9sn.js +1 -0
  66. package/dist/packem_shared/parseJson-DTdEDJwS.js +1 -0
  67. package/dist/packem_shared/readFile-BkNfutxp.js +1 -0
  68. package/dist/packem_shared/readFileSync-4c_c6Qey.js +1 -0
  69. package/dist/packem_shared/readIni-DlyyIBHq.js +1 -0
  70. package/dist/packem_shared/readIniSync-DwomjPMj.js +1 -0
  71. package/dist/packem_shared/readJson-BiskeuNZ.js +1 -0
  72. package/dist/packem_shared/readJson5-ffmra5zp.js +1 -0
  73. package/dist/packem_shared/readJson5Sync-oAo0gBuU.js +1 -0
  74. package/dist/packem_shared/readJsonSync-cmV1NjAI.js +1 -0
  75. package/dist/packem_shared/readJsonc-Bd6QH-bH.js +1 -0
  76. package/dist/packem_shared/readJsoncSync-rcXoQB_7.js +1 -0
  77. package/dist/packem_shared/readToml-4S8Io3SQ.js +1 -0
  78. package/dist/packem_shared/readTomlSync-CcZKONFn.js +1 -0
  79. package/dist/packem_shared/readYaml-D71jaFaB.js +1 -0
  80. package/dist/packem_shared/readYamlSync-B0UyP0rk.js +1 -0
  81. package/dist/packem_shared/remove-DH41Ov_c.js +1 -0
  82. package/dist/packem_shared/removeSync-50OEdnHd.js +1 -0
  83. package/dist/packem_shared/resolve-symlink-target-BofZSDIc.js +1 -0
  84. package/dist/packem_shared/sanitize-CU1xmyrg.js +1 -0
  85. package/dist/packem_shared/stripJsonComments-CzNR77MF.js +1 -0
  86. package/dist/packem_shared/to-uint-8-array-DwgaTasY.js +1 -0
  87. package/dist/packem_shared/types.d-C1ygRkw1.d.ts +1660 -0
  88. package/dist/packem_shared/walk-CFHn3Kig.js +1 -0
  89. package/dist/packem_shared/walk-include-D2widdUw.js +1 -0
  90. package/dist/packem_shared/walkSync-D9PxD1XJ.js +1 -0
  91. package/dist/packem_shared/writeFile-DUmg8P4m.js +1 -0
  92. package/dist/packem_shared/writeFileSync-Cboe5Z4V.js +1 -0
  93. package/dist/packem_shared/writeIni-DioeLq2k.js +4 -0
  94. package/dist/packem_shared/writeIniSync-yk0js2T2.js +4 -0
  95. package/dist/packem_shared/writeJson-D5-N8O0Q.js +4 -0
  96. package/dist/packem_shared/writeJson5-RIZyw1vX.js +4 -0
  97. package/dist/packem_shared/writeJson5Sync-Cnxh1THk.js +4 -0
  98. package/dist/packem_shared/writeJsonSync-BrXiOras.js +4 -0
  99. package/dist/packem_shared/writeJsonc-lGAmFl9u.js +4 -0
  100. package/dist/packem_shared/writeJsoncSync-BFuqkLDq.js +4 -0
  101. package/dist/packem_shared/writeToml-CaXpILHA.js +1 -0
  102. package/dist/packem_shared/writeTomlSync-CQ2mzKjs.js +1 -0
  103. package/dist/packem_shared/writeYaml-DKBXiztZ.js +1 -0
  104. package/dist/packem_shared/writeYamlSync-DVKnrXBl.js +1 -0
  105. package/dist/size.d.ts +246 -246
  106. package/dist/size.js +1 -144
  107. package/dist/toml.d.ts +63 -0
  108. package/dist/toml.js +1 -0
  109. package/dist/utils.d.ts +103 -6
  110. package/dist/utils.js +1 -6
  111. package/dist/yaml.d.ts +13 -5
  112. package/dist/yaml.js +1 -4
  113. package/package.json +69 -18
  114. package/dist/constants.d.ts +0 -42
  115. package/dist/ensure/ensure-dir-sync.d.ts +0 -14
  116. package/dist/ensure/ensure-dir.d.ts +0 -14
  117. package/dist/ensure/ensure-file-sync.d.ts +0 -15
  118. package/dist/ensure/ensure-file.d.ts +0 -27
  119. package/dist/ensure/ensure-link-sync.d.ts +0 -16
  120. package/dist/ensure/ensure-link.d.ts +0 -16
  121. package/dist/ensure/ensure-symlink-sync.d.ts +0 -23
  122. package/dist/ensure/ensure-symlink.d.ts +0 -23
  123. package/dist/ensure/utils/get-file-info-type.d.ts +0 -7
  124. package/dist/ensure/utils/is-stats-identical.d.ts +0 -3
  125. package/dist/ensure/utils/resolve-symlink-target.d.ts +0 -2
  126. package/dist/error/already-exists-error.d.ts +0 -39
  127. package/dist/error/directory-error.d.ts +0 -47
  128. package/dist/error/json-error.d.ts +0 -52
  129. package/dist/error/not-empty-error.d.ts +0 -51
  130. package/dist/error/not-found-error.d.ts +0 -44
  131. package/dist/error/permission-error.d.ts +0 -45
  132. package/dist/error/walk-error.d.ts +0 -51
  133. package/dist/find/collect-sync.d.ts +0 -31
  134. package/dist/find/collect.d.ts +0 -35
  135. package/dist/find/find-up-sync.d.ts +0 -42
  136. package/dist/find/find-up.d.ts +0 -46
  137. package/dist/find/utils/glob-to-regexp.d.ts +0 -2
  138. package/dist/find/utils/walk-include.d.ts +0 -2
  139. package/dist/find/walk-sync.d.ts +0 -34
  140. package/dist/find/walk.d.ts +0 -37
  141. package/dist/is-accessible-sync.d.ts +0 -3
  142. package/dist/is-accessible.d.ts +0 -29
  143. package/dist/move/index.d.ts +0 -68
  144. package/dist/move/types.d.ts +0 -36
  145. package/dist/move/utils/internal-move-file-sync.d.ts +0 -3
  146. package/dist/move/utils/internal-move-file.d.ts +0 -3
  147. package/dist/move/utils/validate-same-directory.d.ts +0 -2
  148. package/dist/packem_shared/AlreadyExistsError-6Y9hjgMn.js +0 -27
  149. package/dist/packem_shared/DirectoryError-BfYPkIYP.js +0 -27
  150. package/dist/packem_shared/F_OK-MldBaGxb.js +0 -8
  151. package/dist/packem_shared/JSONError-BkHRnInH.js +0 -26
  152. package/dist/packem_shared/NotEmptyError-B21RUlVr.js +0 -27
  153. package/dist/packem_shared/NotFoundError-BIp61X6k.js +0 -27
  154. package/dist/packem_shared/PermissionError-CjoiJgip.js +0 -27
  155. package/dist/packem_shared/WalkError-DUdQd6FT.js +0 -24
  156. package/dist/packem_shared/assertValidFileContents-BmcLtsGd.js +0 -7
  157. package/dist/packem_shared/assertValidFileOrDirectoryPath-8HANmVjk.js +0 -7
  158. package/dist/packem_shared/collect-DcBwsYYd.js +0 -14
  159. package/dist/packem_shared/collectSync-Bkjf9Dbm.js +0 -14
  160. package/dist/packem_shared/emptyDir-CYB5Tict.js +0 -43
  161. package/dist/packem_shared/emptyDirSync-BD8-1Ytl.js +0 -41
  162. package/dist/packem_shared/ensureDir-C_kuQ5Ik.js +0 -53
  163. package/dist/packem_shared/ensureDirSync-CI5g-uBI.js +0 -53
  164. package/dist/packem_shared/ensureFile-BUtXGlGT.js +0 -47
  165. package/dist/packem_shared/ensureFileSync-C8hASR-1.js +0 -47
  166. package/dist/packem_shared/ensureLink-BPnAG5-P.js +0 -54
  167. package/dist/packem_shared/ensureLinkSync-B-Z7X0ub.js +0 -54
  168. package/dist/packem_shared/ensureSymlink-U5B6J0BN.js +0 -73
  169. package/dist/packem_shared/ensureSymlinkSync-DHnZj-9F.js +0 -74
  170. package/dist/packem_shared/findUp-BSnyGqer.js +0 -85
  171. package/dist/packem_shared/findUpSync-jRHbSCMV.js +0 -85
  172. package/dist/packem_shared/get-file-info-type-FD4-jsyg.js +0 -14
  173. package/dist/packem_shared/index-CHM-in-V.js +0 -100
  174. package/dist/packem_shared/is-stats-identical-D8FxpvQU.js +0 -3
  175. package/dist/packem_shared/isAccessible-DuVrTNFV.js +0 -38
  176. package/dist/packem_shared/isAccessibleSync-DI8mM0fA.js +0 -38
  177. package/dist/packem_shared/isFsCaseSensitive-D-ayleCy.js +0 -62
  178. package/dist/packem_shared/move-DbpW5_vA.js +0 -134
  179. package/dist/packem_shared/parseJson-C8xb-3LR.js +0 -231
  180. package/dist/packem_shared/readFile-Iz7kvCCk.js +0 -65
  181. package/dist/packem_shared/readFileSync-6GEIrOnl.js +0 -53
  182. package/dist/packem_shared/readJson-vddQ97Ll.js +0 -22
  183. package/dist/packem_shared/readJsonSync-DzeAdYZl.js +0 -22
  184. package/dist/packem_shared/readYaml-D5q2a0e1.js +0 -10
  185. package/dist/packem_shared/readYamlSync-DMV4U-gi.js +0 -10
  186. package/dist/packem_shared/remove-_oDY3uKo.js +0 -38
  187. package/dist/packem_shared/removeSync-DETRj7Qn.js +0 -38
  188. package/dist/packem_shared/resolve-symlink-target-Kh4GovFf.js +0 -16
  189. package/dist/packem_shared/sanitize-lOzE6k2A.js +0 -205
  190. package/dist/packem_shared/stripJsonComments-vo4k0mpF.js +0 -19
  191. package/dist/packem_shared/to-uint-8-array-Dz2nF1y1.js +0 -19
  192. package/dist/packem_shared/walk-BhTbpr3y.js +0 -115
  193. package/dist/packem_shared/walk-include-CZco7BvN.js +0 -16
  194. package/dist/packem_shared/walkSync-DDBq95s8.js +0 -114
  195. package/dist/packem_shared/writeFile-DSHERs0Z.js +0 -83
  196. package/dist/packem_shared/writeFileSync-CJp1kXQR.js +0 -83
  197. package/dist/packem_shared/writeJson-C0OfLDbe.js +0 -50
  198. package/dist/packem_shared/writeJsonSync-Cs21FE7v.js +0 -50
  199. package/dist/packem_shared/writeYaml-n4xzYN9a.js +0 -24
  200. package/dist/packem_shared/writeYamlSync-DnOEnP10.js +0 -24
  201. package/dist/read/read-file-sync.d.ts +0 -37
  202. package/dist/read/read-file.d.ts +0 -41
  203. package/dist/read/read-json-sync.d.ts +0 -5
  204. package/dist/read/read-json.d.ts +0 -5
  205. package/dist/read/read-yaml-sync.d.ts +0 -4
  206. package/dist/read/read-yaml.d.ts +0 -4
  207. package/dist/remove/empty-dir-sync.d.ts +0 -23
  208. package/dist/remove/empty-dir.d.ts +0 -28
  209. package/dist/remove/remove-sync.d.ts +0 -27
  210. package/dist/remove/remove.d.ts +0 -32
  211. package/dist/sanitize.d.ts +0 -31
  212. package/dist/types.d.ts +0 -304
  213. package/dist/utils/assert-valid-file-contents.d.ts +0 -27
  214. package/dist/utils/assert-valid-file-or-directory-path.d.ts +0 -26
  215. package/dist/utils/parse-json.d.ts +0 -5
  216. package/dist/utils/strip-json-comments.d.ts +0 -44
  217. package/dist/write/utils/to-uint-8-array.d.ts +0 -2
  218. package/dist/write/write-file-sync.d.ts +0 -30
  219. package/dist/write/write-file.d.ts +0 -30
  220. package/dist/write/write-json-sync.d.ts +0 -29
  221. package/dist/write/write-json.d.ts +0 -30
  222. package/dist/write/write-yaml-sync.d.ts +0 -4
  223. package/dist/write/write-yaml.d.ts +0 -4
@@ -0,0 +1 @@
1
+ var F=Object.defineProperty;var y=(i,e)=>F(i,"name",{value:e,configurable:!0});import{createRequire as _}from"node:module";import{resolve as T,join as x,normalize as I,basename as N}from"@visulima/path";import{toPath as P}from"@visulima/path/utils";import h from"./WalkError-Olmh4908.js";import q from"./assertValidFileOrDirectoryPath-DgPIPmZT.js";import{p as S,u}from"./walk-include-D2widdUw.js";const v=_(import.meta.url),a=typeof globalThis<"u"&&typeof globalThis.process<"u"?globalThis.process:process,g=y(i=>{if(typeof a<"u"&&a.versions&&a.versions.node){const[e,t]=a.versions.node.split(".").map(Number);if(e>22||e===22&&t>=3||e===20&&t>=16)return a.getBuiltinModule(i)}return v(i)},"__cjs_getBuiltinModule"),{readdir:w,realpath:L,stat:j}=g("node:fs/promises");var O=Object.defineProperty,r=y((i,e)=>O(i,"name",{value:e,configurable:!0}),"r");const B=r(async i=>{const e=I(i),t=N(e),l=await j(e);return{isDirectory:r(()=>l.isDirectory(),"isDirectory"),isFile:r(()=>l.isFile(),"isFile"),isSymbolicLink:r(()=>l.isSymbolicLink(),"isSymbolicLink"),name:t,path:e}},"_createWalkEntry");async function*D(i,{extensions:e,followSymlinks:t=!1,includeDirs:l=!0,includeFiles:p=!0,includeSymlinks:d=!0,match:b,maxDepth:f=Number.POSITIVE_INFINITY,skip:k}={}){if(q(i),f<0)return;const m=b?b.map(s=>typeof s=="string"?S(s):s):void 0,c=k?k.map(s=>typeof s=="string"?S(s):s):void 0;if(i=T(P(i)),l&&u(i,e,m,c)&&(yield await B(i)),!(f<1||!u(i,void 0,void 0,c)))try{const s=await w(i,{withFileTypes:!0});for(const o of s){let n=x(i,o.name);if(o.isSymbolicLink())if(t)n=await L(n);else if(d&&u(n,e,m,c)){yield{isDirectory:r(()=>o.isDirectory(),"isDirectory"),isFile:r(()=>o.isFile(),"isFile"),isSymbolicLink:r(()=>o.isSymbolicLink(),"isSymbolicLink"),name:o.name,path:n};continue}else continue;o.isDirectory()?yield*D(n,{extensions:e,followSymlinks:t,includeDirs:l,includeFiles:p,includeSymlinks:d,match:m,maxDepth:f-1,skip:c}):o.isFile()&&p&&u(n,e,m,c)&&(yield{isDirectory:r(()=>o.isDirectory(),"isDirectory"),isFile:r(()=>o.isFile(),"isFile"),isSymbolicLink:r(()=>o.isSymbolicLink(),"isSymbolicLink"),name:o.name,path:n})}}catch(s){throw s instanceof h?s:new h(s,i)}}y(D,"g");r(D,"walk");export{D as default};
@@ -0,0 +1 @@
1
+ var g=Object.defineProperty;var c=(e,r)=>g(e,"name",{value:r,configurable:!0});var p=Object.defineProperty,o=c((e,r)=>p(e,"name",{value:r,configurable:!0}),"g");const f=o(e=>{const r=e.replace(/[$()+\\^]/g,String.raw`\$&`).replace(/\.\*/g,".([^/]*)").replace(/\*\*/g,"(.*)").replace(/(?<!\.)\*(?!\*)/g,"([^/]*)").replace(/\?/g,"[^/]").replace(/\.(?!\*)/g,String.raw`\.`).replace(/\{/g,"(").replace(/\}/g,")").replace(/,/g,"|").replace(/\[!(.*?)\]/g,"[^$1]");try{return new RegExp(`^${r}$`)}catch(t){throw new Error(`Invalid glob pattern: ${e}`,{cause:t})}},"globToRegExp");var s=Object.defineProperty,u=c((e,r)=>s(e,"name",{value:r,configurable:!0}),"t");const v=u((e,r,t,n)=>{if(Array.isArray(r)&&r.length>0&&!r.some(a=>e.endsWith(a)))return!1;const l=e.includes("\\")?e.replaceAll("\\","/"):e;return t&&!t.some(a=>a.test(l))?!1:!n?.some(a=>a.test(l))},"walkInclude");export{f as p,v as u};
@@ -0,0 +1 @@
1
+ var _=Object.defineProperty;var a=(i,e)=>_(i,"name",{value:e,configurable:!0});import{createRequire as v}from"node:module";import{resolve as x,join as I,normalize as f,basename as P}from"@visulima/path";import{toPath as N}from"@visulima/path/utils";import h from"./WalkError-Olmh4908.js";import q from"./assertValidFileOrDirectoryPath-DgPIPmZT.js";import{p as D,u as y}from"./walk-include-D2widdUw.js";const g=v(import.meta.url),c=typeof globalThis<"u"&&typeof globalThis.process<"u"?globalThis.process:process,L=a(i=>{if(typeof c<"u"&&c.versions&&c.versions.node){const[e,n]=c.versions.node.split(".").map(Number);if(e>22||e===22&&n>=3||e===20&&n>=16)return c.getBuiltinModule(i)}return g(i)},"__cjs_getBuiltinModule"),{readdirSync:j,realpathSync:w,statSync:T}=L("node:fs");var B=Object.defineProperty,r=a((i,e)=>B(i,"name",{value:e,configurable:!0}),"t");const E=r(i=>{const e=f(i),n=T(e);return{isDirectory:r(()=>n.isDirectory(),"isDirectory"),isFile:r(()=>n.isFile(),"isFile"),isSymbolicLink:r(()=>n.isSymbolicLink(),"isSymbolicLink"),name:P(e),path:e}},"_createWalkEntry");function*F(i,{extensions:e,followSymlinks:n=!1,includeDirs:p=!0,includeFiles:d=!0,includeSymlinks:b=!0,match:S,maxDepth:u=Number.POSITIVE_INFINITY,skip:k}={}){if(q(i),u<0)return;const m=S?S.map(s=>typeof s=="string"?D(s):s):void 0,l=k?k.map(s=>typeof s=="string"?D(s):s):void 0;if(i=x(N(i)),p&&y(i,e,m,l)&&(yield E(i)),!(u<1||!y(i,void 0,void 0,l)))try{const s=j(i,{withFileTypes:!0});for(const o of s){let t=I(i,o.name);if(o.isSymbolicLink())if(n)t=w(t);else if(b&&y(t,e,m,l)){yield{isDirectory:r(()=>o.isDirectory(),"isDirectory"),isFile:r(()=>o.isFile(),"isFile"),isSymbolicLink:r(()=>o.isSymbolicLink(),"isSymbolicLink"),name:o.name,path:f(t)};continue}else continue;o.isDirectory()?yield*F(t,{extensions:e,followSymlinks:n,includeDirs:p,includeFiles:d,includeSymlinks:b,match:m,maxDepth:u-1,skip:l}):o.isFile()&&d&&y(t,e,m,l)&&(yield{isDirectory:r(()=>o.isDirectory(),"isDirectory"),isFile:r(()=>o.isFile(),"isFile"),isSymbolicLink:r(()=>o.isSymbolicLink(),"isSymbolicLink"),name:o.name,path:f(t)})}}catch(s){throw s instanceof h?s:new h(s,i)}}a(F,"b");r(F,"walkSync");export{F as default};
@@ -0,0 +1 @@
1
+ var d=Object.defineProperty;var n=(e,o)=>d(e,"name",{value:o,configurable:!0});import{createRequire as l}from"node:module";import{dirname as $}from"@visulima/path";import{toPath as j}from"@visulima/path/utils";import{F_OK as u}from"./F_OK-CAwY1qU7.js";import c from"./isAccessible-CDFxsAAo.js";import F from"./assertValidFileContents-BZFnXa7K.js";import P from"./assertValidFileOrDirectoryPath-DgPIPmZT.js";import{a as k}from"./to-uint-8-array-DwgaTasY.js";const w=l(import.meta.url),s=typeof globalThis<"u"&&typeof globalThis.process<"u"?globalThis.process:process,p=n(e=>{if(typeof s<"u"&&s.versions&&s.versions.node){const[o,t]=s.versions.node.split(".").map(Number);if(o>22||o===22&&t>=3||o===20&&t>=16)return s.getBuiltinModule(e)}return w(e)},"__cjs_getBuiltinModule"),{mkdir:g,writeFile:h,stat:_,rename:f,chown:v,chmod:y,unlink:b}=p("node:fs/promises");var q=Object.defineProperty,B=n((e,o)=>q(e,"name",{value:o,configurable:!0}),"w");const A=B(async(e,o,t)=>{t={encoding:"utf8",flag:"w",overwrite:!0,recursive:!0,...t},P(e),F(o),e=j(e);const r=`${e}.tmp`;try{const a=await c(e,u);if(!a&&t.recursive){const m=$(e);await c(m,u)||await g(m,{recursive:!0})}let i;if(await h(r,typeof o=="string"?Buffer.from(o,t.encoding??"utf8"):k(o),{flag:t.flag}),a&&!t.overwrite&&(i=await _(e),t.chown??={gid:i.gid,uid:i.uid},await f(e,`${e}.bak`)),t.chown)try{await v(r,t.chown.uid,t.chown.gid)}catch{}await y(r,i&&!t.mode?i.mode:t.mode??438),await f(r,e)}catch(a){throw new Error(`Failed to write file at: ${e} - ${a.message}`,{cause:a})}finally{await c(r)&&await b(`${e}.tmp`)}},"writeFile");export{A as default};
@@ -0,0 +1 @@
1
+ var d=Object.defineProperty;var s=(e,t)=>d(e,"name",{value:t,configurable:!0});import{createRequire as l}from"node:module";import{dirname as b}from"@visulima/path";import{toPath as $}from"@visulima/path/utils";import{F_OK as u}from"./F_OK-CAwY1qU7.js";import a from"./isAccessibleSync-5nzZWgin.js";import j from"./assertValidFileContents-BZFnXa7K.js";import F from"./assertValidFileOrDirectoryPath-DgPIPmZT.js";import{a as k}from"./to-uint-8-array-DwgaTasY.js";const p=l(import.meta.url),c=typeof globalThis<"u"&&typeof globalThis.process<"u"?globalThis.process:process,g=s(e=>{if(typeof c<"u"&&c.versions&&c.versions.node){const[t,o]=c.versions.node.split(".").map(Number);if(t>22||t===22&&o>=3||t===20&&o>=16)return c.getBuiltinModule(e)}return p(e)},"__cjs_getBuiltinModule"),{mkdirSync:y,writeFileSync:h,statSync:w,renameSync:m,chownSync:_,chmodSync:v,unlinkSync:S}=g("node:fs");var q=Object.defineProperty,B=s((e,t)=>q(e,"name",{value:t,configurable:!0}),"n");const z=B((e,t,o)=>{o={encoding:"utf8",flag:"w",overwrite:!0,recursive:!0,...o},F(e),j(t),e=$(e);const r=`${e}.tmp`;try{const i=a(e,u);if(!i&&o.recursive){const f=b(e);a(f,u)||y(f,{recursive:!0})}let n;if(h(r,typeof t=="string"?Buffer.from(t,o.encoding??"utf8"):k(t),{flag:o.flag}),i&&!o.overwrite&&(n=w(e),o.chown??={gid:n.gid,uid:n.uid},m(e,`${e}.bak`)),o.chown)try{_(r,o.chown.uid,o.chown.gid)}catch{}v(r,n&&!o.mode?n.mode:o.mode??438),m(r,e)}catch(i){throw new Error(`Failed to write file at: ${e} - ${i.message}`,{cause:i})}finally{a(r)&&S(`${e}.tmp`)}},"writeFileSync");export{z as default};
@@ -0,0 +1,4 @@
1
+ var I=Object.defineProperty;var f=(e,r)=>I(e,"name",{value:r,configurable:!0});import{createRequire as O}from"node:module";import{parse as N,stringify as R}from"ini";import{R_OK as S}from"./F_OK-CAwY1qU7.js";import B from"./isAccessible-CDFxsAAo.js";import{d as M,m as x}from"./ini-preserve-CXc_xkpG.js";import F from"./writeFile-DUmg8P4m.js";const T=O(import.meta.url),s=typeof globalThis<"u"&&typeof globalThis.process<"u"?globalThis.process:process,q=f(e=>{if(typeof s<"u"&&s.versions&&s.versions.node){const[r,n]=s.versions.node.split(".").map(Number);if(r>22||r===22&&n>=3||r===20&&n>=16)return s.getBuiltinModule(e)}return T(e)},"__cjs_getBuiltinModule"),{readFile:E}=q("node:fs/promises");var K=Object.defineProperty,y=f((e,r)=>K(e,"name",{value:r,configurable:!0}),"l");const J=y(async(e,r,n={})=>{const{eol:_,preserveStyle:h=!0,whitespace:v,...w}=n,{align:b,bracketedArray:p,newline:j,platform:P,section:m,sort:k,...A}=w;let a=_,c=v,i,l;if(h&&await B(e,S))try{i=await E(e,"utf8"),l=N(i,{bracketedArray:p??!0});const t=M(i);a??=t.eol,c??=t.whitespace}catch(t){if(t.code!=="ENOENT")throw t}const d={align:b,bracketedArray:p,newline:j,platform:P,section:m,sort:k,whitespace:c},u=y((t,g)=>R(t,g===void 0?d:{...d,section:g}),"freshStringify");let o;i!==void 0&&l?o=x(i,l,r,u,{eol:a??`
2
+ `,whitespace:c??!1}):(o=u(r,m),a===`\r
3
+ `&&(o=o.replaceAll(/\r?\n/g,`\r
4
+ `))),await F(e,o,A)},"writeIni");export{J as default};
@@ -0,0 +1,4 @@
1
+ var k=Object.defineProperty;var f=(e,r)=>k(e,"name",{value:r,configurable:!0});import{createRequire as A}from"node:module";import{parse as N,stringify as P}from"ini";import{R_OK as R}from"./F_OK-CAwY1qU7.js";import B from"./isAccessibleSync-5nzZWgin.js";import{d as M,m as x}from"./ini-preserve-CXc_xkpG.js";import F from"./writeFileSync-Cboe5Z4V.js";const I=A(import.meta.url),s=typeof globalThis<"u"&&typeof globalThis.process<"u"?globalThis.process:process,q=f(e=>{if(typeof s<"u"&&s.versions&&s.versions.node){const[r,n]=s.versions.node.split(".").map(Number);if(r>22||r===22&&n>=3||r===20&&n>=16)return s.getBuiltinModule(e)}return I(e)},"__cjs_getBuiltinModule"),{readFileSync:E}=q("node:fs");var K=Object.defineProperty,g=f((e,r)=>K(e,"name",{value:r,configurable:!0}),"d");const J=g((e,r,n={})=>{const{eol:_,preserveStyle:h=!0,whitespace:v,...b}=n,{align:w,bracketedArray:p,newline:j,platform:S,section:m,sort:O,...T}=b;let c=_,a=v,o,l;if(h&&B(e,R))try{o=E(e,"utf8"),l=N(o,{bracketedArray:p??!0});const t=M(o);c??=t.eol,a??=t.whitespace}catch(t){if(t.code!=="ENOENT")throw t}const d={align:w,bracketedArray:p,newline:j,platform:S,section:m,sort:O,whitespace:a},u=g((t,y)=>P(t,y===void 0?d:{...d,section:y}),"freshStringify");let i;o!==void 0&&l?i=x(o,l,r,u,{eol:c??`
2
+ `,whitespace:a??!1}):(i=u(r,m),c===`\r
3
+ `&&(i=i.replaceAll(/\r?\n/g,`\r
4
+ `))),F(e,i,T)},"writeIniSync");export{J as default};
@@ -0,0 +1,4 @@
1
+ var _=Object.defineProperty;var n=(e,t)=>_(e,"name",{value:t,configurable:!0});import{createRequire as g}from"node:module";import{C as j}from"./index-CYIVJA0W.js";import{R_OK as v}from"./F_OK-CAwY1qU7.js";import w from"./isAccessible-CDFxsAAo.js";import N from"./writeFile-DUmg8P4m.js";const y=g(import.meta.url),o=typeof globalThis<"u"&&typeof globalThis.process<"u"?globalThis.process:process,b=n(e=>{if(typeof o<"u"&&o.versions&&o.versions.node){const[t,i]=o.versions.node.split(".").map(Number);if(t>22||t===22&&i>=3||t===20&&i>=16)return o.getBuiltinModule(e)}return y(e)},"__cjs_getBuiltinModule"),{readFile:h}=b("node:fs/promises");var O=Object.defineProperty,T=n((e,t)=>O(e,"name",{value:t,configurable:!0}),"r");const J=T(async(e,t,i={})=>{const{detectIndent:a,indent:f,replacer:d,stringify:m=JSON.stringify,...p}={indent:" ",...i};let s=f,c=`
2
+ `;if(await w(e,v))try{const r=await h(e,"utf8");if(a){const{indent:l}=j(r);s=l}c=r.endsWith(`
3
+ `)?`
4
+ `:""}catch(r){if(r.code!=="ENOENT")throw r}const u=m(t,d,s);await N(e,`${u}${c}`,p)},"writeJson");export{J as default};
@@ -0,0 +1,4 @@
1
+ var _=Object.defineProperty;var n=(e,t)=>_(e,"name",{value:t,configurable:!0});import{createRequire as g}from"node:module";import{C as j}from"./index-CYIVJA0W.js";import v from"json5";import{R_OK as w}from"./F_OK-CAwY1qU7.js";import q from"./isAccessible-CDFxsAAo.js";import T from"./writeFile-DUmg8P4m.js";const y=g(import.meta.url),r=typeof globalThis<"u"&&typeof globalThis.process<"u"?globalThis.process:process,b=n(e=>{if(typeof r<"u"&&r.versions&&r.versions.node){const[t,i]=r.versions.node.split(".").map(Number);if(t>22||t===22&&i>=3||t===20&&i>=16)return r.getBuiltinModule(e)}return y(e)},"__cjs_getBuiltinModule"),{readFile:h}=b("node:fs/promises");var N=Object.defineProperty,O=n((e,t)=>N(e,"name",{value:t,configurable:!0}),"s");const C=O(async(e,t,i={})=>{const{detectIndent:f,indent:p,quote:d,replacer:m,...u}={indent:" ",...i};let s=p,c=`
2
+ `;if(await q(e,w))try{const o=await h(e,"utf8");if(f){const{indent:a}=j(o);a&&(s=a)}c=o.endsWith(`
3
+ `)?`
4
+ `:""}catch(o){if(o.code!=="ENOENT")throw o}const l=v.stringify(t,{quote:d,replacer:m,space:s});await T(e,`${l}${c}`,u)},"writeJson5");export{C as default};
@@ -0,0 +1,4 @@
1
+ var _=Object.defineProperty;var i=(e,o)=>_(e,"name",{value:o,configurable:!0});import{createRequire as y}from"node:module";import{C as j}from"./index-CYIVJA0W.js";import v from"json5";import{R_OK as q}from"./F_OK-CAwY1qU7.js";import O from"./isAccessibleSync-5nzZWgin.js";import T from"./writeFileSync-Cboe5Z4V.js";const g=y(import.meta.url),t=typeof globalThis<"u"&&typeof globalThis.process<"u"?globalThis.process:process,b=i(e=>{if(typeof t<"u"&&t.versions&&t.versions.node){const[o,n]=t.versions.node.split(".").map(Number);if(o>22||o===22&&n>=3||o===20&&n>=16)return t.getBuiltinModule(e)}return g(e)},"__cjs_getBuiltinModule"),{readFileSync:h}=b("node:fs");var $=Object.defineProperty,E=i((e,o)=>$(e,"name",{value:o,configurable:!0}),"c");const x=E((e,o,n={})=>{const{detectIndent:a,indent:d,quote:p,replacer:m,...u}={indent:" ",...n};let s=d,c=`
2
+ `;if(O(e,q))try{const r=h(e,"utf8");if(a){const{indent:f}=j(r);f&&(s=f)}c=r.endsWith(`
3
+ `)?`
4
+ `:""}catch(r){if(r.code!=="ENOENT")throw r}const l=v.stringify(o,{quote:p,replacer:m,space:s});T(e,`${l}${c}`,u)},"writeJson5Sync");export{x as default};
@@ -0,0 +1,4 @@
1
+ var _=Object.defineProperty;var i=(e,t)=>_(e,"name",{value:t,configurable:!0});import{createRequire as g}from"node:module";import{C as j}from"./index-CYIVJA0W.js";import{R_OK as v}from"./F_OK-CAwY1qU7.js";import O from"./isAccessibleSync-5nzZWgin.js";import N from"./writeFileSync-Cboe5Z4V.js";const y=g(import.meta.url),o=typeof globalThis<"u"&&typeof globalThis.process<"u"?globalThis.process:process,b=i(e=>{if(typeof o<"u"&&o.versions&&o.versions.node){const[t,n]=o.versions.node.split(".").map(Number);if(t>22||t===22&&n>=3||t===20&&n>=16)return o.getBuiltinModule(e)}return y(e)},"__cjs_getBuiltinModule"),{readFileSync:h}=b("node:fs");var T=Object.defineProperty,q=i((e,t)=>T(e,"name",{value:t,configurable:!0}),"r");const J=q((e,t,n={})=>{const{detectIndent:f,indent:d,replacer:a,stringify:l=JSON.stringify,...m}={indent:" ",...n};let s=d,c=`
2
+ `;if(O(e,v))try{const r=h(e,"utf8");if(f){const{indent:u}=j(r);s=u}c=r.endsWith(`
3
+ `)?`
4
+ `:""}catch(r){if(r.code!=="ENOENT")throw r}const p=l(t,a,s);N(e,`${p}${c}`,m)},"writeJsonSync");export{J as default};
@@ -0,0 +1,4 @@
1
+ var _=Object.defineProperty;var c=(e,t)=>_(e,"name",{value:t,configurable:!0});import{createRequire as w}from"node:module";import{C as h}from"./index-CYIVJA0W.js";import{R_OK as j}from"./F_OK-CAwY1qU7.js";import x from"./isAccessible-CDFxsAAo.js";import{b as N}from"./jsonc-merge-CQMjx3Vw.js";import T from"./writeFile-DUmg8P4m.js";const b=w(import.meta.url),a=typeof globalThis<"u"&&typeof globalThis.process<"u"?globalThis.process:process,y=c(e=>{if(typeof a<"u"&&a.versions&&a.versions.node){const[t,n]=a.versions.node.split(".").map(Number);if(t>22||t===22&&n>=3||t===20&&n>=16)return a.getBuiltinModule(e)}return b(e)},"__cjs_getBuiltinModule"),{readFile:v}=y("node:fs/promises");var O=Object.defineProperty,d=c((e,t)=>O(e,"name",{value:t,configurable:!0}),"c");const E=d(async(e,t,n)=>{let r,o=n,s=`
2
+ `;if(!await x(e,j))return{indent:o,trailingNewline:s};try{if(r=await v(e,"utf8"),t){const{indent:i}=h(r);i&&(o=i)}s=r.endsWith(`
3
+ `)?`
4
+ `:""}catch(i){if(i.code!=="ENOENT")throw i}return{existingText:r,indent:o,trailingNewline:s}},"readExisting"),F=d(async(e,t,n={})=>{const{detectIndent:r,formattingOptions:o,indent:s,preserveComments:i=!0,replacer:l,...u}={indent:" ",...n},{existingText:f,indent:m,trailingNewline:p}=await E(e,r,s),g=N(f,t,i,m,p,o,l);await T(e,g,u)},"writeJsonc");export{F as default};
@@ -0,0 +1,4 @@
1
+ var _=Object.defineProperty;var d=(e,t)=>_(e,"name",{value:t,configurable:!0});import{createRequire as b}from"node:module";import{C as j}from"./index-CYIVJA0W.js";import{R_OK as x}from"./F_OK-CAwY1qU7.js";import N from"./isAccessibleSync-5nzZWgin.js";import{b as O}from"./jsonc-merge-CQMjx3Vw.js";import T from"./writeFileSync-Cboe5Z4V.js";const y=b(import.meta.url),c=typeof globalThis<"u"&&typeof globalThis.process<"u"?globalThis.process:process,v=d(e=>{if(typeof c<"u"&&c.versions&&c.versions.node){const[t,n]=c.versions.node.split(".").map(Number);if(t>22||t===22&&n>=3||t===20&&n>=16)return c.getBuiltinModule(e)}return y(e)},"__cjs_getBuiltinModule"),{readFileSync:h}=v("node:fs");var w=Object.defineProperty,a=d((e,t)=>w(e,"name",{value:t,configurable:!0}),"d");const S=a((e,t,n)=>{let i,o=n,s=`
2
+ `;if(!N(e,x))return{indent:o,trailingNewline:s};try{if(i=h(e,"utf8"),t){const{indent:r}=j(i);r&&(o=r)}s=i.endsWith(`
3
+ `)?`
4
+ `:""}catch(r){if(r.code!=="ENOENT")throw r}return{existingText:i,indent:o,trailingNewline:s}},"readExistingSync"),P=a((e,t,n={})=>{const{detectIndent:i,formattingOptions:o,indent:s,preserveComments:r=!0,replacer:l,...u}={indent:" ",...n},{existingText:f,indent:m,trailingNewline:p}=S(e,i,s),g=O(f,t,r,m,p,o,l);T(e,g,u)},"writeJsoncSync");export{P as default};
@@ -0,0 +1 @@
1
+ var o=Object.defineProperty;var t=(r,e)=>o(r,"name",{value:e,configurable:!0});import{stringify as i}from"smol-toml";import f from"./writeFile-DUmg8P4m.js";var m=Object.defineProperty,n=t((r,e)=>m(r,"name",{value:e,configurable:!0}),"o");const p=n(async(r,e,a)=>{await f(r,i(e),a)},"writeToml");export{p as default};
@@ -0,0 +1 @@
1
+ var i=Object.defineProperty;var t=(r,e)=>i(r,"name",{value:e,configurable:!0});import{stringify as a}from"smol-toml";import n from"./writeFileSync-Cboe5Z4V.js";var f=Object.defineProperty,m=t((r,e)=>f(r,"name",{value:e,configurable:!0}),"i");const u=m((r,e,o)=>{n(r,a(e),o)},"writeTomlSync");export{u as default};
@@ -0,0 +1 @@
1
+ var p=Object.defineProperty;var n=(r,o)=>p(r,"name",{value:o,configurable:!0});import{stringify as l}from"yaml";import y from"./writeFile-DUmg8P4m.js";var m=Object.defineProperty,s=n((r,o)=>m(r,"name",{value:o,configurable:!0}),"a");async function u(r,o,e,i){let a,t,c;typeof e=="object"&&e!==null&&!Array.isArray(e)&&typeof e!="function"?(a=e,t=a.replacer,c=a.space):typeof i=="object"?(a=i,t=e,c=a.space):(t=e,c=i);const f=l(o,t,c??a);await y(r,f,a)}n(u,"c");s(u,"writeYaml");export{u as default};
@@ -0,0 +1 @@
1
+ var p=Object.defineProperty;var t=(o,a)=>p(o,"name",{value:a,configurable:!0});import{stringify as l}from"yaml";import y from"./writeFileSync-Cboe5Z4V.js";var u=Object.defineProperty,m=t((o,a)=>u(o,"name",{value:a,configurable:!0}),"a");function b(o,a,e,n){let r,c,f;typeof e=="object"&&e!==null&&!Array.isArray(e)&&typeof e!="function"?(r=e,c=r.replacer,f=r.space):typeof n=="object"?(r=n,c=e,f=r.space):(c=e,f=n);const i=l(a,c,f??r);y(o,i,r)}t(b,"c");m(b,"writeYamlSync");export{b as default};
package/dist/size.d.ts CHANGED
@@ -1,256 +1,256 @@
1
- import { Readable } from "node:stream";
2
- import { URL } from "node:url";
3
- import type { BrotliOptions, ZlibOptions } from "node:zlib";
1
+ import { Readable } from 'node:stream';
2
+ import { URL } from 'node:url';
3
+ import { BrotliOptions, ZlibOptions } from 'node:zlib';
4
4
  /**
5
- * Input type for size calculation functions.
6
- * Can be a Buffer, Readable stream, URL object, or string (file path or content).
7
- */
5
+ * Input type for size calculation functions.
6
+ * Can be a Buffer, Readable stream, URL object, or string (file path or content).
7
+ */
8
8
  type SizeInput = Buffer | Readable | URL | string;
9
9
  /**
10
- * Input type for synchronous size calculation functions.
11
- * Can be a Buffer, URL object, or string (file path or content).
12
- */
10
+ * Input type for synchronous size calculation functions.
11
+ * Can be a Buffer, URL object, or string (file path or content).
12
+ */
13
13
  type SizeInputSync = Buffer | URL | string;
14
14
  /**
15
- * Asynchronously calculates the gzipped size of the given input.
16
- * The input can be a Buffer, a Readable stream, a URL object pointing to a file, or a string (file path or content).
17
- * Uses memory-efficient streaming for files and streams to avoid loading entire contents into memory.
18
- * @param input The input data to gzip and measure.
19
- * @param [options] Optional Zlib options for gzip compression.
20
- * @returns A promise that resolves with the gzipped size in bytes.
21
- * @example
22
- * ```javascript
23
- * import { gzipSize } from "@visulima/fs";
24
- * import { Readable } from "node:stream";
25
- * import { writeFile, unlink } from "node:fs/promises";
26
- * import { join } from "node:path";
27
- *
28
- * const text = "Lorem ipsum dolor sit amet, consectetur adipiscing elit.";
29
- * const filePath = join("temp-file.txt");
30
- *
31
- * async function main() {
32
- * // From Buffer
33
- * const buffer = Buffer.from(text);
34
- * console.log(`Gzip size of buffer: ${await gzipSize(buffer)} bytes`);
35
- *
36
- * // From string (content)
37
- * console.log(`Gzip size of string content: ${await gzipSize(text)} bytes`);
38
- *
39
- * // From file path
40
- * await writeFile(filePath, text);
41
- * console.log(`Gzip size of file: ${await gzipSize(filePath)} bytes`);
42
- *
43
- * // From URL
44
- * const fileUrl = new URL(`file://${filePath}`);
45
- * console.log(`Gzip size of URL: ${await gzipSize(fileUrl)} bytes`);
46
- *
47
- * // From Readable stream
48
- * const stream = Readable.from(text);
49
- * console.log(`Gzip size of stream: ${await gzipSize(stream)} bytes`);
50
- *
51
- * await unlink(filePath); // Clean up temp file
52
- * }
53
- *
54
- * main().catch(console.error);
55
- * ```
56
- */
57
- export declare const gzipSize: (input: SizeInput, options?: ZlibOptions) => Promise<number>;
15
+ * Asynchronously calculates the gzipped size of the given input.
16
+ * The input can be a Buffer, a Readable stream, a URL object pointing to a file, or a string (file path or content).
17
+ * Uses memory-efficient streaming for files and streams to avoid loading entire contents into memory.
18
+ * @param input The input data to gzip and measure.
19
+ * @param [options] Optional Zlib options for gzip compression.
20
+ * @returns A promise that resolves with the gzipped size in bytes.
21
+ * @example
22
+ * ```javascript
23
+ * import { gzipSize } from "@visulima/fs";
24
+ * import { Readable } from "node:stream";
25
+ * import { writeFile, unlink } from "node:fs/promises";
26
+ * import { join } from "node:path";
27
+ *
28
+ * const text = "Lorem ipsum dolor sit amet, consectetur adipiscing elit.";
29
+ * const filePath = join("temp-file.txt");
30
+ *
31
+ * async function main() {
32
+ * // From Buffer
33
+ * const buffer = Buffer.from(text);
34
+ * console.log(`Gzip size of buffer: ${await gzipSize(buffer)} bytes`);
35
+ *
36
+ * // From string (content)
37
+ * console.log(`Gzip size of string content: ${await gzipSize(text)} bytes`);
38
+ *
39
+ * // From file path
40
+ * await writeFile(filePath, text);
41
+ * console.log(`Gzip size of file: ${await gzipSize(filePath)} bytes`);
42
+ *
43
+ * // From URL
44
+ * const fileUrl = new URL(`file://${filePath}`);
45
+ * console.log(`Gzip size of URL: ${await gzipSize(fileUrl)} bytes`);
46
+ *
47
+ * // From Readable stream
48
+ * const stream = Readable.from(text);
49
+ * console.log(`Gzip size of stream: ${await gzipSize(stream)} bytes`);
50
+ *
51
+ * await unlink(filePath); // Clean up temp file
52
+ * }
53
+ *
54
+ * main().catch(console.error);
55
+ * ```
56
+ */
57
+ declare const gzipSize: (input: SizeInput, options?: ZlibOptions) => Promise<number>;
58
58
  /**
59
- * Asynchronously calculates the Brotli compressed size of the given input.
60
- * The input can be a Buffer, a Readable stream, a URL object pointing to a file, or a string (file path or content).
61
- * Uses memory-efficient streaming for files and streams to avoid loading entire contents into memory.
62
- * @param input The input data to compress with Brotli and measure.
63
- * @param [options] Optional Zlib options for Brotli compression.
64
- * @returns A promise that resolves with the Brotli compressed size in bytes.
65
- * @example
66
- * ```javascript
67
- * import { brotliSize } from "@visulima/fs";
68
- * import { Readable } from "node:stream";
69
- * import { writeFile, unlink } from "node:fs/promises";
70
- * import { join } from "node:path";
71
- *
72
- * const text = "This is a test string for Brotli compression efficiency.";
73
- * const filePath = join("temp-brotli-file.txt");
74
- *
75
- * async function main() {
76
- * // From Buffer
77
- * const buffer = Buffer.from(text);
78
- * console.log(`Brotli size of buffer: ${await brotliSize(buffer)} bytes`);
79
- *
80
- * // From string (content)
81
- * console.log(`Brotli size of string content: ${await brotliSize(text)} bytes`);
82
- *
83
- * // From file path
84
- * await writeFile(filePath, text);
85
- * console.log(`Brotli size of file: ${await brotliSize(filePath)} bytes`);
86
- *
87
- * // From URL
88
- * const fileUrl = new URL(`file://${filePath}`);
89
- * console.log(`Brotli size of URL: ${await brotliSize(fileUrl)} bytes`);
90
- *
91
- * // From Readable stream
92
- * const stream = Readable.from(text);
93
- * console.log(`Brotli size of stream: ${await brotliSize(stream)} bytes`);
94
- *
95
- * await unlink(filePath); // Clean up temp file
96
- * }
97
- *
98
- * main().catch(console.error);
99
- * ```
100
- */
101
- export declare const brotliSize: (input: SizeInput, options?: BrotliOptions) => Promise<number>;
59
+ * Asynchronously calculates the Brotli compressed size of the given input.
60
+ * The input can be a Buffer, a Readable stream, a URL object pointing to a file, or a string (file path or content).
61
+ * Uses memory-efficient streaming for files and streams to avoid loading entire contents into memory.
62
+ * @param input The input data to compress with Brotli and measure.
63
+ * @param [options] Optional Zlib options for Brotli compression.
64
+ * @returns A promise that resolves with the Brotli compressed size in bytes.
65
+ * @example
66
+ * ```javascript
67
+ * import { brotliSize } from "@visulima/fs";
68
+ * import { Readable } from "node:stream";
69
+ * import { writeFile, unlink } from "node:fs/promises";
70
+ * import { join } from "node:path";
71
+ *
72
+ * const text = "This is a test string for Brotli compression efficiency.";
73
+ * const filePath = join("temp-brotli-file.txt");
74
+ *
75
+ * async function main() {
76
+ * // From Buffer
77
+ * const buffer = Buffer.from(text);
78
+ * console.log(`Brotli size of buffer: ${await brotliSize(buffer)} bytes`);
79
+ *
80
+ * // From string (content)
81
+ * console.log(`Brotli size of string content: ${await brotliSize(text)} bytes`);
82
+ *
83
+ * // From file path
84
+ * await writeFile(filePath, text);
85
+ * console.log(`Brotli size of file: ${await brotliSize(filePath)} bytes`);
86
+ *
87
+ * // From URL
88
+ * const fileUrl = new URL(`file://${filePath}`);
89
+ * console.log(`Brotli size of URL: ${await brotliSize(fileUrl)} bytes`);
90
+ *
91
+ * // From Readable stream
92
+ * const stream = Readable.from(text);
93
+ * console.log(`Brotli size of stream: ${await brotliSize(stream)} bytes`);
94
+ *
95
+ * await unlink(filePath); // Clean up temp file
96
+ * }
97
+ *
98
+ * main().catch(console.error);
99
+ * ```
100
+ */
101
+ declare const brotliSize: (input: SizeInput, options?: BrotliOptions) => Promise<number>;
102
102
  /**
103
- * Asynchronously calculates the raw (uncompressed) size of the given input.
104
- * The input can be a Buffer, a Readable stream, a URL object pointing to a file, or a string (file path or content).
105
- * Uses memory-efficient streaming for files and streams to avoid loading entire contents into memory.
106
- * @param input The input data to measure.
107
- * @returns A promise that resolves with the raw size in bytes.
108
- * @example
109
- * ```javascript
110
- * import { rawSize } from "@visulima/fs";
111
- * import { Readable } from "node:stream";
112
- * import { writeFile, unlink } from "node:fs/promises";
113
- * import { join } from "node:path";
114
- *
115
- * const text = "Hello, World!";
116
- * const filePath = join("temp-raw-file.txt");
117
- *
118
- * async function main() {
119
- * // From Buffer
120
- * const buffer = Buffer.from(text);
121
- * console.log(`Raw size of buffer: ${await rawSize(buffer)} bytes`);
122
- *
123
- * // From string (content)
124
- * console.log(`Raw size of string content: ${await rawSize(text)} bytes`);
125
- *
126
- * // From file path
127
- * await writeFile(filePath, text);
128
- * console.log(`Raw size of file: ${await rawSize(filePath)} bytes`);
129
- *
130
- * // From URL
131
- * const fileUrl = new URL(`file://${filePath}`);
132
- * console.log(`Raw size of URL: ${await rawSize(fileUrl)} bytes`);
133
- *
134
- * // From Readable stream
135
- * const stream = Readable.from(text);
136
- * console.log(`Raw size of stream: ${await rawSize(stream)} bytes`);
137
- *
138
- * await unlink(filePath); // Clean up temp file
139
- * }
140
- *
141
- * main().catch(console.error);
142
- * ```
143
- */
144
- export declare const rawSize: (input: SizeInput) => Promise<number>;
103
+ * Asynchronously calculates the raw (uncompressed) size of the given input.
104
+ * The input can be a Buffer, a Readable stream, a URL object pointing to a file, or a string (file path or content).
105
+ * Uses memory-efficient streaming for files and streams to avoid loading entire contents into memory.
106
+ * @param input The input data to measure.
107
+ * @returns A promise that resolves with the raw size in bytes.
108
+ * @example
109
+ * ```javascript
110
+ * import { rawSize } from "@visulima/fs";
111
+ * import { Readable } from "node:stream";
112
+ * import { writeFile, unlink } from "node:fs/promises";
113
+ * import { join } from "node:path";
114
+ *
115
+ * const text = "Hello, World!";
116
+ * const filePath = join("temp-raw-file.txt");
117
+ *
118
+ * async function main() {
119
+ * // From Buffer
120
+ * const buffer = Buffer.from(text);
121
+ * console.log(`Raw size of buffer: ${await rawSize(buffer)} bytes`);
122
+ *
123
+ * // From string (content)
124
+ * console.log(`Raw size of string content: ${await rawSize(text)} bytes`);
125
+ *
126
+ * // From file path
127
+ * await writeFile(filePath, text);
128
+ * console.log(`Raw size of file: ${await rawSize(filePath)} bytes`);
129
+ *
130
+ * // From URL
131
+ * const fileUrl = new URL(`file://${filePath}`);
132
+ * console.log(`Raw size of URL: ${await rawSize(fileUrl)} bytes`);
133
+ *
134
+ * // From Readable stream
135
+ * const stream = Readable.from(text);
136
+ * console.log(`Raw size of stream: ${await rawSize(stream)} bytes`);
137
+ *
138
+ * await unlink(filePath); // Clean up temp file
139
+ * }
140
+ *
141
+ * main().catch(console.error);
142
+ * ```
143
+ */
144
+ declare const rawSize: (input: SizeInput) => Promise<number>;
145
145
  /**
146
- * Synchronously calculates the gzipped size of the given input.
147
- * The input can be a Buffer, a URL object pointing to a file, or a string (file path or content).
148
- * Note: For Readable streams or very large files, consider using the asynchronous `gzipSize` function for better performance and to avoid blocking.
149
- * @param input The input data to gzip and measure.
150
- * @param [options] Optional Zlib options for gzip compression.
151
- * @returns The gzipped size in bytes.
152
- * @example
153
- * ```javascript
154
- * import { gzipSizeSync } from "@visulima/fs";
155
- * import { writeFileSync, unlinkSync } from "node:fs";
156
- * import { join } from "node:path";
157
- *
158
- * const text = "Lorem ipsum dolor sit amet, consectetur adipiscing elit.";
159
- * const filePath = join("temp-sync-file.txt");
160
- *
161
- * // From Buffer
162
- * const buffer = Buffer.from(text);
163
- * console.log(`Sync Gzip size of buffer: ${gzipSizeSync(buffer)} bytes`);
164
- *
165
- * // From string (content)
166
- * console.log(`Sync Gzip size of string content: ${gzipSizeSync(text)} bytes`);
167
- *
168
- * // From file path
169
- * try {
170
- * writeFileSync(filePath, text);
171
- * console.log(`Sync Gzip size of file: ${gzipSizeSync(filePath)} bytes`);
172
- *
173
- * // From URL
174
- * const fileUrl = new URL(`file://${filePath}`);
175
- * console.log(`Sync Gzip size of URL: ${gzipSizeSync(fileUrl)} bytes`);
176
- * } finally {
177
- * try { unlinkSync(filePath); } catch {} // Clean up temp file
178
- * }
179
- * ```
180
- */
181
- export declare const gzipSizeSync: (input: SizeInputSync, options?: ZlibOptions) => number;
146
+ * Synchronously calculates the gzipped size of the given input.
147
+ * The input can be a Buffer, a URL object pointing to a file, or a string (file path or content).
148
+ * Note: For Readable streams or very large files, consider using the asynchronous `gzipSize` function for better performance and to avoid blocking.
149
+ * @param input The input data to gzip and measure.
150
+ * @param [options] Optional Zlib options for gzip compression.
151
+ * @returns The gzipped size in bytes.
152
+ * @example
153
+ * ```javascript
154
+ * import { gzipSizeSync } from "@visulima/fs";
155
+ * import { writeFileSync, unlinkSync } from "node:fs";
156
+ * import { join } from "node:path";
157
+ *
158
+ * const text = "Lorem ipsum dolor sit amet, consectetur adipiscing elit.";
159
+ * const filePath = join("temp-sync-file.txt");
160
+ *
161
+ * // From Buffer
162
+ * const buffer = Buffer.from(text);
163
+ * console.log(`Sync Gzip size of buffer: ${gzipSizeSync(buffer)} bytes`);
164
+ *
165
+ * // From string (content)
166
+ * console.log(`Sync Gzip size of string content: ${gzipSizeSync(text)} bytes`);
167
+ *
168
+ * // From file path
169
+ * try {
170
+ * writeFileSync(filePath, text);
171
+ * console.log(`Sync Gzip size of file: ${gzipSizeSync(filePath)} bytes`);
172
+ *
173
+ * // From URL
174
+ * const fileUrl = new URL(`file://${filePath}`);
175
+ * console.log(`Sync Gzip size of URL: ${gzipSizeSync(fileUrl)} bytes`);
176
+ * } finally {
177
+ * try { unlinkSync(filePath); } catch {} // Clean up temp file
178
+ * }
179
+ * ```
180
+ */
181
+ declare const gzipSizeSync: (input: SizeInputSync, options?: ZlibOptions) => number;
182
182
  /**
183
- * Synchronously calculates the Brotli compressed size of the given input.
184
- * The input can be a Buffer, a URL object pointing to a file, or a string (file path or content).
185
- * Note: For Readable streams or very large files, consider using the asynchronous `brotliSize` function for better performance and to avoid blocking.
186
- * @param input The input data to compress with Brotli and measure.
187
- * @param [options] Optional Zlib options for Brotli compression.
188
- * @returns The Brotli compressed size in bytes.
189
- * @example
190
- * ```javascript
191
- * import { brotliSizeSync } from "@visulima/fs";
192
- * import { writeFileSync, unlinkSync } from "node:fs";
193
- * import { join } from "node:path";
194
- *
195
- * const text = "This is a test string for Brotli compression efficiency, synchronously.";
196
- * const filePath = join("temp-brotli-sync-file.txt");
197
- *
198
- * // From Buffer
199
- * const buffer = Buffer.from(text);
200
- * console.log(`Sync Brotli size of buffer: ${brotliSizeSync(buffer)} bytes`);
201
- *
202
- * // From string (content)
203
- * console.log(`Sync Brotli size of string content: ${brotliSizeSync(text)} bytes`);
204
- *
205
- * // From file path
206
- * try {
207
- * writeFileSync(filePath, text);
208
- * console.log(`Sync Brotli size of file: ${brotliSizeSync(filePath)} bytes`);
209
- *
210
- * // From URL
211
- * const fileUrl = new URL(`file://${filePath}`);
212
- * console.log(`Sync Brotli size of URL: ${brotliSizeSync(fileUrl)} bytes`);
213
- * } finally {
214
- * try { unlinkSync(filePath); } catch {} // Clean up temp file
215
- * }
216
- * ```
217
- */
218
- export declare const brotliSizeSync: (input: SizeInputSync, options?: BrotliOptions) => number;
183
+ * Synchronously calculates the Brotli compressed size of the given input.
184
+ * The input can be a Buffer, a URL object pointing to a file, or a string (file path or content).
185
+ * Note: For Readable streams or very large files, consider using the asynchronous `brotliSize` function for better performance and to avoid blocking.
186
+ * @param input The input data to compress with Brotli and measure.
187
+ * @param [options] Optional Zlib options for Brotli compression.
188
+ * @returns The Brotli compressed size in bytes.
189
+ * @example
190
+ * ```javascript
191
+ * import { brotliSizeSync } from "@visulima/fs";
192
+ * import { writeFileSync, unlinkSync } from "node:fs";
193
+ * import { join } from "node:path";
194
+ *
195
+ * const text = "This is a test string for Brotli compression efficiency, synchronously.";
196
+ * const filePath = join("temp-brotli-sync-file.txt");
197
+ *
198
+ * // From Buffer
199
+ * const buffer = Buffer.from(text);
200
+ * console.log(`Sync Brotli size of buffer: ${brotliSizeSync(buffer)} bytes`);
201
+ *
202
+ * // From string (content)
203
+ * console.log(`Sync Brotli size of string content: ${brotliSizeSync(text)} bytes`);
204
+ *
205
+ * // From file path
206
+ * try {
207
+ * writeFileSync(filePath, text);
208
+ * console.log(`Sync Brotli size of file: ${brotliSizeSync(filePath)} bytes`);
209
+ *
210
+ * // From URL
211
+ * const fileUrl = new URL(`file://${filePath}`);
212
+ * console.log(`Sync Brotli size of URL: ${brotliSizeSync(fileUrl)} bytes`);
213
+ * } finally {
214
+ * try { unlinkSync(filePath); } catch {} // Clean up temp file
215
+ * }
216
+ * ```
217
+ */
218
+ declare const brotliSizeSync: (input: SizeInputSync, options?: BrotliOptions) => number;
219
219
  /**
220
- * Synchronously calculates the raw (uncompressed) size of the given input.
221
- * The input can be a Buffer, a URL object pointing to a file, or a string (file path or content).
222
- * For file paths, it uses `statSync` to get the file size.
223
- * Note: For Readable streams or very large files, consider using the asynchronous `rawSize` function for better performance and to avoid blocking.
224
- * @param input The input data to measure.
225
- * @returns The raw size in bytes.
226
- * @example
227
- * ```javascript
228
- * import { rawSizeSync } from "@visulima/fs";
229
- * import { writeFileSync, unlinkSync } from "node:fs";
230
- * import { join } from "node:path";
231
- *
232
- * const text = "Hello, Synchronous World!";
233
- * const filePath = join("temp-raw-sync-file.txt");
234
- *
235
- * // From Buffer
236
- * const buffer = Buffer.from(text);
237
- * console.log(`Sync Raw size of buffer: ${rawSizeSync(buffer)} bytes`);
238
- *
239
- * // From string (content)
240
- * console.log(`Sync Raw size of string content: ${rawSizeSync(text)} bytes`);
241
- *
242
- * // From file path
243
- * try {
244
- * writeFileSync(filePath, text);
245
- * console.log(`Sync Raw size of file: ${rawSizeSync(filePath)} bytes`);
246
- *
247
- * // From URL
248
- * const fileUrl = new URL(`file://${filePath}`);
249
- * console.log(`Sync Raw size of URL: ${rawSizeSync(fileUrl)} bytes`);
250
- * } finally {
251
- * try { unlinkSync(filePath); } catch {} // Clean up temp file
252
- * }
253
- * ```
254
- */
255
- export declare const rawSizeSync: (input: SizeInputSync) => number;
256
- export {};
220
+ * Synchronously calculates the raw (uncompressed) size of the given input.
221
+ * The input can be a Buffer, a URL object pointing to a file, or a string (file path or content).
222
+ * For file paths, it uses `statSync` to get the file size.
223
+ * Note: For Readable streams or very large files, consider using the asynchronous `rawSize` function for better performance and to avoid blocking.
224
+ * @param input The input data to measure.
225
+ * @returns The raw size in bytes.
226
+ * @example
227
+ * ```javascript
228
+ * import { rawSizeSync } from "@visulima/fs";
229
+ * import { writeFileSync, unlinkSync } from "node:fs";
230
+ * import { join } from "node:path";
231
+ *
232
+ * const text = "Hello, Synchronous World!";
233
+ * const filePath = join("temp-raw-sync-file.txt");
234
+ *
235
+ * // From Buffer
236
+ * const buffer = Buffer.from(text);
237
+ * console.log(`Sync Raw size of buffer: ${rawSizeSync(buffer)} bytes`);
238
+ *
239
+ * // From string (content)
240
+ * console.log(`Sync Raw size of string content: ${rawSizeSync(text)} bytes`);
241
+ *
242
+ * // From file path
243
+ * try {
244
+ * writeFileSync(filePath, text);
245
+ * console.log(`Sync Raw size of file: ${rawSizeSync(filePath)} bytes`);
246
+ *
247
+ * // From URL
248
+ * const fileUrl = new URL(`file://${filePath}`);
249
+ * console.log(`Sync Raw size of URL: ${rawSizeSync(fileUrl)} bytes`);
250
+ * } finally {
251
+ * try { unlinkSync(filePath); } catch {} // Clean up temp file
252
+ * }
253
+ * ```
254
+ */
255
+ declare const rawSizeSync: (input: SizeInputSync) => number;
256
+ export { brotliSize, brotliSizeSync, gzipSize, gzipSizeSync, rawSize, rawSizeSync };