MCPcopy Create free account
hub / github.com/ChinaSiro/claude-code-sourcemap / toJS

Method toJS

package/cli.js:664–664  ·  view source on GitHub ↗
({json:q,jsonArg:K,mapAsMap:_,maxAliasCount:z,onAnchor:Y,reviver:$}={})

Source from the content-addressed store, hash-verified

662`))_.push("..."),_.push(wn6.indentComment(w,""));else _.push(`... ${w}`)}else _.push("...");else{let w=q.comment;if(w&&A)w=w.replace(/^\n+/,"");if(w){if((!A||O)&&_[_.length-1]!=="")_.push("");_.push(wn6.indentComment($(w),""))}}return _.join(`
663`)+`
664`}dy_.stringifyDocument=Qy_});var jn6=m((ty_)=>{var ly_=rl6(),Hv6=_G8(),qC=uY(),ny_=a16(),iy_=i16(),ry_=lR1(),oy_=z44(),iR1=eZ8(),ay_=MR1(),sy_=ol6(),rR1=JR1();class oR1{constructor(q,K,_){this.commentBefore=null,this.comment=null,this.errors=[],this.warnings=[],Object.defineProperty(this,qC.NODE_TYPE,{value:qC.DOC});let z=null;if(typeof K==="function"||Array.isArray(K))z=K;else if(_===void 0&&K)_=K,K=void 0;let Y=Object.assign({intAsBigInt:!1,keepSourceTokens:!1,logLevel:"warn",prettyErrors:!0,strict:!0,stringKeys:!1,uniqueKeys:!0,version:"1.2"},_);this.options=Y;let{version:$}=Y;if(_?._directives){if(this.directives=_._directives.atDocument(),this.directives.yaml.explicit)$=this.directives.yaml.version}else this.directives=new rR1.Directives({version:$});this.setSchema($,_),this.contents=q===void 0?null:this.createNode(q,z,_)}clone(){let q=Object.create(oR1.prototype,{[qC.NODE_TYPE]:{value:qC.DOC}});if(q.commentBefore=this.commentBefore,q.comment=this.comment,q.errors=this.errors.slice(),q.warnings=this.warnings.slice(),q.options=Object.assign({},this.options),this.directives)q.directives=this.directives.clone();if(q.schema=this.schema.clone(),q.contents=qC.isNode(this.contents)?this.contents.clone(q.schema):this.contents,this.range)q.range=this.range.slice();return q}add(q){if(Jv6(this.contents))this.contents.add(q)}addIn(q,K){if(Jv6(this.contents))this.contents.addIn(q,K)}createAlias(q,K){if(!q.anchor){let _=iR1.anchorNames(this);q.anchor=!K||_.has(K)?iR1.findNewAnchor(K||"a",_):K}return new ly_.Alias(q.anchor)}createNode(q,K,_){let z=void 0;if(typeof K==="function")q=K.call({"":q},"",q),z=K;else if(Array.isArray(K)){let W=(f)=>typeof f==="number"||f instanceof String||f instanceof Number,D=K.filter(W).map(String);if(D.length>0)K=K.concat(D);z=K}else if(_===void 0&&K)_=K,K=void 0;let{aliasDuplicateObjects:Y,anchorPrefix:$,flow:A,keepUndefined:O,onTagObj:w,tag:j}=_??{},{onAnchor:H,setAnchors:J,sourceObjects:M}=iR1.createNodeAnchors(this,$||"a"),X={aliasDuplicateObjects:Y??!0,keepUndefined:O??!1,onAnchor:H,onTagObj:w,replacer:z,schema:this.schema,sourceObjects:M},P=sy_.createNode(q,j,X);if(A&&qC.isCollection(P))P.flow=!0;return J(),P}createPair(q,K,_={}){let z=this.createNode(q,null,_),Y=this.createNode(K,null,_);return new ny_.Pair(z,Y)}delete(q){return Jv6(this.contents)?this.contents.delete(q):!1}deleteIn(q){if(Hv6.isEmptyPath(q)){if(this.contents==null)return!1;return this.contents=null,!0}return Jv6(this.contents)?this.contents.deleteIn(q):!1}get(q,K){return qC.isCollection(this.contents)?this.contents.get(q,K):void 0}getIn(q,K){if(Hv6.isEmptyPath(q))return!K&&qC.isScalar(this.contents)?this.contents.value:this.contents;return qC.isCollection(this.contents)?this.contents.getIn(q,K):void 0}has(q){return qC.isCollection(this.contents)?this.contents.has(q):!1}hasIn(q){if(Hv6.isEmptyPath(q))return this.contents!==void 0;return qC.isCollection(this.contents)?this.contents.hasIn(q):!1}set(q,K){if(this.contents==null)this.contents=Hv6.collectionFromPath(this.schema,[q],K);else if(Jv6(this.contents))this.contents.set(q,K)}setIn(q,K){if(Hv6.isEmptyPath(q))this.contents=K;else if(this.contents==null)this.contents=Hv6.collectionFromPath(this.schema,Array.from(q),K);else if(Jv6(this.contents))this.contents.setIn(q,K)}setSchema(q,K={}){if(typeof q==="number")q=String(q);let _;switch(q){case"1.1":if(this.directives)this.directives.yaml.version="1.1";else this.directives=new rR1.Directives({version:"1.1"});_={resolveKnownTags:!1,schema:"yaml-1.1"};break;case"1.2":case"next":if(this.directives)this.directives.yaml.version=q;else this.directives=new rR1.Directives({version:q});_={resolveKnownTags:!0,schema:"core"};break;case null:if(this.directives)delete this.directives;_=null;break;default:{let z=JSON.stringify(q);throw Error(`Expected '1.1', '1.2' or null as first argument, but found: ${z}`)}}if(K.schema instanceof Object)this.schema=K.schema;else if(_)this.schema=new ry_.Schema(Object.assign(_,K));else throw Error("With a null YAML version, the { schema: Schema } option is required")}toJS({json:q,jsonArg:K,mapAsMap:_,maxAliasCount:z,onAnchor:Y,reviver:$}={}){let A={anchors:new Map,doc:this,keep:!q,mapAsMap:_===!0,mapKeyWarned:!1,maxAliasCount:typeof z==="number"?z:100},O=iy_.toJS(this.contents,K??"",A);if(typeof Y==="function")for(let{count:w,res:j}of A.anchors.values())Y(j,w);return typeof $==="function"?ay_.applyReviver($,{"":O},"",O):O}toJSON(q,K){return this.toJS({json:!0,jsonArg:q,mapAsMap:!1,onAnchor:K})}toString(q={}){if(this.errors.length>0)throw Error("Document with errors cannot be stringified");if("indent"in q&&(!Number.isInteger(q.indent)||Number(q.indent)<=0)){let K=JSON.stringify(q.indent);throw Error(`"indent" option must be a positive integer, not ${K}`)}return oy_.stringifyDocument(this,q)}}function Jv6(q){if(qC.isCollection(q))return!0;throw Error("Expected a YAML collection as document contents")}ty_.Document=oR1});var Hn6=m((KE_)=>{class RG8 extends Error{constructor(q,K,_,z){super();this.name=q,this.code=_,this.message=z,this.pos=K}}class Y44 extends RG8{constructor(q,K,_){super("YAMLParseError",q,K,_)}}class $44 extends RG8{constructor(q,K,_){super("YAMLWarning",q,K,_)}}var qE_=(q,K)=>(_)=>{if(_.pos[0]===-1)return;_.linePos=_.pos.map((O)=>K.linePos(O));let{line:z,col:Y}=_.linePos[0];_.message+=` at line ${z}, column ${Y}`;let $=Y-1,A=q.substring(K.lineStarts[z-1],K.lineStarts[z]).replace(/[\n\r]+$/,"");if($>=60&&A.length>80){let O=Math.min($-39,A.length-79);A="…"+A.substring(O),$-=O-1}if(A.length>80)A=A.substring(0,79)+"…";if(z>1&&/^ *$/.test(A.substring(0,$))){let O=q.substring(K.lineStarts[z-2],K.lineStarts[z-1]);if(O.length>80)O=O.substring(0,79)+`…
665`;A=O+A}if(/[^ ]/.test(A)){let O=1,w=_.linePos[1];if(w&&w.line===z&&w.col>Y)O=Math.max(1,Math.min(w.col-Y,80-$));let j=" ".repeat($)+"^".repeat(O);_.message+=`:
666
667${A}

Callers 1

toJSONMethod · 0.95

Calls 3

YFunction · 0.70
toJSMethod · 0.45
valuesMethod · 0.45

Tested by

no test coverage detected