code-error-fragment
Advanced tools
Comparing version 0.0.215 to 0.0.216
68
build.js
@@ -7,26 +7,58 @@ (function (global, factory) { | ||
var padStart = (function (string, targetLength, padString) { | ||
if (String.prototype.padStart) { | ||
return string.padStart(targetLength, padString); | ||
} | ||
/*! | ||
* repeat-string <https://github.com/jonschlinkert/repeat-string> | ||
* | ||
* Copyright (c) 2014-2015, Jon Schlinkert. | ||
* Licensed under the MIT License. | ||
*/ | ||
targetLength = targetLength >> 0; // Floor if number or convert non-number to 0; | ||
padString = String(padString || ' '); | ||
'use strict'; | ||
if (string.length > targetLength) { | ||
return String(string); | ||
} else { | ||
targetLength = targetLength - string.length; | ||
if (targetLength > padString.length) { | ||
padString += padString.repeat(targetLength / padString.length); // Append to original to ensure we are longer than needed | ||
} | ||
return padString.slice(0, targetLength) + String(string); | ||
} | ||
}); | ||
'use strict'; | ||
var padStart = function (string, maxLength, fillString) { | ||
if (string == null || maxLength == null) { | ||
return string; | ||
} | ||
var result = String(string); | ||
var targetLen = typeof maxLength === 'number' | ||
? maxLength | ||
: parseInt(maxLength, 10); | ||
if (isNaN(targetLen) || !isFinite(targetLen)) { | ||
return result; | ||
} | ||
var length = result.length; | ||
if (length >= targetLen) { | ||
return result; | ||
} | ||
var fill = fillString == null ? '' : String(fillString); | ||
if (fill === '') { | ||
fill = ' '; | ||
} | ||
var fillLen = targetLen - length; | ||
while (fill.length < fillLen) { | ||
fill += fill; | ||
} | ||
var truncated = fill.length > fillLen ? fill.substr(0, fillLen) : fill; | ||
return truncated + result; | ||
}; | ||
function printLine(line, position, maxNumLength, settings) { | ||
var num = String(position); | ||
var formattedNum = padStart(num, maxNumLength, ' '); | ||
var tabReplacement = repeatString(' ', settings.tabSize); | ||
return formattedNum + ' | ' + line.replace(/\t/g, ' '.repeat(settings.tabSize)); | ||
return formattedNum + ' | ' + line.replace(/\t/g, tabReplacement); | ||
} | ||
@@ -54,3 +86,3 @@ | ||
var targetLineBeforeCursor = printLine(lines[linePos - 1].substring(0, columnPos - 1), linePos, maxNumLength, settings); | ||
var cursorLine = ' '.repeat(targetLineBeforeCursor.length) + '^'; | ||
var cursorLine = repeatString(' ', targetLineBeforeCursor.length) + '^'; | ||
var nextLines = printLines(lines, linePos, endLinePos, maxNumLength, settings); | ||
@@ -57,0 +89,0 @@ |
@@ -1,2 +0,3 @@ | ||
import padStart from './helpers/pad-start.js'; | ||
import nprepeatString from 'repeat-string'; | ||
import padStart from 'pad-start'; | ||
@@ -6,4 +7,5 @@ function printLine(line, position, maxNumLength, settings) { | ||
const formattedNum = padStart(num, maxNumLength, ' '); | ||
const tabReplacement = repeatString(' ', settings.tabSize); | ||
return formattedNum + ' | ' + line.replace(/\t/g, ' '.repeat(settings.tabSize)); | ||
return formattedNum + ' | ' + line.replace(/\t/g, tabReplacement); | ||
} | ||
@@ -32,3 +34,3 @@ | ||
const targetLineBeforeCursor = printLine(lines[linePos - 1].substring(0, columnPos - 1), linePos, maxNumLength, settings); | ||
const cursorLine = ' '.repeat(targetLineBeforeCursor.length) + '^'; | ||
const cursorLine = repeatString(' ', targetLineBeforeCursor.length) + '^'; | ||
const nextLines = printLines(lines, linePos, endLinePos, maxNumLength, settings); | ||
@@ -35,0 +37,0 @@ |
{ | ||
"name": "code-error-fragment", | ||
"version": "0.0.215", | ||
"version": "0.0.216", | ||
"author": "Vlad Trushin", | ||
@@ -18,2 +18,6 @@ "homepage": "https://github.com/vtrushin/code-error-fragment", | ||
"jsnext:main": "index", | ||
"dependencies": { | ||
"pad-start": "^1.0.2", | ||
"repeat-string": "^1.6.1" | ||
}, | ||
"devDependencies": { | ||
@@ -20,0 +24,0 @@ "babel-core": "^6.26.0", |
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
132
7092
2
7
+ Addedpad-start@^1.0.2
+ Addedrepeat-string@^1.6.1
+ Addedpad-start@1.0.2(transitive)
+ Addedrepeat-string@1.6.1(transitive)