From 4371404c5826f56e764fd2afaf34cf3d0d991be6 Mon Sep 17 00:00:00 2001 From: Nitesh Date: Sat, 16 Sep 2017 02:55:23 -0700 Subject: [PATCH] Fixing module imports. Using requires. --- README.md | 12 ++++++------ index.js | 2 +- package.json | 2 +- test.js | 12 ++++++------ 4 files changed, 14 insertions(+), 14 deletions(-) diff --git a/README.md b/README.md index a8d8cff..3169ab5 100644 --- a/README.md +++ b/README.md @@ -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 \ No newline at end of file diff --git a/index.js b/index.js index b5de27c..72f053e 100644 --- a/index.js +++ b/index.js @@ -52,4 +52,4 @@ let shootMe = function () { } }); }; -export { add, subtract, multiply, divide, shootMe }; +module.exports = { add, subtract, multiply, divide, shootMe }; diff --git a/package.json b/package.json index fa8fd05..0607c0a 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "async-math", - "version": "1.0.0", + "version": "1.0.1", "description": "Async math operations", "main": "index.js", "scripts": { diff --git a/test.js b/test.js index 0d11669..1ff629a 100644 --- a/test.js +++ b/test.js @@ -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") }) \ No newline at end of file