Skip to content

Commit

Permalink
Numeral commonjs modules support and tests
Browse files Browse the repository at this point in the history
  • Loading branch information
outring committed Mar 10, 2015
1 parent 9cfe889 commit af699e1
Show file tree
Hide file tree
Showing 3 changed files with 53 additions and 2 deletions.
44 changes: 44 additions & 0 deletions numeraljs/numeraljs-commonjs-tests.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
/// <reference path="numeraljs.d.ts" />
import numeral = require("numeral");

var valueFormat: string = numeral(1000).format('0,0');
// '1,000'

var valueUnformat: number = numeral().unformat('($10,000.00)');
// '-10000'

var value3: Numeral = numeral(1000);
var added: Numeral = value3.add(10);
// 1010

var value4: Numeral = numeral(1000);
var formatValue4a: string = value4.format('0,0');
// '1,000'
var formatValue4b: number = value4.value();
// 1000

var value5: Numeral = numeral();
value5.set(1000);
var value5Num: number = value5.value();
// 1000

var value6: Numeral = numeral(1000);
var value: number = 100;
var difference = value6.difference(value);
// 900

var value7: Numeral = numeral(0);
numeral.zeroFormat('N/A');
var zeroString: string = value7.format('0.0');
// 'N/A'

var a: Numeral = numeral(1000);
var b: Numeral = numeral(a);
var c: Numeral = a.clone();

var aVal: number = a.set(2000).value();
// 2000
var bVal: number = b.value();
// 1000
var cVal: number = c.add(10).value();
// 1010
3 changes: 2 additions & 1 deletion numeraljs/numeraljs-tests.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
/// <reference path="numeraljs.d.ts" />

var valueFormat: string = numeral(1000).format('0,0');
// '1,000'

Expand Down Expand Up @@ -27,7 +28,7 @@ var difference = value6.difference(value);

var value7: Numeral = numeral(0);
numeral.zeroFormat('N/A');
var zeroString: string = value7.format('0.0')
var zeroString: string = value7.format('0.0');
// 'N/A'

var a: Numeral = numeral(1000);
Expand Down
8 changes: 7 additions & 1 deletion numeraljs/numeraljs.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -39,4 +39,10 @@ interface Numeral {
difference(value: any): number;
}

declare var numeral: Numeral;
declare var numeral: Numeral;

declare module "numeral" {

export = Numeral;

}

0 comments on commit af699e1

Please sign in to comment.