Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
40 changed files
with
1,194 additions
and
231 deletions.
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
///<reference path="../../typescript-def/jasmine.d.ts"/> | ||
|
||
import FileUtils = module("../../src/file/FileUtils"); | ||
|
||
describe("File Utils", () => { | ||
|
||
var tempPath = "temp.out", | ||
data = [ | ||
["some value", "2", "3", 4], | ||
["test", "3", "dsf"] | ||
]; | ||
|
||
it("Should write a csv file", () => { | ||
FileUtils.FileUtils.writeCSV(data, tempPath, (err) => { | ||
expect(err).toBeNull(); | ||
}); | ||
}); | ||
|
||
it("Should read a csv file", (done) => { | ||
FileUtils.FileUtils.writeCSV(data, tempPath, () => { | ||
FileUtils.FileUtils.readCSV("temp.out", (err, readObject) => { | ||
expect(readObject).toBeDefined(); | ||
expect(readObject.length).toEqual(2); | ||
expect(readObject[0][2]).toEqual("3"); | ||
expect(readObject[0][3]).toEqual('4'); | ||
expect(readObject[1][2]).toEqual("dsf"); | ||
done(); | ||
}); | ||
}); | ||
}); | ||
|
||
}); |
This file was deleted.
Oops, something went wrong.
Empty file.
Empty file.
This file was deleted.
Oops, something went wrong.
Empty file.
Empty file.
Empty file.
Empty file.
Empty file.
Empty file.
Empty file.
Empty file.
Empty file.
Empty file.
Empty file.
Empty file.
Empty file.
Empty file.
Empty file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,51 @@ | ||
///<reference path="../../typescript-def/node.d.ts"/> | ||
///<reference path="../../typescript-def/underscore.d.ts"/> | ||
|
||
import fs = module("fs"); | ||
import _ = module("underscore"); | ||
|
||
export class FileUtils { | ||
|
||
/** | ||
* Write an object to a csv file. | ||
* @param obj - A double array, each outer array represents a line in the output csv. Each element of the sub-array | ||
* represents an element in each line of the output csv. | ||
* @param filePath | ||
* @param callback | ||
*/ | ||
public static writeCSV(obj: any, filePath: string, callback ?: Function): void { | ||
|
||
var outputString = ""; | ||
|
||
_.each(obj, function(line, i) { | ||
if(i !== 0) outputString += "\r\n"; | ||
|
||
_.each(line, function(el, i) { | ||
outputString += i === 0 ? el : "," + el; | ||
}); | ||
}); | ||
|
||
fs.writeFile(filePath, outputString, callback); | ||
} | ||
|
||
public static readCSV(filePath: string, callback ?: Function): void { | ||
fs.readFile(filePath, (err, data) => { | ||
var lines; | ||
|
||
if(err) callback(err); | ||
|
||
lines = (data+"").split("\r\n"); | ||
|
||
_.each(lines, (line, i) => { | ||
lines[i] = (line+"").split(","); | ||
}); | ||
|
||
callback(null, lines); | ||
|
||
}); | ||
} | ||
|
||
public static writeJSON(obj: Object, filePath: string): void { | ||
|
||
} | ||
} |
Empty file.
Empty file.
Empty file.
Empty file.
Empty file.
Empty file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
some value,2,3,4 | ||
test,3,dsf |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
// Type definitions for Numeral.js | ||
// Project: https://github.com/adamwdraper/Numeral-js | ||
// Definitions by: Vincent Bortone <https://github.com/vbortone/> | ||
// Definitions: https://github.com/borisyankov/DefinitelyTyped | ||
|
||
interface NumeralJSLanguage { | ||
delimiters: { | ||
thousands: string; | ||
decimal: string; | ||
}; | ||
abbreviations: { | ||
thousand: string; | ||
million: string; | ||
billion: string; | ||
trillion: string; | ||
}; | ||
ordinal(num: number): string; | ||
currency: { | ||
symbol: string; | ||
}; | ||
} | ||
|
||
interface Numeral { | ||
(value?: any): Numeral; | ||
version: string; | ||
isNumeral: bool; | ||
language(key: string, values?: NumeralJSLanguage): Numeral; | ||
zeroFormat(format: string): string; | ||
clone(): Numeral; | ||
format(inputString: string): string; | ||
unformat(inputString: string): number; | ||
value(): number; | ||
valueOf(): number; | ||
set (value: any): Numeral; | ||
add(value: any): Numeral; | ||
subtract(value: any): Numeral; | ||
multiply(value: any): Numeral; | ||
divide(value: any): Numeral; | ||
difference(value: any): number; | ||
} | ||
|
||
declare var numeral: Numeral; |
Oops, something went wrong.