1ls 0.1.0 → 0.1.1

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.
@@ -7,9 +7,6 @@ import { parseTOML } from "../formats/toml";
7
7
  export { Lexer, ExpressionParser, JsonNavigator };
8
8
  export { parseYAML, parseCSV, parseTOML };
9
9
  export declare function escapeRegExp(str: string): string;
10
- export declare const EXPAND_PATTERNS: {
11
- regex: RegExp;
12
- replacement: string;
13
- }[];
14
10
  export declare function expandShortcuts(expression: string): string;
11
+ export declare function shortenExpression(expression: string): string;
15
12
  export declare function evaluate(data: unknown, expression: string): unknown;
@@ -1,15 +1,15 @@
1
- var q={".":"DOT","[":"LEFT_BRACKET","]":"RIGHT_BRACKET","{":"LEFT_BRACE","}":"RIGHT_BRACE","(":"LEFT_PAREN",")":"RIGHT_PAREN",":":"COLON",",":"COMMA"},z="+-*/%<>!&|=",Z=[" ","\t",`
2
- `,"\r"];function O(t,e,n){return{type:t,value:e,position:n}}class _{input;position=0;current;constructor(t){this.input=t,this.current=this.input[0]||""}tokenize(){let t=[];while(this.position<this.input.length){if(this.skipWhitespace(),this.position>=this.input.length)break;let e=this.nextToken();if(e)t.push(e)}return t.push(O("EOF","",this.position)),t}nextToken(){let t=this.position,e=q[this.current];if(e){let h=this.current;return this.advance(),O(e,h,t)}if(this.current==="="&&this.peek()===">")return this.advance(),this.advance(),O("ARROW","=>",t);if(this.current==='"'||this.current==="'")return this.readString();let r=this.isDigit(this.current),o=this.current==="-"&&this.isDigit(this.peek());if(r||o)return this.readNumber();if(this.isIdentifierStart(this.current))return this.readIdentifier();if(this.isOperator(this.current))return this.readOperator();return this.advance(),null}readString(){let t=this.position,e=this.current,n=[];this.advance();while(this.current!==e&&this.position<this.input.length){if(this.current==="\\"){if(this.advance(),this.position<this.input.length)n.push(this.current),this.advance();continue}n.push(this.current),this.advance()}if(this.current===e)this.advance();return O("STRING",n.join(""),t)}readNumber(){let t=this.position,e="";if(this.current==="-")e+=this.current,this.advance();while(this.isDigit(this.current))e+=this.current,this.advance();if(this.current==="."&&this.isDigit(this.peek())){e+=this.current,this.advance();while(this.isDigit(this.current))e+=this.current,this.advance()}return O("NUMBER",e,t)}readIdentifier(){let t=this.position,e="";while(this.isIdentifierChar(this.current))e+=this.current,this.advance();return O("IDENTIFIER",e,t)}readOperator(){let t=this.position,e="";while(this.isOperator(this.current))e+=this.current,this.advance();return O("OPERATOR",e,t)}skipWhitespace(){while(this.isWhitespace(this.current))this.advance()}advance(){this.position++,this.current=this.input[this.position]||""}peek(){return this.input[this.position+1]||""}isWhitespace(t){return Z.includes(t)}isDigit(t){return t>="0"&&t<="9"}isIdentifierStart(t){let e=t>="a"&&t<="z",n=t>="A"&&t<="Z";return e||n||t==="_"||t==="$"}isIdentifierChar(t){return this.isIdentifierStart(t)||this.isDigit(t)}isOperator(t){return z.includes(t)}}var T=(t)=>{return{type:"Literal",value:t}},P=(t)=>{if(t==="true")return T(!0);if(t==="false")return T(!1);if(t==="null")return T(null);return};function E(t,e){return`${e} at position ${t.position} (got ${t.type}: "${t.value}")`}function b(t,e){return{type:"PropertyAccess",property:t,object:e}}function dt(t,e){return{type:"IndexAccess",index:t,object:e}}function ft(t,e,n){return{type:"SliceAccess",start:t,end:e,object:n}}function tt(t,e,n){return{type:"MethodCall",method:t,args:e,object:n}}function mt(t,e){return{type:"ObjectOperation",operation:t,object:e}}function At(t){return{type:"ArraySpread",object:t}}function yt(t,e){return{type:"ArrowFunction",params:t,body:e}}function I(t){return{type:"Root",expression:t}}var et=["keys","values","entries","length"];function gt(t){return et.includes(t)}class M{tokens;position=0;current;constructor(t){this.tokens=t,this.current=this.tokens[0]}parse(){if(this.current.type==="EOF")return I();let e=this.parseExpression();return I(e)}parseExpression(){return this.parsePrimary()}parsePrimary(){let t=this.parsePrimaryNode();return this.parsePostfix(t)}parsePrimaryNode(){let t=this.current.type;if(t==="DOT")return this.advance(),this.parseAccessChain();if(t==="LEFT_BRACKET")return this.parseArrayAccess();if(t==="IDENTIFIER")return this.parseIdentifierOrFunction();if(t==="STRING"){let e=this.current.value;return this.advance(),T(e)}if(t==="NUMBER"){let e=Number(this.current.value);return this.advance(),T(e)}if(t==="LEFT_PAREN"){let e=this.parseFunctionParams();return this.parseArrowFunction(e)}throw Error(E(this.current,"Unexpected token"))}parseAccessChain(t){let e=this.current.type;if(e==="IDENTIFIER"){let n=this.current.value;return this.advance(),b(n,t)}if(e==="LEFT_BRACKET")return this.parseBracketAccess(t);if(e==="LEFT_BRACE")return this.parseObjectOperation(t);throw Error(E(this.current,"Expected property name after dot"))}parseBracketAccess(t){if(this.advance(),this.current.type==="RIGHT_BRACKET")return this.advance(),At(t);if(this.current.type==="STRING"){let a=this.current.value;return this.advance(),this.expect("RIGHT_BRACKET"),b(a,t)}let s=this.current.type==="NUMBER",r=this.current.type==="OPERATOR"&&this.current.value==="-",o=this.current.type==="COLON";if(s||r||o)return this.parseNumericIndexOrSlice(t);throw Error(E(this.current,"Unexpected token in bracket access"))}parseNumericIndexOrSlice(t){if(this.current.type==="COLON")return this.parseSliceFromColon(void 0,t);let n=this.parseNumber();if(this.advance(),this.current.type==="COLON")return this.parseSliceFromColon(n,t);return this.expect("RIGHT_BRACKET"),dt(n,t)}parseSliceFromColon(t,e){this.advance();let n=this.current.type==="NUMBER",s=this.current.type==="OPERATOR"&&this.current.value==="-",r=n||s,o=r?this.parseNumber():void 0;if(r)this.advance();return this.expect("RIGHT_BRACKET"),ft(t,o,e)}parseArrayAccess(){return this.parseBracketAccess()}parseObjectOperation(t){if(this.advance(),this.current.type!=="IDENTIFIER")throw Error(E(this.current,"Expected operation name after {"));let n=this.current.value;if(!gt(n)){let s=et.join(", ");throw Error(E(this.current,`Invalid object operation "${n}". Valid operations: ${s}`))}return this.advance(),this.expect("RIGHT_BRACE"),mt(n,t)}parseIdentifierOrFunction(){let t=this.current.value;if(this.advance(),this.current.type==="ARROW")return this.parseArrowFunction([t]);let n=P(t);if(n)return n;return b(t)}parseArrowFunction(t){this.expect("ARROW");let e=this.parseFunctionBody();return yt(t,e)}parseFunctionBody(){if(this.current.type==="LEFT_BRACE"){this.advance();let e=this.parseBinaryExpression();return this.expect("RIGHT_BRACE"),e}return this.parseBinaryExpression()}parseBinaryExpression(){let t=this.parseFunctionTerm();while(this.current.type==="OPERATOR"){let e=this.current.value;this.advance();let n=this.parseFunctionTerm();t=tt(`__operator_${e}__`,[n],t)}return t}parseFunctionTerm(){let t=this.current.type;if(t==="IDENTIFIER")return this.parseIdentifierChain();if(t==="NUMBER"){let e=Number(this.current.value);return this.advance(),T(e)}if(t==="STRING"){let e=this.current.value;return this.advance(),T(e)}if(t==="LEFT_PAREN"){this.advance();let e=this.parseBinaryExpression();return this.expect("RIGHT_PAREN"),e}throw Error(E(this.current,"Unexpected token in function body"))}parseIdentifierChain(){let t=this.current.value;this.advance();let e=P(t);if(e)return e;let n=b(t),s=()=>this.current.type==="DOT",r=()=>this.current.type==="IDENTIFIER",o=()=>this.current.type==="LEFT_PAREN";while(s()||o()){if(o()){let a=n,u=a.property,h=a.object;n=this.parseMethodCall(h?h:I(),u);continue}if(this.advance(),!r())break;let i=this.current.value;this.advance(),n=b(i,n)}return n}parseMethodCall(t,e){this.expect("LEFT_PAREN");let n=this.parseMethodArguments();return this.expect("RIGHT_PAREN"),tt(e,n,t)}parseMethodArguments(){let t=[];while(this.current.type!=="RIGHT_PAREN"&&this.current.type!=="EOF"){let e=this.parseMethodArgument();if(t.push(e),this.current.type==="COMMA")this.advance()}return t}parseMethodArgument(){let t=this.current.type;if(t==="LEFT_PAREN"){let e=this.parseFunctionParams();return this.parseArrowFunction(e)}if(t==="IDENTIFIER"){let e=this.current.value;if(this.advance(),this.current.type==="ARROW")return this.parseArrowFunction([e]);return b(e)}if(t==="NUMBER"){let e=Number(this.current.value);return this.advance(),T(e)}if(t==="STRING"){let e=this.current.value;return this.advance(),T(e)}return this.parseExpression()}parseFunctionParams(){this.expect("LEFT_PAREN");let t=[];while(this.current.type!=="RIGHT_PAREN"&&this.current.type!=="EOF"){if(this.current.type==="IDENTIFIER")t.push(this.current.value),this.advance();if(this.current.type==="COMMA")this.advance()}return this.expect("RIGHT_PAREN"),t}parsePostfix(t){let e=t;while(!0){let n=this.current.type;if(n==="DOT"){e=this.parsePostfixDot(e);continue}if(n==="LEFT_BRACKET"){e=this.parseBracketAccess(e);continue}if(n==="LEFT_PAREN"){if(e.type==="PropertyAccess"&&!e.object){let o=e.property;e=this.parseMethodCall(I(),o);continue}}break}return e}parsePostfixDot(t){this.advance();let e=this.current.type;if(e==="IDENTIFIER"){let n=this.current.value;if(this.advance(),this.current.type==="LEFT_PAREN")return this.parseMethodCall(t,n);return b(n,t)}if(e==="LEFT_BRACKET")return this.parseBracketAccess(t);if(e==="LEFT_BRACE")return this.parseObjectOperation(t);throw Error(E(this.current,"Expected property name after dot"))}parseNumber(){let t=this.current.value==="-";if(t)this.advance();if(this.current.type!=="NUMBER")throw Error(E(this.current,"Expected number after minus sign"));let n=Number(this.current.value);return t?-n:n}advance(){if(this.position++,this.position<this.tokens.length)this.current=this.tokens[this.position]}expect(t){if(this.current.type!==t)throw Error(E(this.current,`Expected ${t} but got ${this.current.type}`));this.advance()}}var Tt={"+":(t,e)=>t+e,"-":(t,e)=>t-e,"*":(t,e)=>t*e,"/":(t,e)=>t/e,"%":(t,e)=>t%e,">":(t,e)=>t>e,"<":(t,e)=>t<e,">=":(t,e)=>t>=e,"<=":(t,e)=>t<=e,"==":(t,e)=>t==e,"===":(t,e)=>t===e,"!=":(t,e)=>t!=e,"!==":(t,e)=>t!==e,"&&":(t,e)=>t&&e,"||":(t,e)=>t||e};function nt(t){return t.startsWith("__operator_")&&t.endsWith("__")}function rt(t){return t.slice(11,-2)}function st(t,e,n){let s=Tt[e];if(!s)throw Error(`Unknown operator: ${e}`);return s(t,n)}function Nt(t,e){return Object.fromEntries(t.map((n,s)=>[n,e[s]]))}function j(t){return Object.values(t)[0]}function it(t){return t!==null&&typeof t==="object"}function B(t,e){if(!it(t))return;return t[e]}function D(t,e){return t<0?e+t:t}function Et(t,e){if(!Array.isArray(t))return;let n=D(e,t.length);return t[n]}function xt(t,e,n){if(!Array.isArray(t))return;let s=t.length,r=e!==void 0?D(e,s):0,o=n!==void 0?D(n,s):s;return t.slice(r,o)}function vt(t,e){if(!it(t))return;switch(e){case"keys":return Object.keys(t);case"values":return Object.values(t);case"entries":return Object.entries(t);case"length":return Array.isArray(t)?t.length:Object.keys(t).length}}var Ot=(t,e)=>{if(t===null||t===void 0)return!1;return typeof t[e]==="function"},bt=(t)=>t instanceof Error?t.message:String(t);function ot(t,e,n){if(!Ot(t,e))throw Error(`Method ${e} does not exist on ${typeof t}`);try{return t[e].call(t,...n)}catch(r){let o=bt(r);throw Error(`Error executing method ${e}: ${o}`)}}class G{evaluate(t,e){switch(t.type){case"Root":return t.expression?this.evaluate(t.expression,e):e;case"PropertyAccess":return this.evaluatePropertyAccess(t,e);case"IndexAccess":return Et(t.object?this.evaluate(t.object,e):e,t.index);case"SliceAccess":return xt(t.object?this.evaluate(t.object,e):e,t.start,t.end);case"ArraySpread":return t.object?this.evaluate(t.object,e):e;case"MethodCall":return this.evaluateMethodCall(t,e);case"ObjectOperation":return vt(t.object?this.evaluate(t.object,e):e,t.operation);case"Literal":return t.value;case"ArrowFunction":return this.createFunction(t);default:throw Error(`Unknown AST node type: ${t.type}`)}}evaluatePropertyAccess(t,e){let n=t.object?this.evaluate(t.object,e):e;return B(n,t.property)}evaluateArg(t,e){return t.type==="ArrowFunction"?this.createFunction(t):this.evaluate(t,e)}evaluateMethodCall(t,e){let n=t.object?this.evaluate(t.object,e):e;if(nt(t.method)){let o=rt(t.method),i=this.evaluate(t.args[0],e);return st(n,o,i)}let r=t.args.map((o)=>this.evaluateArg(o,e));return ot(n,t.method,r)}createFunction(t){return(...e)=>{let n=Nt(t.params,e);return this.evaluateFunctionBody(t.body,n)}}evaluateFunctionBody(t,e){switch(t.type){case"PropertyAccess":return this.evaluatePropertyAccessInFunction(t,e);case"MethodCall":return this.evaluateMethodCallInFunction(t,e);case"Literal":return t.value;case"Root":return t.expression?this.evaluateFunctionBody(t.expression,e):e;default:return this.evaluate(t,j(e))}}evaluatePropertyAccessInFunction(t,e){if(t.object!==void 0){let o=this.evaluateFunctionBody(t.object,e);return B(o,t.property)}if(Object.prototype.hasOwnProperty.call(e,t.property))return e[t.property];let r=j(e);return B(r,t.property)}evaluateMethodCallInFunction(t,e){let n=t.object?this.evaluateFunctionBody(t.object,e):j(e);if(nt(t.method)){let o=rt(t.method),i=this.evaluateFunctionBody(t.args[0],e);return st(n,o,i)}let r=t.args.map((o)=>this.evaluateFunctionBody(o,e));return ot(n,t.method,r)}}var U=[{short:".mp",full:".map",description:"Transform each element",type:"array"},{short:".flt",full:".filter",description:"Filter elements",type:"array"},{short:".rd",full:".reduce",description:"Reduce to single value",type:"array"},{short:".fnd",full:".find",description:"Find first match",type:"array"},{short:".sm",full:".some",description:"Test if any match",type:"array"},{short:".evr",full:".every",description:"Test if all match",type:"array"},{short:".srt",full:".sort",description:"Sort elements",type:"array"},{short:".rvs",full:".reverse",description:"Reverse order",type:"array"},{short:".jn",full:".join",description:"Join to string",type:"array"},{short:".slc",full:".slice",description:"Extract portion",type:"array"},{short:".kys",full:".{keys}",description:"Get object keys",type:"object"},{short:".vls",full:".{values}",description:"Get object values",type:"object"},{short:".ents",full:".{entries}",description:"Get object entries",type:"object"},{short:".len",full:".{length}",description:"Get length/size",type:"object"},{short:".lc",full:".toLowerCase",description:"Convert to lowercase",type:"string"},{short:".uc",full:".toUpperCase",description:"Convert to uppercase",type:"string"},{short:".trm",full:".trim",description:"Remove whitespace",type:"string"},{short:".splt",full:".split",description:"Split string to array",type:"string"},{short:".incl",full:".includes",description:"Check if includes",type:"array"}];var W=(t,e)=>{let s=U.filter((r)=>r.type===t).map((r)=>` ${r.short.padEnd(6)} -> ${r.full.padEnd(14)} ${r.description}`);return`${e}:
3
- ${s.join(`
4
- `)}`},Te=`Expression Shortcuts:
1
+ var q={".":"DOT","[":"LEFT_BRACKET","]":"RIGHT_BRACKET","{":"LEFT_BRACE","}":"RIGHT_BRACE","(":"LEFT_PAREN",")":"RIGHT_PAREN",":":"COLON",",":"COMMA"},Z="+-*/%<>!&|=",tt=[" ","\t",`
2
+ `,"\r"];function v(t,e,n){return{type:t,value:e,position:n}}class _{input;position=0;current;constructor(t){this.input=t,this.current=this.input[0]||""}tokenize(){let t=[];while(this.position<this.input.length){if(this.skipWhitespace(),this.position>=this.input.length)break;let e=this.nextToken();if(e)t.push(e)}return t.push(v("EOF","",this.position)),t}nextToken(){let t=this.position,e=q[this.current];if(e){let h=this.current;return this.advance(),v(e,h,t)}if(this.current==="="&&this.peek()===">")return this.advance(),this.advance(),v("ARROW","=>",t);if(this.current==='"'||this.current==="'")return this.readString();let s=this.isDigit(this.current),o=this.current==="-"&&this.isDigit(this.peek());if(s||o)return this.readNumber();if(this.isIdentifierStart(this.current))return this.readIdentifier();if(this.isOperator(this.current))return this.readOperator();return this.advance(),null}readString(){let t=this.position,e=this.current,n=[];this.advance();while(this.current!==e&&this.position<this.input.length){if(this.current==="\\"){if(this.advance(),this.position<this.input.length)n.push(this.current),this.advance();continue}n.push(this.current),this.advance()}if(this.current===e)this.advance();return v("STRING",n.join(""),t)}readNumber(){let t=this.position,e="";if(this.current==="-")e+=this.current,this.advance();while(this.isDigit(this.current))e+=this.current,this.advance();if(this.current==="."&&this.isDigit(this.peek())){e+=this.current,this.advance();while(this.isDigit(this.current))e+=this.current,this.advance()}return v("NUMBER",e,t)}readIdentifier(){let t=this.position,e="";while(this.isIdentifierChar(this.current))e+=this.current,this.advance();return v("IDENTIFIER",e,t)}readOperator(){let t=this.position,e="";while(this.isOperator(this.current))e+=this.current,this.advance();return v("OPERATOR",e,t)}skipWhitespace(){while(this.isWhitespace(this.current))this.advance()}advance(){this.position++,this.current=this.input[this.position]||""}peek(){return this.input[this.position+1]||""}isWhitespace(t){return tt.includes(t)}isDigit(t){return t>="0"&&t<="9"}isIdentifierStart(t){let e=t>="a"&&t<="z",n=t>="A"&&t<="Z";return e||n||t==="_"||t==="$"}isIdentifierChar(t){return this.isIdentifierStart(t)||this.isDigit(t)}isOperator(t){return Z.includes(t)}}var T=(t)=>{return{type:"Literal",value:t}},P=(t)=>{if(t==="true")return T(!0);if(t==="false")return T(!1);if(t==="null")return T(null);return};function E(t,e){return`${e} at position ${t.position} (got ${t.type}: "${t.value}")`}function b(t,e){return{type:"PropertyAccess",property:t,object:e}}function ft(t,e){return{type:"IndexAccess",index:t,object:e}}function mt(t,e,n){return{type:"SliceAccess",start:t,end:e,object:n}}function et(t,e,n){return{type:"MethodCall",method:t,args:e,object:n}}function At(t,e){return{type:"ObjectOperation",operation:t,object:e}}function yt(t){return{type:"ArraySpread",object:t}}function gt(t,e){return{type:"ArrowFunction",params:t,body:e}}function I(t){return{type:"Root",expression:t}}var nt=["keys","values","entries","length"];function Tt(t){return nt.includes(t)}class M{tokens;position=0;current;constructor(t){this.tokens=t,this.current=this.tokens[0]}parse(){if(this.current.type==="EOF")return I();let e=this.parseExpression();return I(e)}parseExpression(){return this.parsePrimary()}parsePrimary(){let t=this.parsePrimaryNode();return this.parsePostfix(t)}parsePrimaryNode(){let t=this.current.type;if(t==="DOT")return this.advance(),this.parseAccessChain();if(t==="LEFT_BRACKET")return this.parseArrayAccess();if(t==="IDENTIFIER")return this.parseIdentifierOrFunction();if(t==="STRING"){let e=this.current.value;return this.advance(),T(e)}if(t==="NUMBER"){let e=Number(this.current.value);return this.advance(),T(e)}if(t==="LEFT_PAREN"){let e=this.parseFunctionParams();return this.parseArrowFunction(e)}throw Error(E(this.current,"Unexpected token"))}parseAccessChain(t){let e=this.current.type;if(e==="IDENTIFIER"){let n=this.current.value;return this.advance(),b(n,t)}if(e==="LEFT_BRACKET")return this.parseBracketAccess(t);if(e==="LEFT_BRACE")return this.parseObjectOperation(t);throw Error(E(this.current,"Expected property name after dot"))}parseBracketAccess(t){if(this.advance(),this.current.type==="RIGHT_BRACKET")return this.advance(),yt(t);if(this.current.type==="STRING"){let a=this.current.value;return this.advance(),this.expect("RIGHT_BRACKET"),b(a,t)}let r=this.current.type==="NUMBER",s=this.current.type==="OPERATOR"&&this.current.value==="-",o=this.current.type==="COLON";if(r||s||o)return this.parseNumericIndexOrSlice(t);throw Error(E(this.current,"Unexpected token in bracket access"))}parseNumericIndexOrSlice(t){if(this.current.type==="COLON")return this.parseSliceFromColon(void 0,t);let n=this.parseNumber();if(this.advance(),this.current.type==="COLON")return this.parseSliceFromColon(n,t);return this.expect("RIGHT_BRACKET"),ft(n,t)}parseSliceFromColon(t,e){this.advance();let n=this.current.type==="NUMBER",r=this.current.type==="OPERATOR"&&this.current.value==="-",s=n||r,o=s?this.parseNumber():void 0;if(s)this.advance();return this.expect("RIGHT_BRACKET"),mt(t,o,e)}parseArrayAccess(){return this.parseBracketAccess()}parseObjectOperation(t){if(this.advance(),this.current.type!=="IDENTIFIER")throw Error(E(this.current,"Expected operation name after {"));let n=this.current.value;if(!Tt(n)){let r=nt.join(", ");throw Error(E(this.current,`Invalid object operation "${n}". Valid operations: ${r}`))}return this.advance(),this.expect("RIGHT_BRACE"),At(n,t)}parseIdentifierOrFunction(){let t=this.current.value;if(this.advance(),this.current.type==="ARROW")return this.parseArrowFunction([t]);let n=P(t);if(n)return n;return b(t)}parseArrowFunction(t){this.expect("ARROW");let e=this.parseFunctionBody();return gt(t,e)}parseFunctionBody(){if(this.current.type==="LEFT_BRACE"){this.advance();let e=this.parseBinaryExpression();return this.expect("RIGHT_BRACE"),e}return this.parseBinaryExpression()}parseBinaryExpression(){let t=this.parseFunctionTerm();while(this.current.type==="OPERATOR"){let e=this.current.value;this.advance();let n=this.parseFunctionTerm();t=et(`__operator_${e}__`,[n],t)}return t}parseFunctionTerm(){let t=this.current.type;if(t==="IDENTIFIER")return this.parseIdentifierChain();if(t==="NUMBER"){let e=Number(this.current.value);return this.advance(),T(e)}if(t==="STRING"){let e=this.current.value;return this.advance(),T(e)}if(t==="LEFT_PAREN"){this.advance();let e=this.parseBinaryExpression();return this.expect("RIGHT_PAREN"),e}throw Error(E(this.current,"Unexpected token in function body"))}parseIdentifierChain(){let t=this.current.value;this.advance();let e=P(t);if(e)return e;let n=b(t),r=()=>this.current.type==="DOT",s=()=>this.current.type==="IDENTIFIER",o=()=>this.current.type==="LEFT_PAREN";while(r()||o()){if(o()){let a=n,u=a.property,h=a.object;n=this.parseMethodCall(h?h:I(),u);continue}if(this.advance(),!s())break;let i=this.current.value;this.advance(),n=b(i,n)}return n}parseMethodCall(t,e){this.expect("LEFT_PAREN");let n=this.parseMethodArguments();return this.expect("RIGHT_PAREN"),et(e,n,t)}parseMethodArguments(){let t=[];while(this.current.type!=="RIGHT_PAREN"&&this.current.type!=="EOF"){let e=this.parseMethodArgument();if(t.push(e),this.current.type==="COMMA")this.advance()}return t}parseMethodArgument(){let t=this.current.type;if(t==="LEFT_PAREN"){let e=this.parseFunctionParams();return this.parseArrowFunction(e)}if(t==="IDENTIFIER"){let e=this.current.value;if(this.advance(),this.current.type==="ARROW")return this.parseArrowFunction([e]);return b(e)}if(t==="NUMBER"){let e=Number(this.current.value);return this.advance(),T(e)}if(t==="STRING"){let e=this.current.value;return this.advance(),T(e)}return this.parseExpression()}parseFunctionParams(){this.expect("LEFT_PAREN");let t=[];while(this.current.type!=="RIGHT_PAREN"&&this.current.type!=="EOF"){if(this.current.type==="IDENTIFIER")t.push(this.current.value),this.advance();if(this.current.type==="COMMA")this.advance()}return this.expect("RIGHT_PAREN"),t}parsePostfix(t){let e=t;while(!0){let n=this.current.type;if(n==="DOT"){e=this.parsePostfixDot(e);continue}if(n==="LEFT_BRACKET"){e=this.parseBracketAccess(e);continue}if(n==="LEFT_PAREN"){if(e.type==="PropertyAccess"&&!e.object){let o=e.property;e=this.parseMethodCall(I(),o);continue}}break}return e}parsePostfixDot(t){this.advance();let e=this.current.type;if(e==="IDENTIFIER"){let n=this.current.value;if(this.advance(),this.current.type==="LEFT_PAREN")return this.parseMethodCall(t,n);return b(n,t)}if(e==="LEFT_BRACKET")return this.parseBracketAccess(t);if(e==="LEFT_BRACE")return this.parseObjectOperation(t);throw Error(E(this.current,"Expected property name after dot"))}parseNumber(){let t=this.current.value==="-";if(t)this.advance();if(this.current.type!=="NUMBER")throw Error(E(this.current,"Expected number after minus sign"));let n=Number(this.current.value);return t?-n:n}advance(){if(this.position++,this.position<this.tokens.length)this.current=this.tokens[this.position]}expect(t){if(this.current.type!==t)throw Error(E(this.current,`Expected ${t} but got ${this.current.type}`));this.advance()}}var Nt={"+":(t,e)=>t+e,"-":(t,e)=>t-e,"*":(t,e)=>t*e,"/":(t,e)=>t/e,"%":(t,e)=>t%e,">":(t,e)=>t>e,"<":(t,e)=>t<e,">=":(t,e)=>t>=e,"<=":(t,e)=>t<=e,"==":(t,e)=>t==e,"===":(t,e)=>t===e,"!=":(t,e)=>t!=e,"!==":(t,e)=>t!==e,"&&":(t,e)=>t&&e,"||":(t,e)=>t||e};function rt(t){return t.startsWith("__operator_")&&t.endsWith("__")}function st(t){return t.slice(11,-2)}function ot(t,e,n){let r=Nt[e];if(!r)throw Error(`Unknown operator: ${e}`);return r(t,n)}function Et(t,e){return Object.fromEntries(t.map((n,r)=>[n,e[r]]))}function j(t){return Object.values(t)[0]}function ct(t){return t!==null&&typeof t==="object"}function B(t,e){if(!ct(t))return;return t[e]}function D(t,e){return t<0?e+t:t}function xt(t,e){if(!Array.isArray(t))return;let n=D(e,t.length);return t[n]}function Ot(t,e,n){if(!Array.isArray(t))return;let r=t.length,s=e!==void 0?D(e,r):0,o=n!==void 0?D(n,r):r;return t.slice(s,o)}function vt(t,e){if(!ct(t))return;switch(e){case"keys":return Object.keys(t);case"values":return Object.values(t);case"entries":return Object.entries(t);case"length":return Array.isArray(t)?t.length:Object.keys(t).length}}var bt=(t,e)=>{if(t===null||t===void 0)return!1;return typeof t[e]==="function"},St=(t)=>t instanceof Error?t.message:String(t);function it(t,e,n){if(!bt(t,e))throw Error(`Method ${e} does not exist on ${typeof t}`);try{return t[e].call(t,...n)}catch(s){let o=St(s);throw Error(`Error executing method ${e}: ${o}`)}}class G{evaluate(t,e){switch(t.type){case"Root":return t.expression?this.evaluate(t.expression,e):e;case"PropertyAccess":return this.evaluatePropertyAccess(t,e);case"IndexAccess":return xt(t.object?this.evaluate(t.object,e):e,t.index);case"SliceAccess":return Ot(t.object?this.evaluate(t.object,e):e,t.start,t.end);case"ArraySpread":return t.object?this.evaluate(t.object,e):e;case"MethodCall":return this.evaluateMethodCall(t,e);case"ObjectOperation":return vt(t.object?this.evaluate(t.object,e):e,t.operation);case"Literal":return t.value;case"ArrowFunction":return this.createFunction(t);default:throw Error(`Unknown AST node type: ${t.type}`)}}evaluatePropertyAccess(t,e){let n=t.object?this.evaluate(t.object,e):e;return B(n,t.property)}evaluateArg(t,e){return t.type==="ArrowFunction"?this.createFunction(t):this.evaluate(t,e)}evaluateMethodCall(t,e){let n=t.object?this.evaluate(t.object,e):e;if(rt(t.method)){let o=st(t.method),i=this.evaluate(t.args[0],e);return ot(n,o,i)}let s=t.args.map((o)=>this.evaluateArg(o,e));return it(n,t.method,s)}createFunction(t){return(...e)=>{let n=Et(t.params,e);return this.evaluateFunctionBody(t.body,n)}}evaluateFunctionBody(t,e){switch(t.type){case"PropertyAccess":return this.evaluatePropertyAccessInFunction(t,e);case"MethodCall":return this.evaluateMethodCallInFunction(t,e);case"Literal":return t.value;case"Root":return t.expression?this.evaluateFunctionBody(t.expression,e):e;default:return this.evaluate(t,j(e))}}evaluatePropertyAccessInFunction(t,e){if(t.object!==void 0){let o=this.evaluateFunctionBody(t.object,e);return B(o,t.property)}if(Object.prototype.hasOwnProperty.call(e,t.property))return e[t.property];let s=j(e);return B(s,t.property)}evaluateMethodCallInFunction(t,e){let n=t.object?this.evaluateFunctionBody(t.object,e):j(e);if(rt(t.method)){let o=st(t.method),i=this.evaluateFunctionBody(t.args[0],e);return ot(n,o,i)}let s=t.args.map((o)=>this.evaluateFunctionBody(o,e));return it(n,t.method,s)}}var U=[{short:".mp",full:".map",description:"Transform each element",type:"array"},{short:".flt",full:".filter",description:"Filter elements",type:"array"},{short:".rd",full:".reduce",description:"Reduce to single value",type:"array"},{short:".fnd",full:".find",description:"Find first match",type:"array"},{short:".sm",full:".some",description:"Test if any match",type:"array"},{short:".evr",full:".every",description:"Test if all match",type:"array"},{short:".srt",full:".sort",description:"Sort elements",type:"array"},{short:".rvs",full:".reverse",description:"Reverse order",type:"array"},{short:".jn",full:".join",description:"Join to string",type:"array"},{short:".slc",full:".slice",description:"Extract portion",type:"array"},{short:".kys",full:".{keys}",description:"Get object keys",type:"object"},{short:".vls",full:".{values}",description:"Get object values",type:"object"},{short:".ents",full:".{entries}",description:"Get object entries",type:"object"},{short:".len",full:".{length}",description:"Get length/size",type:"object"},{short:".lc",full:".toLowerCase",description:"Convert to lowercase",type:"string"},{short:".uc",full:".toUpperCase",description:"Convert to uppercase",type:"string"},{short:".trm",full:".trim",description:"Remove whitespace",type:"string"},{short:".splt",full:".split",description:"Split string to array",type:"string"},{short:".incl",full:".includes",description:"Check if includes",type:"array"}];var W=(t,e)=>{let r=U.filter((s)=>s.type===t).map((s)=>` ${s.short.padEnd(6)} -> ${s.full.padEnd(14)} ${s.description}`);return`${e}:
3
+ ${r.join(`
4
+ `)}`},Ne=`Expression Shortcuts:
5
5
 
