Commit 3f24bf4a authored by Evgeny's avatar Evgeny

First version

parents
{
"presets": ["es2015"]
}
node_modules/
export default function format(v, type='', str=''){
if(type === '' && str === ''){
return basicFormat(v);
}
}
/**
* Returns lower bound after which exponential format will be used
* @function getLowerBound
* @returns {Number}
*/
export function getLowerBound(){
return 1e-9;
};
/**
* Returns higher bound after which exponential format will be used
* @function getHigherBound
* @returns {Number}
*/
export function getHigherBound(){
return 1e+9;
};
export function basicFormat(x){
var lowerBound = getLowerBound();
var higherBound = getHigherBound();
if(Math.abs(x) >= higherBound || Math.abs(x) < lowerBound && Math.abs(x) !== 0){
return x.toExponential();
}
return '' + x;
};
{
"name": "ed3-format-default",
"version": "0.0.1",
"description": "Default format for ed3 library",
"main": "index.js",
"scripts": {
"test": "mocha --compilers js:babel-register"
},
"keywords": [
"format",
"excel"
],
"author": "missingdays",
"license": "ISC",
"dependencies": {
"d3": "^4.2.0"
},
"devDependencies": {
"babel-preset-es2015": "^6.9.0",
"babel-register": "^6.11.6",
"expect.js": "^0.3.1",
"mocha": "^3.0.0"
}
}
import expect from 'expect.js';
import format from '../index';
describe('format', ()=>{
it('should use basic format', ()=>{
expect(format(0)).to.be('0');
expect(format(1)).to.be('1');
expect(format(1e-10)).to.be('1e-10');
expect(format(1e10)).to.be('1e+10');
});
});
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment