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

ts-auto-guard

Package Overview
Dependencies
Maintainers
2
Versions
48
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

ts-auto-guard - npm Package Compare versions

Comparing version 2.4.1 to 3.0.0

6

lib/index.js

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

var secondArgument = debug
? "argumentName: string = \"" + defaultArgumentName + "\""
: "_argumentName?: string";
var signature = "export function " + functionName + "(obj: any, " + secondArgument + "): obj is " + typeName + " {\n";
? ", argumentName: string = \"" + defaultArgumentName + "\""
: '';
var signature = "export function " + functionName + "(obj: any" + secondArgument + "): obj is " + typeName + " {\n";
var shortCircuit = shortCircuitCondition

@@ -559,0 +559,0 @@ ? "if (" + shortCircuitCondition + ") return true\n"

{
"name": "ts-auto-guard",
"version": "2.4.1",
"version": "3.0.0",
"description": "Generate type guard functions from TypeScript interfaces",

@@ -5,0 +5,0 @@ "homepage": "https://github.com/rhys-vdw/ts-auto-guard",

@@ -140,3 +140,3 @@ import test from 'tape'

export function isEmpty(obj: any, _argumentName?: string): obj is Empty {
export function isEmpty(obj: any): obj is Empty {
return (

@@ -164,3 +164,3 @@ (obj !== null &&

export function isBool(obj: any, _argumentName?: string): obj is Bool {
export function isBool(obj: any): obj is Bool {
return (

@@ -185,3 +185,3 @@ typeof obj === "boolean"

export function isBool(obj: any, _argumentName?: string): obj is Bool {
export function isBool(obj: any): obj is Bool {
return (

@@ -209,3 +209,3 @@ typeof obj === "boolean"

export function isFoo(obj: any, _argumentName?: string): obj is Foo {
export function isFoo(obj: any): obj is Foo {
return (

@@ -227,7 +227,6 @@ (obj !== null &&

const PATH_PREFIX = process.cwd().slice(1) // Remove / from the beginning
testProcessProject(
'show debug info',
{
[`${PATH_PREFIX}/foo/bar/test.ts`]: `
[`foo/bar/test.ts`]: `
/** @see {isFoo} ts-auto-guard:type-guard */

@@ -248,4 +247,4 @@ export interface Foo {

{
[`${PATH_PREFIX}/foo/bar/test.ts`]: null,
[`${PATH_PREFIX}/foo/bar/test.guard.ts`]: `
[`foo/bar/test.ts`]: null,
[`foo/bar/test.guard.ts`]: `
import { Foo, Bar } from "./test";

@@ -274,7 +273,7 @@

evaluate(typeof obj.foo === "number", \`\${argumentName}.foo\`, "number", obj.foo) &&
evaluate(isBar(obj.bar) as boolean, \`\${argumentName}.bar\`, "import(\\"./foo/bar/test\\").Bar", obj.bar) &&
evaluate(isBar(obj.bar) as boolean, \`\${argumentName}.bar\`, "import(\\"/foo/bar/test\\").Bar", obj.bar) &&
evaluate(Array.isArray(obj.bars) &&
obj.bars.every((e: any) =>
isBar(e) as boolean
), \`\${argumentName}.bars\`, "import(\\"./foo/bar/test\\").Bar[]", obj.bars)
), \`\${argumentName}.bars\`, "import(\\"/foo/bar/test\\").Bar[]", obj.bars)
)

@@ -315,3 +314,3 @@ }

export function isFoo(obj: any, _argumentName?: string): obj is Foo {
export function isFoo(obj: any): obj is Foo {
return (

@@ -350,3 +349,3 @@ (obj !== null &&

export function isFoo(obj: any, _argumentName?: string): obj is Foo {
export function isFoo(obj: any): obj is Foo {
return (

@@ -398,3 +397,3 @@ (obj !== null &&

export function isFoo(obj: any, _argumentName?: string): obj is Foo {
export function isFoo(obj: any): obj is Foo {
return (

@@ -424,3 +423,3 @@ (obj !== null &&

export function isFoo(obj: any, _argumentName?: string): obj is Foo {
export function isFoo(obj: any): obj is Foo {
return (

@@ -452,3 +451,3 @@ (obj !== null &&

export function isFoo(obj: any, _argumentName?: string): obj is Foo {
export function isFoo(obj: any): obj is Foo {
return (

@@ -480,3 +479,3 @@ (obj !== null &&

export function isFoo(obj: any, _argumentName?: string): obj is Foo {
export function isFoo(obj: any): obj is Foo {
return (

@@ -506,3 +505,3 @@ (obj !== null &&

export function isFoo(obj: any, _argumentName?: string): obj is Foo {
export function isFoo(obj: any): obj is Foo {
return (

@@ -532,3 +531,3 @@ (obj !== null &&

export function isFoo(obj: any, _argumentName?: string): obj is Foo {
export function isFoo(obj: any): obj is Foo {
return (

@@ -561,3 +560,3 @@ (obj !== null &&

export function isFoo(obj: any, _argumentName?: string): obj is Foo {
export function isFoo(obj: any): obj is Foo {
return (

@@ -590,3 +589,3 @@ (obj !== null &&

export function isFoo(obj: any, _argumentName?: string): obj is Foo {
export function isFoo(obj: any): obj is Foo {
return (

@@ -625,3 +624,3 @@ (obj !== null &&

export function isFoo(obj: any, _argumentName?: string): obj is Foo {
export function isFoo(obj: any): obj is Foo {
return (

@@ -659,3 +658,3 @@ (obj !== null &&

export function isBar(obj: any, _argumentName?: string): obj is Bar {
export function isBar(obj: any): obj is Bar {
return (

@@ -669,3 +668,3 @@ (obj !== null &&

export function isFoo(obj: any, _argumentName?: string): obj is Foo {
export function isFoo(obj: any): obj is Foo {
return (

@@ -699,3 +698,3 @@ (obj !== null &&

export function isFoo(obj: any, _argumentName?: string): obj is Foo {
export function isFoo(obj: any): obj is Foo {
return (

@@ -731,3 +730,3 @@ (obj !== null &&

export function isBar(obj: any, _argumentName?: string): obj is Bar {
export function isBar(obj: any): obj is Bar {
return (

@@ -741,3 +740,3 @@ (obj !== null &&

export function isFoo(obj: any, _argumentName?: string): obj is Foo {
export function isFoo(obj: any): obj is Foo {
return (

@@ -769,3 +768,3 @@ isBar(obj) as boolean &&

export function isFoo(obj: any, _argumentName?: string): obj is Foo {
export function isFoo(obj: any): obj is Foo {
return (

@@ -801,3 +800,3 @@ (obj !== null &&

export function isBar(obj: any, _argumentName?: string): obj is Bar {
export function isBar(obj: any): obj is Bar {
return (

@@ -811,3 +810,3 @@ (obj !== null &&

export function isFoo(obj: any, _argumentName?: string): obj is Foo {
export function isFoo(obj: any): obj is Foo {
return (

@@ -835,3 +834,3 @@ isBar(obj) as boolean &&

export function isFoo(obj: any, _argumentName?: string): obj is Foo {
export function isFoo(obj: any): obj is Foo {
return (

@@ -864,3 +863,3 @@ (obj !== null &&

export function isFoo(obj: any, _argumentName?: string): obj is Foo {
export function isFoo(obj: any): obj is Foo {
return (

@@ -890,3 +889,3 @@ (obj !== null &&

export function isFoo(obj: any, _argumentName?: string): obj is Foo {
export function isFoo(obj: any): obj is Foo {
if (DEBUG) return true

@@ -919,3 +918,3 @@ return (

'test.ts': null,
'test.guard.ts': `"use strict";function isFoo(o,s){return!0}exports.__esModule=!0,exports.isFoo=void 0,exports.isFoo=isFoo;`,
'test.guard.ts': `"use strict";function isFoo(o){return!0}exports.__esModule=!0,exports.isFoo=void 0,exports.isFoo=isFoo;`,
},

@@ -950,3 +949,3 @@ {

export function isPropertyValueType(obj: any, _argumentName?: string): obj is PropertyValueType {
export function isPropertyValueType(obj: any): obj is PropertyValueType {
return (

@@ -960,3 +959,3 @@ (obj !== null &&

export function isPropertyName(obj: any, _argumentName?: string): obj is PropertyName {
export function isPropertyName(obj: any): obj is PropertyName {
return (

@@ -968,3 +967,3 @@ (obj === "name" ||

export function isFoo(obj: any, _argumentName?: string): obj is Foo {
export function isFoo(obj: any): obj is Foo {
return (

@@ -1001,3 +1000,3 @@ (obj !== null &&

export function isBranch1(obj: any, _argumentName?: string): obj is Branch1 {
export function isBranch1(obj: any): obj is Branch1 {
return (

@@ -1012,3 +1011,3 @@ (typeof obj === "string" ||

export function isBranch2(obj: any, _argumentName?: string): obj is Branch2 {
export function isBranch2(obj: any): obj is Branch2 {
return (

@@ -1026,3 +1025,3 @@ (typeof obj === "string" ||

export function isBranch3(obj: any, _argumentName?: string): obj is Branch3 {
export function isBranch3(obj: any): obj is Branch3 {
return (

@@ -1061,3 +1060,3 @@ (typeof obj === "string" ||

export function isX(obj: any, _argumentName?: string): obj is X {
export function isX(obj: any): obj is X {
return (

@@ -1095,3 +1094,3 @@ ((obj !== null &&

export function isTypes(obj: any, _argumentName?: string): obj is Types {
export function isTypes(obj: any): obj is Types {
return (

@@ -1125,3 +1124,3 @@ (obj === Types.TheGood ||

export function isTypes(obj: any, _argumentName?: string): obj is Types {
export function isTypes(obj: any): obj is Types {
return (

@@ -1134,3 +1133,3 @@ (obj === Types.TheGood ||

export function isTestItem(obj: any, _argumentName?: string): obj is TestItem {
export function isTestItem(obj: any): obj is TestItem {
return (

@@ -1169,3 +1168,3 @@ (obj !== null &&

export function isFoo(obj: any, _argumentName?: string): obj is Foo {
export function isFoo(obj: any): obj is Foo {
return (

@@ -1198,3 +1197,3 @@ (obj !== null &&

export function isFoo(obj: any, _argumentName?: string): obj is Foo {
export function isFoo(obj: any): obj is Foo {
return (

@@ -1235,3 +1234,3 @@ (obj !== null &&

export function isTestType(obj: any, _argumentName?: string): obj is TestType {
export function isTestType(obj: any): obj is TestType {
return (

@@ -1246,3 +1245,3 @@ (obj !== null &&

export function isSecondaryTestType(obj: any, _argumentName?: string): obj is SecondaryTestType {
export function isSecondaryTestType(obj: any): obj is SecondaryTestType {
return (

@@ -1282,3 +1281,3 @@ (obj !== null &&

export function isEmpty(obj: any, _argumentName?: string): obj is Empty {
export function isEmpty(obj: any): obj is Empty {
return (

@@ -1317,3 +1316,3 @@ (obj !== null &&

export function isTestTypeList(obj: any, _argumentName?: string): obj is TestTypeList {
export function isTestTypeList(obj: any): obj is TestTypeList {
return (

@@ -1330,3 +1329,3 @@ Array.isArray(obj) &&

export function isTestType(obj: any, _argumentName?: string): obj is TestType {
export function isTestType(obj: any): obj is TestType {
return (

@@ -1361,3 +1360,3 @@ (obj !== null &&

export function isTestType(obj: any, _argumentName?: string): obj is TestType {
export function isTestType(obj: any): obj is TestType {
return (

@@ -1396,3 +1395,3 @@ (obj !== null &&

export function isTestType(obj: any, _argumentName?: string): obj is TestType {
export function isTestType(obj: any): obj is TestType {
return (

@@ -1427,3 +1426,3 @@ (obj !== null &&

export function isTestType(obj: any, _argumentName?: string): obj is TestType {
export function isTestType(obj: any): obj is TestType {
return (

@@ -1456,3 +1455,3 @@ (obj !== null &&

export function isTestType(obj: any, _argumentName?: string): obj is TestType {
export function isTestType(obj: any): obj is TestType {
return (

@@ -1493,3 +1492,3 @@ (obj !== null &&

export function isTestType(obj: any, _argumentName?: string): obj is TestType {
export function isTestType(obj: any): obj is TestType {
return (

@@ -1522,3 +1521,3 @@ (obj !== null &&

export function isTestType(obj: any, _argumentName?: string): obj is TestType {
export function isTestType(obj: any): obj is TestType {
return (

@@ -1557,3 +1556,3 @@ (obj !== null &&

export function isTestType(obj: any, _argumentName?: string): obj is TestType {
export function isTestType(obj: any): obj is TestType {
return (

@@ -1590,3 +1589,3 @@ (obj !== null &&

export function isTestType(obj: any, _argumentName?: string): obj is TestType {
export function isTestType(obj: any): obj is TestType {
return (

@@ -1613,3 +1612,3 @@ typeof obj === "function" &&

export function isX(obj: any, _argumentName?: string): obj is X {
export function isX(obj: any): obj is X {
return (

@@ -1643,3 +1642,3 @@ (obj !== null &&

export function isA(obj: any, _argumentName?: string): obj is A {
export function isA(obj: any): obj is A {
return (

@@ -1667,3 +1666,3 @@ (obj !== null &&

export function isA(obj: any, _argumentName?: string): obj is A {
export function isA(obj: any): obj is A {
return (

@@ -1687,3 +1686,3 @@ Array.isArray(obj)

export function isA(obj: any, _argumentName?: string): obj is A {
export function isA(obj: any): obj is A {
return (

@@ -1707,3 +1706,3 @@ true

export function isA(obj: any, _argumentName?: string): obj is A {
export function isA(obj: any): obj is A {
return (

@@ -1733,3 +1732,3 @@ true

export function isAnyOrString(obj: any, _argumentName?: string): obj is AnyOrString {
export function isAnyOrString(obj: any): obj is AnyOrString {
return (

@@ -1740,3 +1739,3 @@ true

export function isUnknownOrString(obj: any, _argumentName?: string): obj is UnknownOrString {
export function isUnknownOrString(obj: any): obj is UnknownOrString {
return (

@@ -1747,3 +1746,3 @@ true

export function isAnyOrUnknownOrString(obj: any, _argumentName?: string): obj is AnyOrUnknownOrString {
export function isAnyOrUnknownOrString(obj: any): obj is AnyOrUnknownOrString {
return (

@@ -1773,3 +1772,3 @@ true

export function isAnyAndString(obj: any, _argumentName?: string): obj is AnyAndString {
export function isAnyAndString(obj: any): obj is AnyAndString {
return (

@@ -1780,3 +1779,3 @@ true

export function isUnknownAndString(obj: any, _argumentName?: string): obj is UnknownAndString {
export function isUnknownAndString(obj: any): obj is UnknownAndString {
return (

@@ -1787,3 +1786,3 @@ typeof obj === "string"

export function isAnyAndUnknownAndString(obj: any, _argumentName?: string): obj is AnyAndUnknownAndString {
export function isAnyAndUnknownAndString(obj: any): obj is AnyAndUnknownAndString {
return (

@@ -1790,0 +1789,0 @@ true

@@ -73,3 +73,3 @@ import test from 'tape'

export function isFoo(obj: any, _argumentName?: string): obj is Foo {
export function isFoo(obj: any): obj is Foo {
return (

@@ -97,3 +97,3 @@ (obj !== null &&

export function isFoo(obj: any, _argumentName?: string): obj is Foo {
export function isFoo(obj: any): obj is Foo {
return (

@@ -117,3 +117,3 @@ (obj !== null &&

export function isFoo(obj: any, _argumentName?: string): obj is Foo {
export function isFoo(obj: any): obj is Foo {
return (

@@ -139,3 +139,3 @@ (obj !== null &&

export function isFoo(obj: any, _argumentName?: string): obj is Foo {
export function isFoo(obj: any): obj is Foo {
return (

@@ -161,3 +161,3 @@ (obj !== null &&

export function isFoo(obj: any, _argumentName?: string): obj is Foo {
export function isFoo(obj: any): obj is Foo {
return (

@@ -164,0 +164,0 @@ (obj !== null &&

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