Skip to content

Instantly share code, notes, and snippets.

@Raynos
Created May 28, 2020 10:20
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Raynos/2c6bb0a8537dbf7d464a9b85813cd3b1 to your computer and use it in GitHub Desktop.
Save Raynos/2c6bb0a8537dbf7d464a9b85813cd3b1 to your computer and use it in GitHub Desktop.
Cannot require ESM
const isPromise = import('./third-party-is-promise.mjs')
console.log(typeof isPromise)
console.log('then method', typeof isPromise.then)
const isPromise = require('./third-party-is-promise.mjs')
console.log(typeof isPromise)
{
"name": "temp123",
"version": "1.0.0",
"description": "",
"main": "index.js",
"scripts": {
"test": "echo \"Error: no test specified\" && exit 1"
},
"author": "",
"license": "ISC"
}
export default function isPromise(obj) {
return !!obj && (typeof obj === 'object' || typeof obj === 'function') && typeof obj.then === 'function';
}
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