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

kryo

Package Overview
Dependencies
Maintainers
1
Versions
57
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

kryo - npm Package Compare versions

Comparing version 0.10.0 to 0.11.0

7

CHANGELOG.md

@@ -0,1 +1,8 @@

# 0.11.0 (2020-06-01)
- **[Breaking change]** Require Node 14.
- **[Breaking change]** Type `test` and `testError` argument as `unknown`.
- **[Fix]** Fix compilation error with TypeScript 3.9.
- **[Fix]** Update dependencies
# 0.10.0 (2020-04-10)

@@ -2,0 +9,0 @@

2

lib/_helpers/test-error.d.ts

@@ -9,2 +9,2 @@ import { Type } from "../index.js";

*/
export declare function testError<T>(type: Type<T>, value: T): Error | undefined;
export declare function testError<T>(type: Type<T>, value: unknown): Error | undefined;

@@ -7,4 +7,4 @@ import { IoType, Reader, Writer } from "./index.js";

write<W>(writer: Writer<W>, value: T): W;
testError(value: T): Error | undefined;
test(_value: T): boolean;
testError(value: unknown): Error | undefined;
test(_value: unknown): _value is T;
equals(val1: T, val2: T): boolean;

@@ -11,0 +11,0 @@ clone(val: T): T;

@@ -9,4 +9,4 @@ import { IoType, Ord, Reader, VersionedType, Writer } from "./index.js";

write<W>(writer: Writer<W>, value: boolean): W;
testError(val: boolean): Error | undefined;
test(value: boolean): value is boolean;
testError(val: unknown): Error | undefined;
test(value: unknown): value is boolean;
equals(left: boolean, right: boolean): boolean;

@@ -13,0 +13,0 @@ lte(left: boolean, right: boolean): boolean;

@@ -12,4 +12,4 @@ import { IoType, Lazy, Ord, Reader, VersionedType, Writer } from "./index.js";

write<W>(writer: Writer<W>, value: Uint8Array): W;
testError(val: Uint8Array): Error | undefined;
test(val: Uint8Array): boolean;
testError(val: unknown): Error | undefined;
test(value: unknown): value is Uint8Array;
equals(left: Uint8Array, right: Uint8Array): boolean;

@@ -16,0 +16,0 @@ lte(left: Uint8Array, right: Uint8Array): boolean;

