Package Exports
- sumi-math
This package does not declare an exports field, so the exports above have been automatically detected and optimized by JSPM instead. If any package subpath is missing, it is recommended to post an issue to the original package (sumi-math) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.
Readme
sumi-math
A lightweight mathematics library as a replacement for the internal Math object.
Target environments
- IE 6+
- Latest Stable: Firefox, Chrome, Safari, Opera
- Node.js & other non-browser environments or browser extensions
Quick start
Four quick start options are available:
- Download the latest release
- Clone the repo:
git clone https://github.com/rainersu/math.git
- Install with Bower:
bower install sumi-math
- Install with npm:
npm install sumi-math
Example use
Including in a browser:
<script type='text/javascript' src='/path/to/sumi-math-1.0.3.min.js'></script>
<script type='text/javascript'>
var x = Arith.parseFloat('xxx-123.3%xxx', true); // x = -1.233
</script>
As a module that works with AMD(e.g., RequireJS):
define(['/path/to/sumi-math-1.0.3.min.js'], function(Arith) {
var x = Arith.round(55.549, -2); // x = 55.55
});
Including in a CommonJS environment(e.g., Node.js):
var sumiMath = require('/path/to/sumi-math');
var x = sumiMath.toPercent(-0.123, 2); // x = -12.30%
Build from source
First, you need to have Node.js and Grunt installed.
$ git clone git@github.com:rainersu/math.git
$ npm install -g grunt-cli
$ cd math
$ npm install
$ grunt
It provides compiled JS (sumi-math.*
), as well as compiled and minified JS (sumi-math.min.*
). JS source maps (sumi-math.*.map
) are available for use with certain browsers' developer tools.
Running demos for testing
$ grunt test
Build & running documentation locally
$ grunt help
Sorry, the documentation is currently offered only in the Chinese language. Do you have time to help me with some Chinese - English translations?
How to contact me
- rainersu@foxmail.com
- http://cn.linkedin.com/in/rainersu
- http://site.douban.com/185696/
- http://rainersu.github.io
QQ: 2627001536
Copyright and license
Copyright 2015 Rainer Su (苏昱).
Code and documentation is free to use under the MIT license.