Skip to content

Commit 4371404

Browse files
committed
Fixing module imports. Using requires.
1 parent 0a2b4e7 commit 4371404

File tree

4 files changed

+14
-14
lines changed

4 files changed

+14
-14
lines changed

README.md

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2,37 +2,37 @@
22
Npm package for async math operations.
33

44
## Introduction
5-
Stop writing archaic, boring code.
5+
Stop writing archaic, boring code.
66
Why use native operators when you can use an npm package?
77
Why use synchronous arithmetic when you can do so asynchronously?
8-
Why get guaranteed results when you can get the promise of one?
8+
Why get guaranteed results when you can get the promise of one?
99

1010
## Usage
1111

1212
### Adding two numbers
1313
```javascript
14-
import { add } from "async-math"
14+
const { add } = require("async-math")
1515
add(8, 4).then(function(sum) { console.log(sum) })
1616
```
1717
Console output should be 12
1818

1919
### Subtracting a number from another
2020
```javascript
21-
import { subtract } from "async-math"
21+
const { subtract } = require("async-math")
2222
subtract(8, 4).then(function(difference) { console.log(difference) })
2323
```
2424
Console output should be 4
2525

2626
### Multiplying two numbers
2727
```javascript
28-
import { multiply } from "async-math"
28+
const { multiply } = require("async-math")
2929
multiply(8, 4).then(function(product) { console.log(product) })
3030
```
3131
Console output should be 32
3232

3333
### Divide a number from another
3434
```javascript
35-
import { divide } from "async-math"
35+
const { divide } = require("async-math")
3636
divide(8, 4).then(function(quotient) { console.log(quotient) })
3737
```
3838
Console output should be 2

index.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,4 +52,4 @@ let shootMe = function () {
5252
}
5353
});
5454
};
55-
export { add, subtract, multiply, divide, shootMe };
55+
module.exports = { add, subtract, multiply, divide, shootMe };

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "async-math",
3-
"version": "1.0.0",
3+
"version": "1.0.1",
44
"description": "Async math operations",
55
"main": "index.js",
66
"scripts": {

test.js

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,31 +1,31 @@
1-
import * as asyncMath from "./index"
1+
const { add, subtract, multiply, divide, shootMe } = require("async-math")
22

33
test("should add properly", function() {
44
expect.assertions(1)
5-
const result = asyncMath.add(8, 4)
5+
const result = add(8, 4)
66
return expect(result).resolves.toBe(12)
77
})
88

99
test("should subtract properly", function() {
1010
expect.assertions(1)
11-
const result = asyncMath.subtract(8, 4)
11+
const result = subtract(8, 4)
1212
return expect(result).resolves.toBe(4)
1313
})
1414

1515
test("should multiply properly", function() {
1616
expect.assertions(1)
17-
const result = asyncMath.multiply(8, 4)
17+
const result = multiply(8, 4)
1818
return expect(result).resolves.toBe(32)
1919
})
2020

2121
test("should divide properly", function() {
2222
expect.assertions(1)
23-
const result = asyncMath.divide(8, 4)
23+
const result = divide(8, 4)
2424
return expect(result).resolves.toBe(2)
2525
})
2626

2727
test("should shoot properly", function() {
2828
expect.assertions(1)
29-
const result = asyncMath.shootMe()
29+
const result = shootMe()
3030
return expect(result).resolves.toBe("bang")
3131
})

0 commit comments

Comments
 (0)