@wixc3/typescript
Advanced tools
Comparing version 3.0.7 to 3.1.0
@@ -28,3 +28,2 @@ "use strict"; | ||
/* eslint-disable @typescript-eslint/unbound-method */ | ||
/* eslint-disable @typescript-eslint/no-unsafe-assignment */ | ||
const common_1 = require("@wixc3/common"); | ||
@@ -41,4 +40,2 @@ const path_1 = require("path"); | ||
const host = ts.createCompilerHost(options, true); | ||
// eslint-disable-next-line @typescript-eslint/unbound-method | ||
const { readFile } = host; | ||
host.readFile = (path) => { | ||
@@ -49,3 +46,3 @@ if (path === fakePath) { | ||
else { | ||
return readFile(path); | ||
return ''; | ||
} | ||
@@ -52,0 +49,0 @@ }; |
@@ -19,3 +19,3 @@ import type * as ts from 'typescript'; | ||
*/ | ||
export declare function isSame(a?: ts.Node, b?: ts.Node, ignore?: Predicate<ts.Node | undefined>): boolean; | ||
export declare function isSame(a?: ts.Node, b?: ts.Node, ignore?: Predicate<ts.Node | undefined>, reportDiff?: (a?: string, b?: string) => void): boolean; | ||
//# sourceMappingURL=match.d.ts.map |
@@ -46,3 +46,3 @@ "use strict"; | ||
*/ | ||
function isSame(a, b, ignore = () => false) { | ||
function isSame(a, b, ignore = () => false, reportDiff = () => void 0) { | ||
if (ignore(a) || ignore(b)) { | ||
@@ -60,2 +60,3 @@ return true; | ||
if (!isSame(aChildren[i], bChildren[i], ignore)) { | ||
reportDiff(aChildren[i]?.getText(), bChildren[i]?.getText()); | ||
return false; | ||
@@ -66,2 +67,3 @@ } | ||
else { | ||
reportDiff(a.getText(), b.getText()); | ||
return false; | ||
@@ -71,2 +73,3 @@ } | ||
} | ||
reportDiff(a?.getText(), b?.getText()); | ||
return false; | ||
@@ -73,0 +76,0 @@ } |
/* eslint-disable @typescript-eslint/unbound-method */ | ||
/* eslint-disable @typescript-eslint/no-unsafe-assignment */ | ||
import { isString } from '@wixc3/common'; | ||
@@ -14,4 +13,2 @@ import { dirname, join } from 'path'; | ||
const host = ts.createCompilerHost(options, true); | ||
// eslint-disable-next-line @typescript-eslint/unbound-method | ||
const { readFile } = host; | ||
host.readFile = (path) => { | ||
@@ -22,3 +19,3 @@ if (path === fakePath) { | ||
else { | ||
return readFile(path); | ||
return ''; | ||
} | ||
@@ -25,0 +22,0 @@ }; |
@@ -19,3 +19,3 @@ import type * as ts from 'typescript'; | ||
*/ | ||
export declare function isSame(a?: ts.Node, b?: ts.Node, ignore?: Predicate<ts.Node | undefined>): boolean; | ||
export declare function isSame(a?: ts.Node, b?: ts.Node, ignore?: Predicate<ts.Node | undefined>, reportDiff?: (a?: string, b?: string) => void): boolean; | ||
//# sourceMappingURL=match.d.ts.map |
@@ -42,3 +42,3 @@ import { compileCode } from './compile'; | ||
*/ | ||
export function isSame(a, b, ignore = () => false) { | ||
export function isSame(a, b, ignore = () => false, reportDiff = () => void 0) { | ||
if (ignore(a) || ignore(b)) { | ||
@@ -56,2 +56,3 @@ return true; | ||
if (!isSame(aChildren[i], bChildren[i], ignore)) { | ||
reportDiff(aChildren[i]?.getText(), bChildren[i]?.getText()); | ||
return false; | ||
@@ -62,2 +63,3 @@ } | ||
else { | ||
reportDiff(a.getText(), b.getText()); | ||
return false; | ||
@@ -67,4 +69,5 @@ } | ||
} | ||
reportDiff(a?.getText(), b?.getText()); | ||
return false; | ||
} | ||
//# sourceMappingURL=match.js.map |
{ | ||
"name": "@wixc3/typescript", | ||
"version": "3.0.7", | ||
"version": "3.1.0", | ||
"description": "API ", | ||
@@ -5,0 +5,0 @@ "main": "dist/cjs/index.js", |
@@ -23,3 +23,3 @@ [![npm version](https://badge.fury.io/js/@wixc3%2Ftypescript.svg)](https://badge.fury.io/js/@wixc3%2Ftypescript) | ||
| [getTsConfigCompilerOptions(tsConfigJsonPath)](https://wixplosives.github.io/core3-utils/typescript.gettsconfigcompileroptions) | Calculates the effective tsconfig compiler options | | ||
| [isSame(a, b, ignore)](https://wixplosives.github.io/core3-utils/typescript.issame) | Compared 2 code snippet (or ASTs) | | ||
| [isSame(a, b, ignore, reportDiff)](https://wixplosives.github.io/core3-utils/typescript.issame) | Compared 2 code snippet (or ASTs) | | ||
| [match(code, pattern)](https://wixplosives.github.io/core3-utils/typescript.match) | <p>Finds a node matching the pattern. The pattern is a valid TS statement</p><p>It may include:</p><p>- //\[ignore\] to skip some of its structure,</p><p>- //\[return\] to return an inner node instead of the root</p> | | ||
@@ -26,0 +26,0 @@ |
/* eslint-disable @typescript-eslint/unbound-method */ | ||
/* eslint-disable @typescript-eslint/no-unsafe-assignment */ | ||
import { isString } from '@wixc3/common'; | ||
@@ -16,4 +15,2 @@ import { dirname, join } from 'path'; | ||
const host = ts.createCompilerHost(options, true); | ||
// eslint-disable-next-line @typescript-eslint/unbound-method | ||
const { readFile } = host; | ||
host.readFile = (path) => { | ||
@@ -23,3 +20,3 @@ if (path === fakePath) { | ||
} else { | ||
return readFile(path); | ||
return ''; | ||
} | ||
@@ -26,0 +23,0 @@ }; |
@@ -46,3 +46,8 @@ import type * as ts from 'typescript'; | ||
*/ | ||
export function isSame(a?: ts.Node, b?: ts.Node, ignore: Predicate<ts.Node | undefined> = () => false) { | ||
export function isSame( | ||
a?: ts.Node, | ||
b?: ts.Node, | ||
ignore: Predicate<ts.Node | undefined> = () => false, | ||
reportDiff: (a?: string, b?: string) => void = () => void 0 | ||
) { | ||
if (ignore(a) || ignore(b)) { | ||
@@ -60,2 +65,3 @@ return true; | ||
if (!isSame(aChildren[i], bChildren[i], ignore)) { | ||
reportDiff(aChildren[i]?.getText(), bChildren[i]?.getText()); | ||
return false; | ||
@@ -65,2 +71,3 @@ } | ||
} else { | ||
reportDiff(a.getText(), b.getText()); | ||
return false; | ||
@@ -70,3 +77,4 @@ } | ||
} | ||
reportDiff(a?.getText(), b?.getText()); | ||
return false; | ||
} |
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
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
61771
1042