Skip to content

Commit

Permalink
Native ES module support
Browse files Browse the repository at this point in the history
  • Loading branch information
infusion committed Aug 29, 2023
1 parent 4006900 commit 47102bd
Show file tree
Hide file tree
Showing 4 changed files with 130 additions and 121 deletions.
19 changes: 8 additions & 11 deletions fraction.js → fraction.cjs
@@ -1,5 +1,5 @@
/**
* @license Fraction.js v4.2.1 20/08/2023
* @license Fraction.js v4.3.0 20/08/2023
* https://www.xarg.org/2014/03/rational-numbers-in-javascript/
*
* Copyright (c) 2023, Robert Eisele (robert@raw.org)
Expand Down Expand Up @@ -377,9 +377,9 @@
}
}

var DivisionByZero = function() {return new Error("Division by Zero");};
var InvalidParameter = function() {return new Error("Invalid argument");};
var NonIntegerParameter = function() {return new Error("Parameters must be integer");};
var DivisionByZero = function() { return new Error("Division by Zero"); };
var InvalidParameter = function() { return new Error("Invalid argument"); };
var NonIntegerParameter = function() { return new Error("Parameters must be integer"); };

Fraction.prototype = {

Expand Down Expand Up @@ -875,14 +875,11 @@
}
};

if (typeof define === "function" && define["amd"]) {
define([], function() {
return Fraction;
if (typeof exports === "object") {
Object.defineProperty(exports, "__esModule", {
value: true
});
} else if (typeof exports === "object") {
Object.defineProperty(Fraction, "__esModule", { 'value': true });
Fraction['default'] = Fraction;
Fraction['Fraction'] = Fraction;
exports["default"] = Fraction;
module['exports'] = Fraction;
} else {
root['Fraction'] = Fraction;
Expand Down
18 changes: 9 additions & 9 deletions fraction.min.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

93 changes: 51 additions & 42 deletions package.json
@@ -1,43 +1,52 @@
{
"name": "fraction.js",
"title": "fraction.js",
"version": "4.2.1",
"homepage": "https://www.xarg.org/2014/03/rational-numbers-in-javascript/",
"bugs": "https://github.com/infusion/Fraction.js/issues",
"description": "A rational number library",
"keywords": [
"math",
"fraction",
"rational",
"rationals",
"number",
"parser",
"rational numbers"
],
"author": "Robert Eisele <robert@xarg.org> (http://www.xarg.org/)",
"main": "fraction",
"types": "./fraction.d.ts",
"private": false,
"readmeFilename": "README.md",
"directories": {
"example": "examples"
},
"license": "MIT",
"repository": {
"type": "git",
"url": "git://github.com/infusion/Fraction.js.git"
},
"funding": {
"type": "patreon",
"url": "https://www.patreon.com/infusion"
},
"engines": {
"node": "*"
},
"scripts": {
"test": "mocha tests/*.js"
},
"devDependencies": {
"mocha": "*"
}
}
"name": "fraction.js",
"title": "fraction.js",
"version": "4.3.0",
"homepage": "https://www.xarg.org/2014/03/rational-numbers-in-javascript/",
"bugs": "https://github.com/rawify/Fraction.js/issues",
"description": "A rational number library",
"keywords": [
"math",
"fraction",
"rational",
"rationals",
"number",
"parser",
"rational numbers"
],
"author": {
"name": "Robert Eisele",
"email": "robert@raw.org",
"url": "https://raw.org/"
},
"type": "module",
"main": "fraction",
"exports": {
"import": "./fraction.cjs",
"require": "./fraction.cjs"
},
"types": "./fraction.d.ts",
"private": false,
"readmeFilename": "README.md",
"directories": {
"example": "examples"
},
"license": "MIT",
"repository": {
"type": "git",
"url": "git://github.com/rawify/Fraction.js.git"
},
"funding": {
"type": "patreon",
"url": "https://github.com/sponsors/rawify"
},
"engines": {
"node": "*"
},
"scripts": {
"test": "mocha tests/*.js"
},
"devDependencies": {
"mocha": "*"
}
}

0 comments on commit 47102bd

Please sign in to comment.