-
-
Notifications
You must be signed in to change notification settings - Fork 40
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add TypeScript definition and require Node.js 6 #17
Merged
Merged
Changes from all commits
Commits
Show all changes
15 commits
Select commit
Hold shift + click to select a range
d2332fd
Add TypeScript definition
DenisCarriere b391dd4
Fix tests
DenisCarriere ffa8823
Update based on comments
DenisCarriere 3e683e8
Add dot & ignore xo
DenisCarriere 5b9a733
remove {returns} & fix indentation
DenisCarriere 2d1dd15
Update example
DenisCarriere 1c9b6e5
Eslint disable
DenisCarriere 5a45486
Fix indent
DenisCarriere 54aebc1
Convert tabs to spaces
DenisCarriere 6a15428
Add defaults
DenisCarriere d2c300b
Add new line to .gitignore
DenisCarriere 8d85e0c
Add @default
DenisCarriere 4df67a1
Make `data` param "strict"
DenisCarriere 8062f51
Add JSONStringifyable
DenisCarriere 1f282fb
Update index.d.ts
sindresorhus File filter
Filter by extension
Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
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
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@sindresorhus FYI: I've changed it back to
import * as
syntax for the.sync()
example.Reason: Since this is a Typescript definition, it makes more sense to reference the example in the "Typescript" way.