WIP: bootstrap and partial real Solana watcher implementation

This commit is contained in:
2026-08-16 09:17:45 +00:00
commit dc23412c3f
7232 changed files with 1687637 additions and 0 deletions

View File

@@ -0,0 +1,10 @@
'use strict';
const WebSocket = require('./lib/websocket');
WebSocket.createWebSocketStream = require('./lib/stream');
WebSocket.Server = require('./lib/websocket-server');
WebSocket.Receiver = require('./lib/receiver');
WebSocket.Sender = require('./lib/sender');
module.exports = WebSocket;

View File

@@ -0,0 +1,23 @@
// @ts-ignore TS6133
import { expect, test } from "vitest";
import { type SyncParseReturnType, isAborted, isDirty, isValid } from "../helpers/parseUtil.js";
test("parseUtil isInvalid should use structural typing", () => {
// Test for issue #556: https://github.com/colinhacks/zod/issues/556
const aborted: SyncParseReturnType = { status: "aborted" };
const dirty: SyncParseReturnType = { status: "dirty", value: "whatever" };
const valid: SyncParseReturnType = { status: "valid", value: "whatever" };
expect(isAborted(aborted)).toBe(true);
expect(isAborted(dirty)).toBe(false);
expect(isAborted(valid)).toBe(false);
expect(isDirty(aborted)).toBe(false);
expect(isDirty(dirty)).toBe(true);
expect(isDirty(valid)).toBe(false);
expect(isValid(aborted)).toBe(false);
expect(isValid(dirty)).toBe(false);
expect(isValid(valid)).toBe(true);
});

View File

