MCPcopy Index your code
hub / github.com/mozilla/source-map / originalPositionFor

Method originalPositionFor

lib/source-map-consumer.js:827–873  ·  view source on GitHub ↗

* Returns the original source, line, and column information for the generated * source's line and column positions provided. The only argument is an object * with the following properties: * * - line: The line number in the generated source. The line number * is 1-based. *

(aArgs)

Source from the content-addressed store, hash-verified

825 * - name: The original identifier, or null.
826 */
827 originalPositionFor(aArgs) {
828 const needle = {
829 generatedLine: util.getArg(aArgs, "line"),
830 generatedColumn: util.getArg(aArgs, "column"),
831 };
832
833 // Find the section containing the generated position we're trying to map
834 // to an original position.
835 const sectionIndex = binarySearch.search(
836 needle,
837 this._sections,
838 function (aNeedle, section) {
839 const cmp =
840 aNeedle.generatedLine - section.generatedOffset.generatedLine;
841 if (cmp) {
842 return cmp;
843 }
844
845 // The generated column is 0-based, but the section offset column is
846 // stored 1-based.
847 return (
848 aNeedle.generatedColumn -
849 (section.generatedOffset.generatedColumn - 1)
850 );
851 }
852 );
853 const section = this._sections[sectionIndex];
854
855 if (!section) {
856 return {
857 source: null,
858 line: null,
859 column: null,
860 name: null,
861 };
862 }
863
864 return section.consumer.originalPositionFor({
865 line: needle.generatedLine - (section.generatedOffset.generatedLine - 1),
866 column:
867 needle.generatedColumn -
868 (section.generatedOffset.generatedLine === needle.generatedLine
869 ? section.generatedOffset.generatedColumn - 1
870 : 0),
871 bias: aArgs.bias,
872 });
873 }
874
875 /**
876 * Return true if we have the source content for every source in the source

Callers

nothing calls this directly

Calls 1

originalPositionForMethod · 0.65

Tested by

no test coverage detected