@volar/source-map
Advanced tools
Comparing version 2.4.0-alpha.13 to 2.4.0-alpha.14
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.translateOffset = translateOffset; | ||
let warned = false; | ||
function translateOffset(start, fromOffsets, toOffsets, fromLengths, toLengths = fromLengths) { | ||
const isSorted = fromOffsets.every((value, index) => index === 0 || fromOffsets[index - 1] <= value); | ||
if (!isSorted) { | ||
throw new Error('fromOffsets must be sorted in ascending order'); | ||
for (let i = 0; i < fromOffsets.length; i++) { | ||
const fromOffset = fromOffsets[i]; | ||
const fromLength = fromLengths[i]; | ||
if (start >= fromOffset && start <= fromOffset + fromLength) { | ||
const toLength = toLengths[i]; | ||
const toOffset = toOffsets[i]; | ||
let rangeOffset = Math.min(start - fromOffset, toLength); | ||
return toOffset + rangeOffset; | ||
} | ||
} | ||
if (!warned) { | ||
warned = true; | ||
console.warn('fromOffsets should be sorted in ascending order'); | ||
} | ||
} | ||
@@ -9,0 +23,0 @@ let low = 0; |
{ | ||
"name": "@volar/source-map", | ||
"version": "2.4.0-alpha.13", | ||
"version": "2.4.0-alpha.14", | ||
"license": "MIT", | ||
@@ -14,3 +14,3 @@ "files": [ | ||
}, | ||
"gitHead": "5f6d5d8ec51a5dda702d071c283e9133254cae97" | ||
"gitHead": "fc61afbf59f54fd6e92776a8569d6ce591e9b9d5" | ||
} |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
13234
222