Promise在被export输出后失去了.then()方法


p = new Promise((resolve,reject)=>{
	console.log('in promise');
	resolve('fuck');
	}).catch((error)=>{
		console.log('error in fuckingPromise');
		console.log(error);
	});
p.then(console.log('dammn it'))
console.log(p.toString());
// (async ()=>{
// 	p.then((value)=>{
// 		console.log(value);  // 'fuck'
// 	}).catch((error)=>{
// 		console.log('error in motherfucker')
// 		console.log(error);
// 	})
// })
// ()

module.export = p



输出:

in promise
dammn it
[object Promise]
[Finished in 0.2s]

p = require('./fuckingPromise.js');

console.log(p.toString());

function lala(p){
	console.log(typeof p);
	p.then((value)=>{
		console.log(value);  // 'fuck'
	}).catch((error)=>{
		console.log('error in motherfucker')
		console.log(error);
	})
};

lala(p);

// (async (p)=>{
// 	p.then((value)=>{
// 		console.log(value);  // 'fuck'
// 	}).catch((error)=>{
// 		console.log('error in motherfucker')
// 		console.log(error);
// 	})
// })
// (p)

输出

in promise
dammn it
[object Promise]
[object Object]
object
/Users/jack/Desktop/promisemotherfucker.js:7
	p.then((value)=>{
	  ^

TypeError: p.then is not a function
    at lala (/Users/jack/Desktop/promisemotherfucker.js:7:4)
    at Object.<anonymous> (/Users/jack/Desktop/promisemotherfucker.js:15:1)
    at Module._compile (internal/modules/cjs/loader.js:1201:30)
    at Object.Module._extensions..js (internal/modules/cjs/loader.js:1221:10)
    at Module.load (internal/modules/cjs/loader.js:1050:32)
    at Function.Module._load (internal/modules/cjs/loader.js:938:14)
    at Function.executeUserEntryPoint [as runMain] (internal/modules/run_main.js:71:12)
    at internal/main/run_main_module.js:17:47
[Finished in 0.1s with exit code 1]
[shell_cmd: killall node; /usr/bin/env node /Users/jack/Desktop/promisemotherfucker.js]
[dir: /Users/jack/Desktop]
[path: /Library/Frameworks/Python.framework/Versions/3.8/bin:/Users/jack/Library/Python/3.7/bin:/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin:/usr/local/share/dotnet:~/.dotnet/tools:/Library/Frameworks/Mono.framework/Versions/Current/Commands:/usr/local/mysql/bin:/usr/local/mysql/support-files]

真tm操蛋

posted @ 2020-08-25 17:01  Bravo_Jack  阅读(370)  评论(0编辑  收藏  举报