6
6
  ${W("array","Array Methods")}
7
7
 
8
8
  ${W("object","Object Methods")}
9
9
 
10
10
  ${W("string","String Methods")}
11
- `;var ct=/[.*+?^${}()|[\]\\]/g,at=U;var St=/^-?\d+$/,wt=/^[+-]?\d+$/,Rt=/^-?\d+\.\d+$/,kt=/^[+-]?\d+\.\d+$/;var V={INTEGER:St,FLOAT:Rt},H={INTEGER:wt,FLOAT:kt};var It=["true","yes","on"],Ct=["false","no","off"],Ft=["null","~",""],Lt=(t)=>It.includes(t),_t=(t)=>Ct.includes(t),Pt=(t)=>Ft.includes(t),C=(t)=>{if(Lt(t))return!0;if(_t(t))return!1;return},F=(t)=>{if(Pt(t))return null;return},ut=(t)=>{if(t==="")return;let e=Number(t);return isNaN(e)?void 0:e};function Mt(t){if(t.startsWith("!!")){let e=t.indexOf(" ");if(e>0)return{tag:t.substring(2,e),content:t.substring(e+1)}}return{tag:null,content:t}}function k(t){let{tag:e,content:n}=Mt(t);if(e==="str")return n;let s=n.startsWith('"')&&n.endsWith('"'),r=n.startsWith("'")&&n.endsWith("'");if(s||r)return n.slice(1,-1);let i=C(n);if(i!==void 0)return i;let a=F(n);if(a!==void 0)return a;if(V.INTEGER.test(n))return parseInt(n,10);if(V.FLOAT.test(n))return parseFloat(n);if(n.startsWith("[")&&n.endsWith("]"))return n.slice(1,-1).split(",").map((c)=>k(c.trim()));if(n.startsWith("{")&&n.endsWith("}")){let c={};return n.slice(1,-1).split(",").forEach((J)=>{let[S,y]=J.split(":").map((p)=>p.trim());if(S&&y)c[S]=k(y)}),c}return n}function jt(t,e){return Array.from({length:e},(s,r)=>e-1-r).reduce((s,r)=>{if(s!==null)return s;let o=t[r],i=o.indexOf("#");if(i>=0){let f=o.substring(0,i);if((f.match(/["']/g)||[]).length%2===0)o=f}let u=o.trim();if(u&&!u.startsWith("-")&&u.includes(":")){let f=u.indexOf(":"),g=u.substring(0,f).trim(),c=u.substring(f+1).trim();if(!c||c==="|"||c===">"||c==="|+"||c===">-")return g}return null},null)}function $(t){let e=t.indexOf("#");if(e<0)return t;let n=t.substring(0,e);return(n.match(/["']/g)||[]).length%2===0?n:t}function Bt(t){let e=t.indexOf(":");if(e<=0)return!1;let n=t.substring(0,e);return!n.includes(" ")||n.startsWith('"')||n.startsWith("'")}function K(t){return t.length-t.trimStart().length}function Dt(t,e,n,s){let r=[],o=e;while(o<t.length){let a=t[o];if(!a.trim()){r.push(""),o++;continue}if(K(a)<=n)break;r.push(a.substring(n+2)),o++}while(r.length>0&&r[r.length-1]==="")r.pop();return{value:s==="|"?r.join(`
12
- `):r.join(" ").replace(/\s+/g," ").trim(),endIdx:o-1}}function Q(t,e){if(typeof t==="string"&&t.startsWith("*")){let n=t.substring(1);return e[n]!==void 0?e[n]:t}if(Array.isArray(t))return t.map((n)=>Q(n,e));if(typeof t==="object"&&t!==null){let n={};for(let[s,r]of Object.entries(t))if(s==="<<"&&typeof r==="string"&&r.startsWith("*")){let o=r.substring(1),i=e[o];if(typeof i==="object"&&i!==null&&!Array.isArray(i))Object.assign(n,i)}else n[s]=Q(r,e);return n}return t}function Gt(t){let e=t.trim().split(`
13
- `),n={},o=e.find((h)=>{let f=$(h).trim();return f&&f!=="---"&&f!=="..."})?.trim().startsWith("- ")?[]:{},i=[{container:o,indent:-1}];function a(){return i[i.length-1]}function u(h){while(i.length>1&&h(a()))i.pop()}for(let h=0;h<e.length;h++){let f=e[h],g=$(f),c=g.trim();if(!c||c==="---"||c==="...")continue;let d=K(g);if(c.startsWith("- ")||c==="-"){let y=c==="-"?"":c.substring(2).trim();u((A)=>A.indent>d||A.indent>=d&&!Array.isArray(A.container));let l,p=a();if(Array.isArray(p.container)&&(p.indent===d||p.indent===-1&&d===0)){if(l=p.container,p.indent===-1)p.indent=d}else{if(l=[],p.pendingKey)p.container[p.pendingKey]=l,p.pendingKey=void 0;else if(!Array.isArray(p.container)){let A=jt(e,h);if(A)p.container[A]=l}i.push({container:l,indent:d})}if(Bt(y)){let A=y.indexOf(":"),m=y.substring(0,A).trim(),N=y.substring(A+1).trim(),x=null;if(m.includes(" &")){let w=m.split(" &");m=w[0],x=w[1]}let v={[m]:N?k(N):null};if(l.push(v),x)n[x]=v;i.push({container:v,indent:d+2})}else if(y)l.push(k(y));else{let A={};l.push(A),i.push({container:A,indent:d+2})}continue}let S=c.indexOf(":");if(S>0){let y=c.substring(0,S).trim(),l=c.substring(S+1).trim(),p=null;if(l.startsWith("&")){let m=l.indexOf(" ");if(m>0)p=l.substring(1,m),l=l.substring(m+1);else p=l.substring(1),l=""}u((m)=>m.indent>d||m.indent===d&&Array.isArray(m.container));let L=a(),A=L.container;if(Array.isArray(A))continue;if(l==="|"||l===">"||l==="|+"||l===">-"||l==="|-"||l===">+"){let m=l.startsWith("|")?"|":">",{value:N,endIdx:x}=Dt(e,h+1,d,m);if(A[y]=N,p)n[p]=N;h=x}else if(l){let m=k(l);if(A[y]=m,p)n[p]=m}else{let m=h+1,N=m<e.length,x=N?$(e[m]):"",v=x.trim(),w=N?K(x):-1,lt=v.startsWith("- ")||v==="-",ht=N&&w>d&&v;if(lt&&w>d){if(L.pendingKey=y,p){let R={};n[p]=R}}else if(ht){let R={};if(A[y]=R,p)n[p]=R;i.push({container:R,indent:w})}else if(A[y]=null,p)n[p]=null}}}return Q(o,n)}function pt(t,e){let n=[],s="",r=!1,o=t.split("");return o.forEach((i,a)=>{let u=o[a+1];if(i==='"'){if(r&&u==='"'){s+='"',o.splice(a+1,1);return}r=!r;return}if(i===e&&!r){n.push(s),s="";return}s+=i}),n.push(s),n.map((i)=>i.trim())}function Wt(t){let e=t.trim();if(e.startsWith('"')&&e.endsWith('"'))return e.slice(1,-1).replace(/""/g,'"');let s=ut(e);if(s!==void 0)return s;let r=e.toLowerCase(),o=C(r);if(o!==void 0)return o;let i=F(r);if(i!==void 0)return i;return e}function Ut(t,e=","){let n=t.trim().split(`
14
- `);if(n.length===0)return[];let s=pt(n[0],e);if(n.length===1)return[];return n.slice(1).reduce((r,o)=>{let i=pt(o,e);if(i.length===0)return r;let a=Object.fromEntries(s.map((u,h)=>[u,Wt(i[h]||"")]));return[...r,a]},[])}function Y(t){if(t.startsWith('"')&&t.endsWith('"'))return t.slice(1,-1).replace(/\\"/g,'"');if(t.startsWith("'")&&t.endsWith("'"))return t.slice(1,-1);if(t==="true")return!0;if(t==="false")return!1;if(H.INTEGER.test(t))return parseInt(t,10);if(H.FLOAT.test(t))return parseFloat(t);if(t.startsWith("[")&&t.endsWith("]"))return t.slice(1,-1).split(",").map((u)=>Y(u.trim()));if(t.startsWith("{")&&t.endsWith("}")){let a={};return t.slice(1,-1).split(",").forEach((h)=>{let[f,g]=h.split("=").map((c)=>c.trim());if(f&&g)a[f]=Y(g)}),a}return t}function Vt(t){let e=t.trim().split(`
15
- `),n={},s=n,r=[];return e.forEach((o)=>{let i=o,a=i.indexOf("#");if(a>=0){let c=i.substring(0,a);if((c.match(/["']/g)||[]).length%2===0)i=c}let u=i.trim();if(!u)return;if(u.startsWith("[")&&u.endsWith("]")){let c=u.slice(1,-1).split(".");s=n,r=[],c.forEach((d)=>{if(!s[d])s[d]={};s=s[d],r.push(d)});return}let f=u.indexOf("=");if(f>0){let c=u.substring(0,f).trim(),d=u.substring(f+1).trim();s[c]=Y(d)}}),n}function Ht(t){return t.replace(ct,"\\$&")}var $t=at.map((t)=>({regex:new RegExp(`${Ht(t.short)}(?![a-zA-Z])`,"g"),replacement:t.full})).sort((t,e)=>e.replacement.length-t.replacement.length);function Kt(t){return $t.reduce((e,{regex:n,replacement:s})=>e.replace(n,s),t)}function De(t,e){let n=Kt(e),r=new _(n).tokenize(),i=new M(r).parse();return new G().evaluate(i,t)}export{Gt as parseYAML,Vt as parseTOML,Ut as parseCSV,Kt as expandShortcuts,De as evaluate,Ht as escapeRegExp,_ as Lexer,G as JsonNavigator,M as ExpressionParser,$t as EXPAND_PATTERNS};
11
+ `;var at=/[.*+?^${}()|[\]\\]/g,V=U;var wt=/^-?\d+$/,Rt=/^[+-]?\d+$/,kt=/^-?\d+\.\d+$/,It=/^[+-]?\d+\.\d+$/;var H={INTEGER:wt,FLOAT:kt},$={INTEGER:Rt,FLOAT:It};var Ct=["true","yes","on"],Ft=["false","no","off"],Lt=["null","~",""],_t=(t)=>Ct.includes(t),Pt=(t)=>Ft.includes(t),Mt=(t)=>Lt.includes(t),C=(t)=>{if(_t(t))return!0;if(Pt(t))return!1;return},F=(t)=>{if(Mt(t))return null;return},ut=(t)=>{if(t==="")return;let e=Number(t);return isNaN(e)?void 0:e};function jt(t){if(t.startsWith("!!")){let e=t.indexOf(" ");if(e>0)return{tag:t.substring(2,e),content:t.substring(e+1)}}return{tag:null,content:t}}function k(t){let{tag:e,content:n}=jt(t);if(e==="str")return n;let r=n.startsWith('"')&&n.endsWith('"'),s=n.startsWith("'")&&n.endsWith("'");if(r||s)return n.slice(1,-1);let i=C(n);if(i!==void 0)return i;let a=F(n);if(a!==void 0)return a;if(H.INTEGER.test(n))return parseInt(n,10);if(H.FLOAT.test(n))return parseFloat(n);if(n.startsWith("[")&&n.endsWith("]"))return n.slice(1,-1).split(",").map((c)=>k(c.trim()));if(n.startsWith("{")&&n.endsWith("}")){let c={};return n.slice(1,-1).split(",").forEach((J)=>{let[S,y]=J.split(":").map((p)=>p.trim());if(S&&y)c[S]=k(y)}),c}return n}function Bt(t,e){return Array.from({length:e},(r,s)=>e-1-s).reduce((r,s)=>{if(r!==null)return r;let o=t[s],i=o.indexOf("#");if(i>=0){let f=o.substring(0,i);if((f.match(/["']/g)||[]).length%2===0)o=f}let u=o.trim();if(u&&!u.startsWith("-")&&u.includes(":")){let f=u.indexOf(":"),g=u.substring(0,f).trim(),c=u.substring(f+1).trim();if(!c||c==="|"||c===">"||c==="|+"||c===">-")return g}return null},null)}function K(t){let e=t.indexOf("#");if(e<0)return t;let n=t.substring(0,e);return(n.match(/["']/g)||[]).length%2===0?n:t}function Dt(t){let e=t.indexOf(":");if(e<=0)return!1;let n=t.substring(0,e);return!n.includes(" ")||n.startsWith('"')||n.startsWith("'")}function Q(t){return t.length-t.trimStart().length}function Gt(t,e,n,r){let s=[],o=e;while(o<t.length){let a=t[o];if(!a.trim()){s.push(""),o++;continue}if(Q(a)<=n)break;s.push(a.substring(n+2)),o++}while(s.length>0&&s[s.length-1]==="")s.pop();return{value:r==="|"?s.join(`
12
+ `):s.join(" ").replace(/\s+/g," ").trim(),endIdx:o-1}}function Y(t,e){if(typeof t==="string"&&t.startsWith("*")){let n=t.substring(1);return e[n]!==void 0?e[n]:t}if(Array.isArray(t))return t.map((n)=>Y(n,e));if(typeof t==="object"&&t!==null){let n={};for(let[r,s]of Object.entries(t))if(r==="<<"&&typeof s==="string"&&s.startsWith("*")){let o=s.substring(1),i=e[o];if(typeof i==="object"&&i!==null&&!Array.isArray(i))Object.assign(n,i)}else n[r]=Y(s,e);return n}return t}function Wt(t){let e=t.trim().split(`
13
+ `),n={},o=e.find((h)=>{let f=K(h).trim();return f&&f!=="---"&&f!=="..."})?.trim().startsWith("- ")?[]:{},i=[{container:o,indent:-1}];function a(){return i[i.length-1]}function u(h){while(i.length>1&&h(a()))i.pop()}for(let h=0;h<e.length;h++){let f=e[h],g=K(f),c=g.trim();if(!c||c==="---"||c==="...")continue;let d=Q(g);if(c.startsWith("- ")||c==="-"){let y=c==="-"?"":c.substring(2).trim();u((A)=>A.indent>d||A.indent>=d&&!Array.isArray(A.container));let l,p=a();if(Array.isArray(p.container)&&(p.indent===d||p.indent===-1&&d===0)){if(l=p.container,p.indent===-1)p.indent=d}else{if(l=[],p.pendingKey)p.container[p.pendingKey]=l,p.pendingKey=void 0;else if(!Array.isArray(p.container)){let A=Bt(e,h);if(A)p.container[A]=l}i.push({container:l,indent:d})}if(Dt(y)){let A=y.indexOf(":"),m=y.substring(0,A).trim(),N=y.substring(A+1).trim(),x=null;if(m.includes(" &")){let w=m.split(" &");m=w[0],x=w[1]}let O={[m]:N?k(N):null};if(l.push(O),x)n[x]=O;i.push({container:O,indent:d+2})}else if(y)l.push(k(y));else{let A={};l.push(A),i.push({container:A,indent:d+2})}continue}let S=c.indexOf(":");if(S>0){let y=c.substring(0,S).trim(),l=c.substring(S+1).trim(),p=null;if(l.startsWith("&")){let m=l.indexOf(" ");if(m>0)p=l.substring(1,m),l=l.substring(m+1);else p=l.substring(1),l=""}u((m)=>m.indent>d||m.indent===d&&Array.isArray(m.container));let L=a(),A=L.container;if(Array.isArray(A))continue;if(l==="|"||l===">"||l==="|+"||l===">-"||l==="|-"||l===">+"){let m=l.startsWith("|")?"|":">",{value:N,endIdx:x}=Gt(e,h+1,d,m);if(A[y]=N,p)n[p]=N;h=x}else if(l){let m=k(l);if(A[y]=m,p)n[p]=m}else{let m=h+1,N=m<e.length,x=N?K(e[m]):"",O=x.trim(),w=N?Q(x):-1,ht=O.startsWith("- ")||O==="-",dt=N&&w>d&&O;if(ht&&w>d){if(L.pendingKey=y,p){let R={};n[p]=R}}else if(dt){let R={};if(A[y]=R,p)n[p]=R;i.push({container:R,indent:w})}else if(A[y]=null,p)n[p]=null}}}return Y(o,n)}function pt(t,e){let n=[],r="",s=!1,o=t.split("");return o.forEach((i,a)=>{let u=o[a+1];if(i==='"'){if(s&&u==='"'){r+='"',o.splice(a+1,1);return}s=!s;return}if(i===e&&!s){n.push(r),r="";return}r+=i}),n.push(r),n.map((i)=>i.trim())}function Ut(t){let e=t.trim();if(e.startsWith('"')&&e.endsWith('"'))return e.slice(1,-1).replace(/""/g,'"');let r=ut(e);if(r!==void 0)return r;let s=e.toLowerCase(),o=C(s);if(o!==void 0)return o;let i=F(s);if(i!==void 0)return i;return e}function Vt(t,e=","){let n=t.trim().split(`
14
+ `);if(n.length===0)return[];let r=pt(n[0],e);if(n.length===1)return[];return n.slice(1).reduce((s,o)=>{let i=pt(o,e);if(i.length===0)return s;let a=Object.fromEntries(r.map((u,h)=>[u,Ut(i[h]||"")]));return[...s,a]},[])}function z(t){if(t.startsWith('"')&&t.endsWith('"'))return t.slice(1,-1).replace(/\\"/g,'"');if(t.startsWith("'")&&t.endsWith("'"))return t.slice(1,-1);if(t==="true")return!0;if(t==="false")return!1;if($.INTEGER.test(t))return parseInt(t,10);if($.FLOAT.test(t))return parseFloat(t);if(t.startsWith("[")&&t.endsWith("]"))return t.slice(1,-1).split(",").map((u)=>z(u.trim()));if(t.startsWith("{")&&t.endsWith("}")){let a={};return t.slice(1,-1).split(",").forEach((h)=>{let[f,g]=h.split("=").map((c)=>c.trim());if(f&&g)a[f]=z(g)}),a}return t}function Ht(t){let e=t.trim().split(`
15
+ `),n={},r=n,s=[];return e.forEach((o)=>{let i=o,a=i.indexOf("#");if(a>=0){let c=i.substring(0,a);if((c.match(/["']/g)||[]).length%2===0)i=c}let u=i.trim();if(!u)return;if(u.startsWith("[")&&u.endsWith("]")){let c=u.slice(1,-1).split(".");r=n,s=[],c.forEach((d)=>{if(!r[d])r[d]={};r=r[d],s.push(d)});return}let f=u.indexOf("=");if(f>0){let c=u.substring(0,f).trim(),d=u.substring(f+1).trim();r[c]=z(d)}}),n}function lt(t){return t.replace(at,"\\$&")}var $t=V.map((t)=>({regex:new RegExp(`${lt(t.short)}(?![a-zA-Z])`,"g"),replacement:t.full})).sort((t,e)=>e.replacement.length-t.replacement.length),Kt=V.map((t)=>({regex:new RegExp(`${lt(t.full)}(?![a-zA-Z])`,"g"),replacement:t.short})).sort((t,e)=>e.regex.source.length-t.regex.source.length);function Qt(t){return $t.reduce((e,{regex:n,replacement:r})=>e.replace(n,r),t)}function Ge(t){return Kt.reduce((e,{regex:n,replacement:r})=>e.replace(n,r),t)}function We(t,e){let n=Qt(e),s=new _(n).tokenize(),i=new M(s).parse();return new G().evaluate(i,t)}export{Ge as shortenExpression,Wt as parseYAML,Ht as parseTOML,Vt as parseCSV,Qt as expandShortcuts,We as evaluate,lt as escapeRegExp,_ as Lexer,G as JsonNavigator,M as ExpressionParser};
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "1ls",
3
- "version": "0.1.0",
3
+ "version": "0.1.1",
4
4
  "description": "1 line script - Lightweight JSON CLI with JavaScript syntax",
5
5
  "type": "module",
6
6
  "main": "dist/index.js",