-
-
Notifications
You must be signed in to change notification settings - Fork 40
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add TypeScript definition and require Node.js 6 (#17)
- Loading branch information
1 parent
e4c9b99
commit 8a602ea
Showing
5 changed files
with
77 additions
and
5 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1,2 @@ | ||
node_modules | ||
yarn.lock |
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,5 +1,5 @@ | ||
language: node_js | ||
node_js: | ||
- '10' | ||
- '8' | ||
- '6' | ||
- '4' |
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,62 @@ | ||
export type Replacer = (key: string, value: any) => void; | ||
export type SortKeys = (a: string, b: string) => number; | ||
export type JSONStringifyable = object | number | string; | ||
|
||
export interface Options { | ||
/** | ||
* Indentation as a string or number of spaces. Pass in null for no formatting. | ||
* | ||
* @default '\t' | ||
*/ | ||
indent?: string | number | null; | ||
/** | ||
* Detect indentation automatically if the file exists. | ||
* | ||
* @default false | ||
*/ | ||
detectIndent?: boolean; | ||
/** | ||
* Sort the keys recursively. Optionally pass in a compare function. | ||
* | ||
* @default false | ||
*/ | ||
sortKeys?: boolean | SortKeys; | ||
/** | ||
* Passed into `JSON.stringify`. | ||
*/ | ||
replacer?: Replacer | Array<number | string>; | ||
/** | ||
* Mode used when writing the file. | ||
* | ||
* @default 0o666 | ||
*/ | ||
mode?: number; | ||
} | ||
|
||
/** | ||
* Stringify and write JSON to a file atomically. | ||
* | ||
* Creates directories for you as needed. | ||
* | ||
* @example | ||
* import * as writeJsonFile from 'write-json-file'; | ||
* | ||
* writeJsonFile.sync('foo.json', {foo: true}); | ||
* console.log('done'); | ||
*/ | ||
export function sync(filepath: string, data: JSONStringifyable, options?: Options): void; | ||
|
||
/** | ||
* Stringify and write JSON to a file atomically. | ||
* | ||
* Creates directories for you as needed. | ||
* | ||
* @example | ||
* import writeJsonFile from 'write-json-file'; | ||
* | ||
* (async () => { | ||
* await writeJsonFile('foo.json', {foo: true}); | ||
* console.log('done'); | ||
* })(); | ||
*/ | ||
export default function writeJsonFile(filepath: string, data: JSONStringifyable, options?: Options): Promise<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
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