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.1.2 to 0.1.3

tsconfig.production.json

2

dist/scan/index.d.ts

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

export declare const scan: <T>(value: T, condition: (value: unknown) => value is T, callback?: ((value: unknown) => void) | undefined) => T;
export declare const scan: <T>(value: unknown, condition: (value: unknown) => value is T, handleError?: ((value: unknown) => void) | undefined) => T;
"use strict";
exports.__esModule = true;
exports.scan = void 0;
var scan = function (value, condition, callback) {
var scan = function (value, condition, handleError) {
if (condition(value))
return value;
if (callback)
callback(value);
if (handleError)
handleError(value);
throw new Error("type assertion is failed. (value: " + value + ")");

@@ -10,0 +10,0 @@ };

{
"name": "typescanner",
"version": "0.1.2",
"version": "0.1.3",
"description": "A simple library for implementing type guards in TypeScript.",

@@ -26,3 +26,3 @@ "author": "yona3",

"dev": "ts-node-dev --respawn src/index.ts",
"build": "tsc",
"build": "tsc -p tsconfig.production.json",
"test": "jest"

@@ -29,0 +29,0 @@ },

export const scan = <T>(
value: T,
value: unknown,
condition: (value: unknown) => value is T,
callback?: (value: unknown) => void
handleError?: (value: unknown) => void
): T => {
if (condition(value)) return value;
if (callback) callback(value);
if (handleError) handleError(value);
throw new Error(`type assertion is failed. (value: ${value})`);
};

@@ -15,3 +15,3 @@ import {

describe("scan test", () => {
const lang = {
const Lang = {
ja: "ja",

@@ -21,4 +21,4 @@ en: "en",

type Lang = keyof typeof lang;
const langList = Object.values(lang);
type Lang = typeof Lang[keyof typeof Lang];
const langList = Object.values(Lang);

@@ -25,0 +25,0 @@ type Post = {

@@ -16,3 +16,3 @@ {

"include": ["src/**/*.ts", ".eslintrc.js"],
"exclude": ["node_modules", "dist", "src/**/*.spec.ts"]
"exclude": ["node_modules", "dist"]
}

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