WIP: bootstrap and partial real Solana watcher implementation
This commit is contained in:
@@ -0,0 +1,352 @@
|
||||
'use strict'
|
||||
// eslint-disable-next-line
|
||||
if (typeof $1 !== 'undefined') $1 = arguments.callee.caller.arguments[0]
|
||||
|
||||
const test = require('tape')
|
||||
const fresh = require('import-fresh')
|
||||
const pino = require('../browser')
|
||||
|
||||
const parentSerializers = {
|
||||
test: () => 'parent'
|
||||
}
|
||||
|
||||
const childSerializers = {
|
||||
test: () => 'child'
|
||||
}
|
||||
|
||||
test('serializers override values', ({ end, is }) => {
|
||||
const parent = pino({
|
||||
serializers: parentSerializers,
|
||||
browser: {
|
||||
serialize: true,
|
||||
write (o) {
|
||||
is(o.test, 'parent')
|
||||
end()
|
||||
}
|
||||
}
|
||||
})
|
||||
|
||||
parent.fatal({ test: 'test' })
|
||||
})
|
||||
|
||||
test('without the serialize option, serializers do not override values', ({ end, is }) => {
|
||||
const parent = pino({
|
||||
serializers: parentSerializers,
|
||||
browser: {
|
||||
write (o) {
|
||||
is(o.test, 'test')
|
||||
end()
|
||||
}
|
||||
}
|
||||
})
|
||||
|
||||
parent.fatal({ test: 'test' })
|
||||
})
|
||||
|
||||
if (process.title !== 'browser') {
|
||||
test('if serialize option is true, standard error serializer is auto enabled', ({ end, same }) => {
|
||||
const err = Error('test')
|
||||
err.code = 'test'
|
||||
err.type = 'Error' // get that cov
|
||||
const expect = pino.stdSerializers.err(err)
|
||||
|
||||
const consoleError = console.error
|
||||
console.error = function (err) {
|
||||
same(err, expect)
|
||||
}
|
||||
|
||||
const logger = fresh('../browser')({
|
||||
browser: { serialize: true }
|
||||
})
|
||||
|
||||
console.error = consoleError
|
||||
|
||||
logger.fatal(err)
|
||||
end()
|
||||
})
|
||||
|
||||
test('if serialize option is array, standard error serializer is auto enabled', ({ end, same }) => {
|
||||
const err = Error('test')
|
||||
err.code = 'test'
|
||||
const expect = pino.stdSerializers.err(err)
|
||||
|
||||
const consoleError = console.error
|
||||
console.error = function (err) {
|
||||
same(err, expect)
|
||||
}
|
||||
|
||||
const logger = fresh('../browser', require)({
|
||||
browser: { serialize: [] }
|
||||
})
|
||||
|
||||
console.error = consoleError
|
||||
|
||||
logger.fatal(err)
|
||||
end()
|
||||
})
|
||||
|
||||
test('if serialize option is array containing !stdSerializers.err, standard error serializer is disabled', ({ end, is }) => {
|
||||
const err = Error('test')
|
||||
err.code = 'test'
|
||||
const expect = err
|
||||
|
||||
const consoleError = console.error
|
||||
console.error = function (err) {
|
||||
is(err, expect)
|
||||
}
|
||||
|
||||
const logger = fresh('../browser', require)({
|
||||
browser: { serialize: ['!stdSerializers.err'] }
|
||||
})
|
||||
|
||||
console.error = consoleError
|
||||
|
||||
logger.fatal(err)
|
||||
end()
|
||||
})
|
||||
|
||||
test('in browser, serializers apply to all objects', ({ end, is }) => {
|
||||
const consoleError = console.error
|
||||
console.error = function (test, test2, test3, test4, test5) {
|
||||
is(test.key, 'serialized')
|
||||
is(test2.key2, 'serialized2')
|
||||
is(test5.key3, 'serialized3')
|
||||
}
|
||||
|
||||
const logger = fresh('../browser', require)({
|
||||
serializers: {
|
||||
key: () => 'serialized',
|
||||
key2: () => 'serialized2',
|
||||
key3: () => 'serialized3'
|
||||
},
|
||||
browser: { serialize: true }
|
||||
})
|
||||
|
||||
console.error = consoleError
|
||||
|
||||
logger.fatal({ key: 'test' }, { key2: 'test' }, 'str should skip', [{ foo: 'array should skip' }], { key3: 'test' })
|
||||
end()
|
||||
})
|
||||
|
||||
test('serialize can be an array of selected serializers', ({ end, is }) => {
|
||||
const consoleError = console.error
|
||||
console.error = function (test, test2, test3, test4, test5) {
|
||||
is(test.key, 'test')
|
||||
is(test2.key2, 'serialized2')
|
||||
is(test5.key3, 'test')
|
||||
}
|
||||
|
||||
const logger = fresh('../browser', require)({
|
||||
serializers: {
|
||||
key: () => 'serialized',
|
||||
key2: () => 'serialized2',
|
||||
key3: () => 'serialized3'
|
||||
},
|
||||
browser: { serialize: ['key2'] }
|
||||
})
|
||||
|
||||
console.error = consoleError
|
||||
|
||||
logger.fatal({ key: 'test' }, { key2: 'test' }, 'str should skip', [{ foo: 'array should skip' }], { key3: 'test' })
|
||||
end()
|
||||
})
|
||||
|
||||
test('serialize filter applies to child loggers', ({ end, is }) => {
|
||||
const consoleError = console.error
|
||||
console.error = function (binding, test, test2, test3, test4, test5) {
|
||||
is(test.key, 'test')
|
||||
is(test2.key2, 'serialized2')
|
||||
is(test5.key3, 'test')
|
||||
}
|
||||
|
||||
const logger = fresh('../browser', require)({
|
||||
browser: { serialize: ['key2'] }
|
||||
})
|
||||
|
||||
console.error = consoleError
|
||||
|
||||
logger.child({
|
||||
aBinding: 'test'
|
||||
}, {
|
||||
serializers: {
|
||||
key: () => 'serialized',
|
||||
key2: () => 'serialized2',
|
||||
key3: () => 'serialized3'
|
||||
}
|
||||
}).fatal({ key: 'test' }, { key2: 'test' }, 'str should skip', [{ foo: 'array should skip' }], { key3: 'test' })
|
||||
end()
|
||||
})
|
||||
|
||||
test('serialize filter applies to child loggers through bindings', ({ end, is }) => {
|
||||
const consoleError = console.error
|
||||
console.error = function (binding, test, test2, test3, test4, test5) {
|
||||
is(test.key, 'test')
|
||||
is(test2.key2, 'serialized2')
|
||||
is(test5.key3, 'test')
|
||||
}
|
||||
|
||||
const logger = fresh('../browser', require)({
|
||||
browser: { serialize: ['key2'] }
|
||||
})
|
||||
|
||||
console.error = consoleError
|
||||
|
||||
logger.child({
|
||||
aBinding: 'test',
|
||||
serializers: {
|
||||
key: () => 'serialized',
|
||||
key2: () => 'serialized2',
|
||||
key3: () => 'serialized3'
|
||||
}
|
||||
}).fatal({ key: 'test' }, { key2: 'test' }, 'str should skip', [{ foo: 'array should skip' }], { key3: 'test' })
|
||||
end()
|
||||
})
|
||||
|
||||
test('parent serializers apply to child bindings', ({ end, is }) => {
|
||||
const consoleError = console.error
|
||||
console.error = function (binding) {
|
||||
is(binding.key, 'serialized')
|
||||
}
|
||||
|
||||
const logger = fresh('../browser', require)({
|
||||
serializers: {
|
||||
key: () => 'serialized'
|
||||
},
|
||||
browser: { serialize: true }
|
||||
})
|
||||
|
||||
console.error = consoleError
|
||||
|
||||
logger.child({ key: 'test' }).fatal({ test: 'test' })
|
||||
end()
|
||||
})
|
||||
|
||||
test('child serializers apply to child bindings', ({ end, is }) => {
|
||||
const consoleError = console.error
|
||||
console.error = function (binding) {
|
||||
is(binding.key, 'serialized')
|
||||
}
|
||||
|
||||
const logger = fresh('../browser', require)({
|
||||
browser: { serialize: true }
|
||||
})
|
||||
|
||||
console.error = consoleError
|
||||
|
||||
logger.child({
|
||||
key: 'test'
|
||||
}, {
|
||||
serializers: {
|
||||
key: () => 'serialized'
|
||||
}
|
||||
}).fatal({ test: 'test' })
|
||||
end()
|
||||
})
|
||||
}
|
||||
|
||||
test('child does not overwrite parent serializers', ({ end, is }) => {
|
||||
let c = 0
|
||||
const parent = pino({
|
||||
serializers: parentSerializers,
|
||||
browser: {
|
||||
serialize: true,
|
||||
write (o) {
|
||||
c++
|
||||
if (c === 1) is(o.test, 'parent')
|
||||
if (c === 2) {
|
||||
is(o.test, 'child')
|
||||
end()
|
||||
}
|
||||
}
|
||||
}
|
||||
})
|
||||
const child = parent.child({}, { serializers: childSerializers })
|
||||
|
||||
parent.fatal({ test: 'test' })
|
||||
child.fatal({ test: 'test' })
|
||||
})
|
||||
|
||||
test('children inherit parent serializers', ({ end, is }) => {
|
||||
const parent = pino({
|
||||
serializers: parentSerializers,
|
||||
browser: {
|
||||
serialize: true,
|
||||
write (o) {
|
||||
is(o.test, 'parent')
|
||||
}
|
||||
}
|
||||
})
|
||||
|
||||
const child = parent.child({ a: 'property' })
|
||||
child.fatal({ test: 'test' })
|
||||
end()
|
||||
})
|
||||
|
||||
test('children serializers get called', ({ end, is }) => {
|
||||
const parent = pino({
|
||||
browser: {
|
||||
serialize: true,
|
||||
write (o) {
|
||||
is(o.test, 'child')
|
||||
}
|
||||
}
|
||||
})
|
||||
|
||||
const child = parent.child({ a: 'property' }, { serializers: childSerializers })
|
||||
|
||||
child.fatal({ test: 'test' })
|
||||
end()
|
||||
})
|
||||
|
||||
test('children serializers get called when inherited from parent', ({ end, is }) => {
|
||||
const parent = pino({
|
||||
serializers: parentSerializers,
|
||||
browser: {
|
||||
serialize: true,
|
||||
write: (o) => {
|
||||
is(o.test, 'pass')
|
||||
}
|
||||
}
|
||||
})
|
||||
|
||||
const child = parent.child({}, { serializers: { test: () => 'pass' } })
|
||||
|
||||
child.fatal({ test: 'fail' })
|
||||
end()
|
||||
})
|
||||
|
||||
test('non overridden serializers are available in the children', ({ end, is }) => {
|
||||
const pSerializers = {
|
||||
onlyParent: () => 'parent',
|
||||
shared: () => 'parent'
|
||||
}
|
||||
|
||||
const cSerializers = {
|
||||
shared: () => 'child',
|
||||
onlyChild: () => 'child'
|
||||
}
|
||||
|
||||
let c = 0
|
||||
|
||||
const parent = pino({
|
||||
serializers: pSerializers,
|
||||
browser: {
|
||||
serialize: true,
|
||||
write (o) {
|
||||
c++
|
||||
if (c === 1) is(o.shared, 'child')
|
||||
if (c === 2) is(o.onlyParent, 'parent')
|
||||
if (c === 3) is(o.onlyChild, 'child')
|
||||
if (c === 4) is(o.onlyChild, 'test')
|
||||
}
|
||||
}
|
||||
})
|
||||
|
||||
const child = parent.child({}, { serializers: cSerializers })
|
||||
|
||||
child.fatal({ shared: 'test' })
|
||||
child.fatal({ onlyParent: 'test' })
|
||||
child.fatal({ onlyChild: 'test' })
|
||||
parent.fatal({ onlyChild: 'test' })
|
||||
end()
|
||||
})
|
||||
@@ -0,0 +1,87 @@
|
||||
import { FixedSizeCodec, FixedSizeDecoder, FixedSizeEncoder } from '@solana/codecs-core';
|
||||
import { NumberCodecConfig } from './common';
|
||||
/**
|
||||
* Returns an encoder for 16-bit signed integers (`i16`).
|
||||
*
|
||||
* This encoder serializes `i16` values using 2 bytes.
|
||||
* Values can be provided as either `number` or `bigint`.
|
||||
*
|
||||
* For more details, see {@link getI16Codec}.
|
||||
*
|
||||
* @param config - Optional configuration to specify endianness (little by default).
|
||||
* @returns A `FixedSizeEncoder<number | bigint, 2>` for encoding `i16` values.
|
||||
*
|
||||
* @example
|
||||
* Encoding an `i16` value.
|
||||
* ```ts
|
||||
* const encoder = getI16Encoder();
|
||||
* const bytes = encoder.encode(-42); // 0xd6ff
|
||||
* ```
|
||||
*
|
||||
* @see {@link getI16Codec}
|
||||
*/
|
||||
export declare const getI16Encoder: (config?: NumberCodecConfig) => FixedSizeEncoder<bigint | number, 2>;
|
||||
/**
|
||||
* Returns a decoder for 16-bit signed integers (`i16`).
|
||||
*
|
||||
* This decoder deserializes `i16` values from 2 bytes.
|
||||
* The decoded value is always a `number`.
|
||||
*
|
||||
* For more details, see {@link getI16Codec}.
|
||||
*
|
||||
* @param config - Optional configuration to specify endianness (little by default).
|
||||
* @returns A `FixedSizeDecoder<number, 2>` for decoding `i16` values.
|
||||
*
|
||||
* @example
|
||||
* Decoding an `i16` value.
|
||||
* ```ts
|
||||
* const decoder = getI16Decoder();
|
||||
* const value = decoder.decode(new Uint8Array([0xd6, 0xff])); // -42
|
||||
* ```
|
||||
*
|
||||
* @see {@link getI16Codec}
|
||||
*/
|
||||
export declare const getI16Decoder: (config?: NumberCodecConfig) => FixedSizeDecoder<number, 2>;
|
||||
/**
|
||||
* Returns a codec for encoding and decoding 16-bit signed integers (`i16`).
|
||||
*
|
||||
* This codec serializes `i16` values using 2 bytes.
|
||||
* Values can be provided as either `number` or `bigint`, but the decoded value is always a `number`.
|
||||
*
|
||||
* @param config - Optional configuration to specify endianness (little by default).
|
||||
* @returns A `FixedSizeCodec<number | bigint, number, 2>` for encoding and decoding `i16` values.
|
||||
*
|
||||
* @example
|
||||
* Encoding and decoding an `i16` value.
|
||||
* ```ts
|
||||
* const codec = getI16Codec();
|
||||
* const bytes = codec.encode(-42); // 0xd6ff
|
||||
* const value = codec.decode(bytes); // -42
|
||||
* ```
|
||||
*
|
||||
* @example
|
||||
* Using big-endian encoding.
|
||||
* ```ts
|
||||
* const codec = getI16Codec({ endian: Endian.Big });
|
||||
* const bytes = codec.encode(-42); // 0xffd6
|
||||
* ```
|
||||
*
|
||||
* @remarks
|
||||
* This codec supports values between `-2^15` (`-32,768`) and `2^15 - 1` (`32,767`).
|
||||
*
|
||||
* - If you need a smaller signed integer, consider using {@link getI8Codec}.
|
||||
* - If you need a larger signed integer, consider using {@link getI32Codec}.
|
||||
* - If you need unsigned integers, consider using {@link getU16Codec}.
|
||||
*
|
||||
* Separate {@link getI16Encoder} and {@link getI16Decoder} functions are available.
|
||||
*
|
||||
* ```ts
|
||||
* const bytes = getI16Encoder().encode(-42);
|
||||
* const value = getI16Decoder().decode(bytes);
|
||||
* ```
|
||||
*
|
||||
* @see {@link getI16Encoder}
|
||||
* @see {@link getI16Decoder}
|
||||
*/
|
||||
export declare const getI16Codec: (config?: NumberCodecConfig) => FixedSizeCodec<bigint | number, number, 2>;
|
||||
//# sourceMappingURL=i16.d.ts.map
|
||||
@@ -0,0 +1,77 @@
|
||||
"use strict";
|
||||
/* --------------------------------------------------------------------------------------------
|
||||
* Copyright (c) Microsoft Corporation. All rights reserved.
|
||||
* Licensed under the MIT License. See License.txt in the project root for license information.
|
||||
* ------------------------------------------------------------------------------------------ */
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
exports.SharedArrayReceiverStrategy = exports.SharedArraySenderStrategy = void 0;
|
||||
const cancellation_1 = require("./cancellation");
|
||||
var CancellationState;
|
||||
(function (CancellationState) {
|
||||
CancellationState.Continue = 0;
|
||||
CancellationState.Cancelled = 1;
|
||||
})(CancellationState || (CancellationState = {}));
|
||||
class SharedArraySenderStrategy {
|
||||
buffers;
|
||||
constructor() {
|
||||
this.buffers = new Map();
|
||||
}
|
||||
enableCancellation(request) {
|
||||
if (request.id === null) {
|
||||
return;
|
||||
}
|
||||
const buffer = new SharedArrayBuffer(4);
|
||||
const data = new Int32Array(buffer, 0, 1);
|
||||
data[0] = CancellationState.Continue;
|
||||
this.buffers.set(request.id, buffer);
|
||||
request.$cancellationData = buffer;
|
||||
}
|
||||
async sendCancellation(_conn, id) {
|
||||
const buffer = this.buffers.get(id);
|
||||
if (buffer === undefined) {
|
||||
return;
|
||||
}
|
||||
const data = new Int32Array(buffer, 0, 1);
|
||||
Atomics.store(data, 0, CancellationState.Cancelled);
|
||||
}
|
||||
cleanup(id) {
|
||||
this.buffers.delete(id);
|
||||
}
|
||||
dispose() {
|
||||
this.buffers.clear();
|
||||
}
|
||||
}
|
||||
exports.SharedArraySenderStrategy = SharedArraySenderStrategy;
|
||||
class SharedArrayBufferCancellationToken {
|
||||
data;
|
||||
constructor(buffer) {
|
||||
this.data = new Int32Array(buffer, 0, 1);
|
||||
}
|
||||
get isCancellationRequested() {
|
||||
return Atomics.load(this.data, 0) === CancellationState.Cancelled;
|
||||
}
|
||||
get onCancellationRequested() {
|
||||
throw new Error(`Cancellation over SharedArrayBuffer doesn't support cancellation events`);
|
||||
}
|
||||
}
|
||||
class SharedArrayBufferCancellationTokenSource {
|
||||
token;
|
||||
constructor(buffer) {
|
||||
this.token = new SharedArrayBufferCancellationToken(buffer);
|
||||
}
|
||||
cancel() {
|
||||
}
|
||||
dispose() {
|
||||
}
|
||||
}
|
||||
class SharedArrayReceiverStrategy {
|
||||
kind = 'request';
|
||||
createCancellationTokenSource(request) {
|
||||
const buffer = request.$cancellationData;
|
||||
if (buffer === undefined) {
|
||||
return new cancellation_1.CancellationTokenSource();
|
||||
}
|
||||
return new SharedArrayBufferCancellationTokenSource(buffer);
|
||||
}
|
||||
}
|
||||
exports.SharedArrayReceiverStrategy = SharedArrayReceiverStrategy;
|
||||
@@ -0,0 +1,335 @@
|
||||
'use strict';
|
||||
module.exports = function generate_properties(it, $keyword, $ruleType) {
|
||||
var out = ' ';
|
||||
var $lvl = it.level;
|
||||
var $dataLvl = it.dataLevel;
|
||||
var $schema = it.schema[$keyword];
|
||||
var $schemaPath = it.schemaPath + it.util.getProperty($keyword);
|
||||
var $errSchemaPath = it.errSchemaPath + '/' + $keyword;
|
||||
var $breakOnError = !it.opts.allErrors;
|
||||
var $data = 'data' + ($dataLvl || '');
|
||||
var $errs = 'errs__' + $lvl;
|
||||
var $it = it.util.copy(it);
|
||||
var $closingBraces = '';
|
||||
$it.level++;
|
||||
var $nextValid = 'valid' + $it.level;
|
||||
var $key = 'key' + $lvl,
|
||||
$idx = 'idx' + $lvl,
|
||||
$dataNxt = $it.dataLevel = it.dataLevel + 1,
|
||||
$nextData = 'data' + $dataNxt,
|
||||
$dataProperties = 'dataProperties' + $lvl;
|
||||
var $schemaKeys = Object.keys($schema || {}).filter(notProto),
|
||||
$pProperties = it.schema.patternProperties || {},
|
||||
$pPropertyKeys = Object.keys($pProperties).filter(notProto),
|
||||
$aProperties = it.schema.additionalProperties,
|
||||
$someProperties = $schemaKeys.length || $pPropertyKeys.length,
|
||||
$noAdditional = $aProperties === false,
|
||||
$additionalIsSchema = typeof $aProperties == 'object' && Object.keys($aProperties).length,
|
||||
$removeAdditional = it.opts.removeAdditional,
|
||||
$checkAdditional = $noAdditional || $additionalIsSchema || $removeAdditional,
|
||||
$ownProperties = it.opts.ownProperties,
|
||||
$currentBaseId = it.baseId;
|
||||
var $required = it.schema.required;
|
||||
if ($required && !(it.opts.$data && $required.$data) && $required.length < it.opts.loopRequired) {
|
||||
var $requiredHash = it.util.toHash($required);
|
||||
}
|
||||
|
||||
function notProto(p) {
|
||||
return p !== '__proto__';
|
||||
}
|
||||
out += 'var ' + ($errs) + ' = errors;var ' + ($nextValid) + ' = true;';
|
||||
if ($ownProperties) {
|
||||
out += ' var ' + ($dataProperties) + ' = undefined;';
|
||||
}
|
||||
if ($checkAdditional) {
|
||||
if ($ownProperties) {
|
||||
out += ' ' + ($dataProperties) + ' = ' + ($dataProperties) + ' || Object.keys(' + ($data) + '); for (var ' + ($idx) + '=0; ' + ($idx) + '<' + ($dataProperties) + '.length; ' + ($idx) + '++) { var ' + ($key) + ' = ' + ($dataProperties) + '[' + ($idx) + ']; ';
|
||||
} else {
|
||||
out += ' for (var ' + ($key) + ' in ' + ($data) + ') { ';
|
||||
}
|
||||
if ($someProperties) {
|
||||
out += ' var isAdditional' + ($lvl) + ' = !(false ';
|
||||
if ($schemaKeys.length) {
|
||||
if ($schemaKeys.length > 8) {
|
||||
out += ' || validate.schema' + ($schemaPath) + '.hasOwnProperty(' + ($key) + ') ';
|
||||
} else {
|
||||
var arr1 = $schemaKeys;
|
||||
if (arr1) {
|
||||
var $propertyKey, i1 = -1,
|
||||
l1 = arr1.length - 1;
|
||||
while (i1 < l1) {
|
||||
$propertyKey = arr1[i1 += 1];
|
||||
out += ' || ' + ($key) + ' == ' + (it.util.toQuotedString($propertyKey)) + ' ';
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
if ($pPropertyKeys.length) {
|
||||
var arr2 = $pPropertyKeys;
|
||||
if (arr2) {
|
||||
var $pProperty, $i = -1,
|
||||
l2 = arr2.length - 1;
|
||||
while ($i < l2) {
|
||||
$pProperty = arr2[$i += 1];
|
||||
out += ' || ' + (it.usePattern($pProperty)) + '.test(' + ($key) + ') ';
|
||||
}
|
||||
}
|
||||
}
|
||||
out += ' ); if (isAdditional' + ($lvl) + ') { ';
|
||||
}
|
||||
if ($removeAdditional == 'all') {
|
||||
out += ' delete ' + ($data) + '[' + ($key) + ']; ';
|
||||
} else {
|
||||
var $currentErrorPath = it.errorPath;
|
||||
var $additionalProperty = '\' + ' + $key + ' + \'';
|
||||
if (it.opts._errorDataPathProperty) {
|
||||
it.errorPath = it.util.getPathExpr(it.errorPath, $key, it.opts.jsonPointers);
|
||||
}
|
||||
if ($noAdditional) {
|
||||
if ($removeAdditional) {
|
||||
out += ' delete ' + ($data) + '[' + ($key) + ']; ';
|
||||
} else {
|
||||
out += ' ' + ($nextValid) + ' = false; ';
|
||||
var $currErrSchemaPath = $errSchemaPath;
|
||||
$errSchemaPath = it.errSchemaPath + '/additionalProperties';
|
||||
var $$outStack = $$outStack || [];
|
||||
$$outStack.push(out);
|
||||
out = ''; /* istanbul ignore else */
|
||||
if (it.createErrors !== false) {
|
||||
out += ' { keyword: \'' + ('additionalProperties') + '\' , dataPath: (dataPath || \'\') + ' + (it.errorPath) + ' , schemaPath: ' + (it.util.toQuotedString($errSchemaPath)) + ' , params: { additionalProperty: \'' + ($additionalProperty) + '\' } ';
|
||||
if (it.opts.messages !== false) {
|
||||
out += ' , message: \'';
|
||||
if (it.opts._errorDataPathProperty) {
|
||||
out += 'is an invalid additional property';
|
||||
} else {
|
||||
out += 'should NOT have additional properties';
|
||||
}
|
||||
out += '\' ';
|
||||
}
|
||||
if (it.opts.verbose) {
|
||||
out += ' , schema: false , parentSchema: validate.schema' + (it.schemaPath) + ' , data: ' + ($data) + ' ';
|
||||
}
|
||||
out += ' } ';
|
||||
} else {
|
||||
out += ' {} ';
|
||||
}
|
||||
var __err = out;
|
||||
out = $$outStack.pop();
|
||||
if (!it.compositeRule && $breakOnError) {
|
||||
/* istanbul ignore if */
|
||||
if (it.async) {
|
||||
out += ' throw new ValidationError([' + (__err) + ']); ';
|
||||
} else {
|
||||
out += ' validate.errors = [' + (__err) + ']; return false; ';
|
||||
}
|
||||
} else {
|
||||
out += ' var err = ' + (__err) + '; if (vErrors === null) vErrors = [err]; else vErrors.push(err); errors++; ';
|
||||
}
|
||||
$errSchemaPath = $currErrSchemaPath;
|
||||
if ($breakOnError) {
|
||||
out += ' break; ';
|
||||
}
|
||||
}
|
||||
} else if ($additionalIsSchema) {
|
||||
if ($removeAdditional == 'failing') {
|
||||
out += ' var ' + ($errs) + ' = errors; ';
|
||||
var $wasComposite = it.compositeRule;
|
||||
it.compositeRule = $it.compositeRule = true;
|
||||
$it.schema = $aProperties;
|
||||
$it.schemaPath = it.schemaPath + '.additionalProperties';
|
||||
$it.errSchemaPath = it.errSchemaPath + '/additionalProperties';
|
||||
$it.errorPath = it.opts._errorDataPathProperty ? it.errorPath : it.util.getPathExpr(it.errorPath, $key, it.opts.jsonPointers);
|
||||
var $passData = $data + '[' + $key + ']';
|
||||
$it.dataPathArr[$dataNxt] = $key;
|
||||
var $code = it.validate($it);
|
||||
$it.baseId = $currentBaseId;
|
||||
if (it.util.varOccurences($code, $nextData) < 2) {
|
||||
out += ' ' + (it.util.varReplace($code, $nextData, $passData)) + ' ';
|
||||
} else {
|
||||
out += ' var ' + ($nextData) + ' = ' + ($passData) + '; ' + ($code) + ' ';
|
||||
}
|
||||
out += ' if (!' + ($nextValid) + ') { errors = ' + ($errs) + '; if (validate.errors !== null) { if (errors) validate.errors.length = errors; else validate.errors = null; } delete ' + ($data) + '[' + ($key) + ']; } ';
|
||||
it.compositeRule = $it.compositeRule = $wasComposite;
|
||||
} else {
|
||||
$it.schema = $aProperties;
|
||||
$it.schemaPath = it.schemaPath + '.additionalProperties';
|
||||
$it.errSchemaPath = it.errSchemaPath + '/additionalProperties';
|
||||
$it.errorPath = it.opts._errorDataPathProperty ? it.errorPath : it.util.getPathExpr(it.errorPath, $key, it.opts.jsonPointers);
|
||||
var $passData = $data + '[' + $key + ']';
|
||||
$it.dataPathArr[$dataNxt] = $key;
|
||||
var $code = it.validate($it);
|
||||
$it.baseId = $currentBaseId;
|
||||
if (it.util.varOccurences($code, $nextData) < 2) {
|
||||
out += ' ' + (it.util.varReplace($code, $nextData, $passData)) + ' ';
|
||||
} else {
|
||||
out += ' var ' + ($nextData) + ' = ' + ($passData) + '; ' + ($code) + ' ';
|
||||
}
|
||||
if ($breakOnError) {
|
||||
out += ' if (!' + ($nextValid) + ') break; ';
|
||||
}
|
||||
}
|
||||
}
|
||||
it.errorPath = $currentErrorPath;
|
||||
}
|
||||
if ($someProperties) {
|
||||
out += ' } ';
|
||||
}
|
||||
out += ' } ';
|
||||
if ($breakOnError) {
|
||||
out += ' if (' + ($nextValid) + ') { ';
|
||||
$closingBraces += '}';
|
||||
}
|
||||
}
|
||||
var $useDefaults = it.opts.useDefaults && !it.compositeRule;
|
||||
if ($schemaKeys.length) {
|
||||
var arr3 = $schemaKeys;
|
||||
if (arr3) {
|
||||
var $propertyKey, i3 = -1,
|
||||
l3 = arr3.length - 1;
|
||||
while (i3 < l3) {
|
||||
$propertyKey = arr3[i3 += 1];
|
||||
var $sch = $schema[$propertyKey];
|
||||
if ((it.opts.strictKeywords ? (typeof $sch == 'object' && Object.keys($sch).length > 0) || $sch === false : it.util.schemaHasRules($sch, it.RULES.all))) {
|
||||
var $prop = it.util.getProperty($propertyKey),
|
||||
$passData = $data + $prop,
|
||||
$hasDefault = $useDefaults && $sch.default !== undefined;
|
||||
$it.schema = $sch;
|
||||
$it.schemaPath = $schemaPath + $prop;
|
||||
$it.errSchemaPath = $errSchemaPath + '/' + it.util.escapeFragment($propertyKey);
|
||||
$it.errorPath = it.util.getPath(it.errorPath, $propertyKey, it.opts.jsonPointers);
|
||||
$it.dataPathArr[$dataNxt] = it.util.toQuotedString($propertyKey);
|
||||
var $code = it.validate($it);
|
||||
$it.baseId = $currentBaseId;
|
||||
if (it.util.varOccurences($code, $nextData) < 2) {
|
||||
$code = it.util.varReplace($code, $nextData, $passData);
|
||||
var $useData = $passData;
|
||||
} else {
|
||||
var $useData = $nextData;
|
||||
out += ' var ' + ($nextData) + ' = ' + ($passData) + '; ';
|
||||
}
|
||||
if ($hasDefault) {
|
||||
out += ' ' + ($code) + ' ';
|
||||
} else {
|
||||
if ($requiredHash && $requiredHash[$propertyKey]) {
|
||||
out += ' if ( ' + ($useData) + ' === undefined ';
|
||||
if ($ownProperties) {
|
||||
out += ' || ! Object.prototype.hasOwnProperty.call(' + ($data) + ', \'' + (it.util.escapeQuotes($propertyKey)) + '\') ';
|
||||
}
|
||||
out += ') { ' + ($nextValid) + ' = false; ';
|
||||
var $currentErrorPath = it.errorPath,
|
||||
$currErrSchemaPath = $errSchemaPath,
|
||||
$missingProperty = it.util.escapeQuotes($propertyKey);
|
||||
if (it.opts._errorDataPathProperty) {
|
||||
it.errorPath = it.util.getPath($currentErrorPath, $propertyKey, it.opts.jsonPointers);
|
||||
}
|
||||
$errSchemaPath = it.errSchemaPath + '/required';
|
||||
var $$outStack = $$outStack || [];
|
||||
$$outStack.push(out);
|
||||
out = ''; /* istanbul ignore else */
|
||||
if (it.createErrors !== false) {
|
||||
out += ' { keyword: \'' + ('required') + '\' , dataPath: (dataPath || \'\') + ' + (it.errorPath) + ' , schemaPath: ' + (it.util.toQuotedString($errSchemaPath)) + ' , params: { missingProperty: \'' + ($missingProperty) + '\' } ';
|
||||
if (it.opts.messages !== false) {
|
||||
out += ' , message: \'';
|
||||
if (it.opts._errorDataPathProperty) {
|
||||
out += 'is a required property';
|
||||
} else {
|
||||
out += 'should have required property \\\'' + ($missingProperty) + '\\\'';
|
||||
}
|
||||
out += '\' ';
|
||||
}
|
||||
if (it.opts.verbose) {
|
||||
out += ' , schema: validate.schema' + ($schemaPath) + ' , parentSchema: validate.schema' + (it.schemaPath) + ' , data: ' + ($data) + ' ';
|
||||
}
|
||||
out += ' } ';
|
||||
} else {
|
||||
out += ' {} ';
|
||||
}
|
||||
var __err = out;
|
||||
out = $$outStack.pop();
|
||||
if (!it.compositeRule && $breakOnError) {
|
||||
/* istanbul ignore if */
|
||||
if (it.async) {
|
||||
out += ' throw new ValidationError([' + (__err) + ']); ';
|
||||
} else {
|
||||
out += ' validate.errors = [' + (__err) + ']; return false; ';
|
||||
}
|
||||
} else {
|
||||
out += ' var err = ' + (__err) + '; if (vErrors === null) vErrors = [err]; else vErrors.push(err); errors++; ';
|
||||
}
|
||||
$errSchemaPath = $currErrSchemaPath;
|
||||
it.errorPath = $currentErrorPath;
|
||||
out += ' } else { ';
|
||||
} else {
|
||||
if ($breakOnError) {
|
||||
out += ' if ( ' + ($useData) + ' === undefined ';
|
||||
if ($ownProperties) {
|
||||
out += ' || ! Object.prototype.hasOwnProperty.call(' + ($data) + ', \'' + (it.util.escapeQuotes($propertyKey)) + '\') ';
|
||||
}
|
||||
out += ') { ' + ($nextValid) + ' = true; } else { ';
|
||||
} else {
|
||||
out += ' if (' + ($useData) + ' !== undefined ';
|
||||
if ($ownProperties) {
|
||||
out += ' && Object.prototype.hasOwnProperty.call(' + ($data) + ', \'' + (it.util.escapeQuotes($propertyKey)) + '\') ';
|
||||
}
|
||||
out += ' ) { ';
|
||||
}
|
||||
}
|
||||
out += ' ' + ($code) + ' } ';
|
||||
}
|
||||
}
|
||||
if ($breakOnError) {
|
||||
out += ' if (' + ($nextValid) + ') { ';
|
||||
$closingBraces += '}';
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
if ($pPropertyKeys.length) {
|
||||
var arr4 = $pPropertyKeys;
|
||||
if (arr4) {
|
||||
var $pProperty, i4 = -1,
|
||||
l4 = arr4.length - 1;
|
||||
while (i4 < l4) {
|
||||
$pProperty = arr4[i4 += 1];
|
||||
var $sch = $pProperties[$pProperty];
|
||||
if ((it.opts.strictKeywords ? (typeof $sch == 'object' && Object.keys($sch).length > 0) || $sch === false : it.util.schemaHasRules($sch, it.RULES.all))) {
|
||||
$it.schema = $sch;
|
||||
$it.schemaPath = it.schemaPath + '.patternProperties' + it.util.getProperty($pProperty);
|
||||
$it.errSchemaPath = it.errSchemaPath + '/patternProperties/' + it.util.escapeFragment($pProperty);
|
||||
if ($ownProperties) {
|
||||
out += ' ' + ($dataProperties) + ' = ' + ($dataProperties) + ' || Object.keys(' + ($data) + '); for (var ' + ($idx) + '=0; ' + ($idx) + '<' + ($dataProperties) + '.length; ' + ($idx) + '++) { var ' + ($key) + ' = ' + ($dataProperties) + '[' + ($idx) + ']; ';
|
||||
} else {
|
||||
out += ' for (var ' + ($key) + ' in ' + ($data) + ') { ';
|
||||
}
|
||||
out += ' if (' + (it.usePattern($pProperty)) + '.test(' + ($key) + ')) { ';
|
||||
$it.errorPath = it.util.getPathExpr(it.errorPath, $key, it.opts.jsonPointers);
|
||||
var $passData = $data + '[' + $key + ']';
|
||||
$it.dataPathArr[$dataNxt] = $key;
|
||||
var $code = it.validate($it);
|
||||
$it.baseId = $currentBaseId;
|
||||
if (it.util.varOccurences($code, $nextData) < 2) {
|
||||
out += ' ' + (it.util.varReplace($code, $nextData, $passData)) + ' ';
|
||||
} else {
|
||||
out += ' var ' + ($nextData) + ' = ' + ($passData) + '; ' + ($code) + ' ';
|
||||
}
|
||||
if ($breakOnError) {
|
||||
out += ' if (!' + ($nextValid) + ') break; ';
|
||||
}
|
||||
out += ' } ';
|
||||
if ($breakOnError) {
|
||||
out += ' else ' + ($nextValid) + ' = true; ';
|
||||
}
|
||||
out += ' } ';
|
||||
if ($breakOnError) {
|
||||
out += ' if (' + ($nextValid) + ') { ';
|
||||
$closingBraces += '}';
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
if ($breakOnError) {
|
||||
out += ' ' + ($closingBraces) + ' if (' + ($errs) + ' == errors) {';
|
||||
}
|
||||
return out;
|
||||
}
|
||||
@@ -0,0 +1,2 @@
|
||||
declare const _default: "ffffffff-ffff-ffff-ffff-ffffffffffff";
|
||||
export default _default;
|
||||
@@ -0,0 +1 @@
|
||||
{"version":3,"file":"pasta.js","sourceRoot":"","sources":["src/pasta.ts"],"names":[],"mappings":";;;AAAA;;;GAGG;AACH,uCAAsD;AACtD,kBAAkB;AACL,QAAA,MAAM,GAAc,gBAAE,CAAC;AACpC,kBAAkB;AACL,QAAA,KAAK,GAAc,eAAE,CAAC"}
|
||||
File diff suppressed because one or more lines are too long
@@ -0,0 +1,310 @@
|
||||
import type { CompletionItemKind } from "#enums/completionItemKind";
|
||||
import type { DiagnosticCategory } from "#enums/diagnosticCategory";
|
||||
import type { ElementFlags } from "#enums/elementFlags";
|
||||
import type { ObjectFlags } from "#enums/objectFlags";
|
||||
import type { TypeFlags } from "#enums/typeFlags";
|
||||
import type { TypePredicateKind } from "#enums/typePredicateKind";
|
||||
import type { NodeHandle, Symbol } from "./api.ts";
|
||||
/**
|
||||
* A TypeScript type.
|
||||
*
|
||||
* Use TypeFlags to determine the specific kind of type and access
|
||||
* kind-specific properties. For example:
|
||||
*
|
||||
* ```ts
|
||||
* if (type.flags & TypeFlags.StringLiteral) {
|
||||
* console.log((type as StringLiteralType).value); // string
|
||||
* }
|
||||
* ```
|
||||
*/
|
||||
export interface Type {
|
||||
/** Type flags — use to determine the specific kind of type. */
|
||||
readonly flags: TypeFlags;
|
||||
/** Unique identifier for this type */
|
||||
readonly id: number;
|
||||
/** Get the symbol associated with this type, if any */
|
||||
getSymbol(): Promise<Symbol | undefined>;
|
||||
/** Get the type arguments of the type alias this type was instantiated from, if any */
|
||||
getAliasTypeArguments(): Promise<readonly Type[]>;
|
||||
/** Get the symbol of the type alias this type was instantiated from, if any */
|
||||
getAliasSymbol(): Promise<Symbol | undefined>;
|
||||
/**
|
||||
* Get the base types of this type, or `undefined` if it is not a class or
|
||||
* interface type.
|
||||
*/
|
||||
getBaseTypes(): Promise<readonly Type[] | undefined>;
|
||||
/** Whether this type is a class or interface type */
|
||||
isClassOrInterface(): this is InterfaceType;
|
||||
/** Whether this type is a union type */
|
||||
isUnionType(): this is UnionType;
|
||||
/** Whether this type is an intersection type */
|
||||
isIntersectionType(): this is IntersectionType;
|
||||
/** Whether this type is an object type */
|
||||
isObjectType(): this is ObjectType;
|
||||
/** Whether this type is an intrinsic primitive type */
|
||||
isIntrinsicType(): this is IntrinsicType;
|
||||
/**
|
||||
* Whether this is the error type — the placeholder produced when a type
|
||||
* cannot be determined (e.g. an unresolved reference).
|
||||
*/
|
||||
isErrorType(): boolean;
|
||||
/** Whether this type is a literal type */
|
||||
isLiteralType(): this is LiteralType;
|
||||
/** Whether this type is a string literal type */
|
||||
isStringLiteralType(): this is StringLiteralType;
|
||||
/** Whether this type is a number literal type */
|
||||
isNumberLiteralType(): this is NumberLiteralType;
|
||||
/** Whether this type is a bigint literal type */
|
||||
isBigIntLiteralType(): this is BigIntLiteralType;
|
||||
/** Whether this type is a boolean literal type */
|
||||
isBooleanLiteralType(): this is BooleanLiteralType;
|
||||
/** Whether this type is a type reference */
|
||||
isTypeReference(): this is TypeReference;
|
||||
/** Whether this type is a tuple type */
|
||||
isTupleType(): this is TupleType;
|
||||
/** Whether this type is an index type (`keyof T`) */
|
||||
isIndexType(): this is IndexType;
|
||||
/** Whether this type is an indexed access type (`T[K]`) */
|
||||
isIndexedAccessType(): this is IndexedAccessType;
|
||||
/** Whether this type is a conditional type */
|
||||
isConditionalType(): this is ConditionalType;
|
||||
/** Whether this type is a substitution type */
|
||||
isSubstitutionType(): this is SubstitutionType;
|
||||
/** Whether this type is a template literal type */
|
||||
isTemplateLiteralType(): this is TemplateLiteralType;
|
||||
/** Whether this type is a string mapping type */
|
||||
isStringMappingType(): this is StringMappingType;
|
||||
/** Whether this type is a type parameter */
|
||||
isTypeParameter(): this is TypeParameter;
|
||||
}
|
||||
/**
|
||||
* Freshable types (TypeFlags.Freshable) - literal types (TypeFlags.Literal) and computed enum types (TypeFlags.Enum).
|
||||
*/
|
||||
export interface FreshableType extends Type {
|
||||
/** Get the fresh version of this type, if any */
|
||||
getFreshType(): Promise<FreshableType | undefined>;
|
||||
/** Get the regular (non-fresh) version of this type, if any */
|
||||
getRegularType(): Promise<FreshableType | undefined>;
|
||||
}
|
||||
/** Literal types: StringLiteral, NumberLiteral, BigIntLiteral, BooleanLiteral */
|
||||
export interface LiteralType extends FreshableType {
|
||||
/** The literal value. Use TypeFlags to narrow to a specific literal subtype with a concrete value type. */
|
||||
readonly value: string | number | boolean | bigint;
|
||||
}
|
||||
/** String literal types (TypeFlags.StringLiteral) */
|
||||
export interface StringLiteralType extends LiteralType {
|
||||
/** The string value of the literal */
|
||||
readonly value: string;
|
||||
}
|
||||
/** Numeric literal types (TypeFlags.NumberLiteral) */
|
||||
export interface NumberLiteralType extends LiteralType {
|
||||
/** The numeric value of the literal */
|
||||
readonly value: number;
|
||||
}
|
||||
/** BigInt literal types (TypeFlags.BigIntLiteral) */
|
||||
export interface BigIntLiteralType extends LiteralType {
|
||||
/** The bigint value of the literal */
|
||||
readonly value: bigint;
|
||||
}
|
||||
/** Boolean literal types (TypeFlags.BooleanLiteral) */
|
||||
export interface BooleanLiteralType extends LiteralType {
|
||||
/** The boolean value of the literal */
|
||||
readonly value: boolean;
|
||||
}
|
||||
/** Object types (TypeFlags.Object) */
|
||||
export interface ObjectType extends Type {
|
||||
/** Object flags — use to determine the specific kind of object type. */
|
||||
readonly objectFlags: ObjectFlags;
|
||||
}
|
||||
/** Type references (ObjectFlags.Reference) — e.g. Array<string>, Map<K, V> */
|
||||
export interface TypeReference extends ObjectType {
|
||||
/** Get the generic target type (e.g. Array for Array<string>) */
|
||||
getTarget(): Promise<Type>;
|
||||
}
|
||||
/** Interface types — classes and interfaces (ObjectFlags.ClassOrInterface) */
|
||||
export interface InterfaceType extends TypeReference {
|
||||
/** Get all type parameters (outer + local, excluding thisType) */
|
||||
getTypeParameters(): Promise<readonly TypeParameter[]>;
|
||||
/** Get outer type parameters from enclosing declarations */
|
||||
getOuterTypeParameters(): Promise<readonly TypeParameter[]>;
|
||||
/** Get local type parameters declared on this interface/class */
|
||||
getLocalTypeParameters(): Promise<readonly TypeParameter[]>;
|
||||
}
|
||||
/** Tuple types (ObjectFlags.Tuple) */
|
||||
export interface TupleType extends InterfaceType {
|
||||
/** Per-element flags (Required, Optional, Rest, Variadic) */
|
||||
readonly elementFlags: readonly ElementFlags[];
|
||||
/** Number of initial required or optional elements */
|
||||
readonly fixedLength: number;
|
||||
/** Whether the tuple is readonly */
|
||||
readonly readonly: boolean;
|
||||
}
|
||||
/** Union or intersection types (TypeFlags.Union | TypeFlags.Intersection) */
|
||||
export interface UnionOrIntersectionType extends Type {
|
||||
/** Get the constituent types */
|
||||
getTypes(): Promise<readonly Type[]>;
|
||||
}
|
||||
/** Union types (TypeFlags.Union) */
|
||||
export interface UnionType extends UnionOrIntersectionType {
|
||||
}
|
||||
/** Intersection types (TypeFlags.Intersection) */
|
||||
export interface IntersectionType extends UnionOrIntersectionType {
|
||||
}
|
||||
/** Type parameters (TypeFlags.TypeParameter) */
|
||||
export interface TypeParameter extends Type {
|
||||
/** True if this is the synthetic `this` type of an interface, class, or tuple */
|
||||
readonly isThisType?: boolean | undefined;
|
||||
}
|
||||
/** Index types — keyof T (TypeFlags.Index) */
|
||||
export interface IndexType extends Type {
|
||||
/** Get the target type T in `keyof T` */
|
||||
getTarget(): Promise<Type>;
|
||||
}
|
||||
/** Indexed access types — T[K] (TypeFlags.IndexedAccess) */
|
||||
export interface IndexedAccessType extends Type {
|
||||
/** Get the object type T in `T[K]` */
|
||||
getObjectType(): Promise<Type>;
|
||||
/** Get the index type K in `T[K]` */
|
||||
getIndexType(): Promise<Type>;
|
||||
}
|
||||
/** Conditional types — T extends U ? X : Y (TypeFlags.Conditional) */
|
||||
export interface ConditionalType extends Type {
|
||||
/** Get the check type T in `T extends U ? X : Y` */
|
||||
getCheckType(): Promise<Type>;
|
||||
/** Get the extends type U in `T extends U ? X : Y` */
|
||||
getExtendsType(): Promise<Type>;
|
||||
/** Get the true type X in `T extends U ? X : Y` */
|
||||
getTrueType(): Promise<Type>;
|
||||
/** Get the false type Y in `T extends U ? X : Y` */
|
||||
getFalseType(): Promise<Type>;
|
||||
}
|
||||
/** Substitution types (TypeFlags.Substitution) */
|
||||
export interface SubstitutionType extends Type {
|
||||
getBaseType(): Promise<Type>;
|
||||
getConstraint(): Promise<Type>;
|
||||
}
|
||||
/** Template literal types (TypeFlags.TemplateLiteral) */
|
||||
export interface TemplateLiteralType extends Type {
|
||||
/** Text segments (always one more than the number of type spans) */
|
||||
readonly texts: readonly string[];
|
||||
/** Get the types interspersed between text segments */
|
||||
getTypes(): Promise<readonly Type[]>;
|
||||
}
|
||||
/** String mapping types — Uppercase<T>, Lowercase<T>, etc. (TypeFlags.StringMapping) */
|
||||
export interface StringMappingType extends Type {
|
||||
/** Get the mapped type */
|
||||
getTarget(): Promise<Type>;
|
||||
}
|
||||
/** Intrinsic types — any, unknown, string, number, bigint, symbol, void, undefined, null, never, object (TypeFlags.Intrinsic) */
|
||||
export interface IntrinsicType extends Type {
|
||||
/** The intrinsic type name (e.g. "any", "string", "never") */
|
||||
readonly intrinsicName: string;
|
||||
}
|
||||
/** Base for all type predicates */
|
||||
export interface TypePredicateBase {
|
||||
readonly kind: TypePredicateKind;
|
||||
readonly type: Type | undefined;
|
||||
}
|
||||
/** `this is T` */
|
||||
export interface ThisTypePredicate extends TypePredicateBase {
|
||||
readonly kind: TypePredicateKind.This;
|
||||
readonly parameterName: undefined;
|
||||
readonly parameterIndex: undefined;
|
||||
readonly type: Type;
|
||||
}
|
||||
/** `x is T` */
|
||||
export interface IdentifierTypePredicate extends TypePredicateBase {
|
||||
readonly kind: TypePredicateKind.Identifier;
|
||||
readonly parameterName: string;
|
||||
readonly parameterIndex: number;
|
||||
readonly type: Type;
|
||||
}
|
||||
/** `asserts this is T` */
|
||||
export interface AssertsThisTypePredicate extends TypePredicateBase {
|
||||
readonly kind: TypePredicateKind.AssertsThis;
|
||||
readonly parameterName: undefined;
|
||||
readonly parameterIndex: undefined;
|
||||
readonly type: Type | undefined;
|
||||
}
|
||||
/** `asserts x is T` */
|
||||
export interface AssertsIdentifierTypePredicate extends TypePredicateBase {
|
||||
readonly kind: TypePredicateKind.AssertsIdentifier;
|
||||
readonly parameterName: string;
|
||||
readonly parameterIndex: number;
|
||||
readonly type: Type | undefined;
|
||||
}
|
||||
/** A type predicate — e.g. `x is T` or `asserts x is T` */
|
||||
export type TypePredicate = ThisTypePredicate | IdentifierTypePredicate | AssertsThisTypePredicate | AssertsIdentifierTypePredicate;
|
||||
/** An index signature — e.g. `[key: string]: T` */
|
||||
export interface IndexInfo {
|
||||
/** The index key type (e.g. string or number) */
|
||||
readonly keyType: Type;
|
||||
/** The index value type */
|
||||
readonly valueType: Type;
|
||||
/** Whether the index signature is readonly */
|
||||
readonly isReadonly: boolean;
|
||||
/** The index signature declaration, if any */
|
||||
readonly declaration?: NodeHandle | undefined;
|
||||
}
|
||||
/**
|
||||
* A single JSDoc tag attached to a symbol — e.g. `@param`, `@returns`.
|
||||
*/
|
||||
export interface JSDocTagInfo {
|
||||
/** The tag name, without the leading `@` — e.g. `"param"`. */
|
||||
readonly name: string;
|
||||
/** The rendered tag text, if any — e.g. `"a the first number"` for `@param a the first number`. */
|
||||
readonly text?: string | undefined;
|
||||
}
|
||||
export interface CompletionEntryLabelDetails {
|
||||
detail?: string | undefined;
|
||||
description?: string | undefined;
|
||||
}
|
||||
/** Options for {@link Checker.getCompletionsAtPosition}. */
|
||||
export interface CompletionOptions {
|
||||
triggerCharacter?: string | undefined;
|
||||
/** Include a `symbol` property on each completion entry. Only populated for symbol-based completions (not keywords or literals). */
|
||||
includeSymbol?: boolean | undefined;
|
||||
}
|
||||
/** A single completion item returned by {@link Checker.getCompletionsAtPosition}. */
|
||||
export interface CompletionEntry {
|
||||
readonly name: string;
|
||||
readonly kind?: CompletionItemKind | undefined;
|
||||
readonly sortText?: string | undefined;
|
||||
readonly insertText?: string | undefined;
|
||||
readonly filterText?: string | undefined;
|
||||
readonly detail?: string | undefined;
|
||||
readonly labelDetails?: CompletionEntryLabelDetails | undefined;
|
||||
/** The symbol associated with this completion entry. Only set when `includeSymbol: true` is passed and a symbol is available. */
|
||||
readonly symbol?: Symbol | undefined;
|
||||
}
|
||||
/** The result of {@link Checker.getCompletionsAtPosition}. */
|
||||
export interface CompletionInfo {
|
||||
readonly isIncomplete: boolean;
|
||||
readonly entries: readonly CompletionEntry[];
|
||||
}
|
||||
/**
|
||||
* A diagnostic message from the TypeScript compiler.
|
||||
*/
|
||||
export interface Diagnostic {
|
||||
/** File name of the source file this diagnostic belongs to, if any */
|
||||
readonly fileName?: string | undefined;
|
||||
/** Start position of the diagnostic */
|
||||
readonly pos: number;
|
||||
/** End position of the diagnostic */
|
||||
readonly end: number;
|
||||
/** Diagnostic error code */
|
||||
readonly code: number;
|
||||
/** Diagnostic category (error, warning, suggestion, message) */
|
||||
readonly category: DiagnosticCategory;
|
||||
/** Localized diagnostic message text */
|
||||
readonly text: string;
|
||||
/** Whether this diagnostic highlights unnecessary code */
|
||||
readonly reportsUnnecessary?: boolean | undefined;
|
||||
/** Whether this diagnostic highlights deprecated code */
|
||||
readonly reportsDeprecated?: boolean | undefined;
|
||||
/** Chained diagnostic messages */
|
||||
readonly messageChain?: readonly Diagnostic[] | undefined;
|
||||
/** Related diagnostic information */
|
||||
readonly relatedInformation?: readonly Diagnostic[] | undefined;
|
||||
}
|
||||
//# sourceMappingURL=types.d.ts.map
|
||||
@@ -0,0 +1 @@
|
||||
export { _ as default } from "../esm/_sliced_to_array_loose.js";
|
||||
File diff suppressed because it is too large
Load Diff
File diff suppressed because one or more lines are too long
@@ -0,0 +1,4 @@
|
||||
function _tdzError(e) {
|
||||
throw new ReferenceError(e + " is not defined - temporal dead zone");
|
||||
}
|
||||
export { _tdzError as default };
|
||||
@@ -0,0 +1,199 @@
|
||||
class MockerRegistry {
|
||||
registryByUrl = new Map();
|
||||
registryById = new Map();
|
||||
clear() {
|
||||
this.registryByUrl.clear();
|
||||
this.registryById.clear();
|
||||
}
|
||||
keys() {
|
||||
return this.registryByUrl.keys();
|
||||
}
|
||||
add(mock) {
|
||||
this.registryByUrl.set(mock.url, mock);
|
||||
this.registryById.set(mock.id, mock);
|
||||
}
|
||||
register(typeOrEvent, raw, id, url, factoryOrRedirect) {
|
||||
const type = typeof typeOrEvent === "object" ? typeOrEvent.type : typeOrEvent;
|
||||
if (typeof typeOrEvent === "object") {
|
||||
const event = typeOrEvent;
|
||||
if (event instanceof AutomockedModule || event instanceof AutospiedModule || event instanceof ManualMockedModule || event instanceof RedirectedModule) {
|
||||
throw new TypeError(`[vitest] Cannot register a mock that is already defined. ` + `Expected a JSON representation from \`MockedModule.toJSON\`, instead got "${event.type}". ` + `Use "registry.add()" to update a mock instead.`);
|
||||
}
|
||||
if (event.type === "automock") {
|
||||
const module = AutomockedModule.fromJSON(event);
|
||||
this.add(module);
|
||||
return module;
|
||||
} else if (event.type === "autospy") {
|
||||
const module = AutospiedModule.fromJSON(event);
|
||||
this.add(module);
|
||||
return module;
|
||||
} else if (event.type === "redirect") {
|
||||
const module = RedirectedModule.fromJSON(event);
|
||||
this.add(module);
|
||||
return module;
|
||||
} else if (event.type === "manual") {
|
||||
throw new Error(`Cannot set serialized manual mock. Define a factory function manually with \`ManualMockedModule.fromJSON()\`.`);
|
||||
} else {
|
||||
throw new Error(`Unknown mock type: ${event.type}`);
|
||||
}
|
||||
}
|
||||
if (typeof raw !== "string") {
|
||||
throw new TypeError("[vitest] Mocks require a raw string.");
|
||||
}
|
||||
if (typeof url !== "string") {
|
||||
throw new TypeError("[vitest] Mocks require a url string.");
|
||||
}
|
||||
if (typeof id !== "string") {
|
||||
throw new TypeError("[vitest] Mocks require an id string.");
|
||||
}
|
||||
if (type === "manual") {
|
||||
if (typeof factoryOrRedirect !== "function") {
|
||||
throw new TypeError("[vitest] Manual mocks require a factory function.");
|
||||
}
|
||||
const mock = new ManualMockedModule(raw, id, url, factoryOrRedirect);
|
||||
this.add(mock);
|
||||
return mock;
|
||||
} else if (type === "automock" || type === "autospy") {
|
||||
const mock = type === "automock" ? new AutomockedModule(raw, id, url) : new AutospiedModule(raw, id, url);
|
||||
this.add(mock);
|
||||
return mock;
|
||||
} else if (type === "redirect") {
|
||||
if (typeof factoryOrRedirect !== "string") {
|
||||
throw new TypeError("[vitest] Redirect mocks require a redirect string.");
|
||||
}
|
||||
const mock = new RedirectedModule(raw, id, url, factoryOrRedirect);
|
||||
this.add(mock);
|
||||
return mock;
|
||||
} else {
|
||||
throw new Error(`[vitest] Unknown mock type: ${type}`);
|
||||
}
|
||||
}
|
||||
delete(id) {
|
||||
this.registryByUrl.delete(id);
|
||||
}
|
||||
deleteById(id) {
|
||||
this.registryById.delete(id);
|
||||
}
|
||||
get(id) {
|
||||
return this.registryByUrl.get(id);
|
||||
}
|
||||
getById(id) {
|
||||
return this.registryById.get(id);
|
||||
}
|
||||
has(id) {
|
||||
return this.registryByUrl.has(id);
|
||||
}
|
||||
}
|
||||
class AutomockedModule {
|
||||
type = "automock";
|
||||
constructor(raw, id, url) {
|
||||
this.raw = raw;
|
||||
this.id = id;
|
||||
this.url = url;
|
||||
}
|
||||
static fromJSON(data) {
|
||||
return new AutospiedModule(data.raw, data.id, data.url);
|
||||
}
|
||||
toJSON() {
|
||||
return {
|
||||
type: this.type,
|
||||
url: this.url,
|
||||
raw: this.raw,
|
||||
id: this.id
|
||||
};
|
||||
}
|
||||
}
|
||||
class AutospiedModule {
|
||||
type = "autospy";
|
||||
constructor(raw, id, url) {
|
||||
this.raw = raw;
|
||||
this.id = id;
|
||||
this.url = url;
|
||||
}
|
||||
static fromJSON(data) {
|
||||
return new AutospiedModule(data.raw, data.id, data.url);
|
||||
}
|
||||
toJSON() {
|
||||
return {
|
||||
type: this.type,
|
||||
url: this.url,
|
||||
id: this.id,
|
||||
raw: this.raw
|
||||
};
|
||||
}
|
||||
}
|
||||
class RedirectedModule {
|
||||
type = "redirect";
|
||||
constructor(raw, id, url, redirect) {
|
||||
this.raw = raw;
|
||||
this.id = id;
|
||||
this.url = url;
|
||||
this.redirect = redirect;
|
||||
}
|
||||
static fromJSON(data) {
|
||||
return new RedirectedModule(data.raw, data.id, data.url, data.redirect);
|
||||
}
|
||||
toJSON() {
|
||||
return {
|
||||
type: this.type,
|
||||
url: this.url,
|
||||
raw: this.raw,
|
||||
id: this.id,
|
||||
redirect: this.redirect
|
||||
};
|
||||
}
|
||||
}
|
||||
class ManualMockedModule {
|
||||
cache;
|
||||
type = "manual";
|
||||
constructor(raw, id, url, factory) {
|
||||
this.raw = raw;
|
||||
this.id = id;
|
||||
this.url = url;
|
||||
this.factory = factory;
|
||||
}
|
||||
resolve() {
|
||||
if (this.cache) {
|
||||
return this.cache;
|
||||
}
|
||||
let exports$1;
|
||||
try {
|
||||
exports$1 = this.factory();
|
||||
} catch (err) {
|
||||
throw createHelpfulError(err);
|
||||
}
|
||||
if (typeof exports$1 === "object" && typeof exports$1?.then === "function") {
|
||||
return exports$1.then((result) => {
|
||||
assertValidExports(this.raw, result);
|
||||
return this.cache = result;
|
||||
}, (error) => {
|
||||
throw createHelpfulError(error);
|
||||
});
|
||||
}
|
||||
assertValidExports(this.raw, exports$1);
|
||||
return this.cache = exports$1;
|
||||
}
|
||||
static fromJSON(data, factory) {
|
||||
return new ManualMockedModule(data.raw, data.id, data.url, factory);
|
||||
}
|
||||
toJSON() {
|
||||
return {
|
||||
type: this.type,
|
||||
url: this.url,
|
||||
id: this.id,
|
||||
raw: this.raw
|
||||
};
|
||||
}
|
||||
}
|
||||
function createHelpfulError(cause) {
|
||||
const error = new Error("[vitest] There was an error when mocking a module. " + "If you are using \"vi.mock\" factory, make sure there are no top level variables inside, since this call is hoisted to top of the file. " + "Read more: https://vitest.dev/api/vi.html#vi-mock");
|
||||
error.cause = cause;
|
||||
return error;
|
||||
}
|
||||
function assertValidExports(raw, exports$1) {
|
||||
if (exports$1 === null || typeof exports$1 !== "object" || Array.isArray(exports$1)) {
|
||||
throw new TypeError(`[vitest] vi.mock("${raw}", factory?: () => unknown) is not returning an object. Did you mean to return an object with a "default" key?`);
|
||||
}
|
||||
}
|
||||
|
||||
export { AutomockedModule as A, MockerRegistry as M, RedirectedModule as R, ManualMockedModule as a, AutospiedModule as b };
|
||||
@@ -0,0 +1,107 @@
|
||||
'use strict'
|
||||
|
||||
module.exports = {
|
||||
buildSafeSonicBoom: require('./build-safe-sonic-boom.js'),
|
||||
createDate: require('./create-date.js'),
|
||||
deleteLogProperty: require('./delete-log-property.js'),
|
||||
filterLog: require('./filter-log.js'),
|
||||
formatTime: require('./format-time.js'),
|
||||
getPropertyValue: require('./get-property-value.js'),
|
||||
handleCustomLevelsNamesOpts: require('./handle-custom-levels-names-opts.js'),
|
||||
handleCustomLevelsOpts: require('./handle-custom-levels-opts.js'),
|
||||
interpretConditionals: require('./interpret-conditionals.js'),
|
||||
isObject: require('./is-object.js'),
|
||||
isValidDate: require('./is-valid-date.js'),
|
||||
joinLinesWithIndentation: require('./join-lines-with-indentation.js'),
|
||||
noop: require('./noop.js'),
|
||||
parseFactoryOptions: require('./parse-factory-options.js'),
|
||||
prettifyErrorLog: require('./prettify-error-log.js'),
|
||||
prettifyError: require('./prettify-error.js'),
|
||||
prettifyLevel: require('./prettify-level.js'),
|
||||
prettifyMessage: require('./prettify-message.js'),
|
||||
prettifyMetadata: require('./prettify-metadata.js'),
|
||||
prettifyObject: require('./prettify-object.js'),
|
||||
prettifyTime: require('./prettify-time.js'),
|
||||
splitPropertyKey: require('./split-property-key.js'),
|
||||
getLevelLabelData: require('./get-level-label-data')
|
||||
}
|
||||
|
||||
// The remainder of this file consists of jsdoc blocks that are difficult to
|
||||
// determine a more appropriate "home" for. As an example, the blocks associated
|
||||
// with custom prettifiers could live in either the `prettify-level`,
|
||||
// `prettify-metadata`, or `prettify-time` files since they are the primary
|
||||
// files where such code is used. But we want a central place to define common
|
||||
// doc blocks, so we are picking this file as the answer.
|
||||
|
||||
/**
|
||||
* A hash of log property names mapped to prettifier functions. When the
|
||||
* incoming log data is being processed for prettification, any key on the log
|
||||
* that matches a key in a custom prettifiers hash will be prettified using
|
||||
* that matching custom prettifier. The value passed to the custom prettifier
|
||||
* will the value associated with the corresponding log key.
|
||||
*
|
||||
* The hash may contain any arbitrary keys for arbitrary log properties, but it
|
||||
* may also contain a set of predefined key names that map to well-known log
|
||||
* properties. These keys are:
|
||||
*
|
||||
* + `time` (for the timestamp field)
|
||||
* + `level` (for the level label field; value may be a level number instead
|
||||
* of a level label)
|
||||
* + `hostname`
|
||||
* + `pid`
|
||||
* + `name`
|
||||
* + `caller`
|
||||
*
|
||||
* @typedef {Object.<string, CustomPrettifierFunc>} CustomPrettifiers
|
||||
*/
|
||||
|
||||
/**
|
||||
* A synchronous function to be used for prettifying a log property. It must
|
||||
* return a string.
|
||||
*
|
||||
* @typedef {function} CustomPrettifierFunc
|
||||
* @param {any} value The value to be prettified for the key associated with
|
||||
* the prettifier.
|
||||
* @returns {string}
|
||||
*/
|
||||
|
||||
/**
|
||||
* A tokenized string that indicates how the prettified log line should be
|
||||
* formatted. Tokens are either log properties enclosed in curly braces, e.g.
|
||||
* `{levelLabel}`, `{pid}`, or `{req.url}`, or conditional directives in curly
|
||||
* braces. The only conditional directives supported are `if` and `end`, e.g.
|
||||
* `{if pid}{pid}{end}`; every `if` must have a matching `end`. Nested
|
||||
* conditions are not supported.
|
||||
*
|
||||
* @typedef {string} MessageFormatString
|
||||
*
|
||||
* @example
|
||||
* `{levelLabel} - {if pid}{pid} - {end}url:{req.url}`
|
||||
*/
|
||||
|
||||
/**
|
||||
* @typedef {object} PrettifyMessageExtras
|
||||
* @property {object} colors Available color functions based on `useColor` (or `colorize`) context
|
||||
* the options.
|
||||
*/
|
||||
|
||||
/**
|
||||
* A function that accepts a log object, name of the message key, and name of
|
||||
* the level label key and returns a formatted log line.
|
||||
*
|
||||
* Note: this function must be synchronous.
|
||||
*
|
||||
* @typedef {function} MessageFormatFunction
|
||||
* @param {object} log The log object to be processed.
|
||||
* @param {string} messageKey The name of the key in the `log` object that
|
||||
* contains the log message.
|
||||
* @param {string} levelLabel The name of the key in the `log` object that
|
||||
* contains the log level name.
|
||||
* @param {PrettifyMessageExtras} extras Additional data available for message context
|
||||
* @returns {string}
|
||||
*
|
||||
* @example
|
||||
* function (log, messageKey, levelLabel) {
|
||||
* return `${log[levelLabel]} - ${log[messageKey]}`
|
||||
* }
|
||||
*/
|
||||
@@ -0,0 +1 @@
|
||||
{"version":3,"file":"urn.js","sourceRoot":"","sources":["../../../src/schemes/urn.ts"],"names":[],"mappings":"AACA,OAAO,EAAc,OAAO,EAAE,MAAM,QAAQ,CAAC;AAW7C,MAAM,IAAI,GAAG,qCAAqC,CAAC;AACnD,MAAM,YAAY,GAAG,uBAAuB,CAAC;AAC7C,MAAM,OAAO,GAAG,mEAAmE,CAAC;AACpF,MAAM,IAAI,GAAG,QAAQ,GAAG,YAAY,GAAG,GAAG,GAAG,OAAO,GAAG,KAAK,CAAC;AAC7D,MAAM,UAAU,GAAG,IAAI,MAAM,CAAC,UAAU,GAAG,IAAI,GAAG,IAAI,CAAC,CAAC;AACxD,MAAM,QAAQ,GAAG,IAAI,MAAM,CAAC,IAAI,GAAG,IAAI,GAAG,OAAO,GAAG,IAAI,GAAG,IAAI,CAAC,CAAC;AACjE,MAAM,SAAS,GAAG,iBAAiB,CAAC;AACpC,MAAM,YAAY,GAAG,iDAAiD,CAAC;AAEvE,UAAU;AACV,MAAM,OAAO,GAA8C;IAC1D,MAAM,EAAG,KAAK;IAEd,KAAK,EAAG,UAAU,UAAwB,EAAE,OAAkB;QAC7D,MAAM,OAAO,GAAG,UAAU,CAAC,IAAI,IAAI,UAAU,CAAC,IAAI,CAAC,KAAK,CAAC,SAAS,CAAC,CAAC;QACpE,IAAI,aAAa,GAAG,UAA2B,CAAC;QAEhD,IAAI,OAAO,EAAE;YACZ,MAAM,MAAM,GAAG,OAAO,CAAC,MAAM,IAAI,aAAa,CAAC,MAAM,IAAI,KAAK,CAAC;YAC/D,MAAM,GAAG,GAAG,OAAO,CAAC,CAAC,CAAC,CAAC,WAAW,EAAE,CAAC;YACrC,MAAM,GAAG,GAAG,OAAO,CAAC,CAAC,CAAC,CAAC;YACvB,MAAM,SAAS,GAAG,GAAG,MAAM,IAAI,OAAO,CAAC,GAAG,IAAI,GAAG,EAAE,CAAC;YACpD,MAAM,aAAa,GAAG,OAAO,CAAC,SAAS,CAAC,CAAC;YAEzC,aAAa,CAAC,GAAG,GAAG,GAAG,CAAC;YACxB,aAAa,CAAC,GAAG,GAAG,GAAG,CAAC;YACxB,aAAa,CAAC,IAAI,GAAG,SAAS,CAAC;YAE/B,IAAI,aAAa,EAAE;gBAClB,aAAa,GAAG,aAAa,CAAC,KAAK,CAAC,aAAa,EAAE,OAAO,CAAkB,CAAC;aAC7E;SACD;aAAM;YACN,aAAa,CAAC,KAAK,GAAG,aAAa,CAAC,KAAK,IAAI,wBAAwB,CAAC;SACtE;QAED,OAAO,aAAa,CAAC;IACtB,CAAC;IAED,SAAS,EAAG,UAAU,aAA2B,EAAE,OAAkB;QACpE,MAAM,MAAM,GAAG,OAAO,CAAC,MAAM,IAAI,aAAa,CAAC,MAAM,IAAI,KAAK,CAAC;QAC/D,MAAM,GAAG,GAAG,aAAa,CAAC,GAAG,CAAC;QAC9B,MAAM,SAAS,GAAG,GAAG,MAAM,IAAI,OAAO,CAAC,GAAG,IAAI,GAAG,EAAE,CAAC;QACpD,MAAM,aAAa,GAAG,OAAO,CAAC,SAAS,CAAC,CAAC;QAEzC,IAAI,aAAa,EAAE;YAClB,aAAa,GAAG,aAAa,CAAC,SAAS,CAAC,aAAa,EAAE,OAAO,CAAkB,CAAC;SACjF;QAED,MAAM,aAAa,GAAG,aAA8B,CAAC;QACrD,MAAM,GAAG,GAAG,aAAa,CAAC,GAAG,CAAC;QAC9B,aAAa,CAAC,IAAI,GAAG,GAAG,GAAG,IAAI,OAAO,CAAC,GAAG,IAAI,GAAG,EAAE,CAAC;QAEpD,OAAO,aAAa,CAAC;IACtB,CAAC;CACD,CAAC;AAEF,eAAe,OAAO,CAAC"}
|
||||
@@ -0,0 +1,127 @@
|
||||
/**
|
||||
* @fileoverview A rule to warn against using arrow functions when they could be
|
||||
* confused with comparisons
|
||||
* @author Jxck <https://github.com/Jxck>
|
||||
* @deprecated in ESLint v8.53.0
|
||||
*/
|
||||
|
||||
"use strict";
|
||||
|
||||
const astUtils = require("./utils/ast-utils.js");
|
||||
|
||||
//------------------------------------------------------------------------------
|
||||
// Helpers
|
||||
//------------------------------------------------------------------------------
|
||||
|
||||
/**
|
||||
* Checks whether or not a node is a conditional expression.
|
||||
* @param {ASTNode} node node to test
|
||||
* @returns {boolean} `true` if the node is a conditional expression.
|
||||
*/
|
||||
function isConditional(node) {
|
||||
return node && node.type === "ConditionalExpression";
|
||||
}
|
||||
|
||||
//------------------------------------------------------------------------------
|
||||
// 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-confusing-arrow",
|
||||
url: "https://eslint.style/rules/no-confusing-arrow",
|
||||
},
|
||||
},
|
||||
],
|
||||
},
|
||||
type: "suggestion",
|
||||
|
||||
docs: {
|
||||
description:
|
||||
"Disallow arrow functions where they could be confused with comparisons",
|
||||
recommended: false,
|
||||
url: "https://eslint.org/docs/latest/rules/no-confusing-arrow",
|
||||
},
|
||||
|
||||
fixable: "code",
|
||||
|
||||
schema: [
|
||||
{
|
||||
type: "object",
|
||||
properties: {
|
||||
allowParens: { type: "boolean", default: true },
|
||||
onlyOneSimpleParam: { type: "boolean", default: false },
|
||||
},
|
||||
additionalProperties: false,
|
||||
},
|
||||
],
|
||||
|
||||
messages: {
|
||||
confusing:
|
||||
"Arrow function used ambiguously with a conditional expression.",
|
||||
},
|
||||
},
|
||||
|
||||
create(context) {
|
||||
const config = context.options[0] || {};
|
||||
const allowParens = config.allowParens || config.allowParens === void 0;
|
||||
const onlyOneSimpleParam = config.onlyOneSimpleParam;
|
||||
const sourceCode = context.sourceCode;
|
||||
|
||||
/**
|
||||
* Reports if an arrow function contains an ambiguous conditional.
|
||||
* @param {ASTNode} node A node to check and report.
|
||||
* @returns {void}
|
||||
*/
|
||||
function checkArrowFunc(node) {
|
||||
const body = node.body;
|
||||
|
||||
if (
|
||||
isConditional(body) &&
|
||||
!(allowParens && astUtils.isParenthesised(sourceCode, body)) &&
|
||||
!(
|
||||
onlyOneSimpleParam &&
|
||||
!(
|
||||
node.params.length === 1 &&
|
||||
node.params[0].type === "Identifier"
|
||||
)
|
||||
)
|
||||
) {
|
||||
context.report({
|
||||
node,
|
||||
messageId: "confusing",
|
||||
fix(fixer) {
|
||||
// if `allowParens` is not set to true don't bother wrapping in parens
|
||||
return (
|
||||
allowParens &&
|
||||
fixer.replaceText(
|
||||
node.body,
|
||||
`(${sourceCode.getText(node.body)})`,
|
||||
)
|
||||
);
|
||||
},
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
return {
|
||||
ArrowFunctionExpression: checkArrowFunc,
|
||||
};
|
||||
},
|
||||
};
|
||||
@@ -0,0 +1,122 @@
|
||||
/**
|
||||
* Experimental implementation of NTT / FFT (Fast Fourier Transform) over finite fields.
|
||||
* API may change at any time. The code has not been audited. Feature requests are welcome.
|
||||
* @module
|
||||
*/
|
||||
import type { IField } from './modular.ts';
|
||||
export interface MutableArrayLike<T> {
|
||||
[index: number]: T;
|
||||
length: number;
|
||||
slice(start?: number, end?: number): this;
|
||||
[Symbol.iterator](): Iterator<T>;
|
||||
}
|
||||
/** Checks if integer is in form of `1 << X` */
|
||||
export declare function isPowerOfTwo(x: number): boolean;
|
||||
export declare function nextPowerOfTwo(n: number): number;
|
||||
export declare function reverseBits(n: number, bits: number): number;
|
||||
/** Similar to `bitLen(x)-1` but much faster for small integers, like indices */
|
||||
export declare function log2(n: number): number;
|
||||
/**
|
||||
* Moves lowest bit to highest position, which at first step splits
|
||||
* array on even and odd indices, then it applied again to each part,
|
||||
* which is core of fft
|
||||
*/
|
||||
export declare function bitReversalInplace<T extends MutableArrayLike<any>>(values: T): T;
|
||||
export declare function bitReversalPermutation<T>(values: T[]): T[];
|
||||
export type RootsOfUnity = {
|
||||
roots: (bits: number) => bigint[];
|
||||
brp(bits: number): bigint[];
|
||||
inverse(bits: number): bigint[];
|
||||
omega: (bits: number) => bigint;
|
||||
clear: () => void;
|
||||
};
|
||||
/** We limit roots up to 2**31, which is a lot: 2-billion polynomimal should be rare. */
|
||||
export declare function rootsOfUnity(field: IField<bigint>, generator?: bigint): RootsOfUnity;
|
||||
export type Polynomial<T> = MutableArrayLike<T>;
|
||||
/**
|
||||
* Maps great to Field<bigint>, but not to Group (EC points):
|
||||
* - inv from scalar field
|
||||
* - we need multiplyUnsafe here, instead of multiply for speed
|
||||
* - multiplyUnsafe is safe in the context: we do mul(rootsOfUnity), which are public and sparse
|
||||
*/
|
||||
export type FFTOpts<T, R> = {
|
||||
add: (a: T, b: T) => T;
|
||||
sub: (a: T, b: T) => T;
|
||||
mul: (a: T, scalar: R) => T;
|
||||
inv: (a: R) => R;
|
||||
};
|
||||
export type FFTCoreOpts<R> = {
|
||||
N: number;
|
||||
roots: Polynomial<R>;
|
||||
dit: boolean;
|
||||
invertButterflies?: boolean;
|
||||
skipStages?: number;
|
||||
brp?: boolean;
|
||||
};
|
||||
export type FFTCoreLoop<T> = <P extends Polynomial<T>>(values: P) => P;
|
||||
/**
|
||||
* Constructs different flavors of FFT. radix2 implementation of low level mutating API. Flavors:
|
||||
*
|
||||
* - DIT (Decimation-in-Time): Bottom-Up (leaves -> root), Cool-Turkey
|
||||
* - DIF (Decimation-in-Frequency): Top-Down (root -> leaves), Gentleman–Sande
|
||||
*
|
||||
* DIT takes brp input, returns natural output.
|
||||
* DIF takes natural input, returns brp output.
|
||||
*
|
||||
* The output is actually identical. Time / frequence distinction is not meaningful
|
||||
* for Polynomial multiplication in fields.
|
||||
* Which means if protocol supports/needs brp output/inputs, then we can skip this step.
|
||||
*
|
||||
* Cyclic NTT: Rq = Zq[x]/(x^n-1). butterfly_DIT+loop_DIT OR butterfly_DIF+loop_DIT, roots are omega
|
||||
* Negacyclic NTT: Rq = Zq[x]/(x^n+1). butterfly_DIT+loop_DIF, at least for mlkem / mldsa
|
||||
*/
|
||||
export declare const FFTCore: <T, R>(F: FFTOpts<T, R>, coreOpts: FFTCoreOpts<R>) => FFTCoreLoop<T>;
|
||||
export type FFTMethods<T> = {
|
||||
direct<P extends Polynomial<T>>(values: P, brpInput?: boolean, brpOutput?: boolean): P;
|
||||
inverse<P extends Polynomial<T>>(values: P, brpInput?: boolean, brpOutput?: boolean): P;
|
||||
};
|
||||
/**
|
||||
* NTT aka FFT over finite field (NOT over complex numbers).
|
||||
* Naming mirrors other libraries.
|
||||
*/
|
||||
export declare function FFT<T>(roots: RootsOfUnity, opts: FFTOpts<T, bigint>): FFTMethods<T>;
|
||||
export type CreatePolyFn<P extends Polynomial<T>, T> = (len: number, elm?: T) => P;
|
||||
export type PolyFn<P extends Polynomial<T>, T> = {
|
||||
roots: RootsOfUnity;
|
||||
create: CreatePolyFn<P, T>;
|
||||
length?: number;
|
||||
degree: (a: P) => number;
|
||||
extend: (a: P, len: number) => P;
|
||||
add: (a: P, b: P) => P;
|
||||
sub: (a: P, b: P) => P;
|
||||
mul: (a: P, b: P | T) => P;
|
||||
dot: (a: P, b: P) => P;
|
||||
convolve: (a: P, b: P) => P;
|
||||
shift: (p: P, factor: bigint) => P;
|
||||
clone: (a: P) => P;
|
||||
eval: (a: P, basis: P) => T;
|
||||
monomial: {
|
||||
basis: (x: T, n: number) => P;
|
||||
eval: (a: P, x: T) => T;
|
||||
};
|
||||
lagrange: {
|
||||
basis: (x: T, n: number, brp?: boolean) => P;
|
||||
eval: (a: P, x: T, brp?: boolean) => T;
|
||||
};
|
||||
vanishing: (roots: P) => P;
|
||||
};
|
||||
/**
|
||||
* Poly wants a cracker.
|
||||
*
|
||||
* Polynomials are functions like `y=f(x)`, which means when we multiply two polynomials, result is
|
||||
* function `f3(x) = f1(x) * f2(x)`, we don't multiply values. Key takeaways:
|
||||
*
|
||||
* - **Polynomial** is an array of coefficients: `f(x) = sum(coeff[i] * basis[i](x))`
|
||||
* - **Basis** is array of functions
|
||||
* - **Monominal** is Polynomial where `basis[i](x) == x**i` (powers)
|
||||
* - **Array size** is domain size
|
||||
* - **Lattice** is matrix (Polynomial of Polynomials)
|
||||
*/
|
||||
export declare function poly<T>(field: IField<T>, roots: RootsOfUnity, create?: undefined, fft?: FFTMethods<T>, length?: number): PolyFn<T[], T>;
|
||||
export declare function poly<T, P extends Polynomial<T>>(field: IField<T>, roots: RootsOfUnity, create: CreatePolyFn<P, T>, fft?: FFTMethods<T>, length?: number): PolyFn<P, T>;
|
||||
//# sourceMappingURL=fft.d.ts.map
|
||||
@@ -0,0 +1,58 @@
|
||||
import { ChildProcess } from 'child_process';
|
||||
import { Socket } from 'net';
|
||||
import { MessagePort, Worker } from 'worker_threads';
|
||||
import { RAL, AbstractMessageReader, DataCallback, AbstractMessageWriter, Message, ReadableStreamMessageReader, WriteableStreamMessageWriter, MessageWriterOptions, MessageReaderOptions, MessageReader, MessageWriter, ConnectionStrategy, ConnectionOptions, MessageConnection, Logger, Disposable } from '../common/api';
|
||||
export * from '../common/api';
|
||||
export declare class IPCMessageReader extends AbstractMessageReader {
|
||||
private process;
|
||||
constructor(process: NodeJS.Process | ChildProcess);
|
||||
listen(callback: DataCallback): Disposable;
|
||||
}
|
||||
export declare class IPCMessageWriter extends AbstractMessageWriter implements MessageWriter {
|
||||
private readonly process;
|
||||
private errorCount;
|
||||
constructor(process: NodeJS.Process | ChildProcess);
|
||||
write(msg: Message): Promise<void>;
|
||||
private handleError;
|
||||
end(): void;
|
||||
}
|
||||
export declare class PortMessageReader extends AbstractMessageReader implements MessageReader {
|
||||
private onData;
|
||||
constructor(port: MessagePort | Worker);
|
||||
listen(callback: DataCallback): Disposable;
|
||||
}
|
||||
export declare class PortMessageWriter extends AbstractMessageWriter implements MessageWriter {
|
||||
private readonly port;
|
||||
private errorCount;
|
||||
constructor(port: MessagePort | Worker);
|
||||
write(msg: Message): Promise<void>;
|
||||
private handleError;
|
||||
end(): void;
|
||||
}
|
||||
export declare class SocketMessageReader extends ReadableStreamMessageReader {
|
||||
constructor(socket: Socket, encoding?: RAL.MessageBufferEncoding);
|
||||
}
|
||||
export declare class SocketMessageWriter extends WriteableStreamMessageWriter {
|
||||
private socket;
|
||||
constructor(socket: Socket, options?: RAL.MessageBufferEncoding | MessageWriterOptions);
|
||||
dispose(): void;
|
||||
}
|
||||
export declare class StreamMessageReader extends ReadableStreamMessageReader {
|
||||
constructor(readable: NodeJS.ReadableStream, encoding?: RAL.MessageBufferEncoding | MessageReaderOptions);
|
||||
}
|
||||
export declare class StreamMessageWriter extends WriteableStreamMessageWriter {
|
||||
constructor(writable: NodeJS.WritableStream, options?: RAL.MessageBufferEncoding | MessageWriterOptions);
|
||||
}
|
||||
export declare function generateRandomPipeName(): string;
|
||||
export interface PipeTransport {
|
||||
onConnected(): Promise<[MessageReader, MessageWriter]>;
|
||||
}
|
||||
export declare function createClientPipeTransport(pipeName: string, encoding?: RAL.MessageBufferEncoding): Promise<PipeTransport>;
|
||||
export declare function createServerPipeTransport(pipeName: string, encoding?: RAL.MessageBufferEncoding): [MessageReader, MessageWriter];
|
||||
export interface SocketTransport {
|
||||
onConnected(): Promise<[MessageReader, MessageWriter]>;
|
||||
}
|
||||
export declare function createClientSocketTransport(port: number, encoding?: RAL.MessageBufferEncoding): Promise<SocketTransport>;
|
||||
export declare function createServerSocketTransport(port: number, encoding?: RAL.MessageBufferEncoding): [MessageReader, MessageWriter];
|
||||
export declare function createMessageConnection(reader: MessageReader, writer: MessageWriter, logger?: Logger, options?: ConnectionStrategy | ConnectionOptions): MessageConnection;
|
||||
export declare function createMessageConnection(inputStream: NodeJS.ReadableStream, outputStream: NodeJS.WritableStream, logger?: Logger, options?: ConnectionStrategy | ConnectionOptions): MessageConnection;
|
||||
@@ -0,0 +1,177 @@
|
||||
# Retry utility
|
||||
|
||||
by [Nicholas C. Zakas](https://humanwhocodes.com)
|
||||
|
||||
If you find this useful, please consider supporting my work with a [donation](https://humanwhocodes.com/donate) or [nominate me](https://stars.github.com/nominate/) for a GitHub Star.
|
||||
|
||||
## Description
|
||||
|
||||
A utility for retrying failed async JavaScript calls based on the error returned.
|
||||
|
||||
## Usage
|
||||
|
||||
### Node.js
|
||||
|
||||
Install using [npm][npm] or [yarn][yarn]:
|
||||
|
||||
```
|
||||
npm install @humanwhocodes/retry
|
||||
|
||||
# or
|
||||
|
||||
yarn add @humanwhocodes/retry
|
||||
```
|
||||
|
||||
Import into your Node.js project:
|
||||
|
||||
```js
|
||||
// CommonJS
|
||||
const { Retrier } = require("@humanwhocodes/retry");
|
||||
|
||||
// ESM
|
||||
import { Retrier } from "@humanwhocodes/retry";
|
||||
```
|
||||
|
||||
### Deno
|
||||
|
||||
Install using [JSR](https://jsr.io):
|
||||
|
||||
```shell
|
||||
deno add @humanwhocodes/retry
|
||||
|
||||
#or
|
||||
|
||||
jsr add @humanwhocodes/retry
|
||||
```
|
||||
|
||||
Then import into your Deno project:
|
||||
|
||||
```js
|
||||
import { Retrier } from "@humanwhocodes/retry";
|
||||
```
|
||||
|
||||
### Bun
|
||||
|
||||
Install using this command:
|
||||
|
||||
```
|
||||
bun add @humanwhocodes/retry
|
||||
```
|
||||
|
||||
Import into your Bun project:
|
||||
|
||||
```js
|
||||
import { Retrier } from "@humanwhocodes/retry";
|
||||
```
|
||||
|
||||
### Browser
|
||||
|
||||
It's recommended to import the minified version to save bandwidth:
|
||||
|
||||
```js
|
||||
import { Retrier } from "https://cdn.skypack.dev/@humanwhocodes/retry?min";
|
||||
```
|
||||
|
||||
However, you can also import the unminified version for debugging purposes:
|
||||
|
||||
```js
|
||||
import { Retrier } from "https://cdn.skypack.dev/@humanwhocodes/retry";
|
||||
```
|
||||
|
||||
## API
|
||||
|
||||
After importing, create a new instance of `Retrier` and specify the function to run on the error. This function should return `true` if you want the call retried and `false` if not.
|
||||
|
||||
```js
|
||||
// this instance will retry if the specific error code is found
|
||||
const retrier = new Retrier(error => {
|
||||
return error.code === "ENFILE" || error.code === "EMFILE";
|
||||
});
|
||||
```
|
||||
|
||||
Then, call the `retry()` method around the function you'd like to retry, such as:
|
||||
|
||||
```js
|
||||
import fs from "fs/promises";
|
||||
|
||||
const retrier = new Retrier(error => {
|
||||
return error.code === "ENFILE" || error.code === "EMFILE";
|
||||
});
|
||||
|
||||
const text = await retrier.retry(() => fs.readFile("README.md", "utf8"));
|
||||
```
|
||||
|
||||
The `retry()` method will either pass through the result on success or wait and retry on failure. Any error that isn't caught by the retrier is automatically rejected so the end result is a transparent passing through of both success and failure.
|
||||
|
||||
### Setting a Timeout
|
||||
|
||||
You can control how long a task will attempt to retry before giving up by passing the `timeout` option to the `Retrier` constructor. By default, the timeout is one minute.
|
||||
|
||||
```js
|
||||
import fs from "fs/promises";
|
||||
|
||||
const retrier = new Retrier(error => {
|
||||
return error.code === "ENFILE" || error.code === "EMFILE";
|
||||
}, { timeout: 100_000 });
|
||||
|
||||
const text = await retrier.retry(() => fs.readFile("README.md", "utf8"));
|
||||
```
|
||||
|
||||
When a call times out, it rejects the first error that was received from calling the function.
|
||||
|
||||
### Setting a Concurrency Limit
|
||||
|
||||
When processing a large number of function calls, you can limit the number of concurrent function calls by passing the `concurrency` option to the `Retrier` constructor. By default, `concurrency` is 1000.
|
||||
|
||||
```js
|
||||
import fs from "fs/promises";
|
||||
|
||||
const retrier = new Retrier(error => {
|
||||
return error.code === "ENFILE" || error.code === "EMFILE";
|
||||
}, { concurrency: 100 });
|
||||
|
||||
const filenames = getFilenames();
|
||||
const contents = await Promise.all(
|
||||
filenames.map(filename => retrier.retry(() => fs.readFile(filename, "utf8"))
|
||||
);
|
||||
```
|
||||
|
||||
### Aborting with `AbortSignal`
|
||||
|
||||
You can also pass an `AbortSignal` to cancel a retry:
|
||||
|
||||
```js
|
||||
import fs from "fs/promises";
|
||||
|
||||
const controller = new AbortController();
|
||||
const retrier = new Retrier(error => {
|
||||
return error.code === "ENFILE" || error.code === "EMFILE";
|
||||
});
|
||||
|
||||
const text = await retrier.retry(
|
||||
() => fs.readFile("README.md", "utf8"),
|
||||
{ signal: controller.signal }
|
||||
);
|
||||
```
|
||||
|
||||
## Developer Setup
|
||||
|
||||
1. Fork the repository
|
||||
2. Clone your fork
|
||||
3. Run `npm install` to setup dependencies
|
||||
4. Run `npm test` to run tests
|
||||
|
||||
### Debug Output
|
||||
|
||||
Enable debugging output by setting the `DEBUG` environment variable to `"@hwc/retry"` before running.
|
||||
|
||||
## License
|
||||
|
||||
Apache 2.0
|
||||
|
||||
## Prior Art
|
||||
|
||||
This utility is inspired by, and contains code from [`graceful-fs`](https://github.com/isaacs/node-graceful-fs).
|
||||
|
||||
[npm]: https://npmjs.com/
|
||||
[yarn]: https://yarnpkg.com/
|
||||
@@ -0,0 +1,34 @@
|
||||
import type {
|
||||
ZodArray,
|
||||
ZodNullable,
|
||||
ZodObject,
|
||||
ZodOptional,
|
||||
ZodRawShape,
|
||||
ZodTuple,
|
||||
ZodTupleItems,
|
||||
ZodTypeAny,
|
||||
} from "../types.js";
|
||||
|
||||
export namespace partialUtil {
|
||||
export type DeepPartial<T extends ZodTypeAny> = T extends ZodObject<ZodRawShape>
|
||||
? ZodObject<
|
||||
{ [k in keyof T["shape"]]: ZodOptional<DeepPartial<T["shape"][k]>> },
|
||||
T["_def"]["unknownKeys"],
|
||||
T["_def"]["catchall"]
|
||||
>
|
||||
: T extends ZodArray<infer Type, infer Card>
|
||||
? ZodArray<DeepPartial<Type>, Card>
|
||||
: T extends ZodOptional<infer Type>
|
||||
? ZodOptional<DeepPartial<Type>>
|
||||
: T extends ZodNullable<infer Type>
|
||||
? ZodNullable<DeepPartial<Type>>
|
||||
: T extends ZodTuple<infer Items>
|
||||
? {
|
||||
[k in keyof Items]: Items[k] extends ZodTypeAny ? DeepPartial<Items[k]> : never;
|
||||
} extends infer PI
|
||||
? PI extends ZodTupleItems
|
||||
? ZodTuple<PI>
|
||||
: never
|
||||
: never
|
||||
: T;
|
||||
}
|
||||
@@ -0,0 +1,28 @@
|
||||
#!/usr/bin/env node
|
||||
|
||||
import getExePath from "#getExePath";
|
||||
import { execFileSync } from "node:child_process";
|
||||
|
||||
const exe = getExePath();
|
||||
|
||||
if (process.platform !== "win32" && typeof process.execve === "function") {
|
||||
// > v22.15.0
|
||||
try {
|
||||
process.execve(exe, [exe, ...process.argv.slice(2)]);
|
||||
}
|
||||
catch {
|
||||
// may not be available, ignore the error and fallback
|
||||
}
|
||||
}
|
||||
|
||||
try {
|
||||
execFileSync(exe, process.argv.slice(2), { stdio: "inherit" });
|
||||
}
|
||||
catch (e) {
|
||||
if (e.status) {
|
||||
process.exitCode = e.status;
|
||||
}
|
||||
else {
|
||||
throw e;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,133 @@
|
||||
|
||||
# joycon
|
||||
|
||||
[](https://npmjs.com/package/joycon) [](https://npmjs.com/package/joycon) [](https://packagephobia.now.sh/result?p=joycon@2.0.0) [](https://circleci.com/gh/egoist/joycon/tree/master) [](https://github.com/egoist/donate) [](https://chat.egoist.moe)
|
||||
|
||||
## Differences with [cosmiconfig](https://github.com/davidtheclark/cosmiconfig)?
|
||||
|
||||
JoyCon is zero-dependency but feature-complete.
|
||||
|
||||
## Install
|
||||
|
||||
```bash
|
||||
yarn add joycon
|
||||
```
|
||||
|
||||
## Usage
|
||||
|
||||
```js
|
||||
const JoyCon = require('joycon')
|
||||
|
||||
const joycon = new JoyCon()
|
||||
|
||||
joycon.load(['package-lock.json', 'yarn.lock'])
|
||||
.then(result => {
|
||||
// result is {} when files do not exist
|
||||
// otherwise { path, data }
|
||||
})
|
||||
```
|
||||
|
||||
By default non-js files are parsed as JSON, if you want something different you can add a loader:
|
||||
|
||||
```js
|
||||
const joycon = new JoyCon()
|
||||
|
||||
joycon.addLoader({
|
||||
test: /\.toml$/,
|
||||
load(filepath) {
|
||||
return require('toml').parse(filepath)
|
||||
}
|
||||
})
|
||||
|
||||
joycon.load(['cargo.toml'])
|
||||
```
|
||||
|
||||
## API
|
||||
|
||||
### constructor([options])
|
||||
|
||||
#### options
|
||||
|
||||
##### files
|
||||
|
||||
- Type: `string[]`
|
||||
|
||||
The files to search.
|
||||
|
||||
##### cwd
|
||||
|
||||
The directory to search files.
|
||||
|
||||
##### stopDir
|
||||
|
||||
The directory to stop searching.
|
||||
|
||||
##### packageKey
|
||||
|
||||
You can load config from certain property in a `package.json` file. For example, when you set `packageKey: 'babel'`, it will load the `babel` property in `package.json` instead of the entire data.
|
||||
|
||||
##### parseJSON
|
||||
|
||||
- Type: `(str: string) => any`
|
||||
- Default: `JSON.parse`
|
||||
|
||||
The function used to parse JSON string.
|
||||
|
||||
### resolve([files], [cwd], [stopDir])
|
||||
### resolve([options])
|
||||
|
||||
`files` defaults to `options.files`.
|
||||
|
||||
`cwd` defaults to `options.cwd`.
|
||||
|
||||
`stopDir` defaults to `options.stopDir` then `path.parse(cwd).root`.
|
||||
|
||||
If using a single object `options`, it will be the same as constructor options.
|
||||
|
||||
Search files and resolve the path of the file we found.
|
||||
|
||||
There's also `.resolveSync` method.
|
||||
|
||||
### load(...args)
|
||||
|
||||
The signature is the same as [resolve](#resolvefiles-cwd-stopdir).
|
||||
|
||||
Search files and resolve `{ path, data }` of the file we found.
|
||||
|
||||
There's also `.loadSync` method.
|
||||
|
||||
### addLoader(Loader)
|
||||
|
||||
```typescript
|
||||
interface Loader {
|
||||
name?: string
|
||||
test: RegExp
|
||||
load(filepath: string)?: Promise<any>
|
||||
loadSync(filepath: string)?: any
|
||||
}
|
||||
```
|
||||
|
||||
At least one of `load` and `loadSync` is required, depending on whether you're calling the synchonous methods or not.
|
||||
|
||||
### removeLoader(name)
|
||||
|
||||
Remove loaders by loader name.
|
||||
|
||||
### clearCache()
|
||||
|
||||
Each JoyCon instance uses its own cache.
|
||||
|
||||
## Contributing
|
||||
|
||||
1. Fork it!
|
||||
2. Create your feature branch: `git checkout -b my-new-feature`
|
||||
3. Commit your changes: `git commit -am 'Add some feature'`
|
||||
4. Push to the branch: `git push origin my-new-feature`
|
||||
5. Submit a pull request :D
|
||||
|
||||
## Author
|
||||
|
||||
**joycon** © [egoist](https://github.com/egoist), Released under the [MIT](./LICENSE) License.<br>
|
||||
Authored and maintained by egoist with help from contributors ([list](https://github.com/egoist/joycon/contributors)).
|
||||
|
||||
> [github.com/egoist](https://github.com/egoist) · GitHub [@egoist](https://github.com/egoist) · Twitter [@_egoistlily](https://twitter.com/_egoistlily)
|
||||
@@ -0,0 +1,35 @@
|
||||
"use strict";
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
const util_1 = require("../util");
|
||||
const getESLintCoreRule_1 = require("../util/getESLintCoreRule");
|
||||
const baseRule = (0, getESLintCoreRule_1.getESLintCoreRule)('no-loss-of-precision');
|
||||
exports.default = (0, util_1.createRule)({
|
||||
name: 'no-loss-of-precision',
|
||||
meta: {
|
||||
type: 'problem',
|
||||
// defaultOptions, -- base rule does not use defaultOptions
|
||||
deprecated: {
|
||||
deprecatedSince: '8.0.0',
|
||||
replacedBy: [
|
||||
{
|
||||
rule: {
|
||||
name: 'no-loss-of-precision',
|
||||
url: 'https://eslint.org/docs/latest/rules/no-loss-of-precision',
|
||||
},
|
||||
},
|
||||
],
|
||||
url: 'https://github.com/typescript-eslint/typescript-eslint/pull/8832',
|
||||
},
|
||||
docs: {
|
||||
description: 'Disallow literal numbers that lose precision',
|
||||
extendsBaseRule: true,
|
||||
},
|
||||
hasSuggestions: baseRule.meta.hasSuggestions,
|
||||
messages: baseRule.meta.messages,
|
||||
schema: [],
|
||||
},
|
||||
defaultOptions: [],
|
||||
create(context) {
|
||||
return baseRule.create(context);
|
||||
},
|
||||
});
|
||||
@@ -0,0 +1 @@
|
||||
import*as o from"node:worker_threads";import{i as t,m as i,a as e}from"../node-features-JeyyvQz6.mjs";import{r as a,c as m,a as p,b as s,d as l,e as d}from"../register-C4vWVmug.mjs";import"node:crypto";import"../get-pipe-path-_tAJyU_v.mjs";import"node:module";import"node:path";import"node:url";import"../register-C9AniqUt.mjs";import"node:fs";import"esbuild";import"../index-DQtFPMc2.mjs";import"../client-D_mPDF5S.mjs";import"../require-CywAB2e6.mjs";import"node:fs/promises";import"module";import"../temporary-directory-BDDVQOvU.mjs";import"node:os";import"fs";import"os";import"path";import"node:util";import"../index-gbaejti9.mjs";import"node:net";(t(i)&&!o.isInternalThread||t(e)&&o.isMainThread)&&a();const r=d(),c=m(r),n=p(r),f=s(r),u=l(r);export{n as globalPreload,c as initialize,f as load,u as resolve};
|
||||
@@ -0,0 +1,14 @@
|
||||
export var RegularExpressionFlags;
|
||||
(function (RegularExpressionFlags) {
|
||||
RegularExpressionFlags[RegularExpressionFlags["None"] = 0] = "None";
|
||||
RegularExpressionFlags[RegularExpressionFlags["HasIndices"] = 1] = "HasIndices";
|
||||
RegularExpressionFlags[RegularExpressionFlags["Global"] = 2] = "Global";
|
||||
RegularExpressionFlags[RegularExpressionFlags["IgnoreCase"] = 4] = "IgnoreCase";
|
||||
RegularExpressionFlags[RegularExpressionFlags["Multiline"] = 8] = "Multiline";
|
||||
RegularExpressionFlags[RegularExpressionFlags["DotAll"] = 16] = "DotAll";
|
||||
RegularExpressionFlags[RegularExpressionFlags["Unicode"] = 32] = "Unicode";
|
||||
RegularExpressionFlags[RegularExpressionFlags["UnicodeSets"] = 64] = "UnicodeSets";
|
||||
RegularExpressionFlags[RegularExpressionFlags["Sticky"] = 128] = "Sticky";
|
||||
RegularExpressionFlags[RegularExpressionFlags["AnyUnicodeMode"] = 96] = "AnyUnicodeMode";
|
||||
})(RegularExpressionFlags || (RegularExpressionFlags = {}));
|
||||
//# sourceMappingURL=regularExpressionFlags.enum.js.map
|
||||
@@ -0,0 +1,8 @@
|
||||
import type { TSESTree } from '@typescript-eslint/types';
|
||||
import { DefinitionBase } from './DefinitionBase';
|
||||
import { DefinitionType } from './DefinitionType';
|
||||
export declare class TSEnumNameDefinition extends DefinitionBase<DefinitionType.TSEnumName, TSESTree.TSEnumDeclaration, null, TSESTree.Identifier> {
|
||||
readonly isTypeDefinition = true;
|
||||
readonly isVariableDefinition = true;
|
||||
constructor(name: TSESTree.Identifier, node: TSEnumNameDefinition['node']);
|
||||
}
|
||||
@@ -0,0 +1,55 @@
|
||||
import {Buffer} from 'buffer';
|
||||
|
||||
import {generatePrivateKey, getPublicKey} from './utils/ed25519';
|
||||
import {toBuffer} from './utils/to-buffer';
|
||||
import {PublicKey} from './publickey';
|
||||
|
||||
/**
|
||||
* An account key pair (public and secret keys).
|
||||
*
|
||||
* @deprecated since v1.10.0, please use {@link Keypair} instead.
|
||||
*/
|
||||
export class Account {
|
||||
/** @internal */
|
||||
private _publicKey: Buffer;
|
||||
/** @internal */
|
||||
private _secretKey: Buffer;
|
||||
|
||||
/**
|
||||
* Create a new Account object
|
||||
*
|
||||
* If the secretKey parameter is not provided a new key pair is randomly
|
||||
* created for the account
|
||||
*
|
||||
* @param secretKey Secret key for the account
|
||||
*/
|
||||
constructor(secretKey?: Uint8Array | Array<number>) {
|
||||
if (secretKey) {
|
||||
const secretKeyBuffer = toBuffer(secretKey);
|
||||
if (secretKey.length !== 64) {
|
||||
throw new Error('bad secret key size');
|
||||
}
|
||||
this._publicKey = secretKeyBuffer.slice(32, 64);
|
||||
this._secretKey = secretKeyBuffer.slice(0, 32);
|
||||
} else {
|
||||
this._secretKey = toBuffer(generatePrivateKey());
|
||||
this._publicKey = toBuffer(getPublicKey(this._secretKey));
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* The public key for this account
|
||||
*/
|
||||
get publicKey(): PublicKey {
|
||||
return new PublicKey(this._publicKey);
|
||||
}
|
||||
|
||||
/**
|
||||
* The **unencrypted** secret key for this account. The first 32 bytes
|
||||
* is the private scalar and the last 32 bytes is the public key.
|
||||
* Read more: https://blog.mozilla.org/warner/2011/11/29/ed25519-keys/
|
||||
*/
|
||||
get secretKey(): Buffer {
|
||||
return Buffer.concat([this._secretKey, this._publicKey], 64);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1 @@
|
||||
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["src/index.ts"],"names":[],"mappings":""}
|
||||
@@ -0,0 +1,124 @@
|
||||
/**
|
||||
* Miscellaneous, rarely used curves.
|
||||
* jubjub, babyjubjub, pallas, vesta.
|
||||
* @module
|
||||
*/
|
||||
/*! noble-curves - MIT License (c) 2022 Paul Miller (paulmillr.com) */
|
||||
import { blake256 } from '@noble/hashes/blake1.js';
|
||||
import { blake2s } from '@noble/hashes/blake2.js';
|
||||
import { sha256, sha512 } from '@noble/hashes/sha2.js';
|
||||
import { concatBytes, utf8ToBytes } from '@noble/hashes/utils.js';
|
||||
import {
|
||||
twistedEdwards,
|
||||
type CurveFn,
|
||||
type EdwardsOpts,
|
||||
type EdwardsPoint,
|
||||
} from './abstract/edwards.ts';
|
||||
import { Field, mod } from './abstract/modular.ts';
|
||||
import { weierstrass, type CurveFn as WCurveFn } from './abstract/weierstrass.ts';
|
||||
import { bls12_381_Fr } from './bls12-381.ts';
|
||||
import { bn254_Fr } from './bn254.ts';
|
||||
|
||||
// Jubjub curves have 𝔽p over scalar fields of other curves. They are friendly to ZK proofs.
|
||||
// jubjub Fp = bls n. babyjubjub Fp = bn254 n.
|
||||
// verify manually, check bls12-381.ts and bn254.ts.
|
||||
const jubjub_CURVE: EdwardsOpts = {
|
||||
p: bls12_381_Fr.ORDER,
|
||||
n: BigInt('0xe7db4ea6533afa906673b0101343b00a6682093ccc81082d0970e5ed6f72cb7'),
|
||||
h: BigInt(8),
|
||||
a: BigInt('0x73eda753299d7d483339d80809a1d80553bda402fffe5bfeffffffff00000000'),
|
||||
d: BigInt('0x2a9318e74bfa2b48f5fd9207e6bd7fd4292d7f6d37579d2601065fd6d6343eb1'),
|
||||
Gx: BigInt('0x11dafe5d23e1218086a365b99fbf3d3be72f6afd7d1f72623e6b071492d1122b'),
|
||||
Gy: BigInt('0x1d523cf1ddab1a1793132e78c866c0c33e26ba5cc220fed7cc3f870e59d292aa'),
|
||||
};
|
||||
/** Curve over scalar field of bls12-381. jubjub Fp = bls n */
|
||||
export const jubjub: CurveFn = /* @__PURE__ */ twistedEdwards({
|
||||
...jubjub_CURVE,
|
||||
Fp: bls12_381_Fr,
|
||||
hash: sha512,
|
||||
});
|
||||
|
||||
const babyjubjub_CURVE: EdwardsOpts = {
|
||||
p: bn254_Fr.ORDER,
|
||||
n: BigInt('0x30644e72e131a029b85045b68181585d59f76dc1c90770533b94bee1c9093788'),
|
||||
h: BigInt(8),
|
||||
a: BigInt('168700'),
|
||||
d: BigInt('168696'),
|
||||
Gx: BigInt('0x23343e3445b673d38bcba38f25645adb494b1255b1162bb40f41a59f4d4b45e'),
|
||||
Gy: BigInt('0xc19139cb84c680a6e14116da06056174a0cfa121e6e5c2450f87d64fc000001'),
|
||||
};
|
||||
/** Curve over scalar field of bn254. babyjubjub Fp = bn254 n */
|
||||
export const babyjubjub: CurveFn = /* @__PURE__ */ twistedEdwards({
|
||||
...babyjubjub_CURVE,
|
||||
Fp: bn254_Fr,
|
||||
hash: blake256,
|
||||
});
|
||||
|
||||
const jubjub_gh_first_block = utf8ToBytes(
|
||||
'096b36a5804bfacef1691e173c366a47ff5ba84a44f26ddd7e8d9f79d5b42df0'
|
||||
);
|
||||
|
||||
// Returns point at JubJub curve which is prime order and not zero
|
||||
export function jubjub_groupHash(tag: Uint8Array, personalization: Uint8Array): EdwardsPoint {
|
||||
const h = blake2s.create({ personalization, dkLen: 32 });
|
||||
h.update(jubjub_gh_first_block);
|
||||
h.update(tag);
|
||||
// NOTE: returns ExtendedPoint, in case it will be multiplied later
|
||||
let p = jubjub.Point.fromBytes(h.digest());
|
||||
// NOTE: cannot replace with isSmallOrder, returns Point*8
|
||||
p = p.multiply(jubjub_CURVE.h);
|
||||
if (p.equals(jubjub.Point.ZERO)) throw new Error('Point has small order');
|
||||
return p;
|
||||
}
|
||||
|
||||
// No secret data is leaked here at all.
|
||||
// It operates over public data:
|
||||
// const G_SPEND = jubjub.findGroupHash(Uint8Array.of(), utf8ToBytes('Item_G_'));
|
||||
export function jubjub_findGroupHash(m: Uint8Array, personalization: Uint8Array): EdwardsPoint {
|
||||
const tag = concatBytes(m, Uint8Array.of(0));
|
||||
const hashes = [];
|
||||
for (let i = 0; i < 256; i++) {
|
||||
tag[tag.length - 1] = i;
|
||||
try {
|
||||
hashes.push(jubjub_groupHash(tag, personalization));
|
||||
} catch (e) {}
|
||||
}
|
||||
if (!hashes.length) throw new Error('findGroupHash tag overflow');
|
||||
return hashes[0];
|
||||
}
|
||||
|
||||
// Pasta curves. See [Spec](https://o1-labs.github.io/proof-systems/specs/pasta.html).
|
||||
|
||||
export const pasta_p: bigint = BigInt(
|
||||
'0x40000000000000000000000000000000224698fc094cf91b992d30ed00000001'
|
||||
);
|
||||
export const pasta_q: bigint = BigInt(
|
||||
'0x40000000000000000000000000000000224698fc0994a8dd8c46eb2100000001'
|
||||
);
|
||||
|
||||
/**
|
||||
* @deprecated
|
||||
*/
|
||||
export const pallas: WCurveFn = weierstrass({
|
||||
a: BigInt(0),
|
||||
b: BigInt(5),
|
||||
Fp: Field(pasta_p),
|
||||
n: pasta_q,
|
||||
Gx: mod(BigInt(-1), pasta_p),
|
||||
Gy: BigInt(2),
|
||||
h: BigInt(1),
|
||||
hash: sha256,
|
||||
});
|
||||
/**
|
||||
* @deprecated
|
||||
*/
|
||||
export const vesta: WCurveFn = weierstrass({
|
||||
a: BigInt(0),
|
||||
b: BigInt(5),
|
||||
Fp: Field(pasta_q),
|
||||
n: pasta_p,
|
||||
Gx: mod(BigInt(-1), pasta_q),
|
||||
Gy: BigInt(2),
|
||||
h: BigInt(1),
|
||||
hash: sha256,
|
||||
});
|
||||
@@ -0,0 +1,3 @@
|
||||
{
|
||||
"presets": ["es2015"]
|
||||
}
|
||||
@@ -0,0 +1,3 @@
|
||||
# esbuild
|
||||
|
||||
This is a JavaScript bundler and minifier. See https://github.com/evanw/esbuild and the [JavaScript API documentation](https://esbuild.github.io/api/) for details.
|
||||
@@ -0,0 +1,52 @@
|
||||
// Code generated by Herebyfile.mjs generate:enums from internal/checker/types.go. DO NOT EDIT.
|
||||
export var ObjectFlags;
|
||||
(function (ObjectFlags) {
|
||||
ObjectFlags[ObjectFlags["None"] = 0] = "None";
|
||||
ObjectFlags[ObjectFlags["Class"] = 1] = "Class";
|
||||
ObjectFlags[ObjectFlags["Interface"] = 2] = "Interface";
|
||||
ObjectFlags[ObjectFlags["Reference"] = 4] = "Reference";
|
||||
ObjectFlags[ObjectFlags["Tuple"] = 8] = "Tuple";
|
||||
ObjectFlags[ObjectFlags["Anonymous"] = 16] = "Anonymous";
|
||||
ObjectFlags[ObjectFlags["Mapped"] = 32] = "Mapped";
|
||||
ObjectFlags[ObjectFlags["Instantiated"] = 64] = "Instantiated";
|
||||
ObjectFlags[ObjectFlags["ObjectLiteral"] = 128] = "ObjectLiteral";
|
||||
ObjectFlags[ObjectFlags["EvolvingArray"] = 256] = "EvolvingArray";
|
||||
ObjectFlags[ObjectFlags["ObjectLiteralPatternWithComputedProperties"] = 512] = "ObjectLiteralPatternWithComputedProperties";
|
||||
ObjectFlags[ObjectFlags["ReverseMapped"] = 1024] = "ReverseMapped";
|
||||
ObjectFlags[ObjectFlags["JsxAttributes"] = 2048] = "JsxAttributes";
|
||||
ObjectFlags[ObjectFlags["JSLiteral"] = 4096] = "JSLiteral";
|
||||
ObjectFlags[ObjectFlags["FreshLiteral"] = 8192] = "FreshLiteral";
|
||||
ObjectFlags[ObjectFlags["ArrayLiteral"] = 16384] = "ArrayLiteral";
|
||||
ObjectFlags[ObjectFlags["PrimitiveUnion"] = 32768] = "PrimitiveUnion";
|
||||
ObjectFlags[ObjectFlags["ContainsWideningType"] = 65536] = "ContainsWideningType";
|
||||
ObjectFlags[ObjectFlags["ContainsObjectOrArrayLiteral"] = 131072] = "ContainsObjectOrArrayLiteral";
|
||||
ObjectFlags[ObjectFlags["NonInferrableType"] = 262144] = "NonInferrableType";
|
||||
ObjectFlags[ObjectFlags["CouldContainTypeVariablesComputed"] = 524288] = "CouldContainTypeVariablesComputed";
|
||||
ObjectFlags[ObjectFlags["CouldContainTypeVariables"] = 1048576] = "CouldContainTypeVariables";
|
||||
ObjectFlags[ObjectFlags["MembersResolved"] = 2097152] = "MembersResolved";
|
||||
ObjectFlags[ObjectFlags["ClassOrInterface"] = 3] = "ClassOrInterface";
|
||||
ObjectFlags[ObjectFlags["RequiresWidening"] = 196608] = "RequiresWidening";
|
||||
ObjectFlags[ObjectFlags["PropagatingFlags"] = 458752] = "PropagatingFlags";
|
||||
ObjectFlags[ObjectFlags["InstantiatedMapped"] = 96] = "InstantiatedMapped";
|
||||
ObjectFlags[ObjectFlags["InstantiationExpressionType"] = 16777216] = "InstantiationExpressionType";
|
||||
ObjectFlags[ObjectFlags["SingleSignatureType"] = 33554432] = "SingleSignatureType";
|
||||
ObjectFlags[ObjectFlags["ObjectTypeKindMask"] = 50332991] = "ObjectTypeKindMask";
|
||||
ObjectFlags[ObjectFlags["ContainsSpread"] = 4194304] = "ContainsSpread";
|
||||
ObjectFlags[ObjectFlags["ObjectRestType"] = 8388608] = "ObjectRestType";
|
||||
ObjectFlags[ObjectFlags["IsClassInstanceClone"] = 67108864] = "IsClassInstanceClone";
|
||||
ObjectFlags[ObjectFlags["IdenticalBaseTypeCalculated"] = 134217728] = "IdenticalBaseTypeCalculated";
|
||||
ObjectFlags[ObjectFlags["IdenticalBaseTypeExists"] = 268435456] = "IdenticalBaseTypeExists";
|
||||
ObjectFlags[ObjectFlags["UnresolvedMembers"] = 536870912] = "UnresolvedMembers";
|
||||
ObjectFlags[ObjectFlags["FromTypeNode"] = 1073741824] = "FromTypeNode";
|
||||
ObjectFlags[ObjectFlags["IsGenericTypeComputed"] = 4194304] = "IsGenericTypeComputed";
|
||||
ObjectFlags[ObjectFlags["IsGenericObjectType"] = 8388608] = "IsGenericObjectType";
|
||||
ObjectFlags[ObjectFlags["IsGenericIndexType"] = 16777216] = "IsGenericIndexType";
|
||||
ObjectFlags[ObjectFlags["IsGenericType"] = 25165824] = "IsGenericType";
|
||||
ObjectFlags[ObjectFlags["ContainsIntersections"] = 33554432] = "ContainsIntersections";
|
||||
ObjectFlags[ObjectFlags["IsUnknownLikeUnionComputed"] = 67108864] = "IsUnknownLikeUnionComputed";
|
||||
ObjectFlags[ObjectFlags["IsUnknownLikeUnion"] = 134217728] = "IsUnknownLikeUnion";
|
||||
ObjectFlags[ObjectFlags["IsNeverIntersectionComputed"] = 33554432] = "IsNeverIntersectionComputed";
|
||||
ObjectFlags[ObjectFlags["IsNeverIntersection"] = 67108864] = "IsNeverIntersection";
|
||||
ObjectFlags[ObjectFlags["IsConstrainedTypeVariable"] = 134217728] = "IsConstrainedTypeVariable";
|
||||
})(ObjectFlags || (ObjectFlags = {}));
|
||||
//# sourceMappingURL=objectFlags.js.map
|
||||
@@ -0,0 +1,38 @@
|
||||
{
|
||||
"name": "real-require",
|
||||
"version": "1.0.0",
|
||||
"description": "Keep require and import consistent after bundling or transpiling",
|
||||
"author": "Paolo Insogna <shogun@cowtech.it>",
|
||||
"homepage": "https://github.com/pinojs/real-require",
|
||||
"contributors": [
|
||||
{
|
||||
"name": "Paolo Insogna",
|
||||
"url": "https://github.com/ShogunPanda"
|
||||
}
|
||||
],
|
||||
"license": "MIT",
|
||||
"repository": {
|
||||
"type": "git",
|
||||
"url": "git+https://github.com/pinojs/real-require.git"
|
||||
},
|
||||
"bugs": {
|
||||
"url": "https://github.com/pinojs/real-require/issues"
|
||||
},
|
||||
"main": "src/index.js",
|
||||
"files": [
|
||||
"src"
|
||||
],
|
||||
"scripts": {
|
||||
"lint": "eslint .",
|
||||
"lint:fix": "eslint --fix .",
|
||||
"test": "c8 --reporter=text --reporter=html borp 'test/*.test.js'",
|
||||
"test:ci": "c8 --reporter=text --reporter=json --check-coverage --branches 90 --functions 90 --lines 90 --statements 90 borp 'test/*.test.js'",
|
||||
"ci": "npm run lint && npm run test:ci"
|
||||
},
|
||||
"devDependencies": {
|
||||
"borp": "^1.0.0",
|
||||
"c8": "^8.0.0",
|
||||
"eslint": "^9.39.4",
|
||||
"neostandard": "^0.13.0"
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,53 @@
|
||||
'use strict';
|
||||
|
||||
const promisify = require('es6-promisify');
|
||||
const jayson = require('../../../');
|
||||
const promiseUtils = require('../utils');
|
||||
|
||||
/**
|
||||
* Constructor for a Jayson Promise Client
|
||||
* @see Client
|
||||
* @class PromiseClient
|
||||
* @extends Client
|
||||
* @return {PromiseClient}
|
||||
*/
|
||||
const PromiseClient = function(server, options) {
|
||||
if(!(this instanceof PromiseClient)) {
|
||||
return new PromiseClient(server, options);
|
||||
}
|
||||
jayson.Client.apply(this, arguments);
|
||||
this.request = promiseUtils.wrapClientRequestMethod(this.request.bind(this));
|
||||
};
|
||||
require('util').inherits(PromiseClient, jayson.Client);
|
||||
|
||||
/**
|
||||
* @type PromiseClientHttp
|
||||
* @static
|
||||
*/
|
||||
PromiseClient.http = require('./http');
|
||||
|
||||
/**
|
||||
* @type PromiseClientHttps
|
||||
* @static
|
||||
*/
|
||||
PromiseClient.https = require('./https');
|
||||
|
||||
/**
|
||||
* @type PromiseClientTls
|
||||
* @static
|
||||
*/
|
||||
PromiseClient.tls = require('./tls');
|
||||
|
||||
/**
|
||||
* @type PromiseClientTcp
|
||||
* @static
|
||||
*/
|
||||
PromiseClient.tcp = require('./tcp');
|
||||
|
||||
/**
|
||||
* @type PromiseClientWebsocket
|
||||
* @static
|
||||
*/
|
||||
PromiseClient.websocket = require('./websocket');
|
||||
|
||||
module.exports = PromiseClient;
|
||||
@@ -0,0 +1,16 @@
|
||||
import { VariableBase } from './VariableBase';
|
||||
/**
|
||||
* A Variable represents a locally scoped identifier. These include arguments to functions.
|
||||
*/
|
||||
export declare class Variable extends VariableBase {
|
||||
/**
|
||||
* `true` if the variable is valid in a type context, false otherwise
|
||||
* @public
|
||||
*/
|
||||
get isTypeVariable(): boolean;
|
||||
/**
|
||||
* `true` if the variable is valid in a value context, false otherwise
|
||||
* @public
|
||||
*/
|
||||
get isValueVariable(): boolean;
|
||||
}
|
||||
@@ -0,0 +1,96 @@
|
||||
# fast-deep-equal
|
||||
The fastest deep equal with ES6 Map, Set and Typed arrays support.
|
||||
|
||||
[](https://travis-ci.org/epoberezkin/fast-deep-equal)
|
||||
[](https://www.npmjs.com/package/fast-deep-equal)
|
||||
[](https://coveralls.io/github/epoberezkin/fast-deep-equal?branch=master)
|
||||
|
||||
|
||||
## Install
|
||||
|
||||
```bash
|
||||
npm install fast-deep-equal
|
||||
```
|
||||
|
||||
|
||||
## Features
|
||||
|
||||
- ES5 compatible
|
||||
- works in node.js (8+) and browsers (IE9+)
|
||||
- checks equality of Date and RegExp objects by value.
|
||||
|
||||
ES6 equal (`require('fast-deep-equal/es6')`) also supports:
|
||||
- Maps
|
||||
- Sets
|
||||
- Typed arrays
|
||||
|
||||
|
||||
## Usage
|
||||
|
||||
```javascript
|
||||
var equal = require('fast-deep-equal');
|
||||
console.log(equal({foo: 'bar'}, {foo: 'bar'})); // true
|
||||
```
|
||||
|
||||
To support ES6 Maps, Sets and Typed arrays equality use:
|
||||
|
||||
```javascript
|
||||
var equal = require('fast-deep-equal/es6');
|
||||
console.log(equal(Int16Array([1, 2]), Int16Array([1, 2]))); // true
|
||||
```
|
||||
|
||||
To use with React (avoiding the traversal of React elements' _owner
|
||||
property that contains circular references and is not needed when
|
||||
comparing the elements - borrowed from [react-fast-compare](https://github.com/FormidableLabs/react-fast-compare)):
|
||||
|
||||
```javascript
|
||||
var equal = require('fast-deep-equal/react');
|
||||
var equal = require('fast-deep-equal/es6/react');
|
||||
```
|
||||
|
||||
|
||||
## Performance benchmark
|
||||
|
||||
Node.js v12.6.0:
|
||||
|
||||
```
|
||||
fast-deep-equal x 261,950 ops/sec ±0.52% (89 runs sampled)
|
||||
fast-deep-equal/es6 x 212,991 ops/sec ±0.34% (92 runs sampled)
|
||||
fast-equals x 230,957 ops/sec ±0.83% (85 runs sampled)
|
||||
nano-equal x 187,995 ops/sec ±0.53% (88 runs sampled)
|
||||
shallow-equal-fuzzy x 138,302 ops/sec ±0.49% (90 runs sampled)
|
||||
underscore.isEqual x 74,423 ops/sec ±0.38% (89 runs sampled)
|
||||
lodash.isEqual x 36,637 ops/sec ±0.72% (90 runs sampled)
|
||||
deep-equal x 2,310 ops/sec ±0.37% (90 runs sampled)
|
||||
deep-eql x 35,312 ops/sec ±0.67% (91 runs sampled)
|
||||
ramda.equals x 12,054 ops/sec ±0.40% (91 runs sampled)
|
||||
util.isDeepStrictEqual x 46,440 ops/sec ±0.43% (90 runs sampled)
|
||||
assert.deepStrictEqual x 456 ops/sec ±0.71% (88 runs sampled)
|
||||
|
||||
The fastest is fast-deep-equal
|
||||
```
|
||||
|
||||
To run benchmark (requires node.js 6+):
|
||||
|
||||
```bash
|
||||
npm run benchmark
|
||||
```
|
||||
|
||||
__Please note__: this benchmark runs against the available test cases. To choose the most performant library for your application, it is recommended to benchmark against your data and to NOT expect this benchmark to reflect the performance difference in your application.
|
||||
|
||||
|
||||
## Enterprise support
|
||||
|
||||
fast-deep-equal package is a part of [Tidelift enterprise subscription](https://tidelift.com/subscription/pkg/npm-fast-deep-equal?utm_source=npm-fast-deep-equal&utm_medium=referral&utm_campaign=enterprise&utm_term=repo) - it provides a centralised commercial support to open-source software users, in addition to the support provided by software maintainers.
|
||||
|
||||
|
||||
## Security contact
|
||||
|
||||
To report a security vulnerability, please use the
|
||||
[Tidelift security contact](https://tidelift.com/security).
|
||||
Tidelift will coordinate the fix and disclosure. Please do NOT report security vulnerability via GitHub issues.
|
||||
|
||||
|
||||
## License
|
||||
|
||||
[MIT](https://github.com/epoberezkin/fast-deep-equal/blob/master/LICENSE)
|
||||
@@ -0,0 +1,2 @@
|
||||
export declare var ScriptKind: any;
|
||||
//# sourceMappingURL=scriptKind.d.ts.map
|
||||
Reference in New Issue
Block a user