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

typescanner

Package Overview
Dependencies
Maintainers
1
Versions
18
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

typescanner - npm Package Compare versions

Comparing version 0.3.4 to 0.4.0

3

dist/scan/index.d.ts

@@ -1,1 +0,2 @@

export declare const scan: <T>(value: unknown, condition: (value: unknown) => value is T) => T;
import type { Condition } from "../types";
export declare const scan: <T>(value: unknown, condition: Condition<T>) => T;
import type { Condition } from "../types";
export declare const scanner: <T extends Record<string, unknown>>(fields: { [K in keyof Required<T>]: Condition<T[K]> | Condition<T[K]>[]; }) => (value: unknown) => value is T;
export declare const scanner: <T extends Record<string, unknown>>(fields: { [K in keyof Required<T>]: Condition<T[K]> | Condition<T[K]>[]; }, option?: {
isUseWithUnion: boolean;
} | undefined) => Condition<T>;

@@ -5,3 +5,3 @@ "use strict";

var typeGuard_1 = require("../typeGuard");
var scanner = function (fields) {
var scanner = function (fields, option) {
return function (value) {

@@ -12,2 +12,3 @@ // check each value

var key = _a[0], condition = _a[1];
// if union type or not
var isMeet = Array.isArray(condition)

@@ -18,2 +19,5 @@ ? condition.some(function (cond) { return cond(value[key]); })

return true;
// if use with union, return false
if (option === null || option === void 0 ? void 0 : option.isUseWithUnion)
return false;
throw new Error("value." + key + " does not meet the condition.");

@@ -23,2 +27,5 @@ });

return true;
// if use with union, return false
if (option === null || option === void 0 ? void 0 : option.isUseWithUnion)
return false;
throw new Error("value does not meet the condition.");

@@ -25,0 +32,0 @@ };

{
"name": "typescanner",
"version": "0.3.4",
"version": "0.4.0",
"description": "A simple library for implementing type guard in TypeScript.",

@@ -5,0 +5,0 @@ "author": "yona3",

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