WIP: bootstrap and partial real Solana watcher implementation
This commit is contained in:
@@ -0,0 +1,10 @@
|
||||
import uuid from './dist/index.js';
|
||||
export const v1 = uuid.v1;
|
||||
export const v3 = uuid.v3;
|
||||
export const v4 = uuid.v4;
|
||||
export const v5 = uuid.v5;
|
||||
export const NIL = uuid.NIL;
|
||||
export const version = uuid.version;
|
||||
export const validate = uuid.validate;
|
||||
export const stringify = uuid.stringify;
|
||||
export const parse = uuid.parse;
|
||||
@@ -0,0 +1,28 @@
|
||||
/*! *****************************************************************************
|
||||
Copyright (c) Microsoft Corporation. All rights reserved.
|
||||
Licensed under the Apache License, Version 2.0 (the "License"); you may not use
|
||||
this file except in compliance with the License. You may obtain a copy of the
|
||||
License at http://www.apache.org/licenses/LICENSE-2.0
|
||||
|
||||
THIS CODE IS PROVIDED ON AN *AS IS* BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
||||
KIND, EITHER EXPRESS OR IMPLIED, INCLUDING WITHOUT LIMITATION ANY IMPLIED
|
||||
WARRANTIES OR CONDITIONS OF TITLE, FITNESS FOR A PARTICULAR PURPOSE,
|
||||
MERCHANTABLITY OR NON-INFRINGEMENT.
|
||||
|
||||
See the Apache Version 2.0 License for specific language governing permissions
|
||||
and limitations under the License.
|
||||
***************************************************************************** */
|
||||
|
||||
|
||||
/// <reference no-default-lib="true"/>
|
||||
|
||||
/// <reference lib="es2023" />
|
||||
/// <reference lib="esnext.intl" />
|
||||
/// <reference lib="esnext.decorators" />
|
||||
/// <reference lib="esnext.disposable" />
|
||||
/// <reference lib="esnext.promise" />
|
||||
/// <reference lib="esnext.object" />
|
||||
/// <reference lib="esnext.collection" />
|
||||
/// <reference lib="esnext.array" />
|
||||
/// <reference lib="esnext.regexp" />
|
||||
/// <reference lib="esnext.string" />
|
||||
@@ -0,0 +1,4 @@
|
||||
{
|
||||
"main": "../../cjs/_non_iterable_spread.cjs",
|
||||
"module": "../../esm/_non_iterable_spread.js"
|
||||
}
|
||||
@@ -0,0 +1,201 @@
|
||||
"use strict";
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
const utils_1 = require("@typescript-eslint/utils");
|
||||
const util_1 = require("../util");
|
||||
const getESLintCoreRule_1 = require("../util/getESLintCoreRule");
|
||||
const baseRule = (0, getESLintCoreRule_1.getESLintCoreRule)('no-loop-func');
|
||||
const CONSTANT_BINDINGS = new Set(['await using', 'const', 'using']);
|
||||
exports.default = (0, util_1.createRule)({
|
||||
name: 'no-loop-func',
|
||||
meta: {
|
||||
type: 'suggestion',
|
||||
// defaultOptions, -- base rule does not use defaultOptions
|
||||
deprecated: {
|
||||
deprecatedSince: '8.64.0',
|
||||
replacedBy: [
|
||||
{
|
||||
rule: {
|
||||
name: 'no-loop-func',
|
||||
url: 'https://eslint.org/docs/latest/rules/no-loop-func',
|
||||
},
|
||||
},
|
||||
],
|
||||
url: 'https://github.com/typescript-eslint/typescript-eslint/issues/12496',
|
||||
},
|
||||
docs: {
|
||||
description: 'Disallow function declarations that contain unsafe references inside loop statements',
|
||||
extendsBaseRule: true,
|
||||
},
|
||||
hasSuggestions: baseRule.meta.hasSuggestions,
|
||||
messages: baseRule.meta.messages,
|
||||
schema: [],
|
||||
},
|
||||
defaultOptions: [],
|
||||
create(context) {
|
||||
const SKIPPED_IIFE_NODES = new Set();
|
||||
/**
|
||||
* Gets the containing loop node of a specified node.
|
||||
*
|
||||
* We don't need to check nested functions, so this ignores those.
|
||||
* `Scope.through` contains references of nested functions.
|
||||
*
|
||||
* @param node An AST node to get.
|
||||
* @returns The containing loop node of the specified node, or `null`.
|
||||
*/
|
||||
function getContainingLoopNode(node) {
|
||||
for (let currentNode = node; currentNode.parent; currentNode = currentNode.parent) {
|
||||
const parent = currentNode.parent;
|
||||
switch (parent.type) {
|
||||
case utils_1.AST_NODE_TYPES.WhileStatement:
|
||||
case utils_1.AST_NODE_TYPES.DoWhileStatement:
|
||||
return parent;
|
||||
case utils_1.AST_NODE_TYPES.ForStatement:
|
||||
// `init` is outside of the loop.
|
||||
if (parent.init !== currentNode) {
|
||||
return parent;
|
||||
}
|
||||
break;
|
||||
case utils_1.AST_NODE_TYPES.ForInStatement:
|
||||
case utils_1.AST_NODE_TYPES.ForOfStatement:
|
||||
// `right` is outside of the loop.
|
||||
if (parent.right !== currentNode) {
|
||||
return parent;
|
||||
}
|
||||
break;
|
||||
case utils_1.AST_NODE_TYPES.ArrowFunctionExpression:
|
||||
case utils_1.AST_NODE_TYPES.FunctionExpression:
|
||||
case utils_1.AST_NODE_TYPES.FunctionDeclaration:
|
||||
// We don't need to check nested functions.
|
||||
// We need to check nested functions only in case of IIFE.
|
||||
if (SKIPPED_IIFE_NODES.has(parent)) {
|
||||
break;
|
||||
}
|
||||
return null;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
/**
|
||||
* Gets the containing loop node of a given node.
|
||||
* If the loop was nested, this returns the most outer loop.
|
||||
* @param node A node to get. This is a loop node.
|
||||
* @param excludedNode A node that the result node should not include.
|
||||
* @returns The most outer loop node.
|
||||
*/
|
||||
function getTopLoopNode(node, excludedNode) {
|
||||
const border = excludedNode ? excludedNode.range[1] : 0;
|
||||
let retv = node;
|
||||
let containingLoopNode = node;
|
||||
while (containingLoopNode && containingLoopNode.range[0] >= border) {
|
||||
retv = containingLoopNode;
|
||||
containingLoopNode = getContainingLoopNode(containingLoopNode);
|
||||
}
|
||||
return retv;
|
||||
}
|
||||
/**
|
||||
* Checks whether a given reference which refers to an upper scope's variable is
|
||||
* safe or not.
|
||||
* @param loopNode A containing loop node.
|
||||
* @param reference A reference to check.
|
||||
* @returns `true` if the reference is safe or not.
|
||||
*/
|
||||
function isSafe(loopNode, reference) {
|
||||
const variable = reference.resolved;
|
||||
const definition = variable?.defs[0];
|
||||
const declaration = definition?.parent;
|
||||
const kind = declaration?.type === utils_1.AST_NODE_TYPES.VariableDeclaration
|
||||
? declaration.kind
|
||||
: '';
|
||||
// type references are all safe
|
||||
// this only really matters for global types that haven't been configured
|
||||
if (reference.isTypeReference) {
|
||||
return true;
|
||||
}
|
||||
// Variables which are declared by `const`, `using`, or `await using` are
|
||||
// safe. They can't be reassigned, so each iteration captures a fresh one.
|
||||
if (CONSTANT_BINDINGS.has(kind)) {
|
||||
return true;
|
||||
}
|
||||
/*
|
||||
* Variables which are declared by `let` in the loop is safe.
|
||||
* It's a different instance from the next loop step's.
|
||||
*/
|
||||
if (kind === 'let' &&
|
||||
declaration &&
|
||||
declaration.range[0] > loopNode.range[0] &&
|
||||
declaration.range[1] < loopNode.range[1]) {
|
||||
return true;
|
||||
}
|
||||
/*
|
||||
* WriteReferences which exist after this border are unsafe because those
|
||||
* can modify the variable.
|
||||
*/
|
||||
const border = getTopLoopNode(loopNode, kind === 'let' ? declaration : null).range[0];
|
||||
/**
|
||||
* Checks whether a given reference is safe or not.
|
||||
* The reference is every reference of the upper scope's variable we are
|
||||
* looking now.
|
||||
*
|
||||
* It's safe if the reference matches one of the following condition.
|
||||
* - is readonly.
|
||||
* - doesn't exist inside a local function and after the border.
|
||||
*
|
||||
* @param upperRef A reference to check.
|
||||
* @returns `true` if the reference is safe.
|
||||
*/
|
||||
function isSafeReference(upperRef) {
|
||||
const id = upperRef.identifier;
|
||||
return (!upperRef.isWrite() ||
|
||||
(variable?.scope.variableScope === upperRef.from.variableScope &&
|
||||
id.range[0] < border));
|
||||
}
|
||||
return variable?.references.every(isSafeReference) ?? false;
|
||||
}
|
||||
/**
|
||||
* Reports functions which match the following condition:
|
||||
* - has a loop node in ancestors.
|
||||
* - has any references which refers to an unsafe variable.
|
||||
*
|
||||
* @param node The AST node to check.
|
||||
*/
|
||||
function checkForLoops(node) {
|
||||
const loopNode = getContainingLoopNode(node);
|
||||
if (!loopNode) {
|
||||
return;
|
||||
}
|
||||
const references = context.sourceCode.getScope(node).through;
|
||||
if (!(node.async || node.generator) && isIIFE(node)) {
|
||||
const isFunctionExpression = node.type === utils_1.AST_NODE_TYPES.FunctionExpression;
|
||||
// Check if the function is referenced elsewhere in the code
|
||||
const isFunctionReferenced = isFunctionExpression && node.id
|
||||
? references.some(r => r.identifier.name === node.id?.name)
|
||||
: false;
|
||||
if (!isFunctionReferenced) {
|
||||
SKIPPED_IIFE_NODES.add(node);
|
||||
return;
|
||||
}
|
||||
}
|
||||
const unsafeRefs = references
|
||||
.filter(r => r.resolved && !isSafe(loopNode, r))
|
||||
.map(r => r.identifier.name);
|
||||
if (unsafeRefs.length > 0) {
|
||||
context.report({
|
||||
node,
|
||||
messageId: 'unsafeRefs',
|
||||
data: { varNames: `'${unsafeRefs.join("', '")}'` },
|
||||
});
|
||||
}
|
||||
}
|
||||
return {
|
||||
ArrowFunctionExpression: checkForLoops,
|
||||
FunctionDeclaration: checkForLoops,
|
||||
FunctionExpression: checkForLoops,
|
||||
};
|
||||
},
|
||||
});
|
||||
function isIIFE(node) {
|
||||
return (node.parent.type === utils_1.AST_NODE_TYPES.CallExpression &&
|
||||
node.parent.callee === node);
|
||||
}
|
||||
@@ -0,0 +1,183 @@
|
||||
"use strict";
|
||||
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
||||
if (k2 === undefined) k2 = k;
|
||||
var desc = Object.getOwnPropertyDescriptor(m, k);
|
||||
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
||||
desc = { enumerable: true, get: function() { return m[k]; } };
|
||||
}
|
||||
Object.defineProperty(o, k2, desc);
|
||||
}) : (function(o, m, k, k2) {
|
||||
if (k2 === undefined) k2 = k;
|
||||
o[k2] = m[k];
|
||||
}));
|
||||
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
||||
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
||||
}) : function(o, v) {
|
||||
o["default"] = v;
|
||||
});
|
||||
var __importStar = (this && this.__importStar) || function (mod) {
|
||||
if (mod && mod.__esModule) return mod;
|
||||
var result = {};
|
||||
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
||||
__setModuleDefault(result, mod);
|
||||
return result;
|
||||
};
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
exports.default = default_1;
|
||||
const util = __importStar(require("../core/util.cjs"));
|
||||
function getBelarusianPlural(count, one, few, many) {
|
||||
const absCount = Math.abs(count);
|
||||
const lastDigit = absCount % 10;
|
||||
const lastTwoDigits = absCount % 100;
|
||||
if (lastTwoDigits >= 11 && lastTwoDigits <= 19) {
|
||||
return many;
|
||||
}
|
||||
if (lastDigit === 1) {
|
||||
return one;
|
||||
}
|
||||
if (lastDigit >= 2 && lastDigit <= 4) {
|
||||
return few;
|
||||
}
|
||||
return many;
|
||||
}
|
||||
const error = () => {
|
||||
const Sizable = {
|
||||
string: {
|
||||
unit: {
|
||||
one: "сімвал",
|
||||
few: "сімвалы",
|
||||
many: "сімвалаў",
|
||||
},
|
||||
verb: "мець",
|
||||
},
|
||||
array: {
|
||||
unit: {
|
||||
one: "элемент",
|
||||
few: "элементы",
|
||||
many: "элементаў",
|
||||
},
|
||||
verb: "мець",
|
||||
},
|
||||
set: {
|
||||
unit: {
|
||||
one: "элемент",
|
||||
few: "элементы",
|
||||
many: "элементаў",
|
||||
},
|
||||
verb: "мець",
|
||||
},
|
||||
file: {
|
||||
unit: {
|
||||
one: "байт",
|
||||
few: "байты",
|
||||
many: "байтаў",
|
||||
},
|
||||
verb: "мець",
|
||||
},
|
||||
};
|
||||
function getSizing(origin) {
|
||||
return Sizable[origin] ?? null;
|
||||
}
|
||||
const FormatDictionary = {
|
||||
regex: "увод",
|
||||
email: "email адрас",
|
||||
url: "URL",
|
||||
emoji: "эмодзі",
|
||||
uuid: "UUID",
|
||||
uuidv4: "UUIDv4",
|
||||
uuidv6: "UUIDv6",
|
||||
nanoid: "nanoid",
|
||||
guid: "GUID",
|
||||
cuid: "cuid",
|
||||
cuid2: "cuid2",
|
||||
ulid: "ULID",
|
||||
xid: "XID",
|
||||
ksuid: "KSUID",
|
||||
datetime: "ISO дата і час",
|
||||
date: "ISO дата",
|
||||
time: "ISO час",
|
||||
duration: "ISO працягласць",
|
||||
ipv4: "IPv4 адрас",
|
||||
ipv6: "IPv6 адрас",
|
||||
cidrv4: "IPv4 дыяпазон",
|
||||
cidrv6: "IPv6 дыяпазон",
|
||||
base64: "радок у фармаце base64",
|
||||
base64url: "радок у фармаце base64url",
|
||||
json_string: "JSON радок",
|
||||
e164: "нумар E.164",
|
||||
jwt: "JWT",
|
||||
template_literal: "увод",
|
||||
};
|
||||
const TypeDictionary = {
|
||||
nan: "NaN",
|
||||
number: "лік",
|
||||
array: "масіў",
|
||||
};
|
||||
return (issue) => {
|
||||
switch (issue.code) {
|
||||
case "invalid_type": {
|
||||
const expected = TypeDictionary[issue.expected] ?? issue.expected;
|
||||
const receivedType = util.parsedType(issue.input);
|
||||
const received = TypeDictionary[receivedType] ?? receivedType;
|
||||
if (/^[A-Z]/.test(issue.expected)) {
|
||||
return `Няправільны ўвод: чакаўся instanceof ${issue.expected}, атрымана ${received}`;
|
||||
}
|
||||
return `Няправільны ўвод: чакаўся ${expected}, атрымана ${received}`;
|
||||
}
|
||||
case "invalid_value":
|
||||
if (issue.values.length === 1)
|
||||
return `Няправільны ўвод: чакалася ${util.stringifyPrimitive(issue.values[0])}`;
|
||||
return `Няправільны варыянт: чакаўся адзін з ${util.joinValues(issue.values, "|")}`;
|
||||
case "too_big": {
|
||||
const adj = issue.inclusive ? "<=" : "<";
|
||||
const sizing = getSizing(issue.origin);
|
||||
if (sizing) {
|
||||
const maxValue = Number(issue.maximum);
|
||||
const unit = getBelarusianPlural(maxValue, sizing.unit.one, sizing.unit.few, sizing.unit.many);
|
||||
return `Занадта вялікі: чакалася, што ${issue.origin ?? "значэнне"} павінна ${sizing.verb} ${adj}${issue.maximum.toString()} ${unit}`;
|
||||
}
|
||||
return `Занадта вялікі: чакалася, што ${issue.origin ?? "значэнне"} павінна быць ${adj}${issue.maximum.toString()}`;
|
||||
}
|
||||
case "too_small": {
|
||||
const adj = issue.inclusive ? ">=" : ">";
|
||||
const sizing = getSizing(issue.origin);
|
||||
if (sizing) {
|
||||
const minValue = Number(issue.minimum);
|
||||
const unit = getBelarusianPlural(minValue, sizing.unit.one, sizing.unit.few, sizing.unit.many);
|
||||
return `Занадта малы: чакалася, што ${issue.origin} павінна ${sizing.verb} ${adj}${issue.minimum.toString()} ${unit}`;
|
||||
}
|
||||
return `Занадта малы: чакалася, што ${issue.origin} павінна быць ${adj}${issue.minimum.toString()}`;
|
||||
}
|
||||
case "invalid_format": {
|
||||
const _issue = issue;
|
||||
if (_issue.format === "starts_with")
|
||||
return `Няправільны радок: павінен пачынацца з "${_issue.prefix}"`;
|
||||
if (_issue.format === "ends_with")
|
||||
return `Няправільны радок: павінен заканчвацца на "${_issue.suffix}"`;
|
||||
if (_issue.format === "includes")
|
||||
return `Няправільны радок: павінен змяшчаць "${_issue.includes}"`;
|
||||
if (_issue.format === "regex")
|
||||
return `Няправільны радок: павінен адпавядаць шаблону ${_issue.pattern}`;
|
||||
return `Няправільны ${FormatDictionary[_issue.format] ?? issue.format}`;
|
||||
}
|
||||
case "not_multiple_of":
|
||||
return `Няправільны лік: павінен быць кратным ${issue.divisor}`;
|
||||
case "unrecognized_keys":
|
||||
return `Нераспазнаны ${issue.keys.length > 1 ? "ключы" : "ключ"}: ${util.joinValues(issue.keys, ", ")}`;
|
||||
case "invalid_key":
|
||||
return `Няправільны ключ у ${issue.origin}`;
|
||||
case "invalid_union":
|
||||
return "Няправільны ўвод";
|
||||
case "invalid_element":
|
||||
return `Няправільнае значэнне ў ${issue.origin}`;
|
||||
default:
|
||||
return `Няправільны ўвод`;
|
||||
}
|
||||
};
|
||||
};
|
||||
function default_1() {
|
||||
return {
|
||||
localeError: error(),
|
||||
};
|
||||
}
|
||||
module.exports = exports.default;
|
||||
@@ -0,0 +1,166 @@
|
||||
/**
|
||||
* @fileoverview Rule to enforce line breaks between arguments of a function call
|
||||
* @author Alexey Gonchar <https://github.com/finico>
|
||||
* @deprecated in ESLint v8.53.0
|
||||
*/
|
||||
|
||||
"use strict";
|
||||
|
||||
//------------------------------------------------------------------------------
|
||||
// Rule Definition
|
||||
//------------------------------------------------------------------------------
|
||||
|
||||
/** @type {import('../types').Rule.RuleModule} */
|
||||
module.exports = {
|
||||
meta: {
|
||||
deprecated: {
|
||||
message: "Formatting rules are being moved out of ESLint core.",
|
||||
url: "https://eslint.org/blog/2023/10/deprecating-formatting-rules/",
|
||||
deprecatedSince: "8.53.0",
|
||||
availableUntil: "11.0.0",
|
||||
replacedBy: [
|
||||
{
|
||||
message:
|
||||
"ESLint Stylistic now maintains deprecated stylistic core rules.",
|
||||
url: "https://eslint.style/guide/migration",
|
||||
plugin: {
|
||||
name: "@stylistic/eslint-plugin",
|
||||
url: "https://eslint.style",
|
||||
},
|
||||
rule: {
|
||||
name: "function-call-argument-newline",
|
||||
url: "https://eslint.style/rules/function-call-argument-newline",
|
||||
},
|
||||
},
|
||||
],
|
||||
},
|
||||
type: "layout",
|
||||
|
||||
docs: {
|
||||
description:
|
||||
"Enforce line breaks between arguments of a function call",
|
||||
recommended: false,
|
||||
url: "https://eslint.org/docs/latest/rules/function-call-argument-newline",
|
||||
},
|
||||
|
||||
fixable: "whitespace",
|
||||
|
||||
schema: [
|
||||
{
|
||||
enum: ["always", "never", "consistent"],
|
||||
},
|
||||
],
|
||||
|
||||
messages: {
|
||||
unexpectedLineBreak: "There should be no line break here.",
|
||||
missingLineBreak:
|
||||
"There should be a line break after this argument.",
|
||||
},
|
||||
},
|
||||
|
||||
create(context) {
|
||||
const sourceCode = context.sourceCode;
|
||||
|
||||
const checkers = {
|
||||
unexpected: {
|
||||
messageId: "unexpectedLineBreak",
|
||||
check: (prevToken, currentToken) =>
|
||||
prevToken.loc.end.line !== currentToken.loc.start.line,
|
||||
createFix: (token, tokenBefore) => fixer =>
|
||||
fixer.replaceTextRange(
|
||||
[tokenBefore.range[1], token.range[0]],
|
||||
" ",
|
||||
),
|
||||
},
|
||||
missing: {
|
||||
messageId: "missingLineBreak",
|
||||
check: (prevToken, currentToken) =>
|
||||
prevToken.loc.end.line === currentToken.loc.start.line,
|
||||
createFix: (token, tokenBefore) => fixer =>
|
||||
fixer.replaceTextRange(
|
||||
[tokenBefore.range[1], token.range[0]],
|
||||
"\n",
|
||||
),
|
||||
},
|
||||
};
|
||||
|
||||
/**
|
||||
* Check all arguments for line breaks in the CallExpression
|
||||
* @param {CallExpression} node node to evaluate
|
||||
* @param {{ messageId: string, check: Function }} checker selected checker
|
||||
* @returns {void}
|
||||
* @private
|
||||
*/
|
||||
function checkArguments(node, checker) {
|
||||
for (let i = 1; i < node.arguments.length; i++) {
|
||||
const prevArgToken = sourceCode.getLastToken(
|
||||
node.arguments[i - 1],
|
||||
);
|
||||
const currentArgToken = sourceCode.getFirstToken(
|
||||
node.arguments[i],
|
||||
);
|
||||
|
||||
if (checker.check(prevArgToken, currentArgToken)) {
|
||||
const tokenBefore = sourceCode.getTokenBefore(
|
||||
currentArgToken,
|
||||
{ includeComments: true },
|
||||
);
|
||||
|
||||
const hasLineCommentBefore = tokenBefore.type === "Line";
|
||||
|
||||
context.report({
|
||||
node,
|
||||
loc: {
|
||||
start: tokenBefore.loc.end,
|
||||
end: currentArgToken.loc.start,
|
||||
},
|
||||
messageId: checker.messageId,
|
||||
fix: hasLineCommentBefore
|
||||
? null
|
||||
: checker.createFix(currentArgToken, tokenBefore),
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Check if open space is present in a function name
|
||||
* @param {CallExpression} node node to evaluate
|
||||
* @returns {void}
|
||||
* @private
|
||||
*/
|
||||
function check(node) {
|
||||
if (node.arguments.length < 2) {
|
||||
return;
|
||||
}
|
||||
|
||||
const option = context.options[0] || "always";
|
||||
|
||||
if (option === "never") {
|
||||
checkArguments(node, checkers.unexpected);
|
||||
} else if (option === "always") {
|
||||
checkArguments(node, checkers.missing);
|
||||
} else if (option === "consistent") {
|
||||
const firstArgToken = sourceCode.getLastToken(
|
||||
node.arguments[0],
|
||||
);
|
||||
const secondArgToken = sourceCode.getFirstToken(
|
||||
node.arguments[1],
|
||||
);
|
||||
|
||||
if (
|
||||
firstArgToken.loc.end.line === secondArgToken.loc.start.line
|
||||
) {
|
||||
checkArguments(node, checkers.unexpected);
|
||||
} else {
|
||||
checkArguments(node, checkers.missing);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return {
|
||||
CallExpression: check,
|
||||
NewExpression: check,
|
||||
};
|
||||
},
|
||||
};
|
||||
@@ -0,0 +1,142 @@
|
||||
import * as ts from 'typescript';
|
||||
import type { TSError } from './node-utils';
|
||||
import type { ParserWeakMap, ParserWeakMapESTreeToTSNode } from './parser-options';
|
||||
import type { SemanticOrSyntacticError } from './semantic-or-syntactic-errors';
|
||||
import type { TSESTree, TSNode } from './ts-estree';
|
||||
export interface ConverterOptions {
|
||||
allowInvalidAST?: boolean;
|
||||
errorOnUnknownASTType?: boolean;
|
||||
shouldPreserveNodeMaps?: boolean;
|
||||
suppressDeprecatedPropertyWarnings?: boolean;
|
||||
}
|
||||
/**
|
||||
* Extends and formats a given error object
|
||||
* @param error the error object
|
||||
* @returns converted error object
|
||||
*/
|
||||
export declare function convertError(error: SemanticOrSyntacticError | ts.DiagnosticWithLocation): TSError;
|
||||
export interface ASTMaps {
|
||||
esTreeNodeToTSNodeMap: ParserWeakMapESTreeToTSNode;
|
||||
tsNodeToESTreeNodeMap: ParserWeakMap<TSNode, TSESTree.Node>;
|
||||
}
|
||||
export declare class Converter {
|
||||
#private;
|
||||
private allowPattern;
|
||||
private readonly ast;
|
||||
private readonly esTreeNodeToTSNodeMap;
|
||||
private readonly options;
|
||||
private readonly tsNodeToESTreeNodeMap;
|
||||
/**
|
||||
* Converts a TypeScript node into an ESTree node
|
||||
* @param ast the full TypeScript AST
|
||||
* @param options additional options for the conversion
|
||||
* @returns the converted ESTreeNode
|
||||
*/
|
||||
constructor(ast: ts.SourceFile, options?: ConverterOptions);
|
||||
private convertBindingNameWithTypeAnnotation;
|
||||
/**
|
||||
* Coverts body Nodes and add a directive field to StringLiterals
|
||||
* @param nodes of ts.Node
|
||||
* @param parent parentNode
|
||||
* @returns Array of body statements
|
||||
*/
|
||||
private convertBodyExpressions;
|
||||
private convertChainExpression;
|
||||
/**
|
||||
* Converts a TypeScript node into an ESTree node.
|
||||
* @param child the child ts.Node
|
||||
* @param parent parentNode
|
||||
* @returns the converted ESTree node
|
||||
*/
|
||||
private convertChild;
|
||||
/**
|
||||
* Converts TypeScript node array into an ESTree node list.
|
||||
* @param children the child `ts.NodeArray` or `ts.Node[]`
|
||||
* @param parent parentNode
|
||||
* @returns the converted ESTree node list
|
||||
*/
|
||||
private convertChildren;
|
||||
/**
|
||||
* Converts a TypeScript node into an ESTree node.
|
||||
* @param child the child ts.Node
|
||||
* @param parent parentNode
|
||||
* @returns the converted ESTree node
|
||||
*/
|
||||
private convertPattern;
|
||||
/**
|
||||
* Converts a child into a type annotation. This creates an intermediary
|
||||
* TypeAnnotation node to match what Flow does.
|
||||
* @param child The TypeScript AST node to convert.
|
||||
* @param parent parentNode
|
||||
* @returns The type annotation node.
|
||||
*/
|
||||
private convertTypeAnnotation;
|
||||
/**
|
||||
* Converts a ts.Node's typeArguments to TSTypeParameterInstantiation node
|
||||
* @param typeArguments ts.NodeArray typeArguments
|
||||
* @param node parent used to create this node
|
||||
* @returns TypeParameterInstantiation node
|
||||
*/
|
||||
private convertTypeArguments;
|
||||
/**
|
||||
* Converts a ts.Node's typeParameters to TSTypeParameterDeclaration node
|
||||
* @param typeParameters ts.Node typeParameters
|
||||
* @returns TypeParameterDeclaration node
|
||||
*/
|
||||
private convertTypeParameters;
|
||||
/**
|
||||
* Converts an array of ts.Node parameters into an array of ESTreeNode params
|
||||
* @param parameters An array of ts.Node params to be converted
|
||||
* @returns an array of converted ESTreeNode params
|
||||
*/
|
||||
private convertParameters;
|
||||
/**
|
||||
* Converts a TypeScript node into an ESTree node.
|
||||
* @param node the child ts.Node
|
||||
* @param parent parentNode
|
||||
* @param allowPattern flag to determine if patterns are allowed
|
||||
* @returns the converted ESTree node
|
||||
*/
|
||||
private converter;
|
||||
private convertImportAttributes;
|
||||
private convertJSXIdentifier;
|
||||
private convertJSXNamespaceOrIdentifier;
|
||||
/**
|
||||
* Converts a TypeScript JSX node.tagName into an ESTree node.name
|
||||
* @param node the tagName object from a JSX ts.Node
|
||||
* @returns the converted ESTree name object
|
||||
*/
|
||||
private convertJSXTagName;
|
||||
private convertMethodSignature;
|
||||
/**
|
||||
* Uses the provided range location to adjust the location data of the given Node
|
||||
* @param result The node that will have its location data mutated
|
||||
* @param childRange The child node range used to expand location
|
||||
*/
|
||||
private fixParentLocation;
|
||||
/**
|
||||
* Converts a TypeScript node into an ESTree node.
|
||||
* The core of the conversion logic:
|
||||
* Identify and convert each relevant TypeScript SyntaxKind
|
||||
* @returns the converted ESTree node
|
||||
*/
|
||||
private convertNode;
|
||||
private createNode;
|
||||
convertProgram(): TSESTree.Program;
|
||||
/**
|
||||
* For nodes that are copied directly from the TypeScript AST into
|
||||
* ESTree mostly as-is. The only difference is the addition of a type
|
||||
* property instead of a kind property. Recursively copies all children.
|
||||
*/
|
||||
private deeplyCopy;
|
||||
/**
|
||||
* Fixes the exports of the given ts.Node
|
||||
* @returns the ESTreeNode with fixed exports
|
||||
*/
|
||||
private fixExports;
|
||||
getASTMaps(): ASTMaps;
|
||||
/**
|
||||
* Register specific TypeScript node into map with first ESTree node provided
|
||||
*/
|
||||
private registerTSNodeInNodeMap;
|
||||
}
|
||||
@@ -0,0 +1,19 @@
|
||||
import type { BlockScope } from './BlockScope';
|
||||
import type { CatchScope } from './CatchScope';
|
||||
import type { ClassFieldInitializerScope } from './ClassFieldInitializerScope';
|
||||
import type { ClassScope } from './ClassScope';
|
||||
import type { ClassStaticBlockScope } from './ClassStaticBlockScope';
|
||||
import type { ConditionalTypeScope } from './ConditionalTypeScope';
|
||||
import type { ForScope } from './ForScope';
|
||||
import type { FunctionExpressionNameScope } from './FunctionExpressionNameScope';
|
||||
import type { FunctionScope } from './FunctionScope';
|
||||
import type { FunctionTypeScope } from './FunctionTypeScope';
|
||||
import type { GlobalScope } from './GlobalScope';
|
||||
import type { MappedTypeScope } from './MappedTypeScope';
|
||||
import type { ModuleScope } from './ModuleScope';
|
||||
import type { SwitchScope } from './SwitchScope';
|
||||
import type { TSEnumScope } from './TSEnumScope';
|
||||
import type { TSModuleScope } from './TSModuleScope';
|
||||
import type { TypeScope } from './TypeScope';
|
||||
import type { WithScope } from './WithScope';
|
||||
export type Scope = BlockScope | CatchScope | ClassFieldInitializerScope | ClassScope | ClassStaticBlockScope | ConditionalTypeScope | ForScope | FunctionExpressionNameScope | FunctionScope | FunctionTypeScope | GlobalScope | MappedTypeScope | ModuleScope | SwitchScope | TSEnumScope | TSModuleScope | TypeScope | WithScope;
|
||||
@@ -0,0 +1,4 @@
|
||||
{
|
||||
"main": "../../cjs/_read_only_error.cjs",
|
||||
"module": "../../esm/_read_only_error.js"
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
"use strict";
|
||||
|
||||
var _to_primitive = require("./_to_primitive.cjs");
|
||||
var _type_of = require("./_type_of.cjs");
|
||||
|
||||
function _to_property_key(arg) {
|
||||
var key = _to_primitive._(arg, "string");
|
||||
|
||||
return _type_of._(key) === "symbol" ? key : String(key);
|
||||
}
|
||||
exports._ = _to_property_key;
|
||||
@@ -0,0 +1,56 @@
|
||||
declare const _default: {
|
||||
extends: string[];
|
||||
rules: {
|
||||
'@typescript-eslint/await-thenable': "error";
|
||||
'@typescript-eslint/ban-ts-comment': "error";
|
||||
'no-array-constructor': "off";
|
||||
'@typescript-eslint/no-array-constructor': "error";
|
||||
'@typescript-eslint/no-array-delete': "error";
|
||||
'@typescript-eslint/no-base-to-string': "error";
|
||||
'@typescript-eslint/no-duplicate-enum-values': "error";
|
||||
'@typescript-eslint/no-duplicate-type-constituents': "error";
|
||||
'@typescript-eslint/no-empty-object-type': "error";
|
||||
'@typescript-eslint/no-explicit-any': "error";
|
||||
'@typescript-eslint/no-extra-non-null-assertion': "error";
|
||||
'@typescript-eslint/no-floating-promises': "error";
|
||||
'@typescript-eslint/no-for-in-array': "error";
|
||||
'no-implied-eval': "off";
|
||||
'@typescript-eslint/no-implied-eval': "error";
|
||||
'@typescript-eslint/no-misused-new': "error";
|
||||
'@typescript-eslint/no-misused-promises': "error";
|
||||
'@typescript-eslint/no-namespace': "error";
|
||||
'@typescript-eslint/no-non-null-asserted-optional-chain': "error";
|
||||
'@typescript-eslint/no-redundant-type-constituents': "error";
|
||||
'@typescript-eslint/no-require-imports': "error";
|
||||
'@typescript-eslint/no-this-alias': "error";
|
||||
'@typescript-eslint/no-unnecessary-type-assertion': "error";
|
||||
'@typescript-eslint/no-unnecessary-type-constraint': "error";
|
||||
'@typescript-eslint/no-unsafe-argument': "error";
|
||||
'@typescript-eslint/no-unsafe-assignment': "error";
|
||||
'@typescript-eslint/no-unsafe-call': "error";
|
||||
'@typescript-eslint/no-unsafe-declaration-merging': "error";
|
||||
'@typescript-eslint/no-unsafe-enum-comparison': "error";
|
||||
'@typescript-eslint/no-unsafe-function-type': "error";
|
||||
'@typescript-eslint/no-unsafe-member-access': "error";
|
||||
'@typescript-eslint/no-unsafe-return': "error";
|
||||
'@typescript-eslint/no-unsafe-unary-minus': "error";
|
||||
'no-unused-expressions': "off";
|
||||
'@typescript-eslint/no-unused-expressions': "error";
|
||||
'no-unused-vars': "off";
|
||||
'@typescript-eslint/no-unused-vars': "error";
|
||||
'@typescript-eslint/no-wrapper-object-types': "error";
|
||||
'no-throw-literal': "off";
|
||||
'@typescript-eslint/only-throw-error': "error";
|
||||
'@typescript-eslint/prefer-as-const': "error";
|
||||
'@typescript-eslint/prefer-namespace-keyword': "error";
|
||||
'prefer-promise-reject-errors': "off";
|
||||
'@typescript-eslint/prefer-promise-reject-errors': "error";
|
||||
'require-await': "off";
|
||||
'@typescript-eslint/require-await': "error";
|
||||
'@typescript-eslint/restrict-plus-operands': "error";
|
||||
'@typescript-eslint/restrict-template-expressions': "error";
|
||||
'@typescript-eslint/triple-slash-reference': "error";
|
||||
'@typescript-eslint/unbound-method': "error";
|
||||
};
|
||||
};
|
||||
export = _default;
|
||||
@@ -0,0 +1,57 @@
|
||||
{
|
||||
"reg": {
|
||||
"name": "reg",
|
||||
"browser": "Safari 10.0.1 (Mac OS X 10.12.1)",
|
||||
"suite": "escape-short",
|
||||
"hz": 533176.8779355418,
|
||||
"success": true,
|
||||
"fastest": false,
|
||||
"rme": 0.029034713022792057,
|
||||
"rhz": 0.282500548086439,
|
||||
"sampleSize": 164
|
||||
},
|
||||
"fn if": {
|
||||
"name": "fn if",
|
||||
"browser": "Safari 10.0.1 (Mac OS X 10.12.1)",
|
||||
"suite": "escape-short",
|
||||
"hz": 533457.5359566113,
|
||||
"success": true,
|
||||
"fastest": false,
|
||||
"rme": 0.02156079440256287,
|
||||
"rhz": 0.28264925304357064,
|
||||
"sampleSize": 168
|
||||
},
|
||||
"fn if reverse": {
|
||||
"name": "fn if reverse",
|
||||
"browser": "Safari 10.0.1 (Mac OS X 10.12.1)",
|
||||
"suite": "escape-short",
|
||||
"hz": 603198.7984494594,
|
||||
"success": true,
|
||||
"fastest": false,
|
||||
"rme": 0.013174622557629538,
|
||||
"rhz": 0.3196012396990228,
|
||||
"sampleSize": 175
|
||||
},
|
||||
"escape31": {
|
||||
"name": "escape31",
|
||||
"browser": "Safari 10.0.1 (Mac OS X 10.12.1)",
|
||||
"suite": "escape-short",
|
||||
"hz": 713978.8522159118,
|
||||
"success": true,
|
||||
"fastest": false,
|
||||
"rme": 0.011570099195855615,
|
||||
"rhz": 0.37829738201345275,
|
||||
"sampleSize": 174
|
||||
},
|
||||
"native": {
|
||||
"name": "native",
|
||||
"browser": "Safari 10.0.1 (Mac OS X 10.12.1)",
|
||||
"suite": "escape-short",
|
||||
"hz": 1887348.118604008,
|
||||
"success": true,
|
||||
"fastest": true,
|
||||
"rme": 0.02768628880843476,
|
||||
"rhz": 1,
|
||||
"sampleSize": 171
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1 @@
|
||||
export { _ as default } from "../esm/_class_apply_descriptor_set.js";
|
||||
File diff suppressed because it is too large
Load Diff
@@ -0,0 +1,3 @@
|
||||
import {should} from './index.js';
|
||||
|
||||
globalThis.should = should();
|
||||
@@ -0,0 +1,62 @@
|
||||
{
|
||||
"name": "eventemitter3",
|
||||
"version": "5.0.4",
|
||||
"description": "EventEmitter3 focuses on performance while maintaining a Node.js AND browser compatible interface.",
|
||||
"exports": {
|
||||
".": {
|
||||
"types": "./index.d.ts",
|
||||
"import": "./index.mjs",
|
||||
"require": "./index.js"
|
||||
},
|
||||
"./package.json": "./package.json"
|
||||
},
|
||||
"main": "index.js",
|
||||
"types": "index.d.ts",
|
||||
"scripts": {
|
||||
"rollup": "rm -rf dist && rollup -c",
|
||||
"benchmark": "find benchmarks/run -name '*.js' -exec benchmarks/start.sh {} \\;",
|
||||
"test": "c8 --reporter=lcov --reporter=text mocha test/test.js",
|
||||
"test-esm": "mocha test/test.mjs",
|
||||
"prepublishOnly": "npm run rollup"
|
||||
},
|
||||
"files": [
|
||||
"index.js",
|
||||
"index.mjs",
|
||||
"index.d.ts",
|
||||
"dist"
|
||||
],
|
||||
"repository": {
|
||||
"type": "git",
|
||||
"url": "git://github.com/primus/eventemitter3.git"
|
||||
},
|
||||
"keywords": [
|
||||
"EventEmitter",
|
||||
"EventEmitter2",
|
||||
"EventEmitter3",
|
||||
"Events",
|
||||
"addEventListener",
|
||||
"addListener",
|
||||
"emit",
|
||||
"emits",
|
||||
"emitter",
|
||||
"event",
|
||||
"once",
|
||||
"pub/sub",
|
||||
"publish",
|
||||
"reactor",
|
||||
"subscribe"
|
||||
],
|
||||
"author": "Arnout Kazemier",
|
||||
"license": "MIT",
|
||||
"bugs": {
|
||||
"url": "https://github.com/primus/eventemitter3/issues"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@rollup/plugin-commonjs": "^29.0.0",
|
||||
"@rollup/plugin-terser": "^0.4.0",
|
||||
"assume": "^2.2.0",
|
||||
"c8": "^10.1.3",
|
||||
"mocha": "^11.7.5",
|
||||
"rollup": "^4.5.2"
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,12 @@
|
||||
"use strict";
|
||||
// THIS CODE WAS AUTOMATICALLY GENERATED
|
||||
// DO NOT EDIT THIS CODE BY HAND
|
||||
// RUN THE FOLLOWING COMMAND FROM THE WORKSPACE ROOT TO REGENERATE:
|
||||
// npx nx generate-lib repo
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
exports.es2017_date = void 0;
|
||||
const base_config_1 = require("./base-config");
|
||||
exports.es2017_date = {
|
||||
libs: [],
|
||||
variables: [['DateConstructor', base_config_1.TYPE]],
|
||||
};
|
||||
@@ -0,0 +1,4 @@
|
||||
export { AST_NODE_TYPES, AST_TOKEN_TYPES } from './generated/ast-spec';
|
||||
export * from './lib';
|
||||
export * from './parser-options';
|
||||
export * from './ts-estree';
|
||||
@@ -0,0 +1,8 @@
|
||||
/node_modules
|
||||
.*
|
||||
!.gitignore
|
||||
!.travis.yml
|
||||
!.jshintrc
|
||||
!.npmignore
|
||||
/coverage
|
||||
/yarn-error.log
|
||||
@@ -0,0 +1,10 @@
|
||||
'use strict';
|
||||
|
||||
const {chain} = require('stream-chain');
|
||||
|
||||
const Parser = require('../Parser');
|
||||
|
||||
const withParser = (fn, options) =>
|
||||
chain([new Parser(options), fn(options)], Object.assign({}, options, {writableObjectMode: false, readableObjectMode: true}));
|
||||
|
||||
module.exports = withParser;
|
||||
@@ -0,0 +1,22 @@
|
||||
The MIT License (MIT)
|
||||
|
||||
Copyright (c) Roy Riojas & Jared Wray
|
||||
|
||||
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.
|
||||
|
||||
@@ -0,0 +1,13 @@
|
||||
import type { TSESLint, TSESTree } from '@typescript-eslint/utils';
|
||||
import type { InferMessageIdsTypeFromRule, InferOptionsTypeFromRule } from '../util';
|
||||
declare const baseRule: TSESLint.RuleModule<"unsafeRefs", [], unknown, {
|
||||
ArrowFunctionExpression(node: TSESTree.ArrowFunctionExpression): void;
|
||||
FunctionDeclaration(node: TSESTree.FunctionDeclaration): void;
|
||||
FunctionExpression(node: TSESTree.FunctionExpression): void;
|
||||
}>;
|
||||
export type Options = InferOptionsTypeFromRule<typeof baseRule>;
|
||||
export type MessageIds = InferMessageIdsTypeFromRule<typeof baseRule>;
|
||||
declare const _default: TSESLint.RuleModule<"unsafeRefs", [], import("../../rules").ESLintPluginDocs, TSESLint.RuleListener> & {
|
||||
name: string;
|
||||
};
|
||||
export default _default;
|
||||
@@ -0,0 +1,4 @@
|
||||
function _classNameTDZError(e) {
|
||||
throw new ReferenceError('Class "' + e + '" cannot be referenced in computed property keys.');
|
||||
}
|
||||
module.exports = _classNameTDZError, module.exports.__esModule = true, module.exports["default"] = module.exports;
|
||||
@@ -0,0 +1,6 @@
|
||||
export { builtinEnvironments, populateGlobal } from './environments.js';
|
||||
export { VitestSnapshotEnvironment } from './snapshot.js';
|
||||
export { E as Environment, a as EnvironmentReturn, V as VmEnvironmentReturn } from './chunks/environment.d.CrsxCzP1.js';
|
||||
export { VitestRunner, VitestRunnerConfig } from '@vitest/runner';
|
||||
export { SnapshotEnvironment } from '@vitest/snapshot/environment';
|
||||
import '@vitest/utils';
|
||||
@@ -0,0 +1,67 @@
|
||||
export default class BufferList {
|
||||
constructor(public buffers: Buffer[] = []) {}
|
||||
|
||||
public add(buffer: Buffer, front?: boolean) {
|
||||
this.buffers[front ? 'unshift' : 'push'](buffer)
|
||||
return this
|
||||
}
|
||||
|
||||
public addInt16(val: number, front?: boolean) {
|
||||
return this.add(Buffer.from([val >>> 8, val >>> 0]), front)
|
||||
}
|
||||
|
||||
public getByteLength() {
|
||||
return this.buffers.reduce(function (previous, current) {
|
||||
return previous + current.length
|
||||
}, 0)
|
||||
}
|
||||
|
||||
public addInt32(val: number, first?: boolean) {
|
||||
return this.add(
|
||||
Buffer.from([(val >>> 24) & 0xff, (val >>> 16) & 0xff, (val >>> 8) & 0xff, (val >>> 0) & 0xff]),
|
||||
first
|
||||
)
|
||||
}
|
||||
|
||||
public addCString(val: string, front?: boolean) {
|
||||
const len = Buffer.byteLength(val)
|
||||
const buffer = Buffer.alloc(len + 1)
|
||||
buffer.write(val)
|
||||
buffer[len] = 0
|
||||
return this.add(buffer, front)
|
||||
}
|
||||
|
||||
public addString(val: string, front?: boolean) {
|
||||
const len = Buffer.byteLength(val)
|
||||
const buffer = Buffer.alloc(len)
|
||||
buffer.write(val)
|
||||
return this.add(buffer, front)
|
||||
}
|
||||
|
||||
public addChar(char: string, first?: boolean) {
|
||||
return this.add(Buffer.from(char, 'utf8'), first)
|
||||
}
|
||||
|
||||
public addByte(byte: number) {
|
||||
return this.add(Buffer.from([byte]))
|
||||
}
|
||||
|
||||
public join(appendLength?: boolean, char?: string): Buffer {
|
||||
let length = this.getByteLength()
|
||||
if (appendLength) {
|
||||
this.addInt32(length + 4, true)
|
||||
return this.join(false, char)
|
||||
}
|
||||
if (char) {
|
||||
this.addChar(char, true)
|
||||
length++
|
||||
}
|
||||
const result = Buffer.alloc(length)
|
||||
let index = 0
|
||||
this.buffers.forEach(function (buffer) {
|
||||
buffer.copy(result, index, 0)
|
||||
index += buffer.length
|
||||
})
|
||||
return result
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,34 @@
|
||||
'use strict';
|
||||
|
||||
var resolve = require('./resolve');
|
||||
|
||||
module.exports = {
|
||||
Validation: errorSubclass(ValidationError),
|
||||
MissingRef: errorSubclass(MissingRefError)
|
||||
};
|
||||
|
||||
|
||||
function ValidationError(errors) {
|
||||
this.message = 'validation failed';
|
||||
this.errors = errors;
|
||||
this.ajv = this.validation = true;
|
||||
}
|
||||
|
||||
|
||||
MissingRefError.message = function (baseId, ref) {
|
||||
return 'can\'t resolve reference ' + ref + ' from id ' + baseId;
|
||||
};
|
||||
|
||||
|
||||
function MissingRefError(baseId, ref, message) {
|
||||
this.message = message || MissingRefError.message(baseId, ref);
|
||||
this.missingRef = resolve.url(baseId, ref);
|
||||
this.missingSchema = resolve.normalizeId(resolve.fullPath(this.missingRef));
|
||||
}
|
||||
|
||||
|
||||
function errorSubclass(Subclass) {
|
||||
Subclass.prototype = Object.create(Error.prototype);
|
||||
Subclass.prototype.constructor = Subclass;
|
||||
return Subclass;
|
||||
}
|
||||
Reference in New Issue
Block a user