math.js module just for npx execute gist js module testing!
Last active
May 8, 2022 09:32
-
-
Save xgqfrms/1981c08fcb7e09056e1c5d9192f272c8 to your computer and use it in GitHub Desktop.
math.js module just for npx execute gist js module testing!
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
#!/usr/bin/env node | |
// math.js & `bin` package.json | |
console.log('math.js 👻'); | |
const add = (a, b) => { | |
return a + b; | |
} | |
const math = { | |
add, | |
}; | |
// test case | |
const result = add(1, 2); | |
console.log('result =', result, result === (1 + 2) ? '✅' : '❌'); | |
// ESM | |
// export default math; | |
// Declaration or statement expected.ts(1128) ❌ | |
// export math; | |
// CJS | |
// module.exports.add = add; | |
module.exports = math; |
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
{ | |
"version": "0.0.4", | |
"name": "math.js", | |
"author": "xgqfrms", | |
"main": "./math.js", | |
"bin": "./math.js" | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
how to use gist as an npm module ✅
create one gist,
readme.md
or whatever filenameedit gist
add file
https://www.cnblogs.com/xgqfrms/p/16246009.html