Skip to content

Commit e816d7b

Browse files
committed
Fixed module export and import
1 parent 3eea06e commit e816d7b

File tree

6 files changed

+8
-15
lines changed

6 files changed

+8
-15
lines changed

dist/index.js

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,3 @@
1-
"use strict";
2-
Object.defineProperty(exports, "__esModule", { value: true });
3-
exports.testDiff = void 0;
41
function testValue(value1, value2) {
52
if ((typeof value1) !== (typeof value2))
63
return true;
@@ -11,7 +8,7 @@ function testValue(value1, value2) {
118
return false;
129
}
1310
// Returns true if obj1 differs in any way from obj2.
14-
function testDiff(obj1, obj2, deep) {
11+
export default function testDiff(obj1, obj2, deep) {
1512
if (deep === void 0) { deep = true; }
1613
if ((obj1 === null) || (obj2 === null) || ((typeof obj1) !== "object") || ((typeof obj2) !== "object"))
1714
return testValue(obj1, obj2);
@@ -71,4 +68,3 @@ function testDiff(obj1, obj2, deep) {
7168
}
7269
return false;
7370
}
74-
exports.testDiff = testDiff;

dist/lib/unitTest.js

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,6 @@
1-
"use strict";
2-
Object.defineProperty(exports, "__esModule", { value: true });
3-
exports.unitTest = void 0;
41
// Low budget unit tests instead of Jasmine or Chai
52
// Isolates between invocations. Safely contains everything that can go wrong.
6-
function unitTest(description, testFunction) {
3+
export default function unitTest(description, testFunction) {
74
var testLog = ["Test: ".concat(description, ":")];
85
var expectQueue = [];
96
var Expectation = /** @class */ (function () {
@@ -58,4 +55,3 @@ function unitTest(description, testFunction) {
5855
testLog.push("\t\uD83D\uDFE2 Tests PASSED in ".concat(totalTime, "ms."));
5956
console.log(testLog.join("\n") + "\n");
6057
}
61-
exports.unitTest = unitTest;

package.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,12 @@
11
{
22
"name": "js-testdiff",
3+
"type": "module",
34
"version": "1.0.0",
45
"description": "The \"testDiff\" deep diff/test function from Differentia.js, ported to TypeScript. Returns true if input 1 differs in any way from input 2. Performs deep object search by default, works OK with circular references.",
56
"main": "dist/index.js",
67
"scripts": {
78
"test": "npm run build",
8-
"build": "tsc src/index.ts src/lib/unitTest.ts --lib es2016 --outDir dist/ && node test.mjs"
9+
"build": "tsc src/index.ts src/lib/unitTest.ts --module es6 --lib es6 --outDir dist/ && node test.mjs"
910
},
1011
"repository": {
1112
"type": "git",

src/index.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ function testValue(value1:Primitive, value2:Primitive):boolean {
1111
return false;
1212
}
1313
// Returns true if obj1 differs in any way from obj2.
14-
export function testDiff(obj1:searchObj, obj2:searchObj, deep:boolean = true):boolean {
14+
export default function testDiff(obj1:searchObj, obj2:searchObj, deep:boolean = true):boolean {
1515
if((obj1 === null) || (obj2 === null) || ((typeof obj1) !== "object") || ((typeof obj2) !== "object"))
1616
return testValue(obj1, obj2);
1717
const stack:Array<objPair> = [{ obj1: obj1, obj2: obj2 }];

src/lib/unitTest.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
// Low budget unit tests instead of Jasmine or Chai
22
// Isolates between invocations. Safely contains everything that can go wrong.
3-
export function unitTest (description:string, testFunction:Function):void {
3+
export default function unitTest (description:string, testFunction:Function):void {
44
const testLog:Array<string> = [`Test: ${description}:`];
55
const expectQueue:Array<Function> = [];
66
class Expectation {

test.mjs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1-
import { testDiff } from "./dist/index.js";
2-
import { unitTest } from "./dist/lib/unitTest.js";
1+
import testDiff from "./dist/index.js";
2+
import unitTest from "./dist/lib/unitTest.js";
33
// Generic "user data" test object which contains a broad variety of object structures and data types.
44
function createTestObject() {
55
return [

0 commit comments

Comments
 (0)