write-json-file
Advanced tools
Comparing version 3.1.0 to 3.2.0
133
index.d.ts
@@ -1,66 +0,85 @@ | ||
export type Replacer = (this: unknown, key: string, value: unknown) => unknown; | ||
export type SortKeys = (a: string, b: string) => number; | ||
export type JSONStringifyable = string | number | boolean | null | object; | ||
declare namespace writeJsonFile { | ||
type Replacer = (this: unknown, key: string, value: any) => unknown; | ||
type SortKeys = (a: string, b: string) => number; | ||
type JSONStringifyable = string | number | boolean | null | object; | ||
export interface Options { | ||
/** | ||
* Indentation as a string or number of spaces. Pass in null for no formatting. | ||
* | ||
* @default '\t' | ||
*/ | ||
readonly indent?: string | number | null; | ||
interface Options { | ||
/** | ||
Indentation as a string or number of spaces. Pass in null for no formatting. | ||
/** | ||
* Detect indentation automatically if the file exists. | ||
* | ||
* @default false | ||
*/ | ||
readonly detectIndent?: boolean; | ||
@default '\t' | ||
*/ | ||
readonly indent?: string | number | null; | ||
/** | ||
* Sort the keys recursively. Optionally pass in a compare function. | ||
* | ||
* @default false | ||
*/ | ||
readonly sortKeys?: boolean | SortKeys; | ||
/** | ||
Detect indentation automatically if the file exists. | ||
@default false | ||
*/ | ||
readonly detectIndent?: boolean; | ||
/** | ||
Sort the keys recursively. Optionally pass in a compare function. | ||
@default false | ||
*/ | ||
readonly sortKeys?: boolean | SortKeys; | ||
/** | ||
Passed into `JSON.stringify`. | ||
*/ | ||
readonly replacer?: Replacer | Array<number | string>; | ||
/** | ||
Mode used when writing the file. | ||
@default 0o666 | ||
*/ | ||
readonly mode?: number; | ||
} | ||
} | ||
declare const writeJsonFile: { | ||
/** | ||
* Passed into `JSON.stringify`. | ||
*/ | ||
readonly replacer?: Replacer | Array<number | string>; | ||
Stringify and write JSON to a file atomically. | ||
Creates directories for you as needed. | ||
@example | ||
``` | ||
import writeJsonFile = require('write-json-file'); | ||
(async () => { | ||
await writeJsonFile('foo.json', {foo: true}); | ||
})(); | ||
``` | ||
*/ | ||
( | ||
filepath: string, | ||
data: writeJsonFile.JSONStringifyable, | ||
options?: writeJsonFile.Options | ||
): Promise<void>; | ||
/** | ||
* Mode used when writing the file. | ||
* | ||
* @default 0o666 | ||
*/ | ||
readonly mode?: number; | ||
} | ||
Stringify and write JSON to a file atomically. | ||
/** | ||
* 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}); | ||
*/ | ||
export function sync(filepath: string, data: JSONStringifyable, options?: Options): void; | ||
Creates directories for you as needed. | ||
/** | ||
* 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}); | ||
* })(); | ||
*/ | ||
export default function writeJsonFile(filepath: string, data: JSONStringifyable, options?: Options): Promise<void>; | ||
@example | ||
``` | ||
import writeJsonFile = require('write-json-file'); | ||
writeJsonFile.sync('foo.json', {foo: true}); | ||
``` | ||
*/ | ||
sync( | ||
filepath: string, | ||
data: writeJsonFile.JSONStringifyable, | ||
options?: writeJsonFile.Options | ||
): void; | ||
// TODO: Remove this for the next major release | ||
default: typeof writeJsonFile; | ||
}; | ||
export = writeJsonFile; |
@@ -71,2 +71,3 @@ 'use strict'; | ||
module.exports = writeJsonFile; | ||
// TODO: Remove this for the next major release | ||
module.exports.default = writeJsonFile; | ||
@@ -73,0 +74,0 @@ module.exports.sync = (filePath, data, options) => { |
{ | ||
"name": "write-json-file", | ||
"version": "3.1.0", | ||
"version": "3.2.0", | ||
"description": "Stringify and write JSON to a file atomically", | ||
@@ -16,3 +16,3 @@ "license": "MIT", | ||
"scripts": { | ||
"test": "xo && ava && tsd-check" | ||
"test": "xo && ava && tsd" | ||
}, | ||
@@ -39,14 +39,14 @@ "files": [ | ||
"detect-indent": "^5.0.0", | ||
"graceful-fs": "^4.1.2", | ||
"make-dir": "^1.0.0", | ||
"pify": "^4.0.0", | ||
"graceful-fs": "^4.1.15", | ||
"make-dir": "^2.1.0", | ||
"pify": "^4.0.1", | ||
"sort-keys": "^2.0.0", | ||
"write-file-atomic": "^2.0.0" | ||
"write-file-atomic": "^2.4.2" | ||
}, | ||
"devDependencies": { | ||
"ava": "*", | ||
"ava": "^1.4.1", | ||
"tempfile": "^2.0.0", | ||
"tsd-check": "^0.2.1", | ||
"xo": "*" | ||
"tsd": "^0.7.2", | ||
"xo": "^0.24.0" | ||
} | ||
} |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
7461
128
+ Addedmake-dir@2.1.0(transitive)
+ Addedsemver@5.7.2(transitive)
- Removedmake-dir@1.3.0(transitive)
- Removedpify@3.0.0(transitive)
Updatedgraceful-fs@^4.1.15
Updatedmake-dir@^2.1.0
Updatedpify@^4.0.1
Updatedwrite-file-atomic@^2.4.2