Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

typedconverter

Package Overview
Dependencies
Maintainers
1
Versions
193
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

typedconverter - npm Package Compare versions

Comparing version 1.0.0-alpha.6 to 1.0.0-alpha.7

6

lib/index.d.ts

@@ -42,4 +42,4 @@ declare type Converter = (value: any, info: ObjectInfo<Function | Function[]>) => Promise<ConversionResult>;

}
declare abstract class ConverterInvocation implements ObjectInfo<Function | Function[]> {
type: Function | Function[];
declare abstract class ConverterInvocation implements ObjectInfo<Function | Function[] | undefined> {
type: Function | Function[] | undefined;
path: string[];

@@ -49,3 +49,3 @@ converters: Map<string | Function, Converter>;

decorators: any[];
constructor(info: ObjectInfo<Function | Function[]>);
constructor({ type, path, converters, visitors, decorators, ...opts }: ObjectInfo<Function | Function[] | undefined>);
abstract proceed(): Promise<ConversionResult>;

@@ -52,0 +52,0 @@ }

@@ -41,8 +41,10 @@ "use strict";

class ConverterInvocation {
constructor(info) {
this.type = info.type;
this.path = info.path;
this.converters = info.converters;
this.visitors = info.visitors;
this.decorators = info.decorators;
constructor(_a) {
var { type, path, converters, visitors, decorators } = _a, opts = tslib_1.__rest(_a, ["type", "path", "converters", "visitors", "decorators"]);
this.type = type;
this.path = path;
this.converters = converters;
this.visitors = visitors;
this.decorators = decorators;
Object.assign(this, opts);
}

@@ -71,3 +73,3 @@ }

proceed() {
return visitor(this.value, this);
return defaultVisitor(this.value, this);
}

@@ -216,5 +218,5 @@ }

// --------------------------------------------------------------------- //
async function visitor(value, _a) {
async function defaultVisitor(value, _a) {
var { type, converters } = _a, restInfo = tslib_1.__rest(_a, ["type", "converters"]);
if (type === Object || value.constructor === type)
if (value === null || value === undefined || !type || type === Object || value.constructor === type)
return new ConversionResult(value);

@@ -233,4 +235,2 @@ //check if the parameter contains @array()

var { type } = _a, restInfo = tslib_1.__rest(_a, ["type"]);
if (value === null || value === undefined || !type)
return new ConversionResult(value);
return pipe(value, Object.assign({ type }, restInfo));

@@ -249,11 +249,6 @@ }

]);
const expectedType = Array.isArray(option) || typeof option === "function" ? option : option && option.type;
const path = typeof option === "object" && !Array.isArray(option) && option.path || [];
const decorators = typeof option === "object" && !Array.isArray(option) && option.decorators || [];
const result = await convert(value, {
path, type: expectedType || factoryOption.type,
converters: mergedConverters,
visitors: factoryOption.visitors || [],
decorators
});
const opt = Array.isArray(option) || typeof option === "function" ?
{ path: [], decorators: [], type: option } : !!option ? option : { path: [], decorators: [], type: undefined };
const { type = factoryOption.type, path = [], decorators = [] } = opt, restOpt = tslib_1.__rest(opt, ["type", "path", "decorators"]);
const result = await convert(value, Object.assign({ visitors: factoryOption.visitors || [], converters: mergedConverters, path, type, decorators }, restOpt));
if (result.messages.length > 0)

@@ -260,0 +255,0 @@ throw new ConversionError(result.messages);

{
"name": "typedconverter",
"version": "1.0.0-alpha.6",
"version": "1.0.0-alpha.7",
"description": "Convert object into classes match with TypeScript type annotation",

@@ -5,0 +5,0 @@ "main": "lib/index.js",

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