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

x-value

Package Overview
Dependencies
Maintainers
1
Versions
61
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

x-value - npm Package Compare versions

Comparing version 0.0.1-18 to 0.0.1-19

43

bld/library/type/atomic-type.js

@@ -23,3 +23,9 @@ "use strict";

_decode(medium, unpacked, path) {
let value = medium.requireCodec(this.symbol).decode(unpacked);
let value;
try {
value = medium.requireCodec(this.symbol).decode(unpacked);
}
catch (error) {
return buildCodecErrorResult(error, path);
}
let issues = this._diagnose(value, path);

@@ -36,4 +42,8 @@ return [issues.length === 0 ? value : undefined, issues];

}
let unpacked = medium.requireCodec(this.symbol).encode(value);
return [unpacked, []];
try {
return [medium.requireCodec(this.symbol).encode(value), []];
}
catch (error) {
return buildCodecErrorResult(error, path);
}
}

@@ -43,3 +53,9 @@ /** @internal */

let symbol = this.symbol;
let value = from.requireCodec(symbol).decode(unpacked);
let value;
try {
value = from.requireCodec(symbol).decode(unpacked);
}
catch (error) {
return buildCodecErrorResult(error, path);
}
let issues = this._diagnose(value, path);

@@ -49,4 +65,8 @@ if (issues.length > 0) {

}
let transformedUnpacked = to.requireCodec(symbol).encode(value);
return [transformedUnpacked, issues];
try {
return [to.requireCodec(symbol).encode(value), issues];
}
catch (error) {
return buildCodecErrorResult(error, path);
}
}

@@ -74,2 +94,13 @@ /** @internal */

exports.atomic = atomic;
function buildCodecErrorResult(error, path) {
return [
undefined,
[
{
path,
message: typeof error === 'string' ? error : error.message,
},
],
];
}
//# sourceMappingURL=atomic-type.js.map

2

package.json
{
"name": "x-value",
"version": "0.0.1-18",
"version": "0.0.1-19",
"repository": "https://github.com/vilic/x-value.git",

@@ -5,0 +5,0 @@ "license": "MIT",

@@ -29,3 +29,3 @@ [![NPM version](https://img.shields.io/npm/v/x-value?color=%23cb3837&style=flat-square)](https://www.npmjs.com/package/x-value)

foo: x.string,
bar: x.optional(x.number),
bar: x.number.optional(),
});

@@ -47,2 +47,14 @@

);
interface R {
type: 'recursive';
child: R;
}
const R = x.recursive<R>(R =>
x.object({
type: x.literal('recursive'),
child: R,
}),
);
```

@@ -62,3 +74,3 @@

// Or with refined or nominal type.
// Or with refined or nominal type:
const Email = x.string.refine<`${string}@${string}`>(value =>

@@ -68,2 +80,5 @@ value.includes('@'),

const Email = x.string.refine<Nominal<'email'>>(value => value.includes('@'));
// Or just nominal type without extra constraints:
const Email = x.string.nominal<'email'>();
```

@@ -70,0 +85,0 @@

@@ -62,4 +62,10 @@ import type {

): [unknown, TypeIssue[]] {
let value = medium.requireCodec(this.symbol).decode(unpacked);
let value: unknown;
try {
value = medium.requireCodec(this.symbol).decode(unpacked);
} catch (error: any) {
return buildCodecErrorResult(error, path);
}
let issues = this._diagnose(value, path);

@@ -85,5 +91,7 @@

let unpacked = medium.requireCodec(this.symbol).encode(value);
return [unpacked, []];
try {
return [medium.requireCodec(this.symbol).encode(value), []];
} catch (error: any) {
return buildCodecErrorResult(error, path);
}
}

@@ -100,4 +108,10 @@

let value = from.requireCodec(symbol).decode(unpacked);
let value: unknown;
try {
value = from.requireCodec(symbol).decode(unpacked);
} catch (error: any) {
return buildCodecErrorResult(error, path);
}
let issues = this._diagnose(value, path);

@@ -109,5 +123,7 @@

let transformedUnpacked = to.requireCodec(symbol).encode(value);
return [transformedUnpacked, issues];
try {
return [to.requireCodec(symbol).encode(value), issues];
} catch (error: any) {
return buildCodecErrorResult(error, path);
}
}

@@ -145,1 +161,16 @@

}
function buildCodecErrorResult(
error: string | Error,
path: TypePath,
): [undefined, TypeIssue[]] {
return [
undefined,
[
{
path,
message: typeof error === 'string' ? error : error.message,
},
],
];
}

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