New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

seroval

Package Overview
Dependencies
Maintainers
0
Versions
66
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

seroval - npm Package Compare versions

Comparing version 1.2.0 to 1.2.1

16

dist/types/core/context/parser.d.ts

@@ -8,3 +8,3 @@ import type { Plugin, PluginAccessOptions, SerovalMode } from '../plugin';

}
declare const enum NodeType {
export declare const enum ParserNodeType {
Fresh = 0,

@@ -14,12 +14,12 @@ Indexed = 1,

}
interface FreshNode {
type: NodeType.Fresh;
export interface FreshNode {
type: ParserNodeType.Fresh;
value: number;
}
interface IndexedNode {
type: NodeType.Indexed;
export interface IndexedNode {
type: ParserNodeType.Indexed;
value: SerovalIndexedValueNode;
}
interface ReferencedNode {
type: NodeType.Referenced;
export interface ReferencedNode {
type: ParserNodeType.Referenced;
value: SerovalReferenceNode;

@@ -39,4 +39,2 @@ }

protected getReference<T>(current: T): ObjectNode;
protected getStrictReference<T>(current: T): SerovalIndexedValueNode | SerovalReferenceNode;
protected parseFunction(current: (...args: unknown[]) => unknown): SerovalNode;
protected parseWellKnownSymbol(current: symbol): SerovalIndexedValueNode | SerovalWKSymbolNode | SerovalReferenceNode;

@@ -43,0 +41,0 @@ protected parseSpecialReference(ref: SpecialReference): SerovalIndexedValueNode | SerovalSpecialReferenceNode;

@@ -22,4 +22,5 @@ import type { SerovalNode } from '../../types';

private parseObject;
protected parseFunction(current: unknown): Promise<SerovalNode>;
parse<T>(current: T): Promise<SerovalNode>;
}
//# sourceMappingURL=async.d.ts.map

@@ -30,2 +30,3 @@ import type { Stream } from '../../stream';

protected parseStream(id: number, current: Stream<unknown>): SerovalNode;
protected handleAbortSignal(id: number, current: AbortSignal): void;
protected parseAbortSignal(id: number, current: AbortSignal): SerovalAbortSignalConstructorNode | SerovalAbortSignalSyncNode;

@@ -32,0 +33,0 @@ private parseWithError;

@@ -27,2 +27,3 @@ import type { Stream } from '../../stream';

protected parseObject(id: number, current: object): SerovalNode;
protected parseFunction(current: unknown): SerovalNode;
parse<T>(current: T): SerovalNode;

@@ -29,0 +30,0 @@ }

{
"name": "seroval",
"type": "module",
"version": "1.2.0",
"version": "1.2.1",
"files": [

@@ -17,9 +17,9 @@ "dist",

"devDependencies": {
"@types/node": "^22.10.2",
"@vitest/ui": "^2.1.8",
"pridepack": "2.6.3",
"@types/node": "^22.10.10",
"@vitest/ui": "^3.0.4",
"pridepack": "2.6.4",
"ts-prune": "^0.10.3",
"tslib": "^2.8.1",
"typescript": "^5.7.2",
"vitest": "^2.1.8"
"typescript": "^5.7.3",
"vitest": "^3.0.4"
},

@@ -69,3 +69,3 @@ "scripts": {

},
"gitHead": "8554d153be3359ef6fc0b6179d0d702c17f50c77"
"gitHead": "c90be6d96271c63791fd4627672813f3d74fe2eb"
}

@@ -1,13 +0,19 @@

export function abortSignalToPromise(signal: AbortSignal): Promise<any> {
return new Promise(resolve => {
signal.addEventListener(
'abort',
() => {
resolve(signal.reason);
},
{
once: true,
},
);
function resolveAbortSignalResult(
this: AbortSignal,
resolve: (value: any) => void,
): void {
resolve(this.reason);
}
function resolveAbortSignal(
this: AbortSignal,
resolve: (value: any) => void,
): void {
this.addEventListener('abort', resolveAbortSignalResult.bind(this, resolve), {
once: true,
});
}
export function abortSignalToPromise(signal: AbortSignal): Promise<any> {
return new Promise(resolveAbortSignal.bind(signal));
}

@@ -42,3 +42,3 @@ import {

const enum NodeType {
export const enum ParserNodeType {
Fresh = 0,

@@ -49,14 +49,14 @@ Indexed = 1,

interface FreshNode {
type: NodeType.Fresh;
export interface FreshNode {
type: ParserNodeType.Fresh;
value: number;
}
interface IndexedNode {
type: NodeType.Indexed;
export interface IndexedNode {
type: ParserNodeType.Indexed;
value: SerovalIndexedValueNode;
}
interface ReferencedNode {
type: NodeType.Referenced;
export interface ReferencedNode {
type: ParserNodeType.Referenced;
value: SerovalReferenceNode;

@@ -97,3 +97,3 @@ }

return {
type: NodeType.Indexed,
type: ParserNodeType.Indexed,
value: createIndexedValueNode(registeredId),

@@ -105,3 +105,3 @@ };

return {
type: NodeType.Fresh,
type: ParserNodeType.Fresh,
value: id,

@@ -113,3 +113,3 @@ };

const indexed = this.getIndexedValue(current);
if (indexed.type === NodeType.Indexed) {
if (indexed.type === ParserNodeType.Indexed) {
return indexed;

@@ -119,3 +119,3 @@ }

return {
type: NodeType.Referenced,
type: ParserNodeType.Referenced,
value: createReferenceNode(indexed.value, current),

@@ -127,19 +127,2 @@ };

protected getStrictReference<T>(
current: T,
): SerovalIndexedValueNode | SerovalReferenceNode {
assert(hasReferenceID(current), new SerovalUnsupportedTypeError(current));
const result = this.getIndexedValue(current);
if (result.type === NodeType.Indexed) {
return result.value;
}
return createReferenceNode(result.value, current);
}
protected parseFunction(
current: (...args: unknown[]) => unknown,
): SerovalNode {
return this.getStrictReference(current);
}
protected parseWellKnownSymbol(

@@ -149,3 +132,3 @@ current: symbol,

const ref = this.getReference(current);
if (ref.type !== NodeType.Fresh) {
if (ref.type !== ParserNodeType.Fresh) {
return ref.value;

@@ -161,3 +144,3 @@ }

const result = this.getIndexedValue(SPECIAL_REFS[ref]);
if (result.type === NodeType.Indexed) {
if (result.type === ParserNodeType.Indexed) {
return result.value;

@@ -185,3 +168,3 @@ }

const result = this.getIndexedValue(ITERATOR);
if (result.type === NodeType.Indexed) {
if (result.type === ParserNodeType.Indexed) {
return result.value;

@@ -209,3 +192,3 @@ }

const result = this.getIndexedValue(ASYNC_ITERATOR);
if (result.type === NodeType.Indexed) {
if (result.type === ParserNodeType.Indexed) {
return result.value;

@@ -212,0 +195,0 @@ }

@@ -67,3 +67,3 @@ import { abortSignalToPromise } from '../../abort-signal';

} from '../../utils/typed-array';
import { BaseParserContext } from '../parser';
import { BaseParserContext, ParserNodeType } from '../parser';

@@ -484,2 +484,14 @@ type ObjectLikeNode =

protected async parseFunction(current: unknown): Promise<SerovalNode> {
const ref = this.getReference(current);
if (ref.type !== ParserNodeType.Fresh) {
return ref.value;
}
const plugin = await this.parsePlugin(ref.value, current);
if (plugin) {
return plugin;
}
throw new SerovalUnsupportedTypeError(current);
}
async parse<T>(current: T): Promise<SerovalNode> {

@@ -510,3 +522,3 @@ try {

case 'function':
return this.parseFunction(current as (...args: unknown[]) => unknown);
return this.parseFunction(current);
default:

@@ -513,0 +525,0 @@ throw new SerovalUnsupportedTypeError(current);

@@ -284,2 +284,30 @@ import {

protected handleAbortSignal(id: number, current: AbortSignal): void {
if (this.alive) {
const parsed = this.parseWithError(current.reason);
if (parsed) {
this.onParse(
createSerovalNode(
SerovalNodeType.AbortSignalAbort,
id,
NIL,
NIL,
NIL,
NIL,
NIL,
NIL,
[
this.parseSpecialReference(SpecialReference.AbortSignalAbort),
parsed,
],
NIL,
NIL,
NIL,
),
);
}
}
this.popPendingState();
}
protected parseAbortSignal(

@@ -297,29 +325,3 @@ id: number,

'abort',
() => {
if (this.alive) {
const parsed = this.parseWithError(current.reason);
if (parsed) {
this.onParse(
createSerovalNode(
SerovalNodeType.AbortSignalAbort,
id,
NIL,
NIL,
NIL,
NIL,
NIL,
NIL,
[
this.parseSpecialReference(SpecialReference.AbortSignalAbort),
parsed,
],
NIL,
NIL,
NIL,
),
);
}
}
this.popPendingState();
},
this.handleAbortSignal.bind(this, id, current),
{ once: true },

@@ -326,0 +328,0 @@ );

@@ -63,3 +63,3 @@ import {

import type { BaseParserContextOptions } from '../parser';
import { BaseParserContext } from '../parser';
import { BaseParserContext, ParserNodeType } from '../parser';

@@ -393,2 +393,14 @@ type ObjectLikeNode = SerovalObjectNode | SerovalNullConstructorNode;

protected parseFunction(current: unknown): SerovalNode {
const ref = this.getReference(current);
if (ref.type !== ParserNodeType.Fresh) {
return ref.value;
}
const plugin = this.parsePlugin(ref.value, current);
if (plugin) {
return plugin;
}
throw new SerovalUnsupportedTypeError(current);
}
parse<T>(current: T): SerovalNode {

@@ -410,3 +422,3 @@ try {

const ref = this.getReference(current);
return ref.type === 0
return ref.type === ParserNodeType.Fresh
? this.parseObject(ref.value, current as object)

@@ -419,4 +431,5 @@ : ref.value;

return this.parseWellKnownSymbol(current);
case 'function':
return this.parseFunction(current as (...args: unknown[]) => unknown);
case 'function': {
return this.parseFunction(current);
}
default:

@@ -423,0 +436,0 @@ throw new SerovalUnsupportedTypeError(current);

@@ -134,5 +134,3 @@ import { resolvePlugins } from '../plugin';

return () => {
ctx.destroy();
};
return ctx.destroy.bind(ctx);
}

@@ -158,5 +156,3 @@

return () => {
ctx.destroy();
};
return ctx.destroy.bind(ctx);
}

@@ -163,0 +159,0 @@

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc