Socket
Socket
Sign inDemoInstall

@visulima/fs

Package Overview
Dependencies
Maintainers
1
Versions
48
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@visulima/fs - npm Package Compare versions

Comparing version 1.4.0 to 1.5.0

dist/chunk-4WZBYISP.js

13

CHANGELOG.md

@@ -0,1 +1,14 @@

## @visulima/fs [1.5.0](https://github.com/visulima/visulima/compare/@visulima/fs@1.4.0...@visulima/fs@1.5.0) (2024-03-14)
### Features
* **fs:** added findUp array support, based on the other the file will be found ([#343](https://github.com/visulima/visulima/issues/343)) ([4816318](https://github.com/visulima/visulima/commit/4816318770049c4d9a9cfa27c251449ce3077e8f))
* **fs:** added new toPath util ([d65cf3e](https://github.com/visulima/visulima/commit/d65cf3e2f53a4d81f927740050741d59bcccfc9f))
### Bug Fixes
* **fs:** fixed wrong return type on findUp ([f3c96de](https://github.com/visulima/visulima/commit/f3c96def18cd8e70093bdd943c2e2f396436dda4))
## @visulima/fs [1.4.0](https://github.com/visulima/visulima/compare/@visulima/fs@1.3.1...@visulima/fs@1.4.0) (2024-03-11)

@@ -2,0 +15,0 @@

4

dist/index.d.ts

@@ -10,5 +10,5 @@ import { W as WalkOptions, F as FindUpOptions, R as ReadFileOptions, C as ContentType, a as ReadJsonOptions, J as JsonReviver, b as WalkEntry, c as WriteFileOptions, d as WriteJsonOptions } from './types-9INKTu78.js';

declare const findUp: (name: string, options?: FindUpOptions) => Promise<string | undefined>;
declare const findUp: (name: string[] | string, options?: FindUpOptions) => Promise<string | undefined>;
declare const findUpSync: (name: string, options?: FindUpOptions) => string | undefined;
declare const findUpSync: (name: string[] | string, options?: FindUpOptions) => string | undefined;

@@ -15,0 +15,0 @@ declare function isAccessible(path: URL | string, mode?: number): Promise<boolean>;

@@ -1,20 +0,19 @@

import { a, b as b$1 } from './chunk-3EHZOWRU.js';
import { a as a$1 } from './chunk-7UNFLLNN.js';
import { a as a$1, b as b$1 } from './chunk-3EHZOWRU.js';
import { a, b as b$2 } from './chunk-4WZBYISP.js';
import './chunk-UPN3Y5W3.js';
import { readdir, realpath, stat, access, readFile, mkdir, writeFile, rename, chown, chmod, unlink } from 'node:fs/promises';
import { resolve, join, normalize, basename, parse, isAbsolute, dirname } from 'node:path';
import { fileURLToPath } from 'node:url';
import { readdirSync, realpathSync, statSync, accessSync, readFileSync, mkdirSync, writeFileSync, renameSync, chownSync, chmodSync, unlinkSync } from 'node:fs';
import { brotliDecompress, unzip, brotliDecompressSync, unzipSync } from 'node:zlib';
var z=e=>{if(!e||!(e instanceof URL)&&typeof e!="string")throw new TypeError("Path must be a non-empty string or URL.")},w=z;var K=e=>{let t=e.replace(/\.\*/g,".([^/]*)").replace(/\*\*/g,"(.*)").replace(/(?<!\.)\*(?!\*)/g,"([^/]*)").replace(/\?/g,"[^/]").replace(/\.(?!\*)/g,"\\.").replace(/\{/g,"(").replace(/\}/g,")").replace(/,/g,"|").replace(/\[!(.*?)\]/g,"[^$1]");return new RegExp(`^${t}$`)},S=K;var Y=e=>e instanceof URL?fileURLToPath(e):e,l=Y;var H=(e,t,r,i)=>t&&!t.some(n=>e.endsWith(n))||r&&!r.some(n=>n.test(e))?!1:!(i&&i.some(n=>n.test(e))),g=H;var re=async e=>{let t=normalize(e),r=basename(t),i=await stat(t);return {isDirectory:i.isDirectory,isFile:i.isFile,isSymbolicLink:i.isSymbolicLink,name:r,path:t}};async function*k(e,{extensions:t,followSymlinks:r=!1,includeDirs:i=!0,includeFiles:n=!0,includeSymlinks:s=!0,match:a$1,maxDepth:c=Number.POSITIVE_INFINITY,skip:m}={}){if(w(e),c<0)return;let f=a$1?a$1.map(o=>typeof o=="string"?S(o):o):void 0,u=m?m.map(o=>typeof o=="string"?S(o):o):void 0;if(e=resolve(l(e)),i&&g(e,t,f,u)&&(yield await re(e)),!(c<1||!g(e,void 0,void 0,u)))try{for await(let o of await readdir(e,{withFileTypes:!0})){let d=join(e,o.name);if(o.isSymbolicLink())if(r)d=await realpath(d);else if(s&&g(d,t,f,u))yield {isDirectory:o.isDirectory,isFile:o.isFile,isSymbolicLink:o.isSymbolicLink,name:o.name,path:d};else continue;o.isSymbolicLink()||o.isDirectory()?yield*k(d,{extensions:t,followSymlinks:r,includeDirs:i,includeFiles:n,includeSymlinks:s,match:f,maxDepth:c-1,skip:u}):o.isFile()&&n&&g(d,t,f,u)&&(yield {isDirectory:o.isDirectory,isFile:o.isFile,isSymbolicLink:o.isSymbolicLink,name:o.name,path:d});}}catch(o){throw o instanceof a?o:new a(o,e)}}var ie=async(e,t={})=>{let r={extensions:["js","mjs","cjs","ts"],...t},i=[];for await(let n of k(e,r))i.push(n.path);return i},oe=ie;var de=e=>{let t=normalize(e),r=basename(t),i=statSync(t);return {isDirectory:i.isDirectory,isFile:i.isFile,isSymbolicLink:i.isSymbolicLink,name:r,path:t}};function*h(e,{extensions:t,followSymlinks:r=!1,includeDirs:i=!0,includeFiles:n=!0,includeSymlinks:s=!0,match:a$1,maxDepth:c=Number.POSITIVE_INFINITY,skip:m}={}){if(w(e),c<0)return;let f=a$1?a$1.map(o=>typeof o=="string"?S(o):o):void 0,u=m?m.map(o=>typeof o=="string"?S(o):o):void 0;if(e=resolve(l(e)),i&&g(e,t,f,u)&&(yield de(e)),!(c<1||!g(e,void 0,void 0,u)))try{for(let o of readdirSync(e,{withFileTypes:!0})){let d=join(e,o.name);if(o.isSymbolicLink())if(r)d=realpathSync(d);else if(s&&g(d,t,f,u))yield {isDirectory:o.isDirectory,isFile:o.isFile,isSymbolicLink:o.isSymbolicLink,name:o.name,path:d};else continue;o.isSymbolicLink()||o.isDirectory()?yield*h(d,{extensions:t,followSymlinks:r,includeDirs:i,includeFiles:n,includeSymlinks:s,match:f,maxDepth:c-1,skip:u}):o.isFile()&&n&&g(d,t,f,u)&&(yield {isDirectory:o.isDirectory,isFile:o.isFile,isSymbolicLink:o.isSymbolicLink,name:o.name,path:d});}}catch(o){throw o instanceof a?o:new a(o,e)}}var pe=(e,t={})=>{let r={extensions:["js","mjs","cjs","ts"],...t},i=[];for(let n of h(e,r))i.push(n.path);return i},ye=pe;var Fe=async(e,t={})=>{let r=t.cwd?l(t.cwd):process.cwd();w(r);let i=resolve(r),{root:n}=parse(i),s=l(t.stopAt??n);w(s);let a=resolve(i,s),c=t.type??"file";for(;i&&i!==a&&i!==n;){let m=isAbsolute(e)?e:join(i,e);try{let f=await stat(m);if(c==="file"&&f.isFile()||c==="directory"&&f.isDirectory())return m}catch{}i=dirname(i);}},Se=Fe;var Pe=(e,t={})=>{let r=t.cwd?l(t.cwd):process.cwd();w(r);let i=resolve(r),{root:n}=parse(i),s=l(t.stopAt??n);w(s);let a=resolve(i,s),c=t.type??"file";for(;i&&i!==a&&i!==n;){let m=isAbsolute(e)?e:join(i,e);try{let f=statSync(m);if(c==="file"&&f.isFile()||c==="directory"&&f.isDirectory())return m}catch{}i=dirname(i);}},Te=Pe;async function Le(e,t=0){w(e),e=l(e);try{return await access(e,t),!0}catch{return !1}}var b=Le;function We(e,t=0){w(e),e=l(e);try{return accessSync(e,t),!0}catch{return !1}}var O=We;var ve={brotli:brotliDecompress,gzip:unzip,none:(e,t)=>{t(null,e);}},Ve=async(e,t)=>{if(w(e),e=l(e),!await b(e))throw new b$1(`unable to read the non-accessible file: ${e}`);if(!await b(e,4))throw new Error(`Unable to read the non-readable file: ${e}`);let{buffer:r,compression:i,encoding:n,flag:s}=t??{};return await readFile(e,s?{encoding:n,flag:s}:{encoding:n}).then(async a=>await new Promise((c,m)=>{ve[i??"none"](a,(f,u)=>{f?m(f):c(r?u:u.toString());});})).catch(a=>{throw a})},A=Ve;var _e={brotli:brotliDecompressSync,gzip:unzipSync,none:e=>e},Be=(e,t)=>{if(w(e),e=l(e),!O(e))throw new b$1(`unable to read the non-accessible file: ${e}`);if(!O(e,4))throw new b$1(`invalid access to read file at: ${e}`);let{buffer:r,compression:i,encoding:n,flag:s}=t??{},a=readFileSync(e,s?{encoding:n,flag:s}:{encoding:n}),c=_e[i??"none"](a);return r?c:c.toString()},I=Be;async function je(e,t,r){typeof t=="object"&&(r=t,t=void 0);let i=await A(e,{buffer:!0,encoding:void 0}),n=new TextDecoder().decode(i),{beforeParse:s,color:a}=r??{};return typeof s=="function"&&(n=s(n)),a$1(n,t,l(e),{color:a})}var ze=je;function Ke(e,t,r){typeof t=="object"&&(r=t,t=void 0);let i=I(e,{buffer:!0,encoding:void 0}),n=new TextDecoder().decode(i),{beforeParse:s,color:a}=r??{};return typeof s=="function"&&(n=s(n)),a$1(n,t,l(e),{color:a})}var Me=Ke;var Ye=e=>{if(typeof e!="string"&&!(e instanceof ArrayBuffer)&&!ArrayBuffer.isView(e))throw new TypeError("File contents must be a string, ArrayBuffer, or ArrayBuffer view.")},L=Ye;var He=new TextEncoder,Ge=e=>{if(e instanceof Uint8Array)return e;if(typeof e=="string")return He.encode(e);if(e instanceof ArrayBuffer)return new Uint8Array(e);if(ArrayBuffer.isView(e)){let t=e.buffer.slice(e.byteOffset,e.byteOffset+e.byteLength);return new Uint8Array(t)}throw new TypeError("Invalid contents type. Expected string or ArrayBuffer.")},U=Ge;var it=async(e,t,r)=>{r={encoding:"utf8",flag:"w",overwrite:!0,recursive:!0,...r},w(e),L(t),e=l(e);try{let i=await b(e,0);if(!i&&r.recursive){let a=dirname(e);await b(a,0)||await mkdir(a,{recursive:!0});}let n;await writeFile(`${e}.tmp`,U(t),{encoding:r.encoding,flag:r.flag}),i&&!r.overwrite&&(n=await stat(e),r.chown===void 0&&(r.chown={gid:n.gid,uid:n.uid}),await rename(e,`${e}.bak`));let s=`${e}.tmp`;if(r.chown)try{await chown(s,r.chown.uid,r.chown.gid);}catch{}await chmod(s,n&&!r.mode?n.mode:r.mode??438),await rename(s,e);}catch(i){throw new Error(`Failed to write file at: ${e} - ${i.message}`,{cause:i})}finally{await b(`${e}.tmp`)&&await unlink(`${e}.tmp`);}},D=it;var mt=(e,t,r)=>{r={encoding:"utf8",flag:"w",overwrite:!0,recursive:!0,...r},w(e),L(t),e=l(e);try{let i=O(e,0);if(!i&&r.recursive){let a=dirname(e);O(a,0)||mkdirSync(a,{recursive:!0});}let n;writeFileSync(`${e}.tmp`,U(t),{encoding:r.encoding,flag:r.flag}),i&&!r.overwrite&&(n=statSync(e),r.chown===void 0&&(r.chown={gid:n.gid,uid:n.uid}),renameSync(e,`${e}.bak`));let s=`${e}.tmp`;if(r.chown)try{chownSync(s,r.chown.uid,r.chown.gid);}catch{}chmodSync(s,n&&!r.mode?n.mode:r.mode??438),renameSync(s,e);}catch(i){throw new Error(`Failed to write file at: ${e} - ${i.message}`,{cause:i})}finally{O(`${e}.tmp`)&&unlinkSync(`${e}.tmp`);}},v=mt;var dt=/^(?:( )+|\t+)/,E="space",B="tab";function _(e,t){let r=new Map,i=0,n,s;for(let a of e.split(/\n/g)){if(!a)continue;let c,m,f,u,o,d=a.match(dt);if(d===null)i=0,n="";else {if(c=d[0].length,m=d[1]?E:B,t&&m===E&&c===1)continue;m!==n&&(i=0),n=m,f=1,u=0;let T=c-i;if(i=c,T===0)f=0,u=1;else {let j=T>0?T:-T;s=pt(m,j);}o=r.get(s),o=o===void 0?[1,0]:[o[0]+f,o[1]+u],r.set(s,o);}}return r}function pt(e,t){return (e===E?"s":"t")+String(t)}function yt(e){let r=e[0]==="s"?E:B,i=Number(e.slice(1));return {type:r,amount:i}}function ut(e){let t,r=0,i=0;for(let[n,[s,a]]of e)(s>r||s===r&&a>i)&&(r=s,i=a,t=n);return t}function wt(e,t){return (e===E?" ":" ").repeat(t)}function P(e){if(typeof e!="string")throw new TypeError("Expected a string");let t=_(e,!0);t.size===0&&(t=_(e,!1));let r=ut(t),i,n=0,s="";return r!==void 0&&({type:i,amount:n}=yt(r),s=wt(i,n)),{amount:n,type:i,indent:s}}var bt=async(e,t,r={})=>{let{detectIndent:i,indent:n,replacer:s,stringify:a=JSON.stringify,...c}={indent:" ",...r},m=n,f=`
`;if(await b(e,4))try{let o=await readFile(e,"utf8");if(i){let{indent:d}=P(o);m=d;}f=o.endsWith(`
var z=e=>{if(!e||!(e instanceof URL)&&typeof e!="string")throw new TypeError("Path must be a non-empty string or URL.")},g=z;var K=e=>{let t=e.replace(/\.\*/g,".([^/]*)").replace(/\*\*/g,"(.*)").replace(/(?<!\.)\*(?!\*)/g,"([^/]*)").replace(/\?/g,"[^/]").replace(/\.(?!\*)/g,"\\.").replace(/\{/g,"(").replace(/\}/g,")").replace(/,/g,"|").replace(/\[!(.*?)\]/g,"[^$1]");return new RegExp(`^${t}$`)},S=K;var M=(e,t,r,i)=>t&&!t.some(n=>e.endsWith(n))||r&&!r.some(n=>n.test(e))?!1:!(i&&i.some(n=>n.test(e))),w=M;var ee=async e=>{let t=normalize(e),r=basename(t),i=await stat(t);return {isDirectory:i.isDirectory,isFile:i.isFile,isSymbolicLink:i.isSymbolicLink,name:r,path:t}};async function*k(e,{extensions:t,followSymlinks:r=!1,includeDirs:i=!0,includeFiles:n=!0,includeSymlinks:s=!0,match:a$2,maxDepth:l=Number.POSITIVE_INFINITY,skip:d}={}){if(g(e),l<0)return;let f=a$2?a$2.map(o=>typeof o=="string"?S(o):o):void 0,c=d?d.map(o=>typeof o=="string"?S(o):o):void 0;if(e=resolve(a(e)),i&&w(e,t,f,c)&&(yield await ee(e)),!(l<1||!w(e,void 0,void 0,c)))try{for await(let o of await readdir(e,{withFileTypes:!0})){let p=join(e,o.name);if(o.isSymbolicLink())if(r)p=await realpath(p);else if(s&&w(p,t,f,c))yield {isDirectory:o.isDirectory,isFile:o.isFile,isSymbolicLink:o.isSymbolicLink,name:o.name,path:p};else continue;o.isSymbolicLink()||o.isDirectory()?yield*k(p,{extensions:t,followSymlinks:r,includeDirs:i,includeFiles:n,includeSymlinks:s,match:f,maxDepth:l-1,skip:c}):o.isFile()&&n&&w(p,t,f,c)&&(yield {isDirectory:o.isDirectory,isFile:o.isFile,isSymbolicLink:o.isSymbolicLink,name:o.name,path:p});}}catch(o){throw o instanceof a$1?o:new a$1(o,e)}}var te=async(e,t={})=>{let r={extensions:["js","mjs","cjs","ts"],...t},i=[];for await(let n of k(e,r))i.push(n.path);return i},re=te;var le=e=>{let t=normalize(e),r=basename(t),i=statSync(t);return {isDirectory:i.isDirectory,isFile:i.isFile,isSymbolicLink:i.isSymbolicLink,name:r,path:t}};function*R(e,{extensions:t,followSymlinks:r=!1,includeDirs:i=!0,includeFiles:n=!0,includeSymlinks:s=!0,match:a$2,maxDepth:l=Number.POSITIVE_INFINITY,skip:d}={}){if(g(e),l<0)return;let f=a$2?a$2.map(o=>typeof o=="string"?S(o):o):void 0,c=d?d.map(o=>typeof o=="string"?S(o):o):void 0;if(e=resolve(a(e)),i&&w(e,t,f,c)&&(yield le(e)),!(l<1||!w(e,void 0,void 0,c)))try{for(let o of readdirSync(e,{withFileTypes:!0})){let p=join(e,o.name);if(o.isSymbolicLink())if(r)p=realpathSync(p);else if(s&&w(p,t,f,c))yield {isDirectory:o.isDirectory,isFile:o.isFile,isSymbolicLink:o.isSymbolicLink,name:o.name,path:p};else continue;o.isSymbolicLink()||o.isDirectory()?yield*R(p,{extensions:t,followSymlinks:r,includeDirs:i,includeFiles:n,includeSymlinks:s,match:f,maxDepth:l-1,skip:c}):o.isFile()&&n&&w(p,t,f,c)&&(yield {isDirectory:o.isDirectory,isFile:o.isFile,isSymbolicLink:o.isSymbolicLink,name:o.name,path:p});}}catch(o){throw o instanceof a$1?o:new a$1(o,e)}}var me=(e,t={})=>{let r={extensions:["js","mjs","cjs","ts"],...t},i=[];for(let n of R(e,r))i.push(n.path);return i},de=me;var we=async(e,t={})=>{if(typeof e!="string"&&!Array.isArray(e))throw new TypeError("The `name` argument must be of type `string` or `string[]`");let r=t.cwd?a(t.cwd):process.cwd();g(r);let i=resolve(r),{root:n}=parse(i),s=a(t.stopAt??n);g(s);let a$1=resolve(i,s),l=t.type??"file",d=typeof e=="string"?[e]:e;for(;i&&i!==a$1&&i!==n;){for await(let f of d){let c=isAbsolute(f)?f:resolve(i,f);try{let o=await stat(c);if(l==="file"&&o.isFile()||l==="directory"&&o.isDirectory())return c}catch{}}i=dirname(i);}},be=we;var ke=(e,t={})=>{if(typeof e!="string"&&!Array.isArray(e))throw new TypeError("The `name` argument must be of type `string` or `string[]`");let r=t.cwd?a(t.cwd):process.cwd();g(r);let i=resolve(r),{root:n}=parse(i),s=a(t.stopAt??n);g(s);let a$1=resolve(i,s),l=t.type??"file",d=typeof e=="string"?[e]:e;for(;i&&i!==a$1&&i!==n;){for(let f of d){let c=isAbsolute(f)?f:resolve(i,f);try{let o=statSync(c);if(l==="file"&&o.isFile()||l==="directory"&&o.isDirectory())return c}catch{}}i=dirname(i);}},Re=ke;async function Ee(e,t=0){g(e),e=a(e);try{return await access(e,t),!0}catch{return !1}}var b=Ee;function Pe(e,t=0){g(e),e=a(e);try{return accessSync(e,t),!0}catch{return !1}}var O=Pe;var Le={brotli:brotliDecompress,gzip:unzip,none:(e,t)=>{t(null,e);}},Ue=async(e,t)=>{if(g(e),e=a(e),!await b(e))throw new b$1(`unable to read the non-accessible file: ${e}`);if(!await b(e,4))throw new Error(`Unable to read the non-readable file: ${e}`);let{buffer:r,compression:i,encoding:n,flag:s}=t??{};return await readFile(e,s?{encoding:n,flag:s}:{encoding:n}).then(async a=>await new Promise((l,d)=>{Le[i??"none"](a,(f,c)=>{f?d(f):l(r?c:c.toString());});})).catch(a=>{throw a})},D=Ue;var Ve={brotli:brotliDecompressSync,gzip:unzipSync,none:e=>e},$e=(e,t)=>{if(g(e),e=a(e),!O(e))throw new b$1(`unable to read the non-accessible file: ${e}`);if(!O(e,4))throw new b$1(`invalid access to read file at: ${e}`);let{buffer:r,compression:i,encoding:n,flag:s}=t??{},a$1=readFileSync(e,s?{encoding:n,flag:s}:{encoding:n}),l=Ve[i??"none"](a$1);return r?l:l.toString()},v=$e;async function Ne(e,t,r){typeof t=="object"&&(r=t,t=void 0);let i=await D(e,{buffer:!0,encoding:void 0}),n=new TextDecoder().decode(i),{beforeParse:s,color:a$1}=r??{};return typeof s=="function"&&(n=s(n)),b$2(n,t,a(e),{color:a$1})}var Ce=Ne;function _e(e,t,r){typeof t=="object"&&(r=t,t=void 0);let i=v(e,{buffer:!0,encoding:void 0}),n=new TextDecoder().decode(i),{beforeParse:s,color:a$1}=r??{};return typeof s=="function"&&(n=s(n)),b$2(n,t,a(e),{color:a$1})}var Be=_e;var je=e=>{if(typeof e!="string"&&!(e instanceof ArrayBuffer)&&!ArrayBuffer.isView(e))throw new TypeError("File contents must be a string, ArrayBuffer, or ArrayBuffer view.")},A=je;var ze=new TextEncoder,Ke=e=>{if(e instanceof Uint8Array)return e;if(typeof e=="string")return ze.encode(e);if(e instanceof ArrayBuffer)return new Uint8Array(e);if(ArrayBuffer.isView(e)){let t=e.buffer.slice(e.byteOffset,e.byteOffset+e.byteLength);return new Uint8Array(t)}throw new TypeError("Invalid contents type. Expected string or ArrayBuffer.")},W=Ke;var Ze=async(e,t,r)=>{r={encoding:"utf8",flag:"w",overwrite:!0,recursive:!0,...r},g(e),A(t),e=a(e);try{let i=await b(e,0);if(!i&&r.recursive){let a=dirname(e);await b(a,0)||await mkdir(a,{recursive:!0});}let n;await writeFile(`${e}.tmp`,W(t),{encoding:r.encoding,flag:r.flag}),i&&!r.overwrite&&(n=await stat(e),r.chown===void 0&&(r.chown={gid:n.gid,uid:n.uid}),await rename(e,`${e}.bak`));let s=`${e}.tmp`;if(r.chown)try{await chown(s,r.chown.uid,r.chown.gid);}catch{}await chmod(s,n&&!r.mode?n.mode:r.mode??438),await rename(s,e);}catch(i){throw new Error(`Failed to write file at: ${e} - ${i.message}`,{cause:i})}finally{await b(`${e}.tmp`)&&await unlink(`${e}.tmp`);}},V=Ze;var at=(e,t,r)=>{r={encoding:"utf8",flag:"w",overwrite:!0,recursive:!0,...r},g(e),A(t),e=a(e);try{let i=O(e,0);if(!i&&r.recursive){let a=dirname(e);O(a,0)||mkdirSync(a,{recursive:!0});}let n;writeFileSync(`${e}.tmp`,W(t),{encoding:r.encoding,flag:r.flag}),i&&!r.overwrite&&(n=statSync(e),r.chown===void 0&&(r.chown={gid:n.gid,uid:n.uid}),renameSync(e,`${e}.bak`));let s=`${e}.tmp`;if(r.chown)try{chownSync(s,r.chown.uid,r.chown.gid);}catch{}chmodSync(s,n&&!r.mode?n.mode:r.mode??438),renameSync(s,e);}catch(i){throw new Error(`Failed to write file at: ${e} - ${i.message}`,{cause:i})}finally{O(`${e}.tmp`)&&unlinkSync(`${e}.tmp`);}},$=at;var ft=/^(?:( )+|\t+)/,E="space",B="tab";function _(e,t){let r=new Map,i=0,n,s;for(let a of e.split(/\n/g)){if(!a)continue;let l,d,f,c,o,p=a.match(ft);if(p===null)i=0,n="";else {if(l=p[0].length,d=p[1]?E:B,t&&d===E&&l===1)continue;d!==n&&(i=0),n=d,f=1,c=0;let P=l-i;if(i=l,P===0)f=0,c=1;else {let j=P>0?P:-P;s=ct(d,j);}o=r.get(s),o=o===void 0?[1,0]:[o[0]+f,o[1]+c],r.set(s,o);}}return r}function ct(e,t){return (e===E?"s":"t")+String(t)}function lt(e){let r=e[0]==="s"?E:B,i=Number(e.slice(1));return {type:r,amount:i}}function mt(e){let t,r=0,i=0;for(let[n,[s,a]]of e)(s>r||s===r&&a>i)&&(r=s,i=a,t=n);return t}function dt(e,t){return (e===E?" ":" ").repeat(t)}function T(e){if(typeof e!="string")throw new TypeError("Expected a string");let t=_(e,!0);t.size===0&&(t=_(e,!1));let r=mt(t),i,n=0,s="";return r!==void 0&&({type:i,amount:n}=lt(r),s=dt(i,n)),{amount:n,type:i,indent:s}}var yt=async(e,t,r={})=>{let{detectIndent:i,indent:n,replacer:s,stringify:a=JSON.stringify,...l}={indent:" ",...r},d=n,f=`
`;if(await b(e,4))try{let o=await readFile(e,"utf8");if(i){let{indent:p}=T(o);d=p;}f=o.endsWith(`
`)?`
`:"";}catch(o){if(o.code!=="ENOENT")throw o}let u=a(t,s,m);await D(e,`${u}${f}`,c);},Ot=bt;var St=(e,t,r={})=>{let{detectIndent:i,indent:n,replacer:s,stringify:a=JSON.stringify,...c}={indent:" ",...r},m=n,f=`
`;if(O(e,4))try{let o=readFileSync(e,"utf8");if(i){let{indent:d}=P(o);m=d;}f=o.endsWith(`
`:"";}catch(o){if(o.code!=="ENOENT")throw o}let c=a(t,s,d);await V(e,`${c}${f}`,l);},ut=yt;var wt=(e,t,r={})=>{let{detectIndent:i,indent:n,replacer:s,stringify:a=JSON.stringify,...l}={indent:" ",...r},d=n,f=`
`;if(O(e,4))try{let o=readFileSync(e,"utf8");if(i){let{indent:p}=T(o);d=p;}f=o.endsWith(`
`)?`
`:"";}catch(o){if(o.code!=="ENOENT")throw o}let u=a(t,s,m);v(e,`${u}${f}`,c);},Rt=St;
`:"";}catch(o){if(o.code!=="ENOENT")throw o}let c=a(t,s,d);$(e,`${c}${f}`,l);},bt=wt;
export { oe as collect, ye as collectSync, Se as findUp, Te as findUpSync, b as isAccessible, O as isAccessibleSync, A as readFile, I as readFileSync, ze as readJson, Me as readJsonSync, k as walk, h as walkSync, D as writeFile, v as writeFileSync, Ot as writeJson, Rt as writeJsonSync };
export { re as collect, de as collectSync, be as findUp, Re as findUpSync, b as isAccessible, O as isAccessibleSync, D as readFile, v as readFileSync, Ce as readJson, Be as readJsonSync, k as walk, R as walkSync, V as writeFile, $ as writeFileSync, ut as writeJson, bt as writeJsonSync };
//# sourceMappingURL=out.js.map
//# sourceMappingURL=index.js.map

@@ -13,2 +13,4 @@ export { J as JSONError } from './json-error-UVjLdb7z.js';

export { parseJson, stripJsonComments };
declare const toPath: (urlOrPath: URL | string) => string;
export { parseJson, stripJsonComments, toPath };

@@ -1,8 +0,8 @@

export { a as parseJson } from './chunk-7UNFLLNN.js';
export { b as parseJson, a as toPath } from './chunk-4WZBYISP.js';
export { a as JSONError } from './chunk-UPN3Y5W3.js';
var f=(e,{whitespace:t=!0}={})=>e.replace(l,r=>r.startsWith('"')||r[1]==="*"&&!r.endsWith("*/")?r:t?r.replaceAll(/\S/g," "):""),l=/"(?:[^"\\]|\\.)*"?|\/\/[^\r\n]*|\/\*(?:[^*]|\*[^/])*(?:\*\/)?/g,a=f;
var f=(t,{whitespace:e=!0}={})=>t.replace(l,r=>r.startsWith('"')||r[1]==="*"&&!r.endsWith("*/")?r:e?r.replaceAll(/\S/g," "):""),l=/"(?:[^"\\]|\\.)*"?|\/\/[^\r\n]*|\/\*(?:[^*]|\*[^/])*(?:\*\/)?/g,u=f;
export { a as stripJsonComments };
export { u as stripJsonComments };
//# sourceMappingURL=out.js.map
//# sourceMappingURL=utils.js.map
{
"name": "@visulima/fs",
"version": "1.4.0",
"version": "1.5.0",
"description": "Human friendly file system utilities for Node.js",

@@ -5,0 +5,0 @@ "keywords": [

@@ -194,5 +194,6 @@ <div align="center">

Type: `string`
Type: `string | string[]`
The name of the file or directory to find.
> If an array is specified, the first item that exists will be returned.

@@ -199,0 +200,0 @@ #### options

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc