Skip to content

Commit

Permalink
Fixing module imports. Using requires.
Browse files Browse the repository at this point in the history
  • Loading branch information
coffeebite committed Sep 16, 2017
1 parent 0a2b4e7 commit 4371404
Show file tree
Hide file tree
Showing 4 changed files with 14 additions and 14 deletions.
12 changes: 6 additions & 6 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,37 +2,37 @@
Npm package for async math operations.

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

## Usage

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

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

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

### Divide a number from another
```javascript
import { divide } from "async-math"
const { divide } = require("async-math")
divide(8, 4).then(function(quotient) { console.log(quotient) })
```
Console output should be 2
2 changes: 1 addition & 1 deletion index.js
Original file line number Diff line number Diff line change
Expand Up @@ -52,4 +52,4 @@ let shootMe = function () {
}
});
};
export { add, subtract, multiply, divide, shootMe };
module.exports = { add, subtract, multiply, divide, shootMe };
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "async-math",
"version": "1.0.0",
"version": "1.0.1",
"description": "Async math operations",
"main": "index.js",
"scripts": {
Expand Down
12 changes: 6 additions & 6 deletions test.js
Original file line number Diff line number Diff line change
@@ -1,31 +1,31 @@
import * as asyncMath from "./index"
const { add, subtract, multiply, divide, shootMe } = require("async-math")

test("should add properly", function() {
expect.assertions(1)
const result = asyncMath.add(8, 4)
const result = add(8, 4)
return expect(result).resolves.toBe(12)
})

test("should subtract properly", function() {
expect.assertions(1)
const result = asyncMath.subtract(8, 4)
const result = subtract(8, 4)
return expect(result).resolves.toBe(4)
})

test("should multiply properly", function() {
expect.assertions(1)
const result = asyncMath.multiply(8, 4)
const result = multiply(8, 4)
return expect(result).resolves.toBe(32)
})

test("should divide properly", function() {
expect.assertions(1)
const result = asyncMath.divide(8, 4)
const result = divide(8, 4)
return expect(result).resolves.toBe(2)
})

test("should shoot properly", function() {
expect.assertions(1)
const result = asyncMath.shootMe()
const result = shootMe()
return expect(result).resolves.toBe("bang")
})

0 comments on commit 4371404

Please sign in to comment.