Brunobkr/llama.cpp_AlgMor24_github
ΩFFFΣLLIa • llama.cpp • AlgMor24 ██████╗ ███████╗███████╗███████╗██╗ ██╗ ██╗ █████╗ ██╔═══██╗██╔════╝██╔════╝██╔════╝██║ ██║ ██║██╔══██╗ ██║ ██║█████╗ █████╗ █████╗ ██║ ██║ ██║███████║ ██║ ██║██╔══╝ ██╔══╝ ██╔══╝ ██║ ██║ ██║██╔══██║ ╚██████╔╝██║ ██║ ███████╗███████╗███████╗██║██║ ██║ ╚═════╝ ╚═╝ ╚═╝ ╚══════╝╚══════╝╚══════╝╚═╝╚═╝ ╚═╝ High-Performance LLM / VLM Inference & Autonomous Agentic Ecosystem… See the full description on the dataset page: https://huggingface.co/datasets/Brunobkr/llama.cpp_AlgMor24_github.
03.1k
1# Source Map2 3[](https://travis-ci.org/mozilla/source-map)4 5[](https://coveralls.io/github/mozilla/source-map)6 7[](https://www.npmjs.com/package/source-map)8 9This is a library to generate and consume the source map format10[described here][format].11 12[format]: https://docs.google.com/document/d/1U1RGAehQwRypUTovF1KRlpiOFze0b-_2gc6fAH0KY0k/edit13 14## Use with Node15 16 $ npm install source-map17 18## Use on the Web19 20 <script src="https://unpkg.com/source-map@0.7.3/dist/source-map.js"></script>21 <script>22 sourceMap.SourceMapConsumer.initialize({23 "lib/mappings.wasm": "https://unpkg.com/source-map@0.7.3/lib/mappings.wasm"24 });25 </script>26 27--------------------------------------------------------------------------------28 29<!-- `npm run toc` to regenerate the Table of Contents -->30 31<!-- START doctoc generated TOC please keep comment here to allow auto update -->32<!-- DON'T EDIT THIS SECTION, INSTEAD RE-RUN doctoc TO UPDATE -->33## Table of Contents34 35- [Examples](#examples)36 - [Consuming a source map](#consuming-a-source-map)37 - [Generating a source map](#generating-a-source-map)38 - [With SourceNode (high level API)](#with-sourcenode-high-level-api)39 - [With SourceMapGenerator (low level API)](#with-sourcemapgenerator-low-level-api)40- [API](#api)41 - [SourceMapConsumer](#sourcemapconsumer)42 - [SourceMapConsumer.initialize(options)](#sourcemapconsumerinitializeoptions)43 - [new SourceMapConsumer(rawSourceMap)](#new-sourcemapconsumerrawsourcemap)44 - [SourceMapConsumer.with](#sourcemapconsumerwith)45 - [SourceMapConsumer.prototype.destroy()](#sourcemapconsumerprototypedestroy)46 - [SourceMapConsumer.prototype.computeColumnSpans()](#sourcemapconsumerprototypecomputecolumnspans)47 - [SourceMapConsumer.prototype.originalPositionFor(generatedPosition)](#sourcemapconsumerprototypeoriginalpositionforgeneratedposition)48 - [SourceMapConsumer.prototype.generatedPositionFor(originalPosition)](#sourcemapconsumerprototypegeneratedpositionfororiginalposition)49 - [SourceMapConsumer.prototype.allGeneratedPositionsFor(originalPosition)](#sourcemapconsumerprototypeallgeneratedpositionsfororiginalposition)50 - [SourceMapConsumer.prototype.hasContentsOfAllSources()](#sourcemapconsumerprototypehascontentsofallsources)51 - [SourceMapConsumer.prototype.sourceContentFor(source[, returnNullOnMissing])](#sourcemapconsumerprototypesourcecontentforsource-returnnullonmissing)52 - [SourceMapConsumer.prototype.eachMapping(callback, context, order)](#sourcemapconsumerprototypeeachmappingcallback-context-order)53 - [SourceMapGenerator](#sourcemapgenerator)54 - [new SourceMapGenerator([startOfSourceMap])](#new-sourcemapgeneratorstartofsourcemap)55 - [SourceMapGenerator.fromSourceMap(sourceMapConsumer)](#sourcemapgeneratorfromsourcemapsourcemapconsumer)56 - [SourceMapGenerator.prototype.addMapping(mapping)](#sourcemapgeneratorprototypeaddmappingmapping)57 - [SourceMapGenerator.prototype.setSourceContent(sourceFile, sourceContent)](#sourcemapgeneratorprototypesetsourcecontentsourcefile-sourcecontent)58 - [SourceMapGenerator.prototype.applySourceMap(sourceMapConsumer[, sourceFile[, sourceMapPath]])](#sourcemapgeneratorprototypeapplysourcemapsourcemapconsumer-sourcefile-sourcemappath)59 - [SourceMapGenerator.prototype.toString()](#sourcemapgeneratorprototypetostring)60 - [SourceNode](#sourcenode)61 - [new SourceNode([line, column, source[, chunk[, name]]])](#new-sourcenodeline-column-source-chunk-name)62 - [SourceNode.fromStringWithSourceMap(code, sourceMapConsumer[, relativePath])](#sourcenodefromstringwithsourcemapcode-sourcemapconsumer-relativepath)63 - [SourceNode.prototype.add(chunk)](#sourcenodeprototypeaddchunk)64 - [SourceNode.prototype.prepend(chunk)](#sourcenodeprototypeprependchunk)65 - [SourceNode.prototype.setSourceContent(sourceFile, sourceContent)](#sourcenodeprototypesetsourcecontentsourcefile-sourcecontent)66 - [SourceNode.prototype.walk(fn)](#sourcenodeprototypewalkfn)67 - [SourceNode.prototype.walkSourceContents(fn)](#sourcenodeprototypewalksourcecontentsfn)68 - [SourceNode.prototype.join(sep)](#sourcenodeprototypejoinsep)69 - [SourceNode.prototype.replaceRight(pattern, replacement)](#sourcenodeprototypereplacerightpattern-replacement)70 - [SourceNode.prototype.toString()](#sourcenodeprototypetostring)71 - [SourceNode.prototype.toStringWithSourceMap([startOfSourceMap])](#sourcenodeprototypetostringwithsourcemapstartofsourcemap)72 73<!-- END doctoc generated TOC please keep comment here to allow auto update -->74 75## Examples76 77### Consuming a source map78 79```js80const rawSourceMap = {81 version: 3,82 file: 'min.js',83 names: ['bar', 'baz', 'n'],84 sources: ['one.js', 'two.js'],85 sourceRoot: 'http://example.com/www/js/',86 mappings: 'CAAC,IAAI,IAAM,SAAUA,GAClB,OAAOC,IAAID;CCDb,IAAI,IAAM,SAAUE,GAClB,OAAOA'87};88 89const whatever = await SourceMapConsumer.with(rawSourceMap, null, consumer => {90 91 console.log(consumer.sources);92 // [ 'http://example.com/www/js/one.js',93 // 'http://example.com/www/js/two.js' ]94 95 console.log(consumer.originalPositionFor({96 line: 2,97 column: 2898 }));99 // { source: 'http://example.com/www/js/two.js',100 // line: 2,101 // column: 10,102 // name: 'n' }103 104 console.log(consumer.generatedPositionFor({105 source: 'http://example.com/www/js/two.js',106 line: 2,107 column: 10108 }));109 // { line: 2, column: 28 }110 111 consumer.eachMapping(function (m) {112 // ...113 });114 115 return computeWhatever();116});117```118 119### Generating a source map120 121In depth guide:122[**Compiling to JavaScript, and Debugging with Source Maps**](https://hacks.mozilla.org/2013/05/compiling-to-javascript-and-debugging-with-source-maps/)123 124#### With SourceNode (high level API)125 126```js127function compile(ast) {128 switch (ast.type) {129 case 'BinaryExpression':130 return new SourceNode(131 ast.location.line,132 ast.location.column,133 ast.location.source,134 [compile(ast.left), " + ", compile(ast.right)]135 );136 case 'Literal':137 return new SourceNode(138 ast.location.line,139 ast.location.column,140 ast.location.source,141 String(ast.value)142 );143 // ...144 default:145 throw new Error("Bad AST");146 }147}148 149var ast = parse("40 + 2", "add.js");150console.log(compile(ast).toStringWithSourceMap({151 file: 'add.js'152}));153// { code: '40 + 2',154// map: [object SourceMapGenerator] }155```156 157#### With SourceMapGenerator (low level API)158 159```js160var map = new SourceMapGenerator({161 file: "source-mapped.js"162});163 164map.addMapping({165 generated: {166 line: 10,167 column: 35168 },169 source: "foo.js",170 original: {171 line: 33,172 column: 2173 },174 name: "christopher"175});176 177console.log(map.toString());178// '{"version":3,"file":"source-mapped.js","sources":["foo.js"],"names":["christopher"],"mappings":";;;;;;;;;mCAgCEA"}'179```180 181## API182 183Get a reference to the module:184 185```js186// Node.js187var sourceMap = require('source-map');188 189// Browser builds190var sourceMap = window.sourceMap;191 192// Inside Firefox193const sourceMap = require("devtools/toolkit/sourcemap/source-map.js");194```195 196### SourceMapConsumer197 198A `SourceMapConsumer` instance represents a parsed source map which we can query199for information about the original file positions by giving it a file position200in the generated source.201 202#### SourceMapConsumer.initialize(options)203 204When using `SourceMapConsumer` outside of node.js, for example on the Web, it205needs to know from what URL to load `lib/mappings.wasm`. You must inform it by206calling `initialize` before constructing any `SourceMapConsumer`s.207 208The options object has the following properties:209 210* `"lib/mappings.wasm"`: A `String` containing the URL of the211 `lib/mappings.wasm` file, or an `ArrayBuffer` with the contents of `lib/mappings.wasm`.212 213```js214sourceMap.SourceMapConsumer.initialize({215 "lib/mappings.wasm": "https://example.com/source-map/lib/mappings.wasm"216});217```218 219#### new SourceMapConsumer(rawSourceMap)220 221The only parameter is the raw source map (either as a string which can be222`JSON.parse`'d, or an object). According to the spec, source maps have the223following attributes:224 225* `version`: Which version of the source map spec this map is following.226 227* `sources`: An array of URLs to the original source files.228 229* `names`: An array of identifiers which can be referenced by individual230 mappings.231 232* `sourceRoot`: Optional. The URL root from which all sources are relative.233 234* `sourcesContent`: Optional. An array of contents of the original source files.235 236* `mappings`: A string of base64 VLQs which contain the actual mappings.237 238* `file`: Optional. The generated filename this source map is associated with.239 240The promise of the constructed souce map consumer is returned.241 242When the `SourceMapConsumer` will no longer be used anymore, you must call its243`destroy` method.244 245```js246const consumer = await new sourceMap.SourceMapConsumer(rawSourceMapJsonData);247doStuffWith(consumer);248consumer.destroy();249```250 251Alternatively, you can use `SourceMapConsumer.with` to avoid needing to remember252to call `destroy`.253 254#### SourceMapConsumer.with255 256Construct a new `SourceMapConsumer` from `rawSourceMap` and `sourceMapUrl`257(see the `SourceMapConsumer` constructor for details. Then, invoke the `async258function f(SourceMapConsumer) -> T` with the newly constructed consumer, wait259for `f` to complete, call `destroy` on the consumer, and return `f`'s return260value.261 262You must not use the consumer after `f` completes!263 264By using `with`, you do not have to remember to manually call `destroy` on265the consumer, since it will be called automatically once `f` completes.266 267```js268const xSquared = await SourceMapConsumer.with(269 myRawSourceMap,270 null,271 async function (consumer) {272 // Use `consumer` inside here and don't worry about remembering273 // to call `destroy`.274 275 const x = await whatever(consumer);276 return x * x;277 }278);279 280// You may not use that `consumer` anymore out here; it has281// been destroyed. But you can use `xSquared`.282console.log(xSquared);283```284 285#### SourceMapConsumer.prototype.destroy()286 287Free this source map consumer's associated wasm data that is manually-managed.288 289```js290consumer.destroy();291```292 293Alternatively, you can use `SourceMapConsumer.with` to avoid needing to remember294to call `destroy`.295 296#### SourceMapConsumer.prototype.computeColumnSpans()297 298Compute the last column for each generated mapping. The last column is299inclusive.300 301```js302// Before:303consumer.allGeneratedPositionsFor({ line: 2, source: "foo.coffee" })304// [ { line: 2,305// column: 1 },306// { line: 2,307// column: 10 },308// { line: 2,309// column: 20 } ]310 311consumer.computeColumnSpans();312 313// After:314consumer.allGeneratedPositionsFor({ line: 2, source: "foo.coffee" })315// [ { line: 2,316// column: 1,317// lastColumn: 9 },318// { line: 2,319// column: 10,320// lastColumn: 19 },321// { line: 2,322// column: 20,323// lastColumn: Infinity } ]324```325 326#### SourceMapConsumer.prototype.originalPositionFor(generatedPosition)327 328Returns the original source, line, and column information for the generated329source's line and column positions provided. The only argument is an object with330the following properties:331 332* `line`: The line number in the generated source. Line numbers in333 this library are 1-based (note that the underlying source map334 specification uses 0-based line numbers -- this library handles the335 translation).336 337* `column`: The column number in the generated source. Column numbers338 in this library are 0-based.339 340* `bias`: Either `SourceMapConsumer.GREATEST_LOWER_BOUND` or341 `SourceMapConsumer.LEAST_UPPER_BOUND`. Specifies whether to return the closest342 element that is smaller than or greater than the one we are searching for,343 respectively, if the exact element cannot be found. Defaults to344 `SourceMapConsumer.GREATEST_LOWER_BOUND`.345 346and an object is returned with the following properties:347 348* `source`: The original source file, or null if this information is not349 available.350 351* `line`: The line number in the original source, or null if this information is352 not available. The line number is 1-based.353 354* `column`: The column number in the original source, or null if this355 information is not available. The column number is 0-based.356 357* `name`: The original identifier, or null if this information is not available.358 359```js360consumer.originalPositionFor({ line: 2, column: 10 })361// { source: 'foo.coffee',362// line: 2,363// column: 2,364// name: null }365 366consumer.originalPositionFor({ line: 99999999999999999, column: 999999999999999 })367// { source: null,368// line: null,369// column: null,370// name: null }371```372 373#### SourceMapConsumer.prototype.generatedPositionFor(originalPosition)374 375Returns the generated line and column information for the original source,376line, and column positions provided. The only argument is an object with377the following properties:378 379* `source`: The filename of the original source.380 381* `line`: The line number in the original source. The line number is382 1-based.383 384* `column`: The column number in the original source. The column385 number is 0-based.386 387and an object is returned with the following properties:388 389* `line`: The line number in the generated source, or null. The line390 number is 1-based.391 392* `column`: The column number in the generated source, or null. The393 column number is 0-based.394 395```js396consumer.generatedPositionFor({ source: "example.js", line: 2, column: 10 })397// { line: 1,398// column: 56 }399```400 401#### SourceMapConsumer.prototype.allGeneratedPositionsFor(originalPosition)402 403Returns all generated line and column information for the original source, line,404and column provided. If no column is provided, returns all mappings405corresponding to a either the line we are searching for or the next closest line406that has any mappings. Otherwise, returns all mappings corresponding to the407given line and either the column we are searching for or the next closest column408that has any offsets.409 410The only argument is an object with the following properties:411 412* `source`: The filename of the original source.413 414* `line`: The line number in the original source. The line number is415 1-based.416 417* `column`: Optional. The column number in the original source. The418 column number is 0-based.419 420and an array of objects is returned, each with the following properties:421 422* `line`: The line number in the generated source, or null. The line423 number is 1-based.424 425* `column`: The column number in the generated source, or null. The426 column number is 0-based.427 428```js429consumer.allGeneratedpositionsfor({ line: 2, source: "foo.coffee" })430// [ { line: 2,431// column: 1 },432// { line: 2,433// column: 10 },434// { line: 2,435// column: 20 } ]436```437 438#### SourceMapConsumer.prototype.hasContentsOfAllSources()439 440Return true if we have the embedded source content for every source listed in441the source map, false otherwise.442 443In other words, if this method returns `true`, then444`consumer.sourceContentFor(s)` will succeed for every source `s` in445`consumer.sources`.446 447```js448// ...449if (consumer.hasContentsOfAllSources()) {450 consumerReadyCallback(consumer);451} else {452 fetchSources(consumer, consumerReadyCallback);453}454// ...455```456 457#### SourceMapConsumer.prototype.sourceContentFor(source[, returnNullOnMissing])458 459Returns the original source content for the source provided. The only460argument is the URL of the original source file.461 462If the source content for the given source is not found, then an error is463thrown. Optionally, pass `true` as the second param to have `null` returned464instead.465 466```js467consumer.sources468// [ "my-cool-lib.clj" ]469 470consumer.sourceContentFor("my-cool-lib.clj")471// "..."472 473consumer.sourceContentFor("this is not in the source map");474// Error: "this is not in the source map" is not in the source map475 476consumer.sourceContentFor("this is not in the source map", true);477// null478```479 480#### SourceMapConsumer.prototype.eachMapping(callback, context, order)481 482Iterate over each mapping between an original source/line/column and a483generated line/column in this source map.484 485* `callback`: The function that is called with each mapping. Mappings have the486 form `{ source, generatedLine, generatedColumn, originalLine, originalColumn,487 name }`488 489* `context`: Optional. If specified, this object will be the value of `this`490 every time that `callback` is called.491 492* `order`: Either `SourceMapConsumer.GENERATED_ORDER` or493 `SourceMapConsumer.ORIGINAL_ORDER`. Specifies whether you want to iterate over494 the mappings sorted by the generated file's line/column order or the495 original's source/line/column order, respectively. Defaults to496 `SourceMapConsumer.GENERATED_ORDER`.497 498```js499consumer.eachMapping(function (m) { console.log(m); })500// ...501// { source: 'illmatic.js',502// generatedLine: 1,503// generatedColumn: 0,504// originalLine: 1,505// originalColumn: 0,506// name: null }507// { source: 'illmatic.js',508// generatedLine: 2,509// generatedColumn: 0,510// originalLine: 2,511// originalColumn: 0,512// name: null }513// ...514```515### SourceMapGenerator516 517An instance of the SourceMapGenerator represents a source map which is being518built incrementally.519 520#### new SourceMapGenerator([startOfSourceMap])521 522You may pass an object with the following properties:523 524* `file`: The filename of the generated source that this source map is525 associated with.526 527* `sourceRoot`: A root for all relative URLs in this source map.528 529* `skipValidation`: Optional. When `true`, disables validation of mappings as530 they are added. This can improve performance but should be used with531 discretion, as a last resort. Even then, one should avoid using this flag when532 running tests, if possible.533 534```js535var generator = new sourceMap.SourceMapGenerator({536 file: "my-generated-javascript-file.js",537 sourceRoot: "http://example.com/app/js/"538});539```540 541#### SourceMapGenerator.fromSourceMap(sourceMapConsumer)542 543Creates a new `SourceMapGenerator` from an existing `SourceMapConsumer` instance.544 545* `sourceMapConsumer` The SourceMap.546 547```js548var generator = sourceMap.SourceMapGenerator.fromSourceMap(consumer);549```550 551#### SourceMapGenerator.prototype.addMapping(mapping)552 553Add a single mapping from original source line and column to the generated554source's line and column for this source map being created. The mapping object555should have the following properties:556 557* `generated`: An object with the generated line and column positions.558 559* `original`: An object with the original line and column positions.560 561* `source`: The original source file (relative to the sourceRoot).562 563* `name`: An optional original token name for this mapping.564 565```js566generator.addMapping({567 source: "module-one.scm",568 original: { line: 128, column: 0 },569 generated: { line: 3, column: 456 }570})571```572 573#### SourceMapGenerator.prototype.setSourceContent(sourceFile, sourceContent)574 575Set the source content for an original source file.576 577* `sourceFile` the URL of the original source file.578 579* `sourceContent` the content of the source file.580 581```js582generator.setSourceContent("module-one.scm",583 fs.readFileSync("path/to/module-one.scm"))584```585 586#### SourceMapGenerator.prototype.applySourceMap(sourceMapConsumer[, sourceFile[, sourceMapPath]])587 588Applies a SourceMap for a source file to the SourceMap.589Each mapping to the supplied source file is rewritten using the590supplied SourceMap. Note: The resolution for the resulting mappings591is the minimum of this map and the supplied map.592 593* `sourceMapConsumer`: The SourceMap to be applied.594 595* `sourceFile`: Optional. The filename of the source file.596 If omitted, sourceMapConsumer.file will be used, if it exists.597 Otherwise an error will be thrown.598 599* `sourceMapPath`: Optional. The dirname of the path to the SourceMap600 to be applied. If relative, it is relative to the SourceMap.601 602 This parameter is needed when the two SourceMaps aren't in the same603 directory, and the SourceMap to be applied contains relative source604 paths. If so, those relative source paths need to be rewritten605 relative to the SourceMap.606 607 If omitted, it is assumed that both SourceMaps are in the same directory,608 thus not needing any rewriting. (Supplying `'.'` has the same effect.)609 610#### SourceMapGenerator.prototype.toString()611 612Renders the source map being generated to a string.613 614```js615generator.toString()616// '{"version":3,"sources":["module-one.scm"],"names":[],"mappings":"...snip...","file":"my-generated-javascript-file.js","sourceRoot":"http://example.com/app/js/"}'617```618 619### SourceNode620 621SourceNodes provide a way to abstract over interpolating and/or concatenating622snippets of generated JavaScript source code, while maintaining the line and623column information associated between those snippets and the original source624code. This is useful as the final intermediate representation a compiler might625use before outputting the generated JS and source map.626 627#### new SourceNode([line, column, source[, chunk[, name]]])628 629* `line`: The original line number associated with this source node, or null if630 it isn't associated with an original line. The line number is 1-based.631 632* `column`: The original column number associated with this source node, or null633 if it isn't associated with an original column. The column number634 is 0-based.635 636* `source`: The original source's filename; null if no filename is provided.637 638* `chunk`: Optional. Is immediately passed to `SourceNode.prototype.add`, see639 below.640 641* `name`: Optional. The original identifier.642 643```js644var node = new SourceNode(1, 2, "a.cpp", [645 new SourceNode(3, 4, "b.cpp", "extern int status;\n"),646 new SourceNode(5, 6, "c.cpp", "std::string* make_string(size_t n);\n"),647 new SourceNode(7, 8, "d.cpp", "int main(int argc, char** argv) {}\n"),648]);649```650 651#### SourceNode.fromStringWithSourceMap(code, sourceMapConsumer[, relativePath])652 653Creates a SourceNode from generated code and a SourceMapConsumer.654 655* `code`: The generated code656 657* `sourceMapConsumer` The SourceMap for the generated code658 659* `relativePath` The optional path that relative sources in `sourceMapConsumer`660 should be relative to.661 662```js663const consumer = await new SourceMapConsumer(fs.readFileSync("path/to/my-file.js.map", "utf8"));664const node = SourceNode.fromStringWithSourceMap(fs.readFileSync("path/to/my-file.js"), consumer);665```666 667#### SourceNode.prototype.add(chunk)668 669Add a chunk of generated JS to this source node.670 671* `chunk`: A string snippet of generated JS code, another instance of672 `SourceNode`, or an array where each member is one of those things.673 674```js675node.add(" + ");676node.add(otherNode);677node.add([leftHandOperandNode, " + ", rightHandOperandNode]);678```679 680#### SourceNode.prototype.prepend(chunk)681 682Prepend a chunk of generated JS to this source node.683 684* `chunk`: A string snippet of generated JS code, another instance of685 `SourceNode`, or an array where each member is one of those things.686 687```js688node.prepend("/** Build Id: f783haef86324gf **/\n\n");689```690 691#### SourceNode.prototype.setSourceContent(sourceFile, sourceContent)692 693Set the source content for a source file. This will be added to the694`SourceMap` in the `sourcesContent` field.695 696* `sourceFile`: The filename of the source file697 698* `sourceContent`: The content of the source file699 700```js701node.setSourceContent("module-one.scm",702 fs.readFileSync("path/to/module-one.scm"))703```704 705#### SourceNode.prototype.walk(fn)706 707Walk over the tree of JS snippets in this node and its children. The walking708function is called once for each snippet of JS and is passed that snippet and709the its original associated source's line/column location.710 711* `fn`: The traversal function.712 713```js714var node = new SourceNode(1, 2, "a.js", [715 new SourceNode(3, 4, "b.js", "uno"),716 "dos",717 [718 "tres",719 new SourceNode(5, 6, "c.js", "quatro")720 ]721]);722 723node.walk(function (code, loc) { console.log("WALK:", code, loc); })724// WALK: uno { source: 'b.js', line: 3, column: 4, name: null }725// WALK: dos { source: 'a.js', line: 1, column: 2, name: null }726// WALK: tres { source: 'a.js', line: 1, column: 2, name: null }727// WALK: quatro { source: 'c.js', line: 5, column: 6, name: null }728```729 730#### SourceNode.prototype.walkSourceContents(fn)731 732Walk over the tree of SourceNodes. The walking function is called for each733source file content and is passed the filename and source content.734 735* `fn`: The traversal function.736 737```js738var a = new SourceNode(1, 2, "a.js", "generated from a");739a.setSourceContent("a.js", "original a");740var b = new SourceNode(1, 2, "b.js", "generated from b");741b.setSourceContent("b.js", "original b");742var c = new SourceNode(1, 2, "c.js", "generated from c");743c.setSourceContent("c.js", "original c");744 745var node = new SourceNode(null, null, null, [a, b, c]);746node.walkSourceContents(function (source, contents) { console.log("WALK:", source, ":", contents); })747// WALK: a.js : original a748// WALK: b.js : original b749// WALK: c.js : original c750```751 752#### SourceNode.prototype.join(sep)753 754Like `Array.prototype.join` except for SourceNodes. Inserts the separator755between each of this source node's children.756 757* `sep`: The separator.758 759```js760var lhs = new SourceNode(1, 2, "a.rs", "my_copy");761var operand = new SourceNode(3, 4, "a.rs", "=");762var rhs = new SourceNode(5, 6, "a.rs", "orig.clone()");763 764var node = new SourceNode(null, null, null, [ lhs, operand, rhs ]);765var joinedNode = node.join(" ");766```767 768#### SourceNode.prototype.replaceRight(pattern, replacement)769 770Call `String.prototype.replace` on the very right-most source snippet. Useful771for trimming white space from the end of a source node, etc.772 773* `pattern`: The pattern to replace.774 775* `replacement`: The thing to replace the pattern with.776 777```js778// Trim trailing white space.779node.replaceRight(/\s*$/, "");780```781 782#### SourceNode.prototype.toString()783 784Return the string representation of this source node. Walks over the tree and785concatenates all the various snippets together to one string.786 787```js788var node = new SourceNode(1, 2, "a.js", [789 new SourceNode(3, 4, "b.js", "uno"),790 "dos",791 [792 "tres",793 new SourceNode(5, 6, "c.js", "quatro")794 ]795]);796 797node.toString()798// 'unodostresquatro'799```800 801#### SourceNode.prototype.toStringWithSourceMap([startOfSourceMap])802 803Returns the string representation of this tree of source nodes, plus a804SourceMapGenerator which contains all the mappings between the generated and805original sources.806 807The arguments are the same as those to `new SourceMapGenerator`.808 809```js810var node = new SourceNode(1, 2, "a.js", [811 new SourceNode(3, 4, "b.js", "uno"),812 "dos",813 [814 "tres",815 new SourceNode(5, 6, "c.js", "quatro")816 ]817]);818 819node.toStringWithSourceMap({ file: "my-output-file.js" })820// { code: 'unodostresquatro',821// map: [object SourceMapGenerator] }822```823 