Befor generating

This commit is contained in:
marys
2026-06-01 13:17:37 +02:00
parent 3383f4bf4a
commit 1aa1b5f625
6756 changed files with 649946 additions and 1 deletions
+21
View File
@@ -0,0 +1,21 @@
MIT License
Copyright (c) 2017 Vlad Trushin
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
+23
View File
@@ -0,0 +1,23 @@
[npm-icon]: https://img.shields.io/npm/v/code-error-fragment.svg
[npm-downloads-icon]: https://img.shields.io/npm/dm/code-error-fragment.svg
[npm-url]: https://www.npmjs.com/package/code-error-fragment
[node-versions-icon]: https://img.shields.io/node/v/code-error-fragment.svg
[node-url]: https://nodejs.org
[test-icon]: https://travis-ci.org/vtrushin/code-error-fragment.svg?branch=master
[test-url]: https://travis-ci.org/vtrushin/code-error-fragment
[coverage-icon]: https://coveralls.io/repos/github/vtrushin/code-error-fragment/badge.svg?branch=master
[coverage-url]: https://coveralls.io/github/vtrushin/code-error-fragment?branch=master
# Code error fragment
[![NPM][npm-icon]][npm-url]
[![NPM downloads][npm-downloads-icon]][npm-url]
[![Requirements][node-versions-icon]][node-url]
[![Travis-CI][test-icon]][test-url]
<img src="logo.svg" alt="Code error fragment" width="144" height="111" />
Partially taken from https://github.com/csstree/csstree/blob/master/lib/tokenizer/error.js
+169
View File
@@ -0,0 +1,169 @@
(function (global, factory) {
typeof exports === 'object' && typeof module !== 'undefined' ? module.exports = factory() :
typeof define === 'function' && define.amd ? define(factory) :
(global.codeErrorFragment = factory());
}(this, (function () { 'use strict';
/*!
* repeat-string <https://github.com/jonschlinkert/repeat-string>
*
* Copyright (c) 2014-2015, Jon Schlinkert.
* Licensed under the MIT License.
*/
'use strict';
/**
* Results cache
*/
var res = '';
var cache;
/**
* Expose `repeat`
*/
var repeatString = repeat;
/**
* Repeat the given `string` the specified `number`
* of times.
*
* **Example:**
*
* ```js
* var repeat = require('repeat-string');
* repeat('A', 5);
* //=> AAAAA
* ```
*
* @param {String} `string` The string to repeat
* @param {Number} `number` The number of times to repeat the string
* @return {String} Repeated string
* @api public
*/
function repeat(str, num) {
if (typeof str !== 'string') {
throw new TypeError('expected a string');
}
// cover common, quick use cases
if (num === 1) return str;
if (num === 2) return str + str;
var max = str.length * num;
if (cache !== str || typeof cache === 'undefined') {
cache = str;
res = '';
} else if (res.length >= max) {
return res.substr(0, max);
}
while (max > res.length && num > 1) {
if (num & 1) {
res += str;
}
num >>= 1;
str += str;
}
res += str;
res = res.substr(0, max);
return res;
}
'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;
};
var _extends = Object.assign || function (target) {
for (var i = 1; i < arguments.length; i++) {
var source = arguments[i];
for (var key in source) {
if (Object.prototype.hasOwnProperty.call(source, key)) {
target[key] = source[key];
}
}
}
return target;
};
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, tabReplacement);
}
function printLines(lines, start, end, maxNumLength, settings) {
return lines.slice(start, end).map(function (line, i) {
return printLine(line, start + i + 1, maxNumLength, settings);
}).join('\n');
}
var defaultSettings = {
extraLines: 2,
tabSize: 4
};
var index = (function (input, linePos, columnPos, settings) {
settings = _extends({}, defaultSettings, settings);
var lines = input.split(/\r\n?|\n|\f/);
var startLinePos = Math.max(1, linePos - settings.extraLines) - 1;
var endLinePos = Math.min(linePos + settings.extraLines, lines.length);
var maxNumLength = String(endLinePos).length;
var prevLines = printLines(lines, startLinePos, linePos, maxNumLength, settings);
var targetLineBeforeCursor = printLine(lines[linePos - 1].substring(0, columnPos - 1), linePos, maxNumLength, settings);
var cursorLine = repeatString(' ', targetLineBeforeCursor.length) + '^';
var nextLines = printLines(lines, linePos, endLinePos, maxNumLength, settings);
return [prevLines, cursorLine, nextLines].filter(Boolean).join('\n');
});
return index;
})));
+53
View File
@@ -0,0 +1,53 @@
{
"name": "code-error-fragment",
"version": "0.0.230",
"author": "Vlad Trushin",
"description": "Shows code error fragment of input file",
"homepage": "https://github.com/vtrushin/code-error-fragment",
"repository": "vtrushin/code-error-fragment",
"maintainers": [
{
"name": "Vlad Trushin <monospectr@mail.ru> (https://github.com/vtrushin)",
"email": "monospectr@mail.ru",
"github-username": "vtrushin"
}
],
"keywords": [
"code-errors",
"error-formatting",
"error-fragment"
],
"main": "build.js",
"files": [
"build.js",
"LICENSE",
"README.md"
],
"engines": {
"node": ">= 4"
},
"scripts": {
"build": "rollup -c",
"watch": "rollup -c -w",
"pretest": "npm run build",
"test": "mocha",
"prepublishOnly": "npm run build"
},
"devDependencies": {
"babel-core": "^6.26.0",
"babel-helpers": "^6.24.1",
"babel-plugin-external-helpers": "^6.22.0",
"babel-plugin-transform-object-assign": "^6.22.0",
"babel-preset-es2015": "^6.24.1",
"babel-preset-stage-3": "^6.24.1",
"coveralls": "^3.0.0",
"mocha": "^4.0.1",
"pad-start": "^1.0.2",
"repeat-string": "^1.6.1",
"rollup": "^0.50.0",
"rollup-plugin-babel": "^3.0.2",
"rollup-plugin-commonjs": "^8.2.3",
"rollup-plugin-node-resolve": "^3.0.0"
},
"license": "MIT"
}