@@ -42,4 +42,4 @@ import { lazyProperties } from "./_helpers/lazy-properties.js";

}
test(val) {
return this.testError(val) === undefined;
test(value) {
return this.testError(value) === undefined;
}

@@ -46,0 +46,0 @@ equals(left, right) {

@@ -83,4 +83,4 @@ import { IoType, Lazy, Reader, VersionedType, Writer } from "./index.js";

write<W>(writer: Writer<W>, value: string): W;
testError(val: string): Error | undefined;
test(val: string): boolean;
testError(value: unknown): Error | undefined;
test(value: unknown): value is string;
equals(val1: string, val2: string): boolean;

@@ -87,0 +87,0 @@ clone(val: string): string;

@@ -88,5 +88,5 @@ import incident from "incident";

}
testError(val) {
if (!(typeof val === "string")) {
return createInvalidTypeError("string", val);
testError(value) {
if (!(typeof value === "string")) {
return createInvalidTypeError("string", value);
}

@@ -98,3 +98,3 @@ switch (this.normalization) {

}
if (val !== this.unorm.nfc(val)) {
if (value !== this.unorm.nfc(value)) {
return incident.Incident("UnicodeNormalization", "Not NFC-Normalized");

@@ -108,11 +108,11 @@ }

}
if (this.lowerCase && val !== val.toLowerCase()) {
return createLowerCaseError(val);
if (this.lowerCase && value !== value.toLowerCase()) {
return createLowerCaseError(value);
}
if (this.trimmed && val !== val.trim()) {
return createNotTrimmedError(val);
if (this.trimmed && value !== value.trim()) {
return createNotTrimmedError(value);
}
let codepointCount;
try {
codepointCount = checkedUcs2Decode(val).length;
codepointCount = checkedUcs2Decode(value).length;
}

@@ -124,6 +124,6 @@ catch (err) {

if (typeof minCodepoints === "number" && codepointCount < minCodepoints) {
return createMinCodepointsError(val, codepointCount, minCodepoints);
return createMinCodepointsError(value, codepointCount, minCodepoints);
}
if (codepointCount > this.maxCodepoints) {
return createMaxCodepointsError(val, codepointCount, this.maxCodepoints);
return createMaxCodepointsError(value, codepointCount, this.maxCodepoints);
}

@@ -134,4 +134,4 @@ if (this.pattern instanceof RegExp) {

}
if (!this.pattern.test(val)) {
return createPatternNotMatchedError(this.pattern, val);
if (!this.pattern.test(value)) {
return createPatternNotMatchedError(this.pattern, value);
}

@@ -141,4 +141,4 @@ }

}
test(val) {
return this.testError(val) === undefined;
test(value) {
return this.testError(value) === undefined;
}

@@ -145,0 +145,0 @@ equals(val1, val2) {

@@ -6,3 +6,3 @@ import { Lazy, Reader, Type, Writer } from "./index.js";

export declare type Write<T> = <W>(writer: Writer<W>, value: T) => W;
export declare type TestError<T> = (val: T) => Error | undefined;
export declare type TestError = (val: unknown) => Error | undefined;
export declare type Equals<T> = (val1: T, val2: T) => boolean;

@@ -13,3 +13,3 @@ export declare type Clone<T> = (val: T) => T;

write: Write<T>;
testError: TestError<T>;
testError: TestError;
equals: Equals<T>;

@@ -22,3 +22,3 @@ clone: Clone<T>;

readonly write: Write<T>;
readonly testError: TestError<T>;
readonly testError: TestError;
readonly equals: Equals<T>;

@@ -28,4 +28,4 @@ readonly clone: Clone<T>;

constructor(options: Lazy<CustomTypeOptions<T>>);
test(val: T): boolean;
test(value: unknown): value is T;
private _applyOptions;
}

@@ -15,4 +15,4 @@ import { lazyProperties } from "./_helpers/lazy-properties.js";

}
test(val) {
return this.testError(val) === undefined;
test(value) {
return this.testError(value) === undefined;
}

@@ -19,0 +19,0 @@ _applyOptions() {

@@ -9,4 +9,4 @@ import { IoType, Ord, Reader, VersionedType, Writer } from "./index.js";

write<W>(writer: Writer<W>, value: Date): W;
testError(val: Date): Error | undefined;
test(val: Date): val is Date;
testError(value: unknown): Error | undefined;
test(value: unknown): value is Date;
equals(left: Date, right: Date): boolean;

@@ -13,0 +13,0 @@ lte(left: Date, right: Date): boolean;

@@ -25,14 +25,14 @@ import { createInvalidTimestampError } from "./errors/invalid-timestamp.js";

}
testError(val) {
if (!(val instanceof Date)) {
return createInvalidTypeError("Date", val);
testError(value) {
if (!(value instanceof Date)) {
return createInvalidTypeError("Date", value);
}
const time = val.getTime();
const time = value.getTime();
if (isNaN(time) || time > Number.MAX_SAFE_INTEGER || time < Number.MIN_SAFE_INTEGER) {
return createInvalidTimestampError(val);
return createInvalidTimestampError(value);
}
return undefined;
}
test(val) {
return this.testError(val) === undefined;
test(value) {
return this.testError(value) === undefined;
}

@@ -39,0 +39,0 @@ equals(left, right) {

@@ -39,4 +39,4 @@ import { IoType, Lazy, Ord, Reader, VersionedType, Writer } from "./index.js";

write<W>(writer: Writer<W>, value: number): W;
testError(val: number): Error | undefined;
test(val: number): boolean;
testError(val: unknown): Error | undefined;
test(value: unknown): value is number;
/**

@@ -43,0 +43,0 @@ * Tests the equivalence of two valid float64 values.

@@ -55,6 +55,6 @@ import { lazyProperties } from "./_helpers/lazy-properties.js";

}
test(val) {
return typeof val === "number"
&& (this.allowNaN || !isNaN(val))
&& (this.allowInfinity || Math.abs(val) !== Infinity);
test(value) {
return typeof value === "number"
&& (this.allowNaN || !isNaN(value))
&& (this.allowInfinity || Math.abs(value) !== Infinity);
}

@@ -61,0 +61,0 @@ /**

@@ -29,3 +29,3 @@ /**

*/
test(value: T): boolean;
test(value: unknown): value is T;
/**

@@ -64,3 +64,3 @@ * Tests if `left` is equal to `value`.

*/
testError?(value: T): Error | undefined;
testError?(value: unknown): Error | undefined;
/**

@@ -67,0 +67,0 @@ * Compares two valid values.

@@ -45,4 +45,4 @@ import { IoType, Lazy, Ord, Reader, VersionedType, Writer } from "./index.js";

write<W>(writer: Writer<W>, value: number): W;
testError(val: number): Error | undefined;
test(val: number): boolean;
testError(val: unknown): Error | undefined;
test(value: unknown): value is number;
equals(left: number, right: number): boolean;

@@ -49,0 +49,0 @@ lte(left: number, right: number): boolean;

@@ -67,4 +67,4 @@ import incident from "incident";

}
test(val) {
return typeof val === "number" && val >= this.min && val <= this.max && Math.round(val) === val;
test(value) {
return typeof value === "number" && value >= this.min && value <= this.max && Math.round(value) === value;
}

@@ -71,0 +71,0 @@ equals(left, right) {

@@ -21,4 +21,4 @@ import { IoType, Lazy, Reader, VersionedType, Writer } from "./index.js";

write<W>(writer: Writer<W>, value: Map<K, V>): W;
testError(val: Map<K, V>): Error | undefined;
test(val: Map<K, V>): boolean;
testError(val: unknown): Error | undefined;
test(val: unknown): val is Map<K, V>;
equals(val1: Map<K, V>, val2: Map<K, V>): boolean;

@@ -25,0 +25,0 @@ clone(val: Map<K, V>): Map<K, V>;

@@ -8,4 +8,4 @@ import { IoType, Reader, VersionedType, Writer } from "./index.js";

write<W>(writer: Writer<W>, _: null): W;
testError(val: null): Error | undefined;
test(val: null): val is null;
testError(val: unknown): Error | undefined;
test(val: unknown): val is null;
equals(val1: null, val2: null): boolean;

@@ -12,0 +12,0 @@ clone(val: null): null;

@@ -131,3 +131,3 @@ import incident from "incident";

const descriptor = this.properties[key];
const propertyValue = val[key];
const propertyValue = Reflect.get(val, key);
if (propertyValue === undefined) {

@@ -159,3 +159,3 @@ if (!descriptor.optional) {

const descriptor = this.properties[key];
const propertyValue = val[key];
const propertyValue = Reflect.get(val, key);
if (propertyValue === undefined) {

@@ -162,0 +162,0 @@ if (!descriptor.optional) {

@@ -20,3 +20,3 @@ import { IoType, Lazy, Reader, VersionedType, Writer } from "./index.js";

constructor(options: Lazy<TaggedUnionTypeOptions<T, K>>);
match(value: T): K | undefined;
match(value: unknown): K | undefined;
matchTrusted(value: T): K;

@@ -26,4 +26,4 @@ write<W>(writer: Writer<W>, value: T): W;

variantRead<R>(reader: Reader<R>, raw: R): [K, T];
testError(value: T): Error | undefined;
test(value: T): boolean;
testError(value: unknown): Error | undefined;
test(value: unknown): value is T;
equals(val1: T, val2: T): boolean;

@@ -30,0 +30,0 @@ clone(val: T): T;

@@ -20,4 +20,7 @@ import incident from "incident";

match(value) {
if (typeof value !== "object" || value === null) {
throw createInvalidTypeError("object", value);
}
const tag = this.tag;
const tagValue = value[tag];
const tagValue = Reflect.get(value, tag);
if (tagValue === undefined) {

@@ -24,0 +27,0 @@ return undefined;

@@ -18,3 +18,3 @@ import { IoType, Lazy, Reader, Type, VersionedType, Writer } from "./index.js";

constructor(options: Lazy<TryUnionTypeOptions<T, M>>);
match(value: T): M | undefined;
match(value: unknown): M | undefined;
matchTrusted(value: T): M;

@@ -24,4 +24,4 @@ write<W>(writer: Writer<W>, value: T): W;

variantRead<R>(reader: Reader<R>, raw: R): VariantValue<T, M>;
testError(value: T): Error | undefined;
test(val: T): boolean;
testError(value: unknown): Error | undefined;
test(val: unknown): val is T;
equals(val1: T, val2: T): boolean;

@@ -28,0 +28,0 @@ clone(val: T): T;

@@ -26,3 +26,3 @@ import { CaseStyle, IoType, Lazy, Reader, Writer } from "./index.js";

*/
export declare class TsEnumType<E extends string | number, EO extends any = any> implements IoType<E>, TsEnumTypeOptions<E, EO> {
export declare class TsEnumType<E extends string | number, EO extends {} = {}> implements IoType<E>, TsEnumTypeOptions<E, EO> {
readonly name: Name;

@@ -43,4 +43,4 @@ readonly enum: Record<keyof EO, E>;

write<W>(writer: Writer<W>, value: E): W;
testError(value: E): Error | undefined;
test(value: E): value is E;
testError(value: unknown): Error | undefined;
test(value: unknown): value is E;
equals(val1: E, val2: E): boolean;

@@ -47,0 +47,0 @@ clone(val: E): E;

@@ -109,4 +109,4 @@ import { IoType, Lazy, Reader, VersionedType, Writer } from "./index.js";

write<W>(writer: Writer<W>, value: string): W;
testError(val: string): Error | undefined;
test(val: string): boolean;
testError(val: unknown): Error | undefined;
test(val: unknown): val is string;
equals(val1: string, val2: string): boolean;

@@ -113,0 +113,0 @@ clone(val: string): string;

@@ -17,4 +17,4 @@ import { IoType, Lazy, Reader, VersionedType, Writer } from "./index.js";

write<W>(writer: Writer<W>, value: T): W;
testError(val: T): Error | undefined;
test(value: T): boolean;
testError(val: unknown): Error | undefined;
test(value: unknown): value is T;
equals(val1: T, val2: T): boolean;

@@ -21,0 +21,0 @@ clone(val: T): T;

{
"name": "kryo",
"version": "0.10.0",
"version": "0.11.0",
"description": "Runtime types for validation and serialization",

@@ -22,5 +22,2 @@ "license": "MIT",

},
"engines": {
"node": ">=13.7"
},
"scripts": {

@@ -35,17 +32,18 @@ "build": "tsc --build src/lib/tsconfig.json",

},
"engines": {
"node": ">=14.0"
},
"dependencies": {
"@types/object-inspect": "^1.6.0",
"incident": "^3.2.0",
"@types/object-inspect": "^1.6.1",
"incident": "^3.2.1",
"object-inspect": "^1.7.0",
"tslib": "^1.11.1"
"tslib": "^2.0.0"
},
"devDependencies": {
"@types/chai": "^4.2.8",
"@types/mocha": "^7.0.1",
"@types/node": "^13.7.0",
"@types/unorm": "^1.3.27",
"@types/chai": "^4.2.11",
"@types/mocha": "^7.0.2",
"@types/node": "^14.0.6",
"@types/unorm": "^1.3.28",
"c88": "^0.3.4",
"chai": "^4.2.0",
"mocha": "^7.1.1",
"typescript": "^3.7.5",
"unorm": "^1.6.0"

@@ -52,0 +50,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

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