Commit d60e5922 authored by Evgeny's avatar Evgeny

Add exponential formatting

parent 929968c8
......@@ -6,6 +6,9 @@ export default function format(v, type='', str=''){
return basicFormat(v);
}
if(type === 'Number' && str.toLowerCase() === 'e'){
return v.toExponential();
}
if(type === 'DateTime'){
if(!(v instanceof Date)){
......
{
"name": "ed3-format-default",
"version": "0.1.0",
"version": "0.2.1",
"description": "Default format for ed3 library",
"main": "index.js",
"scripts": {
......
......@@ -47,4 +47,9 @@ describe('format', ()=>{
expect(format(1000*60*60*24, 'DateTime', 'yyyy-mm-dd')).to.be('1970-01-02');
});
it('should do exponential formatting', ()=>{
expect(format(0, 'Number', 'e')).to.be('0e+0');
expect(format(0, 'Number', 'E')).to.be('0e+0');
});
});
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