-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #4 from flandrade/add-support-node-6
feat: Add support for Node v.6.4+
- Loading branch information
Showing
11 changed files
with
80 additions
and
32 deletions.
There are no files selected for viewing
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 |
---|---|---|
@@ -1,2 +1,3 @@ | ||
import * as Promise from "bluebird"; | ||
export declare function read(filePath: string): Promise<string>; | ||
export declare function write(filePath: string): (data: string) => Promise<void>; | ||
export declare function write(filePath: string): (data: string) => void; |
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 |
---|---|---|
@@ -1,14 +1,17 @@ | ||
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
const Promise = require("bluebird"); | ||
const fs = require("fs"); | ||
const util = require("util"); | ||
const readFileAsync = util.promisify(fs.readFile); | ||
const writeFileAsync = util.promisify(fs.writeFile); | ||
const DEFAULT_ENCODING = "utf8"; | ||
const readFileAsync = Promise.promisify(fs.readFile); | ||
const writeFileAsync = Promise.promisify(fs.writeFile); | ||
function read(filePath) { | ||
return readFileAsync(filePath, { encoding: "utf8" }); | ||
return readFileAsync(filePath, DEFAULT_ENCODING); | ||
} | ||
exports.read = read; | ||
function write(filePath) { | ||
return data => writeFileAsync(filePath, data, { encoding: "utf8" }); | ||
return data => { | ||
writeFileAsync(filePath, data, { encoding: DEFAULT_ENCODING }); | ||
}; | ||
} | ||
exports.write = write; |
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
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
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 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 |
---|---|---|
@@ -1,16 +1,28 @@ | ||
import * as Promise from "bluebird"; | ||
import * as fs from "fs"; | ||
import * as util from "util"; | ||
|
||
const readFileAsync = util.promisify(fs.readFile); | ||
const writeFileAsync = util.promisify(fs.writeFile); | ||
const DEFAULT_ENCODING: string = "utf8"; | ||
|
||
const readFileAsync: ( | ||
file: string, | ||
encoding: string | ||
) => Promise<string> | ||
= Promise.promisify<string, string, string>(fs.readFile); | ||
|
||
const writeFileAsync: ( | ||
file: string, | ||
data: any, | ||
options: fs.WriteFileOptions | ||
) => Promise<void> | ||
= Promise.promisify<void, string, any, fs.WriteFileOptions>(fs.writeFile); | ||
|
||
export function read(filePath: string): Promise<string> { | ||
return readFileAsync(filePath, { encoding: "utf8" }); | ||
return readFileAsync(filePath, DEFAULT_ENCODING); | ||
} | ||
|
||
export function write( | ||
filePath: string | ||
): (data: string) => Promise<void> { | ||
return data => | ||
writeFileAsync(filePath, data, { encoding: "utf8" }); | ||
): (data: string) => void { | ||
return data => { | ||
writeFileAsync(filePath, data, { encoding: DEFAULT_ENCODING }); | ||
}; | ||
} |
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