@@ -0,0 +1,150 @@
# Changelog
## [0.15.0](https://github.com/humanwhocodes/humanfs/compare/types-v0.14.0...types-v0.15.0) (2024-09-09)
### Features
* Add depth to HfsWalkEntry ([#130](https://github.com/humanwhocodes/humanfs/issues/130)) ([a633452](https://github.com/humanwhocodes/humanfs/commit/a63345260562b798e73c2ea63612e6fe95ac400d))
## [0.14.0](https://github.com/humanwhocodes/humanfs/compare/types-v0.13.0...types-v0.14.0) (2024-06-12)
### Features
* Implement Hfs#walk() method ([#119](https://github.com/humanwhocodes/humanfs/issues/119)) ([2aeade0](https://github.com/humanwhocodes/humanfs/commit/2aeade0ffbef886103dc38d16694e9b63191a8df))
## [0.13.0](https://github.com/humanwhocodes/humanfs/compare/types-v0.12.0...types-v0.13.0) (2024-03-20)
### ⚠ BREAKING CHANGES
* delete/deleteAll should not throw on ENOENT ([#105](https://github.com/humanwhocodes/humanfs/issues/105))
### Features
* delete/deleteAll should not throw on ENOENT ([#105](https://github.com/humanwhocodes/humanfs/issues/105)) ([b508df1](https://github.com/humanwhocodes/humanfs/commit/b508df19845f7a914895c13cfe47707c0cd1a7c7))
## [0.12.0](https://github.com/humanwhocodes/humanfs/compare/types-v0.11.0...types-v0.12.0) (2024-02-27)
### Features
* impl write() method only needs to handle Uint8Arrays ([#92](https://github.com/humanwhocodes/humanfs/issues/92)) ([68bcfb5](https://github.com/humanwhocodes/humanfs/commit/68bcfb59a6684b184c55f97536aad730636299b5))
## [0.11.0](https://github.com/humanwhocodes/humanfs/compare/types-v0.10.0...types-v0.11.0) (2024-02-23)
### Features
* Impls only need bytes() method to read data ([#90](https://github.com/humanwhocodes/humanfs/issues/90)) ([c0c3b36](https://github.com/humanwhocodes/humanfs/commit/c0c3b36413c8d10e63a94ad1cc6a5cead7b52e88))
## [0.10.0](https://github.com/humanwhocodes/humanfs/compare/types-v0.9.0...types-v0.10.0) (2024-02-16)
### ⚠ BREAKING CHANGES
* Rewrite MemoryHfsImpl to support lastModified() ([#87](https://github.com/humanwhocodes/humanfs/issues/87))
### Features
* Add lastModified() method ([#84](https://github.com/humanwhocodes/humanfs/issues/84)) ([9cbcd03](https://github.com/humanwhocodes/humanfs/commit/9cbcd03c86e4c1bed5985e10da6ab452e8c2b44c))
* Rewrite MemoryHfsImpl to support lastModified() ([#87](https://github.com/humanwhocodes/humanfs/issues/87)) ([84e9812](https://github.com/humanwhocodes/humanfs/commit/84e98129e48acb3f2ea067b0ea745d591e8d8b91))
## [0.9.0](https://github.com/humanwhocodes/humanfs/compare/types-v0.8.0...types-v0.9.0) (2024-02-14)
### Features
* Add append() method ([#82](https://github.com/humanwhocodes/humanfs/issues/82)) ([ab7b978](https://github.com/humanwhocodes/humanfs/commit/ab7b978ff3be84dc3fd2fd4d6fa1131dfdec8134))
* Add move() and moveAll() methods ([#80](https://github.com/humanwhocodes/humanfs/issues/80)) ([85f100b](https://github.com/humanwhocodes/humanfs/commit/85f100b721c99b920b307779548c2a043e7e18b5))
## [0.8.0](https://github.com/humanwhocodes/humanfs/compare/types-v0.7.0...types-v0.8.0) (2024-02-09)
### Features
* Add copyAll() method ([#77](https://github.com/humanwhocodes/humanfs/issues/77)) ([3c0852a](https://github.com/humanwhocodes/humanfs/commit/3c0852af99cb835b3941f58fdc2206e7b1179e21))
## [0.7.0](https://github.com/humanwhocodes/humanfs/compare/types-v0.6.0...types-v0.7.0) (2024-02-08)
### Features
* Add copy() method ([#69](https://github.com/humanwhocodes/humanfs/issues/69)) ([f252bac](https://github.com/humanwhocodes/humanfs/commit/f252bac6692a5b5c973ee3c696f5190caa5f12c7))
## [0.6.0](https://github.com/humanwhocodes/humanfs/compare/types-v0.5.1...types-v0.6.0) (2024-02-07)
### Features
* Allow URL file and directory paths ([#62](https://github.com/humanwhocodes/humanfs/issues/62)) ([a767e37](https://github.com/humanwhocodes/humanfs/commit/a767e372287b1556c4c9e8bdb26c23ff81866f99))
## [0.5.1](https://github.com/humanwhocodes/humanfs/compare/types-v0.5.0...types-v0.5.1) (2024-01-31)
### Bug Fixes
* Order of exports and engines in package.json ([66204c2](https://github.com/humanwhocodes/humanfs/commit/66204c24bc2dd02380aa2fb3c5769ca2cf5238a7)), closes [#61](https://github.com/humanwhocodes/humanfs/issues/61)
## [0.5.0](https://github.com/humanwhocodes/humanfs/compare/types-v0.4.0...types-v0.5.0) (2024-01-30)
### ⚠ BREAKING CHANGES
* Rename fsx -> humanfs ([#56](https://github.com/humanwhocodes/humanfs/issues/56))
### Features
* Rename fsx -> humanfs ([#56](https://github.com/humanwhocodes/humanfs/issues/56)) ([f5dc533](https://github.com/humanwhocodes/humanfs/commit/f5dc533c8a46d45afd7aad602af39a6074f8a07b))
## [0.4.0](https://github.com/humanwhocodes/fsx/compare/fsx-types-v0.3.0...fsx-types-v0.4.0) (2024-01-27)
### Features
* New size() method ([#51](https://github.com/humanwhocodes/fsx/issues/51)) ([ffd12e6](https://github.com/humanwhocodes/fsx/commit/ffd12e6b0db318320dd5a9dbb8eb248106d60afa))
## [0.3.0](https://github.com/humanwhocodes/fsx/compare/fsx-types-v0.2.0...fsx-types-v0.3.0) (2024-01-23)
### ⚠ BREAKING CHANGES
* Safer delete(); new deleteAll() method ([#37](https://github.com/humanwhocodes/fsx/issues/37))
### Features
* Safer delete(); new deleteAll() method ([#37](https://github.com/humanwhocodes/fsx/issues/37)) ([2e85142](https://github.com/humanwhocodes/fsx/commit/2e85142e34bdc3cc18e18aa0b051cc9007fca4b8))
* write() to accept ArrayBuffer views as file contents ([1fd5517](https://github.com/humanwhocodes/fsx/commit/1fd55174a528ef3dcbabc154347006bec799f3f9))
### Bug Fixes
* **types:** Ensure FsxImpl methods also return undefined ([14eadc6](https://github.com/humanwhocodes/fsx/commit/14eadc66b19e40d7406a166e019004d9888075d3)), closes [#32](https://github.com/humanwhocodes/fsx/issues/32)
## [0.2.0](https://github.com/humanwhocodes/fsx/compare/fsx-types-v0.1.0...fsx-types-v0.2.0) (2024-01-19)
### Features
* Add list() method ([#25](https://github.com/humanwhocodes/fsx/issues/25)) ([dad841b](https://github.com/humanwhocodes/fsx/commit/dad841b7c9f5312996ff23db9be36774af985157))
## [0.1.0](https://github.com/humanwhocodes/fsx/compare/fsx-types-v0.0.3...fsx-types-v0.1.0) (2024-01-18)
### Features
* Add bytes() method, deprecate arrayBuffer() ([718c9c8](https://github.com/humanwhocodes/fsx/commit/718c9c84a0a1dcaef3cc032c882b1308e9cb3273))
## [0.0.3](https://github.com/humanwhocodes/fsx/compare/fsx-types-v0.0.2...fsx-types-v0.0.3) (2024-01-16)
### Bug Fixes
* Ensure isFile/isDirectory rethrow non-ENOENT errors. ([d31ee56](https://github.com/humanwhocodes/fsx/commit/d31ee56788e898cbc1fc0d6a54d1551f9b17cd45)), closes [#14](https://github.com/humanwhocodes/fsx/issues/14)
## [0.0.2](https://github.com/humanwhocodes/fsx/compare/fsx-types-v0.0.1...fsx-types-v0.0.2) (2024-01-06)
### Bug Fixes
- **docs:** Correct package names in READMEs ([6c552ac](https://github.com/humanwhocodes/fsx/commit/6c552ac74542a245cdc2675101858da022336a1a))

View File

@@ -0,0 +1,5 @@
type RequiredProperty<Type, Keys extends keyof Type> = Type & {
[P in Keys]-?: Type[P];
};
export type { RequiredProperty as R };

View File

@@ -0,0 +1,230 @@
"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"));
const capitalizeFirstCharacter = (text) => {
return text.charAt(0).toUpperCase() + text.slice(1);
};
function getUnitTypeFromNumber(number) {
const abs = Math.abs(number);
const last = abs % 10;
const last2 = abs % 100;
if ((last2 >= 11 && last2 <= 19) || last === 0)
return "many";
if (last === 1)
return "one";
return "few";
}
const error = () => {
const Sizable = {
string: {
unit: {
one: "simbolis",
few: "simboliai",
many: "simbolių",
},
verb: {
smaller: {
inclusive: "turi būti ne ilgesnė kaip",
notInclusive: "turi būti trumpesnė kaip",
},
bigger: {
inclusive: "turi būti ne trumpesnė kaip",
notInclusive: "turi būti ilgesnė kaip",
},
},
},
file: {
unit: {
one: "baitas",
few: "baitai",
many: "baitų",
},
verb: {
smaller: {
inclusive: "turi būti ne didesnis kaip",
notInclusive: "turi būti mažesnis kaip",
},
bigger: {
inclusive: "turi būti ne mažesnis kaip",
notInclusive: "turi būti didesnis kaip",
},
},
},
array: {
unit: {
one: "elementą",
few: "elementus",
many: "elementų",
},
verb: {
smaller: {
inclusive: "turi turėti ne daugiau kaip",
notInclusive: "turi turėti mažiau kaip",
},
bigger: {
inclusive: "turi turėti ne mažiau kaip",
notInclusive: "turi turėti daugiau kaip",
},
},
},
set: {
unit: {
one: "elementą",
few: "elementus",
many: "elementų",
},
verb: {
smaller: {
inclusive: "turi turėti ne daugiau kaip",
notInclusive: "turi turėti mažiau kaip",
},
bigger: {
inclusive: "turi turėti ne mažiau kaip",
notInclusive: "turi turėti daugiau kaip",
},
},
},
};
function getSizing(origin, unitType, inclusive, targetShouldBe) {
const result = Sizable[origin] ?? null;
if (result === null)
return result;
return {
unit: result.unit[unitType],
verb: result.verb[targetShouldBe][inclusive ? "inclusive" : "notInclusive"],
};
}
const FormatDictionary = {
regex: "įvestis",
email: "el. pašto adresas",
url: "URL",
emoji: "jaustukas",
uuid: "UUID",
uuidv4: "UUIDv4",
uuidv6: "UUIDv6",
nanoid: "nanoid",
guid: "GUID",
cuid: "cuid",
cuid2: "cuid2",
ulid: "ULID",
xid: "XID",
ksuid: "KSUID",
datetime: "ISO data ir laikas",
date: "ISO data",
time: "ISO laikas",
duration: "ISO trukmė",
ipv4: "IPv4 adresas",
ipv6: "IPv6 adresas",
cidrv4: "IPv4 tinklo prefiksas (CIDR)",
cidrv6: "IPv6 tinklo prefiksas (CIDR)",
base64: "base64 užkoduota eilutė",
base64url: "base64url užkoduota eilutė",
json_string: "JSON eilutė",
e164: "E.164 numeris",
jwt: "JWT",
template_literal: "įvestis",
};
const TypeDictionary = {
nan: "NaN",
number: "skaičius",
bigint: "sveikasis skaičius",
string: "eilutė",
boolean: "loginė reikšmė",
undefined: "neapibrėžta reikšmė",
function: "funkcija",
symbol: "simbolis",
array: "masyvas",
object: "objektas",
null: "nulinė reikšmė",
};
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 `Gautas tipas ${received}, o tikėtasi - instanceof ${issue.expected}`;
}
return `Gautas tipas ${received}, o tikėtasi - ${expected}`;
}
case "invalid_value":
if (issue.values.length === 1)
return `Privalo būti ${util.stringifyPrimitive(issue.values[0])}`;
return `Privalo būti vienas iš ${util.joinValues(issue.values, "|")} pasirinkimų`;
case "too_big": {
const origin = TypeDictionary[issue.origin] ?? issue.origin;
const sizing = getSizing(issue.origin, getUnitTypeFromNumber(Number(issue.maximum)), issue.inclusive ?? false, "smaller");
if (sizing?.verb)
return `${capitalizeFirstCharacter(origin ?? issue.origin ?? "reikšmė")} ${sizing.verb} ${issue.maximum.toString()} ${sizing.unit ?? "elementų"}`;
const adj = issue.inclusive ? "ne didesnis kaip" : "mažesnis kaip";
return `${capitalizeFirstCharacter(origin ?? issue.origin ?? "reikšmė")} turi būti ${adj} ${issue.maximum.toString()} ${sizing?.unit}`;
}
case "too_small": {
const origin = TypeDictionary[issue.origin] ?? issue.origin;
const sizing = getSizing(issue.origin, getUnitTypeFromNumber(Number(issue.minimum)), issue.inclusive ?? false, "bigger");
if (sizing?.verb)
return `${capitalizeFirstCharacter(origin ?? issue.origin ?? "reikšmė")} ${sizing.verb} ${issue.minimum.toString()} ${sizing.unit ?? "elementų"}`;
const adj = issue.inclusive ? "ne mažesnis kaip" : "didesnis kaip";
return `${capitalizeFirstCharacter(origin ?? issue.origin ?? "reikšmė")} turi būti ${adj} ${issue.minimum.toString()} ${sizing?.unit}`;
}
case "invalid_format": {
const _issue = issue;
if (_issue.format === "starts_with") {
return `Eilutė privalo prasidėti "${_issue.prefix}"`;
}
if (_issue.format === "ends_with")
return `Eilutė privalo pasibaigti "${_issue.suffix}"`;
if (_issue.format === "includes")
return `Eilutė privalo įtraukti "${_issue.includes}"`;
if (_issue.format === "regex")
return `Eilutė privalo atitikti ${_issue.pattern}`;
return `Neteisingas ${FormatDictionary[_issue.format] ?? issue.format}`;
}
case "not_multiple_of":
return `Skaičius privalo būti ${issue.divisor} kartotinis.`;
case "unrecognized_keys":
return `Neatpažint${issue.keys.length > 1 ? "i" : "as"} rakt${issue.keys.length > 1 ? "ai" : "as"}: ${util.joinValues(issue.keys, ", ")}`;
case "invalid_key":
return "Rastas klaidingas raktas";
case "invalid_union":
return "Klaidinga įvestis";
case "invalid_element": {
const origin = TypeDictionary[issue.origin] ?? issue.origin;
return `${capitalizeFirstCharacter(origin ?? issue.origin ?? "reikšmė")} turi klaidingą įvestį`;
}
default:
return "Klaidinga įvestis";
}
};
};
function default_1() {
return {
localeError: error(),
};
}
module.exports = exports.default;

View File

@@ -0,0 +1,253 @@
/**
* @fileoverview Rule to disallow mixed binary operators.
* @author Toru Nagashima
* @deprecated in ESLint v8.53.0
*/
"use strict";
//------------------------------------------------------------------------------
// Requirements
//------------------------------------------------------------------------------
const astUtils = require("./utils/ast-utils.js");
//------------------------------------------------------------------------------
// Helpers
//------------------------------------------------------------------------------
const ARITHMETIC_OPERATORS = ["+", "-", "*", "/", "%", "**"];
const BITWISE_OPERATORS = ["&", "|", "^", "~", "<<", ">>", ">>>"];
const COMPARISON_OPERATORS = ["==", "!=", "===", "!==", ">", ">=", "<", "<="];
const LOGICAL_OPERATORS = ["&&", "||"];
const RELATIONAL_OPERATORS = ["in", "instanceof"];
const TERNARY_OPERATOR = ["?:"];
const COALESCE_OPERATOR = ["??"];
const ALL_OPERATORS = [].concat(
ARITHMETIC_OPERATORS,
BITWISE_OPERATORS,
COMPARISON_OPERATORS,
LOGICAL_OPERATORS,
RELATIONAL_OPERATORS,
TERNARY_OPERATOR,
COALESCE_OPERATOR,
);
const DEFAULT_GROUPS = [
ARITHMETIC_OPERATORS,
BITWISE_OPERATORS,
COMPARISON_OPERATORS,
LOGICAL_OPERATORS,
RELATIONAL_OPERATORS,
];
const TARGET_NODE_TYPE = /^(?:Binary|Logical|Conditional)Expression$/u;
/**
* Normalizes options.
* @param {Object|undefined} options A options object to normalize.
* @returns {Object} Normalized option object.
*/
function normalizeOptions(options = {}) {
const hasGroups = options.groups && options.groups.length > 0;
const groups = hasGroups ? options.groups : DEFAULT_GROUPS;
const allowSamePrecedence = options.allowSamePrecedence !== false;
return {
groups,
allowSamePrecedence,
};
}
/**
* Checks whether any group which includes both given operator exists or not.
* @param {Array<string[]>} groups A list of groups to check.
* @param {string} left An operator.
* @param {string} right Another operator.
* @returns {boolean} `true` if such group existed.
*/
function includesBothInAGroup(groups, left, right) {
return groups.some(group => group.includes(left) && group.includes(right));
}
/**
* Checks whether the given node is a conditional expression and returns the test node else the left node.
* @param {ASTNode} node A node which can be a BinaryExpression or a LogicalExpression node.
* This parent node can be BinaryExpression, LogicalExpression
* , or a ConditionalExpression node
* @returns {ASTNode} node the appropriate node(left or test).
*/
function getChildNode(node) {
return node.type === "ConditionalExpression" ? node.test : node.left;
}
//------------------------------------------------------------------------------
// 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: "no-mixed-operators",
url: "https://eslint.style/rules/no-mixed-operators",
},
},
],
},
type: "suggestion",
docs: {
description: "Disallow mixed binary operators",
recommended: false,
url: "https://eslint.org/docs/latest/rules/no-mixed-operators",
},
schema: [
{
type: "object",
properties: {
groups: {
type: "array",
items: {
type: "array",
items: { enum: ALL_OPERATORS },
minItems: 2,
uniqueItems: true,
},
uniqueItems: true,
},
allowSamePrecedence: {
type: "boolean",
default: true,
},
},
additionalProperties: false,
},
],
messages: {
unexpectedMixedOperator:
"Unexpected mix of '{{leftOperator}}' and '{{rightOperator}}'. Use parentheses to clarify the intended order of operations.",
},
},
create(context) {
const sourceCode = context.sourceCode;
const options = normalizeOptions(context.options[0]);
/**
* Checks whether a given node should be ignored by options or not.
* @param {ASTNode} node A node to check. This is a BinaryExpression
* node or a LogicalExpression node. This parent node is one of
* them, too.
* @returns {boolean} `true` if the node should be ignored.
*/
function shouldIgnore(node) {
const a = node;
const b = node.parent;
return (
!includesBothInAGroup(
options.groups,
a.operator,
b.type === "ConditionalExpression" ? "?:" : b.operator,
) ||
(options.allowSamePrecedence &&
astUtils.getPrecedence(a) === astUtils.getPrecedence(b))
);
}
/**
* Checks whether the operator of a given node is mixed with parent
* node's operator or not.
* @param {ASTNode} node A node to check. This is a BinaryExpression
* node or a LogicalExpression node. This parent node is one of
* them, too.
* @returns {boolean} `true` if the node was mixed.
*/
function isMixedWithParent(node) {
return (
node.operator !== node.parent.operator &&
!astUtils.isParenthesised(sourceCode, node)
);
}
/**
* Gets the operator token of a given node.
* @param {ASTNode} node A node to check. This is a BinaryExpression
* node or a LogicalExpression node.
* @returns {Token} The operator token of the node.
*/
function getOperatorToken(node) {
return sourceCode.getTokenAfter(
getChildNode(node),
astUtils.isNotClosingParenToken,
);
}
/**
* Reports both the operator of a given node and the operator of the
* parent node.
* @param {ASTNode} node A node to check. This is a BinaryExpression
* node or a LogicalExpression node. This parent node is one of
* them, too.
* @returns {void}
*/
function reportBothOperators(node) {
const parent = node.parent;
const left = getChildNode(parent) === node ? node : parent;
const right = getChildNode(parent) !== node ? node : parent;
const data = {
leftOperator: left.operator || "?:",
rightOperator: right.operator || "?:",
};
context.report({
node: left,
loc: getOperatorToken(left).loc,
messageId: "unexpectedMixedOperator",
data,
});
context.report({
node: right,
loc: getOperatorToken(right).loc,
messageId: "unexpectedMixedOperator",
data,
});
}
/**
* Checks between the operator of this node and the operator of the
* parent node.
* @param {ASTNode} node A node to check.
* @returns {void}
*/
function check(node) {
if (
TARGET_NODE_TYPE.test(node.parent.type) &&
isMixedWithParent(node) &&
!shouldIgnore(node)
) {
reportBothOperators(node);
}
}
return {
BinaryExpression: check,
LogicalExpression: check,
};
},
};

View File

@@ -0,0 +1,47 @@
'use strict';
const {Transform} = require('stream');
const alwaysTrue = () => true;
class TakeWhile extends Transform {
constructor(options) {
super(Object.assign({}, options, {writableObjectMode: true, readableObjectMode: true}));
this._condition = alwaysTrue;
if (options) {
'condition' in options && (this._condition = options.condition);
}
}
_transform(chunk, encoding, callback) {
const result = this._condition.call(this, chunk);
if (result && typeof result.then == 'function') {
result.then(
flag => {
if (flag) {
this.push(chunk);
} else {
this._transform = this._doNothing;
}
callback(null);
},
error => callback(error)
);
} else {
if (result) {
this.push(chunk);
} else {
this._transform = this._doNothing;
}
callback(null);
}
}
_doNothing(chunk, encoding, callback) {
callback(null);
}
static make(condition) {
return new TakeWhile(typeof condition == 'object' ? condition : {condition});
}
}
TakeWhile.make.Constructor = TakeWhile;
module.exports = TakeWhile.make;

View File

@@ -0,0 +1,478 @@
'use strict';
/**
* @fileoverview A utility for retrying failed async method calls.
*/
/* global setTimeout, clearTimeout */
//-----------------------------------------------------------------------------
// Constants
//-----------------------------------------------------------------------------
const MAX_TASK_TIMEOUT = 60000;
const MAX_TASK_DELAY = 100;
const MAX_CONCURRENCY = 1000;
//-----------------------------------------------------------------------------
// Helpers
//-----------------------------------------------------------------------------
/**
* Logs a message to the console if the DEBUG environment variable is set.
* @param {string} message The message to log.
* @returns {void}
*/
function debug(message) {
if (globalThis?.process?.env.DEBUG === "@hwc/retry") {
console.debug(message);
}
}
/*
* The following logic has been extracted from graceful-fs.
*
* The ISC License
*
* Copyright (c) 2011-2023 Isaac Z. Schlueter, Ben Noordhuis, and Contributors
*
* Permission to use, copy, modify, and/or distribute this software for any
* purpose with or without fee is hereby granted, provided that the above
* copyright notice and this permission notice appear in all copies.
*
* THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
* WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
* MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
* ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
* WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
* ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR
* IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
*/
/**
* Checks if it is time to retry a task based on the timestamp and last attempt time.
* @param {RetryTask} task The task to check.
* @param {number} maxDelay The maximum delay for the queue.
* @returns {boolean} true if it is time to retry, false otherwise.
*/
function isTimeToRetry(task, maxDelay) {
const timeSinceLastAttempt = Date.now() - task.lastAttempt;
const timeSinceStart = Math.max(task.lastAttempt - task.timestamp, 1);
const desiredDelay = Math.min(timeSinceStart * 1.2, maxDelay);
return timeSinceLastAttempt >= desiredDelay;
}
/**
* Checks if it is time to bail out based on the given timestamp.
* @param {RetryTask} task The task to check.
* @param {number} timeout The timeout for the queue.
* @returns {boolean} true if it is time to bail, false otherwise.
*/
function isTimeToBail(task, timeout) {
return task.age > timeout;
}
/**
* Creates a new promise with resolve and reject functions.
* @returns {{promise:Promise<any>, resolve:(value:any) => any, reject: (value:any) => any}} A new promise.
*/
function createPromise() {
if (Promise.withResolvers) {
return Promise.withResolvers();
}
let resolve, reject;
const promise = new Promise((res, rej) => {
resolve = res;
reject = rej;
});
if (resolve === undefined || reject === undefined) {
throw new Error("Promise executor did not initialize resolve or reject.");
}
return { promise, resolve, reject };
}
/**
* A class to represent a task in the retry queue.
*/
class RetryTask {
/**
* The unique ID for the task.
* @type {string}
*/
id = Math.random().toString(36).slice(2);
/**
* The function to call.
* @type {Function}
*/
fn;
/**
* The error that was thrown.
* @type {Error}
*/
error;
/**
* The timestamp of the task.
* @type {number}
*/
timestamp = Date.now();
/**
* The timestamp of the last attempt.
* @type {number}
*/
lastAttempt = this.timestamp;
/**
* The resolve function for the promise.
* @type {Function}
*/
resolve;
/**
* The reject function for the promise.
* @type {Function}
*/
reject;
/**
* The AbortSignal to monitor for cancellation.
* @type {AbortSignal|undefined}
*/
signal;
/**
* Creates a new instance.
* @param {Function} fn The function to call.
* @param {Error} error The error that was thrown.
* @param {Function} resolve The resolve function for the promise.
* @param {Function} reject The reject function for the promise.
* @param {AbortSignal|undefined} signal The AbortSignal to monitor for cancellation.
*/
constructor(fn, error, resolve, reject, signal) {
this.fn = fn;
this.error = error;
this.timestamp = Date.now();
this.lastAttempt = Date.now();
this.resolve = resolve;
this.reject = reject;
this.signal = signal;
}
/**
* Gets the age of the task.
* @returns {number} The age of the task in milliseconds.
* @readonly
*/
get age() {
return Date.now() - this.timestamp;
}
}
//-----------------------------------------------------------------------------
// Exports
//-----------------------------------------------------------------------------
/**
* A class that manages a queue of retry jobs.
*/
class Retrier {
/**
* Represents the queue for processing tasks.
* @type {Array<RetryTask>}
*/
#retrying = [];
/**
* Represents the queue for pending tasks.
* @type {Array<Function>}
*/
#pending = [];
/**
* The number of tasks currently being processed.
* @type {number}
*/
#working = 0;
/**
* The timeout for the queue.
* @type {number}
*/
#timeout;
/**
* The maximum delay for the queue.
* @type {number}
*/
#maxDelay;
/**
* The setTimeout() timer ID.
* @type {NodeJS.Timeout|undefined}
*/
#timerId;
/**
* The function to call.
* @type {Function}
*/
#check;
/**
* The maximum number of concurrent tasks.
* @type {number}
*/
#concurrency;
/**
* Creates a new instance.
* @param {Function} check The function to call.
* @param {object} [options] The options for the instance.
* @param {number} [options.timeout] The timeout for the queue.
* @param {number} [options.maxDelay] The maximum delay for the queue.
* @param {number} [options.concurrency] The maximum number of concurrent tasks.
*/
constructor(check, { timeout = MAX_TASK_TIMEOUT, maxDelay = MAX_TASK_DELAY, concurrency = MAX_CONCURRENCY } = {}) {
if (typeof check !== "function") {
throw new Error("Missing function to check errors");
}
this.#check = check;
this.#timeout = timeout;
this.#maxDelay = maxDelay;
this.#concurrency = concurrency;
}
/**
* Gets the number of tasks waiting to be retried.
* @returns {number} The number of tasks in the retry queue.
*/
get retrying() {
return this.#retrying.length;
}
/**
* Gets the number of tasks waiting to be processed in the pending queue.
* @returns {number} The number of tasks in the pending queue.
*/
get pending() {
return this.#pending.length;
}
/**
* Gets the number of tasks currently being processed.
* @returns {number} The number of tasks currently being processed.
*/
get working() {
return this.#working;
}
/**
* Calls the function and retries if it fails.
* @param {Function} fn The function to call.
* @param {Object} options The options for the job.
* @param {AbortSignal} [options.signal] The AbortSignal to monitor for cancellation.
* @param {Promise<any>} options.promise The promise to return when the function settles.
* @param {Function} options.resolve The resolve function for the promise.
* @param {Function} options.reject The reject function for the promise.
* @returns {Promise<any>} A promise that resolves when the function is
* called successfully.
*/
#call(fn, { signal, promise, resolve, reject }) {
let result;
try {
result = fn();
} catch (/** @type {any} */ error) {
reject(new Error(`Synchronous error: ${error.message}`, { cause: error }));
return promise;
}
// if the result is not a promise then reject an error
if (!result || typeof result.then !== "function") {
reject(new Error("Result is not a promise."));
return promise;
}
this.#working++;
promise.finally(() => {
this.#working--;
this.#processPending();
})
// `promise.finally` creates a new promise that may be rejected, so it must be handled.
.catch(() => { });
// call the original function and catch any ENFILE or EMFILE errors
Promise.resolve(result)
.then(value => {
debug("Function called successfully without retry.");
resolve(value);
})
.catch(error => {
if (!this.#check(error)) {
reject(error);
return;
}
const task = new RetryTask(fn, error, resolve, reject, signal);
debug(`Function failed, queuing for retry with task ${task.id}.`);
this.#retrying.push(task);
signal?.addEventListener("abort", () => {
debug(`Task ${task.id} was aborted due to AbortSignal.`);
reject(signal.reason);
});
this.#processQueue();
});
return promise;
}
/**
* Adds a new retry job to the queue.
* @template {(...args: unknown[]) => Promise<unknown>} Func
* @template {Awaited<ReturnType<Func>>} RetVal
* @param {Func} fn The function to call.
* @param {object} [options] The options for the job.
* @param {AbortSignal} [options.signal] The AbortSignal to monitor for cancellation.
* @returns {Promise<RetVal>} A promise that resolves when the queue is processed.
*/
retry(fn, { signal } = {}) {
signal?.throwIfAborted();
const { promise, resolve, reject } = createPromise();
this.#pending.push(() => this.#call(fn, { signal, promise, resolve, reject }));
this.#processPending();
return promise;
}
/**
* Processes the pending queue and the retry queue.
* @returns {void}
*/
#processAll() {
if (this.pending) {
this.#processPending();
}
if (this.retrying) {
this.#processQueue();
}
}
/**
* Processes the pending queue to see which tasks can be started.
* @returns {void}
*/
#processPending() {
debug(`Processing pending tasks: ${this.pending} pending, ${this.working} working.`);
const available = this.#concurrency - this.working;
if (available <= 0) {
return;
}
const count = Math.min(this.pending, available);
for (let i = 0; i < count; i++) {
const task = this.#pending.shift();
task?.();
}
debug(`Processed pending tasks: ${this.pending} pending, ${this.working} working.`);
}
/**
* Processes the queue.
* @returns {void}
*/
#processQueue() {
// clear any timer because we're going to check right now
clearTimeout(this.#timerId);
this.#timerId = undefined;
debug(`Processing retry queue: ${this.retrying} retrying, ${this.working} working.`);
const processAgain = () => {
this.#timerId = setTimeout(() => this.#processAll(), 0);
};
// if there's nothing in the queue, we're done
const task = this.#retrying.shift();
if (!task) {
debug("Queue is empty, exiting.");
if (this.pending) {
processAgain();
}
return;
}
// if it's time to bail, then bail
if (isTimeToBail(task, this.#timeout)) {
debug(`Task ${task.id} was abandoned due to timeout.`);
task.reject(task.error);
processAgain();
return;
}
// if it's not time to retry, then wait and try again
if (!isTimeToRetry(task, this.#maxDelay)) {
debug(`Task ${task.id} is not ready to retry, skipping.`);
this.#retrying.push(task);
processAgain();
return;
}
// otherwise, try again
task.lastAttempt = Date.now();
// Promise.resolve needed in case it's a thenable but not a Promise
Promise.resolve(task.fn())
// @ts-ignore because we know it's any
.then(result => {
debug(`Task ${task.id} succeeded after ${task.age}ms.`);
task.resolve(result);
})
// @ts-ignore because we know it's any
.catch(error => {
if (!this.#check(error)) {
debug(`Task ${task.id} failed with non-retryable error: ${error.message}.`);
task.reject(error);
return;
}
// update the task timestamp and push to back of queue to try again
task.lastAttempt = Date.now();
this.#retrying.push(task);
debug(`Task ${task.id} failed, requeueing to try again.`);
})
.finally(() => {
this.#processAll();
});
}
}
exports.Retrier = Retrier;

View File

@@ -0,0 +1,10 @@
"use strict";
var _async_generator = require("./_async_generator.cjs");
function _wrap_async_generator(fn) {
return function() {
return new _async_generator._(fn.apply(this, arguments));
};
}
exports._ = _wrap_async_generator;

View File

@@ -0,0 +1,597 @@
'use strict'
exports['string/varchar'] = {
format: 'text',
id: 1043,
tests: [
['bang', 'bang']
]
}
exports['integer/int4'] = {
format: 'text',
id: 23,
tests: [
['2147483647', 2147483647]
]
}
exports['smallint/int2'] = {
format: 'text',
id: 21,
tests: [
['32767', 32767]
]
}
exports['bigint/int8'] = {
format: 'text',
id: 20,
tests: [
['9223372036854775807', '9223372036854775807']
]
}
exports.oid = {
format: 'text',
id: 26,
tests: [
['103', 103]
]
}
var bignum = '31415926535897932384626433832795028841971693993751058.16180339887498948482045868343656381177203091798057628'
exports.numeric = {
format: 'text',
id: 1700,
tests: [
[bignum, bignum]
]
}
exports['real/float4'] = {
format: 'text',
id: 700,
tests: [
['123.456', 123.456]
]
}
exports['double precision / float 8'] = {
format: 'text',
id: 701,
tests: [
['12345678.12345678', 12345678.12345678]
]
}
exports.boolean = {
format: 'text',
id: 16,
tests: [
['TRUE', true],
['t', true],
['true', true],
['y', true],
['yes', true],
['on', true],
['1', true],
['f', false],
[null, null]
]
}
exports.timestamptz = {
format: 'text',
id: 1184,
tests: [
[
'2010-10-31 14:54:13.74-05:30',
dateEquals(2010, 9, 31, 20, 24, 13, 740)
],
[
'2011-01-23 22:05:00.68-06',
dateEquals(2011, 0, 24, 4, 5, 0, 680)
],
[
'2010-10-30 14:11:12.730838Z',
dateEquals(2010, 9, 30, 14, 11, 12, 730)
],
[
'2010-10-30 13:10:01+05',
dateEquals(2010, 9, 30, 8, 10, 1, 0)
]
]
}
exports.timestamp = {
format: 'text',
id: 1114,
tests: [
[
'2010-10-31 00:00:00',
function (t, value) {
t.equal(
value.toUTCString(),
new Date(2010, 9, 31, 0, 0, 0, 0, 0).toUTCString()
)
t.equal(
value.toString(),
new Date(2010, 9, 31, 0, 0, 0, 0, 0, 0).toString()
)
}
]
]
}
exports.date = {
format: 'text',
id: 1082,
tests: [
['2010-10-31', function (t, value) {
var now = new Date(2010, 9, 31)
dateEquals(
2010,
now.getUTCMonth(),
now.getUTCDate(),
now.getUTCHours(), 0, 0, 0)(t, value)
t.equal(value.getHours(), now.getHours())
}]
]
}
exports.inet = {
format: 'text',
id: 869,
tests: [
['8.8.8.8', '8.8.8.8'],
['2001:4860:4860::8888', '2001:4860:4860::8888'],
['127.0.0.1', '127.0.0.1'],
['fd00:1::40e', 'fd00:1::40e'],
['1.2.3.4', '1.2.3.4']
]
}
exports.cidr = {
format: 'text',
id: 650,
tests: [
['172.16.0.0/12', '172.16.0.0/12'],
['fe80::/10', 'fe80::/10'],
['fc00::/7', 'fc00::/7'],
['192.168.0.0/24', '192.168.0.0/24'],
['10.0.0.0/8', '10.0.0.0/8']
]
}
exports.macaddr = {
format: 'text',
id: 829,
tests: [
['08:00:2b:01:02:03', '08:00:2b:01:02:03'],
['16:10:9f:0d:66:00', '16:10:9f:0d:66:00']
]
}
exports.numrange = {
format: 'text',
id: 3906,
tests: [
['[,]', '[,]'],
['(,)', '(,)'],
['(,]', '(,]'],
['[1,)', '[1,)'],
['[,1]', '[,1]'],
['(1,2)', '(1,2)'],
['(1,20.5]', '(1,20.5]']
]
}
exports.interval = {
format: 'text',
id: 1186,
tests: [
['01:02:03', function (t, value) {
t.equal(value.toPostgres(), '3 seconds 2 minutes 1 hours')
t.deepEqual(value, {hours: 1, minutes: 2, seconds: 3})
}],
['01:02:03.456', function (t, value) {
t.deepEqual(value, {hours: 1, minutes:2, seconds: 3, milliseconds: 456})
}],
['1 year -32 days', function (t, value) {
t.equal(value.toPostgres(), '-32 days 1 years')
t.deepEqual(value, {years: 1, days: -32})
}],
['1 day -00:00:03', function (t, value) {
t.equal(value.toPostgres(), '-3 seconds 1 days')
t.deepEqual(value, {days: 1, seconds: -3})
}]
]
}
exports.bytea = {
format: 'text',
id: 17,
tests: [
['foo\\000\\200\\\\\\377', function (t, value) {
var buffer = new Buffer([102, 111, 111, 0, 128, 92, 255])
t.ok(buffer.equals(value))
}],
['', function (t, value) {
var buffer = new Buffer(0)
t.ok(buffer.equals(value))
}]
]
}
exports['array/boolean'] = {
format: 'text',
id: 1000,
tests: [
['{true,false}', function (t, value) {
t.deepEqual(value, [true, false])
}]
]
}
exports['array/char'] = {
format: 'text',
id: 1014,
tests: [
['{foo,bar}', function (t, value) {
t.deepEqual(value, ['foo', 'bar'])
}]
]
}
exports['array/varchar'] = {
format: 'text',
id: 1015,
tests: [
['{foo,bar}', function (t, value) {
t.deepEqual(value, ['foo', 'bar'])
}]
]
}
exports['array/text'] = {
format: 'text',
id: 1008,
tests: [
['{foo}', function (t, value) {
t.deepEqual(value, ['foo'])
}]
]
}
exports['array/bytea'] = {
format: 'text',
id: 1001,
tests: [
['{"\\\\x00000000"}', function (t, value) {
var buffer = new Buffer('00000000', 'hex')
t.ok(Array.isArray(value))
t.equal(value.length, 1)
t.ok(buffer.equals(value[0]))
}],
['{NULL,"\\\\x4e554c4c"}', function (t, value) {
var buffer = new Buffer('4e554c4c', 'hex')
t.ok(Array.isArray(value))
t.equal(value.length, 2)
t.equal(value[0], null)
t.ok(buffer.equals(value[1]))
}],
]
}
exports['array/numeric'] = {
format: 'text',
id: 1231,
tests: [
['{1.2,3.4}', function (t, value) {
t.deepEqual(value, [1.2, 3.4])
}]
]
}
exports['array/int2'] = {
format: 'text',
id: 1005,
tests: [
['{-32768, -32767, 32766, 32767}', function (t, value) {
t.deepEqual(value, [-32768, -32767, 32766, 32767])
}]
]
}
exports['array/int4'] = {
format: 'text',
id: 1005,
tests: [
['{-2147483648, -2147483647, 2147483646, 2147483647}', function (t, value) {
t.deepEqual(value, [-2147483648, -2147483647, 2147483646, 2147483647])
}]
]
}
exports['array/int8'] = {
format: 'text',
id: 1016,
tests: [
[
'{-9223372036854775808, -9223372036854775807, 9223372036854775806, 9223372036854775807}',
function (t, value) {
t.deepEqual(value, [
'-9223372036854775808',
'-9223372036854775807',
'9223372036854775806',
'9223372036854775807'
])
}
]
]
}
exports['array/json'] = {
format: 'text',
id: 199,
tests: [
[
'{{1,2},{[3],"[4,5]"},{null,NULL}}',
function (t, value) {
t.deepEqual(value, [
[1, 2],
[[3], [4, 5]],
[null, null],
])
}
]
]
}
exports['array/jsonb'] = {
format: 'text',
id: 3807,
tests: exports['array/json'].tests
}
exports['array/point'] = {
format: 'text',
id: 1017,
tests: [
['{"(25.1,50.5)","(10.1,40)"}', function (t, value) {
t.deepEqual(value, [{x: 25.1, y: 50.5}, {x: 10.1, y: 40}])
}]
]
}
exports['array/oid'] = {
format: 'text',
id: 1028,
tests: [
['{25864,25860}', function (t, value) {
t.deepEqual(value, [25864, 25860])
}]
]
}
exports['array/float4'] = {
format: 'text',
id: 1021,
tests: [
['{1.2, 3.4}', function (t, value) {
t.deepEqual(value, [1.2, 3.4])
}]
]
}
exports['array/float8'] = {
format: 'text',
id: 1022,
tests: [
['{-12345678.1234567, 12345678.12345678}', function (t, value) {
t.deepEqual(value, [-12345678.1234567, 12345678.12345678])
}]
]
}
exports['array/date'] = {
format: 'text',
id: 1182,
tests: [
['{2014-01-01,2015-12-31}', function (t, value) {
var expecteds = [new Date(2014, 0, 1), new Date(2015, 11, 31)]
t.equal(value.length, 2)
value.forEach(function (date, index) {
var expected = expecteds[index]
dateEquals(
expected.getUTCFullYear(),
expected.getUTCMonth(),
expected.getUTCDate(),
expected.getUTCHours(), 0, 0, 0)(t, date)
})
}]
]
}
exports['array/interval'] = {
format: 'text',
id: 1187,
tests: [
['{01:02:03,1 day -00:00:03}', function (t, value) {
var expecteds = [{hours: 1, minutes: 2, seconds: 3},
{days: 1, seconds: -3}]
t.equal(value.length, 2)
t.deepEqual(value, expecteds);
}]
]
}
exports['array/inet'] = {
format: 'text',
id: 1041,
tests: [
['{8.8.8.8}', function (t, value) {
t.deepEqual(value, ['8.8.8.8']);
}],
['{2001:4860:4860::8888}', function (t, value) {
t.deepEqual(value, ['2001:4860:4860::8888']);
}],
['{127.0.0.1,fd00:1::40e,1.2.3.4}', function (t, value) {
t.deepEqual(value, ['127.0.0.1', 'fd00:1::40e', '1.2.3.4']);
}]
]
}
exports['array/cidr'] = {
format: 'text',
id: 651,
tests: [
['{172.16.0.0/12}', function (t, value) {
t.deepEqual(value, ['172.16.0.0/12']);
}],
['{fe80::/10}', function (t, value) {
t.deepEqual(value, ['fe80::/10']);
}],
['{10.0.0.0/8,fc00::/7,192.168.0.0/24}', function (t, value) {
t.deepEqual(value, ['10.0.0.0/8', 'fc00::/7', '192.168.0.0/24']);
}]
]
}
exports['array/macaddr'] = {
format: 'text',
id: 1040,
tests: [
['{08:00:2b:01:02:03,16:10:9f:0d:66:00}', function (t, value) {
t.deepEqual(value, ['08:00:2b:01:02:03', '16:10:9f:0d:66:00']);
}]
]
}
exports['array/numrange'] = {
format: 'text',
id: 3907,
tests: [
['{"[1,2]","(4.5,8)","[10,40)","(-21.2,60.3]"}', function (t, value) {
t.deepEqual(value, ['[1,2]', '(4.5,8)', '[10,40)', '(-21.2,60.3]']);
}],
['{"[,20]","[3,]","[,]","(,35)","(1,)","(,)"}', function (t, value) {
t.deepEqual(value, ['[,20]', '[3,]', '[,]', '(,35)', '(1,)', '(,)']);
}],
['{"[,20)","[3,)","[,)","[,35)","[1,)","[,)"}', function (t, value) {
t.deepEqual(value, ['[,20)', '[3,)', '[,)', '[,35)', '[1,)', '[,)']);
}]
]
}
exports['binary-string/varchar'] = {
format: 'binary',
id: 1043,
tests: [
['bang', 'bang']
]
}
exports['binary-integer/int4'] = {
format: 'binary',
id: 23,
tests: [
[[0, 0, 0, 100], 100]
]
}
exports['binary-smallint/int2'] = {
format: 'binary',
id: 21,
tests: [
[[0, 101], 101]
]
}
exports['binary-bigint/int8'] = {
format: 'binary',
id: 20,
tests: [
[new Buffer([0x7f, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff]), '9223372036854775807']
]
}
exports['binary-oid'] = {
format: 'binary',
id: 26,
tests: [
[[0, 0, 0, 103], 103]
]
}
exports['binary-numeric'] = {
format: 'binary',
id: 1700,
tests: [
[
[0, 2, 0, 0, 0, 0, 0, hex('0x64'), 0, 12, hex('0xd'), hex('0x48'), 0, 0, 0, 0],
12.34
]
]
}
exports['binary-real/float4'] = {
format: 'binary',
id: 700,
tests: [
[['0x41', '0x48', '0x00', '0x00'].map(hex), 12.5]
]
}
exports['binary-boolean'] = {
format: 'binary',
id: 16,
tests: [
[[1], true],
[[0], false],
[null, null]
]
}
exports['binary-string'] = {
format: 'binary',
id: 25,
tests: [
[
new Buffer(['0x73', '0x6c', '0x61', '0x64', '0x64', '0x61'].map(hex)),
'sladda'
]
]
}
exports.point = {
format: 'text',
id: 600,
tests: [
['(25.1,50.5)', function (t, value) {
t.deepEqual(value, {x: 25.1, y: 50.5})
}]
]
}
exports.circle = {
format: 'text',
id: 718,
tests: [
['<(25,10),5>', function (t, value) {
t.deepEqual(value, {x: 25, y: 10, radius: 5})
}]
]
}
function hex (string) {
return parseInt(string, 16)
}
function dateEquals () {
var timestamp = Date.UTC.apply(Date, arguments)
return function (t, value) {
t.equal(value.toUTCString(), new Date(timestamp).toUTCString())
}
}

View File

@@ -0,0 +1,180 @@
'use strict';
const { Duplex } = require('stream');
/**
* Emits the `'close'` event on a stream.
*
* @param {Duplex} stream The stream.
* @private
*/
function emitClose(stream) {
stream.emit('close');
}
/**
* The listener of the `'end'` event.
*
* @private
*/
function duplexOnEnd() {
if (!this.destroyed && this._writableState.finished) {
this.destroy();
}
}
/**
* The listener of the `'error'` event.
*
* @param {Error} err The error
* @private
*/
function duplexOnError(err) {
this.removeListener('error', duplexOnError);
this.destroy();
if (this.listenerCount('error') === 0) {
// Do not suppress the throwing behavior.
this.emit('error', err);
}
}
/**
* Wraps a `WebSocket` in a duplex stream.
*
* @param {WebSocket} ws The `WebSocket` to wrap
* @param {Object} [options] The options for the `Duplex` constructor
* @return {Duplex} The duplex stream
* @public
*/
function createWebSocketStream(ws, options) {
let resumeOnReceiverDrain = true;
let terminateOnDestroy = true;
function receiverOnDrain() {
if (resumeOnReceiverDrain) ws._socket.resume();
}
if (ws.readyState === ws.CONNECTING) {
ws.once('open', function open() {
ws._receiver.removeAllListeners('drain');
ws._receiver.on('drain', receiverOnDrain);
});
} else {
ws._receiver.removeAllListeners('drain');
ws._receiver.on('drain', receiverOnDrain);
}
const duplex = new Duplex({
...options,
autoDestroy: false,
emitClose: false,
objectMode: false,
writableObjectMode: false
});
ws.on('message', function message(msg) {
if (!duplex.push(msg)) {
resumeOnReceiverDrain = false;
ws._socket.pause();
}
});
ws.once('error', function error(err) {
if (duplex.destroyed) return;
// Prevent `ws.terminate()` from being called by `duplex._destroy()`.
//
// - If the `'error'` event is emitted before the `'open'` event, then
// `ws.terminate()` is a noop as no socket is assigned.
// - Otherwise, the error is re-emitted by the listener of the `'error'`
// event of the `Receiver` object. The listener already closes the
// connection by calling `ws.close()`. This allows a close frame to be
// sent to the other peer. If `ws.terminate()` is called right after this,
// then the close frame might not be sent.
terminateOnDestroy = false;
duplex.destroy(err);
});
ws.once('close', function close() {
if (duplex.destroyed) return;
duplex.push(null);
});
duplex._destroy = function (err, callback) {
if (ws.readyState === ws.CLOSED) {
callback(err);
process.nextTick(emitClose, duplex);
return;
}
let called = false;
ws.once('error', function error(err) {
called = true;
callback(err);
});
ws.once('close', function close() {
if (!called) callback(err);
process.nextTick(emitClose, duplex);
});
if (terminateOnDestroy) ws.terminate();
};
duplex._final = function (callback) {
if (ws.readyState === ws.CONNECTING) {
ws.once('open', function open() {
duplex._final(callback);
});
return;
}
// If the value of the `_socket` property is `null` it means that `ws` is a
// client websocket and the handshake failed. In fact, when this happens, a
// socket is never assigned to the websocket. Wait for the `'error'` event
// that will be emitted by the websocket.
if (ws._socket === null) return;
if (ws._socket._writableState.finished) {
callback();
if (duplex._readableState.endEmitted) duplex.destroy();
} else {
ws._socket.once('finish', function finish() {
// `duplex` is not destroyed here because the `'end'` event will be
// emitted on `duplex` after this `'finish'` event. The EOF signaling
// `null` chunk is, in fact, pushed when the websocket emits `'close'`.
callback();
});
ws.close();
}
};
duplex._read = function () {
if (
(ws.readyState === ws.OPEN || ws.readyState === ws.CLOSING) &&
!resumeOnReceiverDrain
) {
resumeOnReceiverDrain = true;
if (!ws._receiver._writableState.needDrain) ws._socket.resume();
}
};
duplex._write = function (chunk, encoding, callback) {
if (ws.readyState === ws.CONNECTING) {
ws.once('open', function open() {
duplex._write(chunk, encoding, callback);
});
return;
}
ws.send(chunk, callback);
};
duplex.on('end', duplexOnEnd);
duplex.on('error', duplexOnError);
return duplex;
}
module.exports = createWebSocketStream;

View File

@@ -0,0 +1,58 @@
# node-gyp-build
> Build tool and bindings loader for [`node-gyp`][node-gyp] that supports prebuilds.
```
npm install node-gyp-build
```
[![Test](https://github.com/prebuild/node-gyp-build/actions/workflows/test.yml/badge.svg)](https://github.com/prebuild/node-gyp-build/actions/workflows/test.yml)
Use together with [`prebuildify`][prebuildify] to easily support prebuilds for your native modules.
## Usage
> **Note.** Prebuild names have changed in [`prebuildify@3`][prebuildify] and `node-gyp-build@4`. Please see the documentation below.
`node-gyp-build` works similar to [`node-gyp build`][node-gyp] except that it will check if a build or prebuild is present before rebuilding your project.
It's main intended use is as an npm install script and bindings loader for native modules that bundle prebuilds using [`prebuildify`][prebuildify].
First add `node-gyp-build` as an install script to your native project
``` js
{
...
"scripts": {
"install": "node-gyp-build"
}
}
```
Then in your `index.js`, instead of using the [`bindings`](https://www.npmjs.com/package/bindings) module use `node-gyp-build` to load your binding.
``` js
var binding = require('node-gyp-build')(__dirname)
```
If you do these two things and bundle prebuilds with [`prebuildify`][prebuildify] your native module will work for most platforms
without having to compile on install time AND will work in both node and electron without the need to recompile between usage.
Users can override `node-gyp-build` and force compiling by doing `npm install --build-from-source`.
Prebuilds will be attempted loaded from `MODULE_PATH/prebuilds/...` and then next `EXEC_PATH/prebuilds/...` (the latter allowing use with `zeit/pkg`)
## Supported prebuild names
If so desired you can bundle more specific flavors, for example `musl` builds to support Alpine, or targeting a numbered ARM architecture version.
These prebuilds can be bundled in addition to generic prebuilds; `node-gyp-build` will try to find the most specific flavor first. Prebuild filenames are composed of _tags_. The runtime tag takes precedence, as does an `abi` tag over `napi`. For more details on tags, please see [`prebuildify`][prebuildify].
Values for the `libc` and `armv` tags are auto-detected but can be overridden through the `LIBC` and `ARM_VERSION` environment variables, respectively.
## License
MIT
[prebuildify]: https://github.com/prebuild/prebuildify
[node-gyp]: https://www.npmjs.com/package/node-gyp

View File

@@ -0,0 +1,131 @@
import type { $ZodStringFormats } from "../core/checks.js";
import type * as errors from "../core/errors.js";
import * as util from "../core/util.js";
const error: () => errors.$ZodErrorMap = () => {
const Sizable: Record<string, { unit: string; verb: string }> = {
string: { unit: "znakova", verb: "imati" },
file: { unit: "bajtova", verb: "imati" },
array: { unit: "stavki", verb: "imati" },
set: { unit: "stavki", verb: "imati" },
};
function getSizing(origin: string): { unit: string; verb: string } | null {
return Sizable[origin] ?? null;
}
const FormatDictionary: {
[k in $ZodStringFormats | (string & {})]?: string;
} = {
regex: "unos",
email: "email adresa",
url: "URL",
emoji: "emoji",
uuid: "UUID",
uuidv4: "UUIDv4",
uuidv6: "UUIDv6",
nanoid: "nanoid",
guid: "GUID",
cuid: "cuid",
cuid2: "cuid2",
ulid: "ULID",
xid: "XID",
ksuid: "KSUID",
datetime: "ISO datum i vrijeme",
date: "ISO datum",
time: "ISO vrijeme",
duration: "ISO trajanje",
ipv4: "IPv4 adresa",
ipv6: "IPv6 adresa",
cidrv4: "IPv4 raspon",
cidrv6: "IPv6 raspon",
base64: "base64 kodirani tekst",
base64url: "base64url kodirani tekst",
json_string: "JSON tekst",
e164: "E.164 broj",
jwt: "JWT",
template_literal: "unos",
};
const TypeDictionary: {
[k in errors.$ZodInvalidTypeExpected | (string & {})]?: string;
} = {
nan: "NaN",
string: "tekst",
number: "broj",
boolean: "boolean",
array: "niz",
object: "objekt",
set: "skup",
file: "datoteka",
date: "datum",
bigint: "bigint",
symbol: "simbol",
undefined: "undefined",
null: "null",
function: "funkcija",
map: "mapa",
};
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 `Neispravan unos: očekuje se instanceof ${issue.expected}, a primljeno je ${received}`;
}
return `Neispravan unos: očekuje se ${expected}, a primljeno je ${received}`;
}
case "invalid_value":
if (issue.values.length === 1)
return `Neispravna vrijednost: očekivano ${util.stringifyPrimitive(issue.values[0])}`;
return `Neispravna opcija: očekivano jedno od ${util.joinValues(issue.values, "|")}`;
case "too_big": {
const adj = issue.inclusive ? "<=" : "<";
const sizing = getSizing(issue.origin);
const origin = TypeDictionary[issue.origin] ?? issue.origin;
if (sizing)
return `Preveliko: očekivano da ${origin ?? "vrijednost"} ima ${adj}${issue.maximum.toString()} ${sizing.unit ?? "elemenata"}`;
return `Preveliko: očekivano da ${origin ?? "vrijednost"} bude ${adj}${issue.maximum.toString()}`;
}
case "too_small": {
const adj = issue.inclusive ? ">=" : ">";
const sizing = getSizing(issue.origin);
const origin = TypeDictionary[issue.origin] ?? issue.origin;
if (sizing) {
return `Premalo: očekivano da ${origin} ima ${adj}${issue.minimum.toString()} ${sizing.unit}`;
}
return `Premalo: očekivano da ${origin} bude ${adj}${issue.minimum.toString()}`;
}
case "invalid_format": {
const _issue = issue as errors.$ZodStringFormatIssues;
if (_issue.format === "starts_with") return `Neispravan tekst: mora započinjati s "${_issue.prefix}"`;
if (_issue.format === "ends_with") return `Neispravan tekst: mora završavati s "${_issue.suffix}"`;
if (_issue.format === "includes") return `Neispravan tekst: mora sadržavati "${_issue.includes}"`;
if (_issue.format === "regex") return `Neispravan tekst: mora odgovarati uzorku ${_issue.pattern}`;
return `Neispravna ${FormatDictionary[_issue.format] ?? issue.format}`;
}
case "not_multiple_of":
return `Neispravan broj: mora biti višekratnik od ${issue.divisor}`;
case "unrecognized_keys":
return `Neprepoznat${issue.keys.length > 1 ? "i ključevi" : " ključ"}: ${util.joinValues(issue.keys, ", ")}`;
case "invalid_key":
return `Neispravan ključ u ${TypeDictionary[issue.origin] ?? issue.origin}`;
case "invalid_union":
return "Neispravan unos";
case "invalid_element":
return `Neispravna vrijednost u ${TypeDictionary[issue.origin] ?? issue.origin}`;
default:
return `Neispravan unos`;
}
};
};
export default function (): { localeError: errors.$ZodErrorMap } {
return {
localeError: error(),
};
}

View File

@@ -0,0 +1 @@
"use strict";var m=Object.defineProperty;var q=(r,e)=>m(r,"name",{value:e,configurable:!0});var s=require("../../register-Ciecs-Zx.cjs"),c=require("node:crypto");require("../../get-pipe-path-D4YM6rQt.cjs");var t=require("../../register-C557imBs.cjs");require("../../require-DDxgG93A.cjs");var n=require("../../node-features-CEjg7cMX.cjs");require("node:module"),require("node:worker_threads"),require("node:url"),require("node:fs"),require("node:fs/promises"),require("../../index-6kqi0x0U.cjs"),require("node:path"),require("esbuild"),require("node:os"),require("../../temporary-directory-B83uKxJF.cjs"),require("../../client-D3mGB526.cjs"),require("node:net"),require("module"),require("fs"),require("os"),require("path"),require("node:util"),require("../../index-BWFBUo6r.cjs");const g=q((r,e)=>{if(!e||typeof e=="object"&&!e.parentURL)throw new Error("The current file path (import.meta.url) must be provided in the second argument of tsImport()");const i=typeof e=="string",u=i?e:e.parentURL,a=c.randomUUID(),o=t.register({namespace:a});return!n.isFeatureSupported(n.esmLoadReadFile)&&!t.isBarePackageNamePattern.test(r)&&t.cjsExtensionPattern.test(r)?Promise.resolve(o.require(r,u)):s.register({namespace:a,...i?{}:e}).import(r,u)},"tsImport");exports.register=s.register,exports.tsImport=g;

View File

@@ -0,0 +1,46 @@
// Code generated by Herebyfile.mjs generate:enums from internal/ast/nodeflags.go. DO NOT EDIT.
export var NodeFlags;
(function (NodeFlags) {
NodeFlags[NodeFlags["None"] = 0] = "None";
NodeFlags[NodeFlags["Let"] = 1] = "Let";
NodeFlags[NodeFlags["Const"] = 2] = "Const";
NodeFlags[NodeFlags["Using"] = 4] = "Using";
NodeFlags[NodeFlags["Reparsed"] = 8] = "Reparsed";
NodeFlags[NodeFlags["Synthesized"] = 16] = "Synthesized";
NodeFlags[NodeFlags["OptionalChain"] = 32] = "OptionalChain";
NodeFlags[NodeFlags["ExportContext"] = 64] = "ExportContext";
NodeFlags[NodeFlags["ContainsThis"] = 128] = "ContainsThis";
NodeFlags[NodeFlags["HasImplicitReturn"] = 256] = "HasImplicitReturn";
NodeFlags[NodeFlags["HasExplicitReturn"] = 512] = "HasExplicitReturn";
NodeFlags[NodeFlags["DisallowInContext"] = 1024] = "DisallowInContext";
NodeFlags[NodeFlags["YieldContext"] = 2048] = "YieldContext";
NodeFlags[NodeFlags["DecoratorContext"] = 4096] = "DecoratorContext";
NodeFlags[NodeFlags["AwaitContext"] = 8192] = "AwaitContext";
NodeFlags[NodeFlags["DisallowConditionalTypesContext"] = 16384] = "DisallowConditionalTypesContext";
NodeFlags[NodeFlags["ThisNodeHasError"] = 32768] = "ThisNodeHasError";
NodeFlags[NodeFlags["JavaScriptFile"] = 65536] = "JavaScriptFile";
NodeFlags[NodeFlags["ThisNodeOrAnySubNodesHasError"] = 131072] = "ThisNodeOrAnySubNodesHasError";
NodeFlags[NodeFlags["HasAsyncFunctions"] = 262144] = "HasAsyncFunctions";
NodeFlags[NodeFlags["PossiblyContainsDynamicImport"] = 524288] = "PossiblyContainsDynamicImport";
NodeFlags[NodeFlags["PossiblyContainsImportMeta"] = 1048576] = "PossiblyContainsImportMeta";
NodeFlags[NodeFlags["HasJSDoc"] = 2097152] = "HasJSDoc";
NodeFlags[NodeFlags["JSDoc"] = 4194304] = "JSDoc";
NodeFlags[NodeFlags["Ambient"] = 8388608] = "Ambient";
NodeFlags[NodeFlags["InWithStatement"] = 16777216] = "InWithStatement";
NodeFlags[NodeFlags["JsonFile"] = 33554432] = "JsonFile";
NodeFlags[NodeFlags["PossiblyContainsDeprecatedTag"] = 67108864] = "PossiblyContainsDeprecatedTag";
NodeFlags[NodeFlags["Unreachable"] = 134217728] = "Unreachable";
NodeFlags[NodeFlags["ReparserTransformedLiteral"] = 268435456] = "ReparserTransformedLiteral";
NodeFlags[NodeFlags["BlockScoped"] = 7] = "BlockScoped";
NodeFlags[NodeFlags["Constant"] = 6] = "Constant";
NodeFlags[NodeFlags["AwaitUsing"] = 6] = "AwaitUsing";
NodeFlags[NodeFlags["ReachabilityCheckFlags"] = 768] = "ReachabilityCheckFlags";
NodeFlags[NodeFlags["ReachabilityAndEmitFlags"] = 262912] = "ReachabilityAndEmitFlags";
NodeFlags[NodeFlags["ContextFlags"] = 25263104] = "ContextFlags";
NodeFlags[NodeFlags["TypeExcludesFlags"] = 10240] = "TypeExcludesFlags";
NodeFlags[NodeFlags["PermanentlySetIncrementalFlags"] = 1572864] = "PermanentlySetIncrementalFlags";
NodeFlags[NodeFlags["IdentifierHasExtendedUnicodeEscape"] = 128] = "IdentifierHasExtendedUnicodeEscape";
NodeFlags[NodeFlags["IdentifierIsInJSDocNamespace"] = 262144] = "IdentifierIsInJSDocNamespace";
NodeFlags[NodeFlags["NestedNamespace"] = 32] = "NestedNamespace";
})(NodeFlags || (NodeFlags = {}));
//# sourceMappingURL=nodeFlags.js.map

View File

@@ -0,0 +1,8 @@
function _taggedTemplateLiteral(e, t) {
return t || (t = e.slice(0)), Object.freeze(Object.defineProperties(e, {
raw: {
value: Object.freeze(t)
}
}));
}
export { _taggedTemplateLiteral as default };

View File

@@ -0,0 +1,14 @@
| Suite | Browser | keys-while | keys-for | incr-for |
| :---- | :-------------------------------------- | ----------------: | ----------------: | --------------: |
| iter | Chrome 60.0.3112 (Windows 7 0.0.0) | *100.00% (±1.19%) | *98.26% (±1.51%) | 30.51% (±0.67%) |
| iter | Chrome Mobile 39.0.0 (Android 5.1.1) | *100.00% (±2.29%) | 93.22% (±1.78%) | 37.71% (±0.67%) |
| iter | Chrome Mobile 55.0.2883 (Android 6.0.0) | *100.00% (±2.89%) | 95.03% (±2.24%) | 32.52% (±0.61%) |
| iter | Edge 14.14393.0 (Windows 10 0.0.0) | *100.00% (±1.79%) | *98.76% (±2.02%) | 37.88% (±0.64%) |
| iter | Firefox 54.0.0 (Windows 7 0.0.0) | *100.00% (±2.06%) | *99.28% (±2.17%) | 8.57% (±0.10%) |
| iter | IE 10.0.0 (Windows 7 0.0.0) | *100.00% (±2.27%) | *94.97% (±2.48%) | 41.65% (±1.21%) |
| iter | IE 11.0.0 (Windows 7 0.0.0) | *100.00% (±1.98%) | 95.75% (±1.72%) | 38.21% (±0.75%) |
| iter | IE 9.0.0 (Windows 7 0.0.0) | *100.00% (±1.37%) | 90.99% (±1.59%) | 45.06% (±0.93%) |
| iter | Mobile Safari 10.0.0 (iOS 10.3.0) | *100.00% (±3.09%) | *99.25% (±2.38%) | 47.22% (±1.16%) |
| iter | Mobile Safari 9.0.0 (iOS 9.2.0) | 97.40% (±2.65%) | *100.00% (±1.98%) | 57.77% (±1.32%) |
| iter | Safari 10.0.1 (Mac OS X 10.12.1) | *100.00% (±0.60%) | *93.17% (±2.38%) | 47.47% (±0.55%) |
| iter | Safari 9.1.2 (Mac OS X 10.11.6) | *100.00% (±1.96%) | 98.12% (±1.52%) | 51.10% (±0.89%) |

View File

@@ -0,0 +1,4 @@
{
"main": "../../cjs/_defaults.cjs",
"module": "../../esm/_defaults.js"
}

View File

@@ -0,0 +1,9 @@
import { JSONHydrator } from './postcss.js'
interface FromJSON extends JSONHydrator {
default: FromJSON
}
declare let fromJSON: FromJSON
export = fromJSON

View File

@@ -0,0 +1,4 @@
{
"main": "../../cjs/_class_apply_descriptor_set.cjs",
"module": "../../esm/_class_apply_descriptor_set.js"
}

View File

@@ -0,0 +1,22 @@
import superPropBase from "./superPropBase.js";
import defineProperty from "./defineProperty.js";
function set(e, r, t, o) {
return set = "undefined" != typeof Reflect && Reflect.set ? Reflect.set : function (e, r, t, o) {
var f,
i = superPropBase(e, r);
if (i) {
if ((f = Object.getOwnPropertyDescriptor(i, r)).set) return f.set.call(o, t), !0;
if (!f.writable) return !1;
}
if (f = Object.getOwnPropertyDescriptor(o, r)) {
if (!f.writable) return !1;
f.value = t, Object.defineProperty(o, r, f);
} else defineProperty(o, r, t);
return !0;
}, set(e, r, t, o);
}
function _set(e, r, t, o, f) {
if (!set(e, r, t, o || e) && f) throw new TypeError("failed to set property");
return t;
}
export { _set as default };