Skip to content

Commit 94cb78e

Browse files
committed
Generate files
1 parent 67f6881 commit 94cb78e

49 files changed

Lines changed: 830 additions & 0 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
<!-- docId=node-core-library.filedifftest.assertequal -->
2+
3+
[Home](./index.md) &gt; [node-core-library](./node-core-library.md) &gt; [FileDiffTest](./node-core-library.filedifftest.md)
4+
5+
# FileDiffTest.assertEqual method
6+
7+
Compares the contents of two files, and returns true if they are equivalent. Note that these files are not normally edited by a human; the "equivalence" comparison here is intended to ignore spurious changes that might be introduced by a tool, e.g. Git newline normalization or an editor that strips whitespace when saving.
8+
9+
**Signature:**
10+
```javascript
11+
public static assertEqual(actualFilePath: string, expectedFilePath: string): void;
12+
```
13+
**Returns:** `void`
14+
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
<!-- docId=node-core-library.filedifftest.clearcache -->
2+
3+
[Home](./index.md) &gt; [node-core-library](./node-core-library.md) &gt; [FileDiffTest](./node-core-library.filedifftest.md)
4+
5+
# FileDiffTest.clearCache method
6+
7+
Clears the internal file cache.
8+
9+
**Signature:**
10+
```javascript
11+
public static clearCache(): void;
12+
```
13+
**Returns:** `void`
14+
15+
16+
## Remarks
17+
18+
Call this method if changes have been made to the package.json files on disk.
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
<!-- docId=node-core-library.filedifftest -->
2+
3+
[Home](./index.md) &gt; [node-core-library](./node-core-library.md)
4+
5+
# FileDiffTest class
6+
7+
Implements a unit testing strategy that generates output files, and then compares them against the expected input. If the files are different, then the test fails.
8+
9+
## Constructor
10+
11+
Constructs a new instance of the `FileDiffTest` class
12+
13+
## Methods
14+
15+
| Method | Access Modifier | Returns | Description |
16+
| --- | --- | --- | --- |
17+
| [`assertEqual()`](./node-core-library.filedifftest.assertequal.md) | `public` | `void` | Compares the contents of two files, and returns true if they are equivalent. Note that these files are not normally edited by a human; the "equivalence" comparison here is intended to ignore spurious changes that might be introduced by a tool, e.g. Git newline normalization or an editor that strips whitespace when saving. |
18+
| [`clearCache()`](./node-core-library.filedifftest.clearcache.md) | `public` | `void` | Clears the internal file cache. |
19+
| [`prepareFolder(unitTestDirName, testModule)`](./node-core-library.filedifftest.preparefolder.md) | `public` | `string` | Sets up a folder in the temp directory where the unit test should write its output files to be diffed. Any previous contents of the folder will be deleted. |
20+
Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
<!-- docId=node-core-library.filedifftest.preparefolder -->
2+
3+
[Home](./index.md) &gt; [node-core-library](./node-core-library.md) &gt; [FileDiffTest](./node-core-library.filedifftest.md)
4+
5+
# FileDiffTest.prepareFolder method
6+
7+
Sets up a folder in the temp directory where the unit test should write its output files to be diffed. Any previous contents of the folder will be deleted.
8+
9+
**Signature:**
10+
```javascript
11+
public static prepareFolder(unitTestDirName: string, testModule: string): string;
12+
```
13+
**Returns:** `string`
14+
15+
A fully qualified path of the folder where the unit test should write its output
16+
17+
## Parameters
18+
19+
| Parameter | Type | Description |
20+
| --- | --- | --- |
21+
| `unitTestDirName` | `string` | the "\_\_dirname" variable, evaluated in the context of the unit test |
22+
| `testModule` | `string` | the name of the class being unit tested; must contain only letters, numbers, and underscores. |
23+
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
<!-- docId=node-core-library.jsonfile.load -->
2+
3+
[Home](./index.md) &gt; [node-core-library](./node-core-library.md) &gt; [JsonFile](./node-core-library.jsonfile.md)
4+
5+
# JsonFile.load method
6+
7+
Loads a JSON file.
8+
9+
**Signature:**
10+
```javascript
11+
public static load(jsonFilename: string): any;
12+
```
13+
**Returns:** `any`
14+
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
<!-- docId=node-core-library.jsonfile.loadandvalidate -->
2+
3+
[Home](./index.md) &gt; [node-core-library](./node-core-library.md) &gt; [JsonFile](./node-core-library.jsonfile.md)
4+
5+
# JsonFile.loadAndValidate method
6+
7+
Loads a JSON file and validate its schema.
8+
9+
**Signature:**
10+
```javascript
11+
public static loadAndValidate(jsonFilename: string, jsonSchema: JsonSchema,
12+
options?: IJsonSchemaValidateOptions): any;
13+
```
14+
**Returns:** `any`
15+
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
<!-- docId=node-core-library.jsonfile.loadandvalidatewithcallback -->
2+
3+
[Home](./index.md) &gt; [node-core-library](./node-core-library.md) &gt; [JsonFile](./node-core-library.jsonfile.md)
4+
5+
# JsonFile.loadAndValidateWithCallback method
6+
7+
Loads a JSON file and validate its schema, reporting errors using a callback
8+
9+
**Signature:**
10+
```javascript
11+
public static loadAndValidateWithCallback(jsonFilename: string, jsonSchema: JsonSchema,
12+
errorCallback: (errorInfo: IJsonSchemaErrorInfo) => void): any;
13+
```
14+
**Returns:** `any`
15+
16+
17+
## Remarks
18+
19+
See JsonSchema.validateObjectWithCallback() for more info.

