fs-promise: JSON replacer should be a string

This commit is contained in:
Andy Hanson
2017-01-01 16:45:22 -08:00
committed by andy-ms
parent 3633866ea5
commit a15229fb73
2 changed files with 8 additions and 2 deletions

View File

@@ -6,7 +6,13 @@ var dir: string;
var path: string;
var data: any;
var writeOptions: fs.WriteOptions;
var writeJsonOptions: fs.WriteJsonOptions;
var writeJsonOptions: fs.WriteJsonOptions = {
spaces: 2,
replacer(key, value) {
src = key;
return value;
}
};
var readJsonOptions: fs.ReadJsonOptions;
async function test() {

View File

@@ -15,7 +15,7 @@ export interface WriteOptions {
type JsonReplacerArray = Array<number | string>;
type JsonReplacerFunction = (key: any, value: any) => any;
type JsonReplacerFunction = (key: string, value: any) => any;
type JsonReplacer = JsonReplacerArray | JsonReplacerFunction;