-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
e82dcb0
commit dc466e9
Showing
4 changed files
with
86 additions
and
66 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
const { TeleportSingleton } = require("../lib/index"); | ||
|
||
|
||
(function(){ | ||
|
||
|
||
// Arrange | ||
const teleport = TeleportSingleton.getInstance(); | ||
const eventNames = ['event1', 'event2', 'event3']; | ||
const expectedData = ['Data 1', 'Data 2', 'Data 3']; | ||
let receivedData = []; | ||
|
||
// Act | ||
setTimeout(() => { | ||
teleport.multiReceive(eventNames, (...data) => { | ||
receivedData = data; | ||
console.log(data); | ||
}); | ||
}, 1000); | ||
|
||
eventNames.forEach((eventName, index) => { | ||
teleport.emit(eventName, expectedData[index]); | ||
}); | ||
|
||
|
||
console.log(expectedData, receivedData); | ||
}()) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,46 +1,44 @@ | ||
{ | ||
"compilerOptions": { | ||
"baseUrl": ".", | ||
"outDir": "lib", // 输出目录 | ||
"sourceMap": false, // 是否生成sourceMap | ||
"target": "ES2015", // 编译目标 | ||
"module": "CommonJS", // 模块类型 | ||
"moduleResolution": "node", | ||
"allowJs": false, // 是否编辑js文件 | ||
"strict": true, // 严格模式 | ||
"noUnusedLocals": true, // 未使用变量报错 | ||
"experimentalDecorators": true, // 启动装饰器 | ||
"resolveJsonModule": true, // 加载json | ||
"esModuleInterop": true, | ||
// "removeComments": false, // 删除注释 | ||
|
||
|
||
"declaration": true, // 生成定义文件 | ||
"declarationMap": false, // 生成定义sourceMap | ||
"compilerOptions": { | ||
"baseUrl": ".", | ||
"outDir": "lib", // 输出目录 | ||
"sourceMap": false, // 是否生成sourceMap | ||
"target": "ES2015", // 编译目标 | ||
"module": "CommonJS", // 模块类型 | ||
"moduleResolution": "node", | ||
"allowJs": false, // 是否编辑js文件 | ||
"strict": true, // 严格模式 | ||
"noUnusedLocals": true, // 未使用变量报错 | ||
"experimentalDecorators": true, // 启动装饰器 | ||
"resolveJsonModule": true, // 加载json | ||
"esModuleInterop": true, | ||
// "removeComments": false, // 删除注释 | ||
"declaration": true, // 生成定义文件 | ||
"declarationMap": false, // 生成定义sourceMap | ||
// "declarationDir": "./dist/types", // 定义文件输出目录 | ||
|
||
|
||
"noImplicitAny": true, | ||
"strictNullChecks": true, | ||
"strictFunctionTypes": true, | ||
"strictBindCallApply": true, | ||
"strictPropertyInitialization": true, | ||
"noImplicitThis": true, | ||
"alwaysStrict": true, | ||
"noUnusedParameters": true, | ||
"noImplicitReturns": true, | ||
"noFallthroughCasesInSwitch": true, | ||
"noUncheckedIndexedAccess": true, | ||
"noImplicitOverride": true, | ||
"noPropertyAccessFromIndexSignature": true, | ||
"forceConsistentCasingInFileNames": true, | ||
"skipLibCheck": true, | ||
}, | ||
"include": [ | ||
"src/*", // 导入目录 | ||
"**/*.ts" | ||
], | ||
"exclude": [ | ||
"node_modules", "**/__tests__/*", "./lib/**/*" | ||
] | ||
"noImplicitAny": true, | ||
"strictNullChecks": true, | ||
"strictFunctionTypes": true, | ||
"strictBindCallApply": true, | ||
"strictPropertyInitialization": true, | ||
"noImplicitThis": true, | ||
"alwaysStrict": true, | ||
"noUnusedParameters": true, | ||
"noImplicitReturns": true, | ||
"noFallthroughCasesInSwitch": true, | ||
"noUncheckedIndexedAccess": true, | ||
"noImplicitOverride": true, | ||
"noPropertyAccessFromIndexSignature": true, | ||
"forceConsistentCasingInFileNames": true, | ||
"skipLibCheck": true, | ||
}, | ||
"include": [ | ||
"src/*", // 导入目录 | ||
"**/*.ts" | ||
], | ||
"exclude": [ | ||
"node_modules", | ||
"**/__tests__/*", | ||
"./lib/**/*" | ||
] | ||
} |