Created
May 28, 2020 10:20
-
-
Save Raynos/2c6bb0a8537dbf7d464a9b85813cd3b1 to your computer and use it in GitHub Desktop.
Cannot require ESM
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
const isPromise = import('./third-party-is-promise.mjs') | |
console.log(typeof isPromise) | |
console.log('then method', typeof isPromise.then) | |
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
const isPromise = require('./third-party-is-promise.mjs') | |
console.log(typeof isPromise) |
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
{ | |
"name": "temp123", | |
"version": "1.0.0", | |
"description": "", | |
"main": "index.js", | |
"scripts": { | |
"test": "echo \"Error: no test specified\" && exit 1" | |
}, | |
"author": "", | |
"license": "ISC" | |
} |
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
export default function isPromise(obj) { | |
return !!obj && (typeof obj === 'object' || typeof obj === 'function') && typeof obj.then === 'function'; | |
} |
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
import isPromise from './third-party-is-promise.mjs' | |
console.log(typeof isPromise) | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment