typed-assert
Advanced tools
Comparing version 1.0.5 to 1.0.6
@@ -50,2 +50,7 @@ "use strict"; | ||
t.setBaseAssert(baseAssert); | ||
test("isUnknown", () => { | ||
for (const value of Object.values(fixtures)) { | ||
expect(() => t.isUnknown(value)).not.toThrow(); | ||
} | ||
}); | ||
test("isNotNull", () => { | ||
@@ -52,0 +57,0 @@ const v = orNull(fixtures.string); |
@@ -9,2 +9,3 @@ export declare type WeakAssert = (input: unknown, message?: string) => void; | ||
export declare const safeJsonParse: (json: string) => unknown; | ||
export declare function isUnknown(_input: unknown): _input is unknown; | ||
export declare function isNotNull<T>(input: null | T, message?: string): asserts input is T; | ||
@@ -11,0 +12,0 @@ export declare function isNotUndefined<T>(input: undefined | T, message?: string): asserts input is T; |
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.check = exports.isPromise = exports.isInstanceOf = exports.isOneOfType = exports.isOneOf = exports.isOptionOfType = exports.isArrayOfType = exports.isRecordOfType = exports.isArray = exports.isRecordWithKeys = exports.isRecord = exports.isDate = exports.isString = exports.isNumber = exports.isBoolean = exports.isExactly = exports.isNotUndefined = exports.isNotNull = exports.safeJsonParse = exports.setBaseAssert = exports.assert = exports.defaultAssert = void 0; | ||
exports.check = exports.isPromise = exports.isInstanceOf = exports.isOneOfType = exports.isOneOf = exports.isOptionOfType = exports.isArrayOfType = exports.isRecordOfType = exports.isArray = exports.isRecordWithKeys = exports.isRecord = exports.isDate = exports.isString = exports.isNumber = exports.isBoolean = exports.isExactly = exports.isNotUndefined = exports.isNotNull = exports.isUnknown = exports.safeJsonParse = exports.setBaseAssert = exports.assert = exports.defaultAssert = void 0; | ||
const expectedToBe = (type) => `expected to be ${type}`; | ||
@@ -19,2 +19,6 @@ exports.defaultAssert = (condition, message) => { | ||
exports.safeJsonParse = (json) => JSON.parse(json); | ||
function isUnknown(_input) { | ||
return true; | ||
} | ||
exports.isUnknown = isUnknown; | ||
function isNotNull(input, message = expectedToBe("not null")) { | ||
@@ -21,0 +25,0 @@ exports.assert(input !== null, message); |
{ | ||
"name": "typed-assert", | ||
"version": "1.0.5", | ||
"version": "1.0.6", | ||
"description": "typesafe assertion library for TypeScript 3.7+", | ||
@@ -5,0 +5,0 @@ "main": "build/index.js", |
@@ -56,2 +56,9 @@ import nodeAssert from "assert"; | ||
t.setBaseAssert(baseAssert); | ||
test("isUnknown", () => { | ||
for (const value of Object.values(fixtures)) { | ||
expect(() => t.isUnknown(value)).not.toThrow(); | ||
} | ||
}); | ||
test("isNotNull", () => { | ||
@@ -58,0 +65,0 @@ const v = orNull(fixtures.string); |
@@ -36,2 +36,6 @@ const expectedToBe = (type: string): string => `expected to be ${type}`; | ||
export function isUnknown(_input: unknown): _input is unknown { | ||
return true; | ||
} | ||
export function isNotNull<T>( | ||
@@ -38,0 +42,0 @@ input: null | T, |
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
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
129749
1232