commitsmile
Version:
Make smile on your commits
2 lines • 1.67 kB
JavaScript
import {createRequire}from'node:module';import {b as b$1,k as k$1}from'./chunk-G5RJVSXQ.mjs';createRequire(import.meta.url);
function g(t,n){let e=new Map,o=0,r,i;for(let c of t.split(/\n/g)){if(!c)continue;let f,u,l,d,s,m=c.match(x);if(m===null)o=0,r="";else {if(f=m[0].length,u=m[1]?a:h,n&&u===a&&f===1)continue;u!==r&&(o=0),r=u,l=1,d=0;let p=f-o;if(o=f,p===0)l=0,d=1;else {let w=p>0?p:-p;i=S(u,w);}s=e.get(i),s=s===void 0?[1,0]:[s[0]+l,s[1]+d],e.set(i,s);}}return e}function S(t,n){return (t===a?"s":"t")+String(n)}function _(t){let n=t[0]==="s"?a:h,e=Number(t.slice(1));return {type:n,amount:e}}function j(t){let n,e=0,o=0;for(let[r,[i,c]]of t)(i>e||i===e&&c>o)&&(e=i,o=c,n=r);return n}function E(t,n){return (t===a?" ":" ").repeat(n)}function z(t){if(typeof t!="string")throw new TypeError("Expected a string");let n=g(t,!0);n.size===0&&(n=g(t,!1));let e=j(n),o,r=0,i="";return e!==void 0&&({type:o,amount:r}=_(e),i=E(o,r)),{amount:r,type:o,indent:i}}function T(t,n={}){let e=n.indent===void 0&&n.preserveIndentation!==!1&&t.slice(0,n?.sampleSize||1024),o=n.preserveWhitespace===!1?void 0:{start:I.exec(t)?.[0]||"",end:N.exec(t)?.[0]||""};return {sample:e,whiteSpace:o}}function O(t,n,e){!n||typeof n!="object"||Object.defineProperty(n,b,{enumerable:!1,configurable:!0,writable:!0,value:T(t,e)});}function P(t,n){if(!t||typeof t!="object"||!(b in t))return {indent:n?.indent,whitespace:{start:"",end:""}};let e=t[b];return {indent:n?.indent||z(e.sample||"").indent,whitespace:e.whiteSpace||{start:"",end:""}}}var x,a,h,b,I,N,k=b$1(()=>{k$1();x=/^(?:( )+|\t+)/,a="space",h="tab";b=Symbol.for("__confbox_fmt__"),I=/^(\s+)/,N=/(\s+)$/;});export{O as a,P as b,k as c};