moved to es6 module system
This commit is contained in:
25
ts/export/formatter.ts
Normal file
25
ts/export/formatter.ts
Normal file
@ -0,0 +1,25 @@
|
||||
import * as _ from "lodash";
|
||||
|
||||
export class Formatter {
|
||||
|
||||
format(input: any) {
|
||||
var stringified = JSON.stringify(input);
|
||||
var newJson = JSON.parse(stringified);
|
||||
this.deepTraverseJson(newJson, (parent, value, key) => {
|
||||
parent.blah = parent[key];
|
||||
|
||||
});
|
||||
|
||||
return newJson;
|
||||
}
|
||||
|
||||
private deepTraverseJson(json, lambda: (json: any, value: any, key: string) => void) {
|
||||
_.forOwn(json, function(value, key) {
|
||||
if (_.isObject(value)) {
|
||||
this.deepTraverseJson(value, lambda);
|
||||
return;
|
||||
}
|
||||
lambda(json, value, key);
|
||||
});
|
||||
};
|
||||
}
|
Reference in New Issue
Block a user