api/node-core-library.jsonfile.md

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
<!-- docId=node-core-library.jsonfile -->
2+
3+
[Home](./index.md) &gt; [node-core-library](./node-core-library.md)
4+
5+
# JsonFile class
6+
7+
Utilities for reading/writing JSON files.
8+
9+
## Constructor
10+
11+
Constructs a new instance of the `JsonFile` class
12+
13+
## Methods
14+
15+
| Method | Access Modifier | Returns | Description |
16+
| --- | --- | --- | --- |
17+
| [`load()`](./node-core-library.jsonfile.load.md) | `public` | `any` | Loads a JSON file. |
18+
| [`loadAndValidate()`](./node-core-library.jsonfile.loadandvalidate.md) | `public` | `any` | Loads a JSON file and validate its schema. |
19+
| [`loadAndValidateWithCallback()`](./node-core-library.jsonfile.loadandvalidatewithcallback.md) | `public` | `any` | Loads a JSON file and validate its schema, reporting errors using a callback |
20+
| [`save(jsonObject, jsonFilename, options)`](./node-core-library.jsonfile.save.md) | `public` | `boolean` | Saves the file to disk. Returns false if nothing was written due to options.onlyIfChanged. |
21+
| [`stringify(jsonObject, options)`](./node-core-library.jsonfile.stringify.md) | `public` | `string` | Serializes the specified JSON object to a string buffer. |
22+
| [`validateNoUndefinedMembers()`](./node-core-library.jsonfile.validatenoundefinedmembers.md) | `public` | `void` | Used to validate a data structure before writing. Reports an error if there are any undefined members. |
23+
Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
<!-- docId=node-core-library.jsonfile.save -->
2+
3+
[Home](./index.md) &gt; [node-core-library](./node-core-library.md) &gt; [JsonFile](./node-core-library.jsonfile.md)
4+
5+
# JsonFile.save method
6+
7+
Saves the file to disk. Returns false if nothing was written due to options.onlyIfChanged.
8+
9+
**Signature:**
10+
```javascript
11+
public static save(jsonObject: Object, jsonFilename: string, options: IJsonFileSaveOptions = {}): boolean;
12+
```
13+
**Returns:** `boolean`
14+
15+
false if ISaveJsonFileOptions.onlyIfChanged didn't save anything; true otherwise
16+
17+
## Parameters
18+
19+
| Parameter | Type | Description |
20+
| --- | --- | --- |
21+
| `jsonObject` | `Object` | the object to be saved |
22+
| `jsonFilename` | `string` | the file path to write |
23+
| `options` | `IJsonFileSaveOptions` | other settings that control how the file is saved |
24+
Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
<!-- docId=node-core-library.jsonfile.stringify -->
2+
3+
[Home](./index.md) &gt; [node-core-library](./node-core-library.md) &gt; [JsonFile](./node-core-library.jsonfile.md)
4+
5+
# JsonFile.stringify method
6+
7+
Serializes the specified JSON object to a string buffer.
8+
9+
**Signature:**
10+
```javascript
11+
public static stringify(jsonObject: Object, options?: IJsonFileStringifyOptions): string;
12+
```
13+
**Returns:** `string`
14+
15+
a JSON string, with newlines, and indented with two spaces
16+
17+
## Parameters
18+
19+
| Parameter | Type | Description |
20+
| --- | --- | --- |
21+
| `jsonObject` | `Object` | the object to be serialized |
22+
| `options` | `IJsonFileStringifyOptions` | other settings that control serialization |
23+

0 commit comments

Comments
 (0)