version bump 1.0.6: module cleanup
This commit is contained in:
parent
5d66247109
commit
395ea31e95
19
.eslintrc
Normal file
19
.eslintrc
Normal file
@ -0,0 +1,19 @@
|
||||
{
|
||||
"env": { "shared-node-browser":true },
|
||||
"globals": {},
|
||||
"parserOptions": {
|
||||
"ecmaVersion": 3,
|
||||
},
|
||||
"plugins": [ "html", "json" ],
|
||||
"rules": {
|
||||
"no-use-before-define": [ 1, {
|
||||
"functions":false, "classes":true, "variables":true
|
||||
}],
|
||||
"no-bitwise": 0,
|
||||
"curly": 0,
|
||||
"comma-style": [ 2, "last" ],
|
||||
"no-trailing-spaces": 2,
|
||||
"semi": [ 2, "always" ],
|
||||
"comma-dangle": [ 2, "never" ]
|
||||
}
|
||||
}
|
@ -1,6 +1,8 @@
|
||||
[ignore]
|
||||
.*/node_modules/.*
|
||||
.*/dist/.*
|
||||
.*/ctest/mocha.js
|
||||
.*/ctest/sauce.*
|
||||
.*/test.js
|
||||
.*/frac.js
|
||||
|
||||
|
@ -1,5 +1,9 @@
|
||||
test_files/*.tsv
|
||||
ctest/
|
||||
test.js
|
||||
Makefile
|
||||
.gitignore
|
||||
.npmignore
|
||||
node_modules/
|
||||
coverage.html
|
||||
.travis.yml
|
||||
@ -13,3 +17,5 @@ build/
|
||||
MANIFEST
|
||||
*.gz
|
||||
*.tgz
|
||||
*.py
|
||||
*.html
|
||||
|
@ -8,8 +8,8 @@ node_js:
|
||||
- "0.10"
|
||||
- "0.8"
|
||||
before_install:
|
||||
- "npm install -g npm@next"
|
||||
- "npm install -g mocha voc"
|
||||
- "npm install -g npm@4.3.0"
|
||||
- "npm install -g mocha@2.x voc"
|
||||
- "npm install blanket"
|
||||
- "npm install coveralls mocha-lcov-reporter"
|
||||
after_success:
|
||||
|
14
Makefile
14
Makefile
@ -2,12 +2,15 @@ LIB=frac
|
||||
REQS=
|
||||
ADDONS=
|
||||
AUXTARGETS=
|
||||
CMDS=
|
||||
HTMLLINT=index.html
|
||||
|
||||
ULIB=$(shell echo $(LIB) | tr a-z A-Z)
|
||||
DEPS=$(LIB).md
|
||||
TARGET=$(LIB).js
|
||||
FLOWTARGET=$(LIB).flow.js
|
||||
UGLIFYOPTS=--support-ie8
|
||||
CLOSURE=/usr/local/lib/node_modules/google-closure-compiler/compiler.jar
|
||||
|
||||
## Main Targets
|
||||
|
||||
@ -40,11 +43,18 @@ ctestserv: ## Start a test server on port 8000
|
||||
@cd ctest && python -mSimpleHTTPServer
|
||||
|
||||
.PHONY: lint
|
||||
lint: $(TARGET) $(AUXTARGETS) ## Run jshint and jscs checks
|
||||
lint: $(TARGET) $(AUXTARGETS) ## Run eslint checks
|
||||
@eslint --ext .js,.njs,.json,.html,.htm $(TARGET) $(AUXTARGETS) $(CMDS) $(HTMLLINT) package.json bower.json
|
||||
if [ -e $(CLOSURE) ]; then java -jar $(CLOSURE) $(REQS) $(FLOWTARGET) --jscomp_warning=reportUnknownTypes >/dev/null; fi
|
||||
|
||||
.PHONY: old-lint
|
||||
old-lint: $(TARGET) $(AUXTARGETS) ## Run jshint and jscs checks
|
||||
@jshint --show-non-errors $(TARGET) $(AUXTARGETS)
|
||||
@jshint --show-non-errors $(CMDS)
|
||||
@jshint --show-non-errors package.json
|
||||
@jshint --show-non-errors --extract=always $(HTMLLINT)
|
||||
@jscs $(TARGET) $(AUXTARGETS)
|
||||
if [ -e $(CLOSURE) ]; then java -jar $(CLOSURE) $(REQS) $(FLOWTARGET) --jscomp_warning=reportUnknownTypes >/dev/null; fi
|
||||
|
||||
.PHONY: flow
|
||||
flow: lint ## Run flow checker
|
||||
@ -64,7 +74,7 @@ coveralls: ## Coverage Test + Send to coveralls.io
|
||||
dist: dist-deps $(TARGET) ## Prepare JS files for distribution
|
||||
cp $(TARGET) dist/
|
||||
cp LICENSE dist/
|
||||
uglifyjs $(TARGET) -o dist/$(LIB).min.js --source-map dist/$(LIB).min.map --preamble "$$(head -n 1 frac.js)"
|
||||
uglifyjs $(UGLIFYOPTS) $(TARGET) -o dist/$(LIB).min.js --source-map dist/$(LIB).min.map --preamble "$$(head -n 1 frac.js)"
|
||||
misc/strip_sourcemap.sh dist/$(LIB).min.js
|
||||
|
||||
.PHONY: aux
|
||||
|
13
README.md
13
README.md
@ -6,7 +6,8 @@ Uses the [Mediant Method](https://en.wikipedia.org/wiki/Mediant_method).
|
||||
|
||||
This module also provides an implementation of the continued fraction method as
|
||||
described by Aberth in "A method for exact computation with rational numbers".
|
||||
|
||||
The algorithm is used in <a href="http://sheetjs.com">SheetJS Libraries</a> to
|
||||
replicate fraction formats.
|
||||
|
||||
## Installation
|
||||
|
||||
@ -109,12 +110,20 @@ The test TSV baselines in the `test_files` directory have four columns:
|
||||
## License
|
||||
|
||||
Please consult the attached LICENSE file for details. All rights not explicitly
|
||||
granted by the Apache 2.0 license are reserved by the Original Author.
|
||||
granted by the Apache 2.0 License are reserved by the Original Author.
|
||||
|
||||
## Badges
|
||||
|
||||
[![Build Status](https://saucelabs.com/browser-matrix/frac.svg)](https://saucelabs.com/u/frac)
|
||||
|
||||
[![Build Status](https://travis-ci.org/SheetJS/frac.svg?branch=master)](https://travis-ci.org/SheetJS/frac)
|
||||
|
||||
[![Coverage Status](http://img.shields.io/coveralls/SheetJS/frac/master.svg)](https://coveralls.io/r/SheetJS/frac?branch=master)
|
||||
|
||||
[![NPM Downloads](https://img.shields.io/npm/dt/frac.svg)](https://npmjs.org/package/frac)
|
||||
|
||||
[![Dependencies Status](https://david-dm.org/sheetjs/frac/status.svg)](https://david-dm.org/sheetjs/frac)
|
||||
|
||||
[![ghit.me](https://ghit.me/badge.svg?repo=sheetjs/js-xlsx)](https://ghit.me/repo/sheetjs/js-xlsx)
|
||||
|
||||
[![Analytics](https://ga-beacon.appspot.com/UA-36810333-1/SheetJS/frac?pixel)](https://github.com/SheetJS/frac)
|
||||
|
134
index.html
134
index.html
@ -1,16 +1,21 @@
|
||||
<!DOCTYPE html>
|
||||
<!-- frac.js (C) 2012-present SheetJS http://sheetjs.com -->
|
||||
<!-- frac.js (C) 2012-present SheetJS http://sheetjs.com -->
|
||||
<!-- vim: set ts=2: -->
|
||||
<html>
|
||||
<head>
|
||||
<title>Fraction Live Demo</title>
|
||||
<script src="frac.js"></script>
|
||||
</head>
|
||||
<body>
|
||||
<b>Fraction Live Demo</b><br />
|
||||
<a href="https://github.com/SheetJS/frac">Source Code</a><br />
|
||||
<a href="https://github.com/SheetJS/frac/issues">Issues? Something look weird? Click here and report an issue</a><br />
|
||||
<br />
|
||||
<head>
|
||||
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
|
||||
<title>Fraction Live Demo</title>
|
||||
<style>
|
||||
a { text-decoration: none }
|
||||
</style>
|
||||
</head>
|
||||
<body>
|
||||
<pre>
|
||||
<b><a href="http://sheetjs.com">SheetJS Fraction Live Demo</a></b>
|
||||
|
||||
<a href="https://github.com/SheetJS/frac">Source Code Repo</a>
|
||||
<a href="https://github.com/SheetJS/frac/issues">Issues? Something look weird? Click here and report an issue</a>
|
||||
</pre>
|
||||
<table>
|
||||
<tr><td><b>Number:</b></td><td><input type="text" id="val" value="1.3"></td></tr>
|
||||
<tr><td><b>Denominator Digits:</b></td><td><input type="text" id="fmt" value="1"></td></tr>
|
||||
@ -19,62 +24,63 @@
|
||||
<tr><td><b>Mediant Fraction:</b></td><td><pre id="frm"></pre></td></tr>
|
||||
<tr><td><b>Aberth Fraction:</b></td><td><pre id="fra"></pre></td></tr>
|
||||
</table>
|
||||
</body>
|
||||
<script>
|
||||
/*jshint browser:true */
|
||||
var V = document.getElementById('val');
|
||||
var F = document.getElementById('fmt');
|
||||
var X = document.getElementById('mix');
|
||||
var M = document.getElementById('frm');
|
||||
var A = document.getElementById('fra');
|
||||
<script src="frac.js"></script>
|
||||
<script>
|
||||
/*jshint browser:true */
|
||||
/*global frac */
|
||||
var V = document.getElementById('val');
|
||||
var F = document.getElementById('fmt');
|
||||
var X = document.getElementById('mix');
|
||||
var M = document.getElementById('frm');
|
||||
var A = document.getElementById('fra');
|
||||
|
||||
function update() {
|
||||
var x, D, mixed, oM, oA;
|
||||
x = Number(V.value);
|
||||
D = Math.pow(10, Number(F.value))-1;
|
||||
mixed = X.checked;
|
||||
if(x !== x) { M.innerHTML=A.innerHTML = V.value + " not valid"; return; }
|
||||
if(D !== D) { M.innerHTML=A.innerHTML = F.value + " not valid"; return; }
|
||||
try {
|
||||
oM = frac(x, D, mixed);
|
||||
M.innerHTML = oM[0] + " " + oM[1] + "/" + oM[2];
|
||||
} catch(e) { M.innerHTML = e.message; }
|
||||
try {
|
||||
oA = frac.cont(x, D, mixed);
|
||||
A.innerHTML = oA[0] + " " + oA[1] + "/" + oA[2];
|
||||
} catch(e) { A.innerHTML = e.message; }
|
||||
}
|
||||
function update() {
|
||||
var x, D, mixed, oM, oA;
|
||||
x = Number(V.value);
|
||||
D = Math.pow(10, Number(F.value))-1;
|
||||
mixed = X.checked;
|
||||
if(x !== x) { M.innerHTML=A.innerHTML = V.value + " not valid"; return; }
|
||||
if(D !== D) { M.innerHTML=A.innerHTML = F.value + " not valid"; return; }
|
||||
try {
|
||||
oM = frac(x, D, mixed);
|
||||
M.innerHTML = oM[0] + " " + oM[1] + "/" + oM[2];
|
||||
} catch(e) { M.innerHTML = e.message; }
|
||||
try {
|
||||
oA = frac.cont(x, D, mixed);
|
||||
A.innerHTML = oA[0] + " " + oA[1] + "/" + oA[2];
|
||||
} catch(e) { A.innerHTML = e.message; }
|
||||
}
|
||||
|
||||
/* Bind to relevant events */
|
||||
if(F.addEventListener) {
|
||||
F.addEventListener('keyup', update);
|
||||
V.addEventListener('keyup', update);
|
||||
M.addEventListener('change', update);
|
||||
X.addEventListener('change', update);
|
||||
} else if(F.attachEvent) {
|
||||
F.attachEvent('onkeyup', update);
|
||||
V.attachEvent('onkeyup', update);
|
||||
M.attachEvent('onchange', update);
|
||||
X.attachEvent('onchange', update);
|
||||
} else {
|
||||
F.oninput = update;
|
||||
V.oninput = update;
|
||||
M.onchange = update;
|
||||
X.onchange = update;
|
||||
}
|
||||
/* Bind to relevant events */
|
||||
if(F.addEventListener) {
|
||||
F.addEventListener('keyup', update);
|
||||
V.addEventListener('keyup', update);
|
||||
M.addEventListener('change', update);
|
||||
X.addEventListener('change', update);
|
||||
} else if(F.attachEvent) {
|
||||
F.attachEvent('onkeyup', update);
|
||||
V.attachEvent('onkeyup', update);
|
||||
M.attachEvent('onchange', update);
|
||||
X.attachEvent('onchange', update);
|
||||
} else {
|
||||
F.oninput = update;
|
||||
V.oninput = update;
|
||||
M.onchange = update;
|
||||
X.onchange = update;
|
||||
}
|
||||
|
||||
update();
|
||||
</script>
|
||||
<script type="text/javascript">
|
||||
var _gaq = _gaq || [];
|
||||
_gaq.push(['_setAccount', 'UA-36810333-1']);
|
||||
_gaq.push(['_trackPageview']);
|
||||
update();
|
||||
</script>
|
||||
<script type="text/javascript">
|
||||
var _gaq = _gaq || [];
|
||||
_gaq.push(['_setAccount', 'UA-36810333-1']);
|
||||
_gaq.push(['_trackPageview']);
|
||||
|
||||
(function() {
|
||||
var ga = document.createElement('script'); ga.type = 'text/javascript'; ga.async = true;
|
||||
ga.src = ('https:' == document.location.protocol ? 'https://ssl' : 'http://www') + '.google-analytics.com/ga.js';
|
||||
var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(ga, s);
|
||||
})();
|
||||
</script>
|
||||
(function() {
|
||||
var ga = document.createElement('script'); ga.type = 'text/javascript'; ga.async = true;
|
||||
ga.src = ('https:' == document.location.protocol ? 'https://ssl' : 'http://www') + '.google-analytics.com/ga.js';
|
||||
var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(ga, s);
|
||||
})();
|
||||
</script>
|
||||
</body>
|
||||
</html>
|
||||
|
||||
|
@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "frac",
|
||||
"version": "1.0.5",
|
||||
"version": "1.0.6",
|
||||
"author": "SheetJS",
|
||||
"description": "Rational approximation with bounded denominator",
|
||||
"keywords": [ "math", "fraction", "rational", "approximation" ],
|
||||
@ -20,6 +20,7 @@
|
||||
"pattern": "frac.js"
|
||||
}
|
||||
},
|
||||
"homepage": "http://oss.sheetjs.com/frac",
|
||||
"bugs": { "url": "https://github.com/SheetJS/frac/issues" },
|
||||
"license": "Apache-2.0",
|
||||
"engines": { "node": ">=0.8" }
|
||||
|
Loading…
Reference in New Issue
Block a user