@rob.hameetman/eslint-plugin 1.1.8 → 1.1.9

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.
@@ -1 +0,0 @@
1
- import{fileURLToPath as t}from"url";import{dirname as e}from"path";import r from"node:path";import s from"node:fs/promises";import{fileURLToPath as t}from"node:url";const i=new TextDecoder,o=new TextEncoder;class n extends Error{constructor(t){super(`Method "${t}" does not exist on impl.`)}}class a extends Error{constructor(t){super(`Method "${t}" is not supported on this impl.`)}}class l extends Error{constructor(){super("Implementation already set.")}}function c(t){if(!t||!(t instanceof URL)&&"string"!=typeof t)throw new TypeError("Path must be a non-empty string or URL.")}function h(t){if(!("string"==typeof t||t instanceof ArrayBuffer||ArrayBuffer.isView(t)))throw new TypeError("File contents must be a string, ArrayBuffer, or ArrayBuffer view.")}function p(t){if(t instanceof Uint8Array)return t;if("string"==typeof t)return o.encode(t);if(t instanceof ArrayBuffer)return new Uint8Array(t);if(ArrayBuffer.isView(t)){const e=t.buffer.slice(t.byteOffset,t.byteOffset+t.byteLength);return new Uint8Array(e)}throw new TypeError("Invalid contents type. Expected string or ArrayBuffer.")}class m{type;data;timestamp=Date.now();constructor(t,e){this.type=t,this.data=e}}class f{#t;#e;#r=new Map;constructor({impl:t}){this.#t=t,this.#e=t}#s(t,...e){for(const r of this.#r.values())r.push(new m("call",{methodName:t,args:e}))}logStart(t){if(!t||"string"!=typeof t)throw new TypeError("Log name must be a non-empty string.");if(this.#r.has(t))throw new Error(`Log "${t}" already exists.`);this.#r.set(t,[])}logEnd(t){if(this.#r.has(t)){const e=this.#r.get(t);return this.#r.delete(t),e}throw new Error(`Log "${t}" does not exist.`)}isBaseImpl(){return this.#e===this.#t}setImpl(t){if(this.#s("implSet",t),this.#e!==this.#t)throw new l;this.#e=t}resetImpl(){this.#s("implReset"),this.#e=this.#t}#i(t){if("function"!=typeof this.#e[t])throw new n(t)}#o(t,e){if("function"!=typeof this.#e[t])throw new a(e)}#n(t,...e){return this.#s(t,...e),this.#i(t),this.#e[t](...e)}#a(t,...e){return this.#i(t),this.#e[t](...e)}#l(t,e,...r){return this.#s(e,...r),this.#o(t,e),this.#e[t](...r)}async text(t){c(t);const e=await this.#l("bytes","text",t);return e?i.decode(e):void 0}async json(t){c(t);const e=await this.#l("bytes","json",t);return e?JSON.parse(i.decode(e)):void 0}async arrayBuffer(t){c(t);const e=await this.#l("bytes","arrayBuffer",t);return e?.buffer}async bytes(t){return c(t),this.#n("bytes",t)}async write(t,e){c(t),h(e),this.#s("write",t,e);let r=p(e);return this.#a("write",t,r)}async append(t,e){c(t),h(e),this.#s("append",t,e);let r=p(e);return this.#a("append",t,r)}async isFile(t){return c(t),this.#n("isFile",t)}async isDirectory(t){return c(t),this.#n("isDirectory",t)}async createDirectory(t){return c(t),this.#n("createDirectory",t)}async delete(t){return c(t),this.#n("delete",t)}async deleteAll(t){return c(t),this.#n("deleteAll",t)}async*list(t){c(t),yield*await this.#n("list",t)}async*walk(t,{directoryFilter:e=(()=>!0),entryFilter:r=(()=>!0)}={}){c(t),this.#s("walk",t,{directoryFilter:e,entryFilter:r});const s=async function*(t,{directoryFilter:e,entryFilter:r,parentPath:i="",depth:o=1}){let n;try{n=await this.#a("list",t)}catch(t){if("ENOENT"===t.code)return;throw t}for await(const a of n){const n={path:a.name,depth:o,...a};i&&(n.path=`${i}/${n.path}`);let l=r(n);if(l.then&&(l=await l),l&&(yield n),a.isDirectory){let i=e(n);if(i.then&&(i=await i),!i)continue;const l=t instanceof URL?new URL(a.name,t.href.endsWith("/")?t.href:`${t.href}/`):`${t.endsWith("/")?t:`${t}/`}${a.name}`;yield*s(l,{directoryFilter:e,entryFilter:r,parentPath:n.path,depth:o+1})}}}.bind(this);yield*s(t,{directoryFilter:e,entryFilter:r})}async size(t){return c(t),this.#n("size",t)}async lastModified(t){return c(t),this.#n("lastModified",t)}async copy(t,e){return c(t),c(e),this.#n("copy",t,e)}async copyAll(t,e){return c(t),c(e),this.#n("copyAll",t,e)}async move(t,e){return c(t),c(e),this.#n("move",t,e)}async moveAll(t,e){return c(t),c(e),this.#n("moveAll",t,e)}}class u{id=Math.random().toString(36).slice(2);fn;error;timestamp=Date.now();lastAttempt=this.timestamp;resolve;reject;signal;constructor(t,e,r,s,i){this.fn=t,this.error=e,this.timestamp=Date.now(),this.lastAttempt=Date.now(),this.resolve=r,this.reject=s,this.signal=i}get age(){return Date.now()-this.timestamp}}class d{#c=[];#h;#p;#m;#f;constructor(t,{timeout:e=6e4,maxDelay:r=100}={}){if("function"!=typeof t)throw new Error("Missing function to check errors");this.#f=t,this.#h=e,this.#p=r}retry(t,{signal:e}={}){let r;e?.throwIfAborted();try{r=t()}catch(t){return Promise.reject(new Error(`Synchronous error: ${t.message}`,{cause:t}))}return r&&"function"==typeof r.then?Promise.resolve(r).catch((r=>{if(!this.#f(r))throw r;return new Promise(((s,i)=>{this.#c.push(new u(t,r,s,i,e)),e?.addEventListener("abort",(()=>{i(e.reason)})),this.#u()}))})):Promise.reject(new Error("Result is not a promise."))}#u(){clearTimeout(this.#m),this.#m=void 0;const t=this.#c.shift();if(!t)return;const e=()=>{this.#m=setTimeout((()=>this.#u()),0)};return function(t,e){return t.age>e}(t,this.#h)?(t.reject(t.error),void e()):function(t,e){const r=Date.now()-t.lastAttempt,s=Math.max(t.lastAttempt-t.timestamp,1);return r>=Math.min(1.2*s,e)}(t,this.#p)?(t.lastAttempt=Date.now(),void Promise.resolve(t.fn()).then((e=>t.resolve(e))).catch((e=>{this.#f(e)?(t.lastAttempt=Date.now(),this.#c.push(t)):t.reject(e)})).finally((()=>this.#u()))):(this.#c.push(t),void e())}}const y=new Set(["ENFILE","EMFILE"]);class w{name;isFile;isDirectory;isSymlink;constructor(t){this.name=t.name,this.isFile=t.isFile(),this.isDirectory=t.isDirectory(),this.isSymlink=t.isSymbolicLink()}}class I{#d;#y;constructor({fsp:t=s}={}){this.#d=t,this.#y=new d((t=>y.has(t.code)))}bytes(t){return this.#y.retry((()=>this.#d.readFile(t))).then((t=>new Uint8Array(t.buffer))).catch((t=>{if("ENOENT"!==t.code)throw t}))}async write(e,s){const i=Buffer.from(s);return this.#y.retry((()=>this.#d.writeFile(e,i))).catch((s=>{if("ENOENT"===s.code){const s=r.dirname(e instanceof URL?t(e):e);return this.#d.mkdir(s,{recursive:!0}).then((()=>this.#d.writeFile(e,i)))}throw s}))}async append(e,s){const i=Buffer.from(s);return this.#y.retry((()=>this.#d.appendFile(e,i))).catch((s=>{if("ENOENT"===s.code){const s=r.dirname(e instanceof URL?t(e):e);return this.#d.mkdir(s,{recursive:!0}).then((()=>this.#d.appendFile(e,i)))}throw s}))}isFile(t){return this.#d.stat(t).then((t=>t.isFile())).catch((t=>{if("ENOENT"===t.code)return!1;throw t}))}isDirectory(t){return this.#d.stat(t).then((t=>t.isDirectory())).catch((t=>{if("ENOENT"===t.code)return!1;throw t}))}async createDirectory(t){await this.#d.mkdir(t,{recursive:!0})}delete(t){return this.#d.rm(t).then((()=>!0)).catch((e=>{if("ERR_FS_EISDIR"===e.code)return this.#d.rmdir(t).then((()=>!0));if("ENOENT"===e.code)return!1;throw e}))}deleteAll(t){return this.#d.rm(t,{recursive:!0}).then((()=>!0)).catch((t=>{if("ENOENT"===t.code)return!1;throw t}))}async*list(t){const e=await this.#d.readdir(t,{withFileTypes:!0});for(const t of e)yield new w(t)}size(t){return this.#d.stat(t).then((t=>t.size)).catch((t=>{if("ENOENT"!==t.code)throw t}))}lastModified(t){return this.#d.stat(t).then((t=>t.mtime)).catch((t=>{if("ENOENT"!==t.code)throw t}))}copy(t,e){return this.#d.copyFile(t,e)}async copyAll(e,s){if(await this.isFile(e))return this.copy(e,s);const i=e instanceof URL?t(e):e,o=s instanceof URL?t(s):s;await this.createDirectory(s);for await(const t of this.list(e)){const e=r.join(i,t.name),s=r.join(o,t.name);t.isDirectory?await this.copyAll(e,s):await this.copy(e,s)}}move(t,e){return this.#d.stat(t).then((r=>{if(r.isDirectory())throw new Error(`EISDIR: illegal operation on a directory, move '${t}' -> '${e}'`);return this.#d.rename(t,e)}))}async moveAll(t,e){return this.#d.rename(t,e)}}class g extends f{constructor({fsp:t}={}){super({impl:new I({fsp:t})})}}const E=new g;export{f as Hfs,g as NodeHfs,I as NodeHfsImpl,E as hfs};
@@ -1 +0,0 @@
1
- import{fileURLToPath as r}from"url";import{dirname as o}from"path";import{g as t,r as e}from"./index-B0aKcQEr.js";var a=t(e()),m=Object.freeze({__proto__:null,default:a});export{m as t};