1
0
mirror of https://github.com/kamyu1537/eamuse-card-wasm.git synced 2024-11-24 03:50:10 +01:00

🏷 @ts-ignore 제거

This commit is contained in:
Byeon Seongun 2020-05-14 21:48:06 +09:00
parent 37df2db7a5
commit 85642b7af5
No known key found for this signature in database
GPG Key ID: DA5BD8E6CBC00CC3
2 changed files with 18 additions and 7 deletions

View File

@ -965,7 +965,7 @@ func jsDecode(_ js.Value, inputs []js.Value) interface{} {
func main() { func main() {
c := make(chan bool) c := make(chan bool)
js.Global().Set("KONAMI_CARD_ENCODE", js.FuncOf(jsEncode)) js.Global().Set("__konami_card_encode", js.FuncOf(jsEncode))
js.Global().Set("KONAMI_CARD_DECODE", js.FuncOf(jsDecode)) js.Global().Set("__konami_card_decode", js.FuncOf(jsDecode))
<-c <-c
} }

View File

@ -11,9 +11,13 @@ crypto['getRandomValues'] = (buf: Array<number> | Uint8Array | Buffer): Uint8Arr
return buf; return buf;
}; };
declare class Go {
public importObject: any;
run(instance: WebAssembly.Instance): Promise<any>
}
require('./wasm_exec'); require('./wasm_exec');
//@ts-ignore
const go = new Go(); const go = new Go();
const path = require('path').join(__dirname, 'konami-card.wasm'); const path = require('path').join(__dirname, 'konami-card.wasm');
const bytes = require('fs').readFileSync(path); const bytes = require('fs').readFileSync(path);
@ -21,10 +25,18 @@ const wasmModule = new WebAssembly.Module(bytes);
const wasmInstance = new WebAssembly.Instance(wasmModule, go.importObject); const wasmInstance = new WebAssembly.Instance(wasmModule, go.importObject);
go.run(wasmInstance).then(); go.run(wasmInstance).then();
declare global {
namespace NodeJS {
interface Global {
__konami_card_encode(nfcId: string, func: (result: string) => void): void;
__konami_card_decode(cardId: string, func: (result: string) => void): void;
}
}
}
export const encode = function(nfcId: string): Promise<string> { export const encode = function(nfcId: string): Promise<string> {
return new Promise((resolve) => { return new Promise((resolve) => {
// @ts-ignore global.__konami_card_encode(nfcId, function(result: string) {
KONAMI_CARD_ENCODE(nfcId, function(result: string) {
resolve(result); resolve(result);
}); });
}); });
@ -32,8 +44,7 @@ export const encode = function(nfcId: string): Promise<string> {
export const decode = function(cardId: string): Promise<string> { export const decode = function(cardId: string): Promise<string> {
return new Promise((resolve) => { return new Promise((resolve) => {
// @ts-ignore global.__konami_card_decode(cardId, function(result: string) {
KONAMI_CARD_DECODE(cardId, function(result: string) {
resolve(result); resolve(result);
}); });
}); });