Skip to content

Instantly share code, notes, and snippets.

@hawkrives
Last active October 20, 2024 17:12
Show Gist options
  • Select an option

  • Save hawkrives/17a2d54ddb3614197931 to your computer and use it in GitHub Desktop.

Select an option

Save hawkrives/17a2d54ddb3614197931 to your computer and use it in GitHub Desktop.
6to5 _interopRequire and node `exports`
let coursesAtOrAboveLevel = (level, course) => (course.level >= level)
export {coursesAtOrAboveLevel}
// test/courseLevels.test.js
import courseLevels from './src'
let coursesAtOrAboveLevel = courseLevels.coursesAtOrAboveLevel
assert(coursesAtOrAboveLevel(200, {level: 200}) === true)
@hawkrives

Copy link
Copy Markdown
Author

When run (6to5-node test.js), you would expect to be able to read the coursesAtOrAboveLevel property off the imported object.

You can't; node dies with

let coursesAtOrAboveLevel = courseLevels.coursesAtOrAboveLevel
                                        ^
TypeError: Cannot read property 'coursesAtOrAboveLevel' of undefined

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment