@fgv/ts-json-base
Advanced tools
Comparing version 4.1.0 to 4.2.0
@@ -5,2 +5,14 @@ { | ||
{ | ||
"version": "4.2.0", | ||
"tag": "@fgv/ts-json-base_v4.2.0", | ||
"date": "Mon, 20 Jan 2025 09:46:53 GMT", | ||
"comments": { | ||
"none": [ | ||
{ | ||
"comment": "plumb conversion context through" | ||
} | ||
] | ||
} | ||
}, | ||
{ | ||
"version": "4.1.0", | ||
@@ -7,0 +19,0 @@ "tag": "@fgv/ts-json-base_v4.1.0", |
# Change Log - @fgv/ts-json-base | ||
This log was last generated on Thu, 09 Jan 2025 05:33:39 GMT and should not be manually modified. | ||
This log was last generated on Mon, 20 Jan 2025 09:46:53 GMT and should not be manually modified. | ||
## 4.2.0 | ||
Mon, 20 Jan 2025 09:46:53 GMT | ||
### Updates | ||
- plumb conversion context through | ||
## 4.1.0 | ||
@@ -6,0 +13,0 @@ Thu, 09 Jan 2025 05:33:39 GMT |
@@ -33,3 +33,3 @@ import { Converter } from '@fgv/ts-utils'; | ||
*/ | ||
declare function convertJsonDirectorySync<T>(srcPath: string, options: IJsonFsDirectoryOptions<T>): Result<IReadDirectoryItem<T>[]>; | ||
declare function convertJsonDirectorySync<T, TC = unknown>(srcPath: string, options: IJsonFsDirectoryOptions<T, TC>): Result<IReadDirectoryItem<T>[]>; | ||
@@ -54,3 +54,3 @@ /** | ||
*/ | ||
declare function convertJsonFileSync<T>(srcPath: string, converter: Converter<T>): Result<T>; | ||
declare function convertJsonFileSync<T, TC = unknown>(srcPath: string, converter: Converter<T, TC>): Result<T>; | ||
@@ -263,3 +263,3 @@ /** | ||
*/ | ||
convertJsonFileSync<T, TC = unknown>(srcPath: string, cv: Converter<T, TC> | Validator<T, TC>): Result<T>; | ||
convertJsonFileSync<T, TC = unknown>(srcPath: string, cv: Converter<T, TC> | Validator<T, TC>, context?: TC): Result<T>; | ||
/** | ||
@@ -271,3 +271,3 @@ * Reads all JSON files from a directory and apply a supplied converter or validator. | ||
*/ | ||
convertJsonDirectorySync<T>(srcPath: string, options: IJsonFsDirectoryOptions<T>): Result<IReadDirectoryItem<T>[]>; | ||
convertJsonDirectorySync<T, TC = unknown>(srcPath: string, options: IJsonFsDirectoryOptions<T>, context?: TC): Result<IReadDirectoryItem<T>[]>; | ||
/** | ||
@@ -281,3 +281,3 @@ * Reads and converts or validates all JSON files from a directory, returning a | ||
*/ | ||
convertJsonDirectoryToMapSync<T, TC = unknown>(srcPath: string, options: IJsonFsDirectoryToMapOptions<T, TC>): Result<Map<string, T>>; | ||
convertJsonDirectoryToMapSync<T, TC = unknown>(srcPath: string, options: IJsonFsDirectoryToMapOptions<T, TC>, context?: unknown): Result<Map<string, T>>; | ||
/** | ||
@@ -284,0 +284,0 @@ * Write type-safe JSON to a file. |
@@ -16,3 +16,3 @@ import { Converter, Result } from '@fgv/ts-utils'; | ||
*/ | ||
export declare function convertJsonFileSync<T>(srcPath: string, converter: Converter<T>): Result<T>; | ||
export declare function convertJsonFileSync<T, TC = unknown>(srcPath: string, converter: Converter<T, TC>): Result<T>; | ||
/** | ||
@@ -25,3 +25,3 @@ * Reads all JSON files from a directory and apply a supplied converter. | ||
*/ | ||
export declare function convertJsonDirectorySync<T>(srcPath: string, options: IJsonFsDirectoryOptions<T>): Result<IReadDirectoryItem<T>[]>; | ||
export declare function convertJsonDirectorySync<T, TC = unknown>(srcPath: string, options: IJsonFsDirectoryOptions<T, TC>): Result<IReadDirectoryItem<T>[]>; | ||
/** | ||
@@ -28,0 +28,0 @@ * Reads and converts all JSON files from a directory, returning a |
@@ -95,3 +95,3 @@ import { Converter, Result, Validator } from '@fgv/ts-utils'; | ||
*/ | ||
convertJsonFileSync<T, TC = unknown>(srcPath: string, cv: Converter<T, TC> | Validator<T, TC>): Result<T>; | ||
convertJsonFileSync<T, TC = unknown>(srcPath: string, cv: Converter<T, TC> | Validator<T, TC>, context?: TC): Result<T>; | ||
/** | ||
@@ -103,3 +103,3 @@ * Reads all JSON files from a directory and apply a supplied converter or validator. | ||
*/ | ||
convertJsonDirectorySync<T>(srcPath: string, options: IJsonFsDirectoryOptions<T>): Result<IReadDirectoryItem<T>[]>; | ||
convertJsonDirectorySync<T, TC = unknown>(srcPath: string, options: IJsonFsDirectoryOptions<T>, context?: TC): Result<IReadDirectoryItem<T>[]>; | ||
/** | ||
@@ -113,3 +113,3 @@ * Reads and converts or validates all JSON files from a directory, returning a | ||
*/ | ||
convertJsonDirectoryToMapSync<T, TC = unknown>(srcPath: string, options: IJsonFsDirectoryToMapOptions<T, TC>): Result<Map<string, T>>; | ||
convertJsonDirectoryToMapSync<T, TC = unknown>(srcPath: string, options: IJsonFsDirectoryToMapOptions<T, TC>, context?: unknown): Result<Map<string, T>>; | ||
/** | ||
@@ -116,0 +116,0 @@ * Write type-safe JSON to a file. |
@@ -113,5 +113,5 @@ "use strict"; | ||
*/ | ||
convertJsonFileSync(srcPath, cv) { | ||
convertJsonFileSync(srcPath, cv, context) { | ||
return this.readJsonFileSync(srcPath).onSuccess((json) => { | ||
return cv.convert(json); | ||
return cv.convert(json, context); | ||
}); | ||
@@ -125,3 +125,3 @@ } | ||
*/ | ||
convertJsonDirectorySync(srcPath, options) { | ||
convertJsonDirectorySync(srcPath, options, context) { | ||
return (0, ts_utils_1.captureResult)(() => { | ||
@@ -137,3 +137,3 @@ const fullPath = path.resolve(srcPath); | ||
const filePath = path.resolve(fullPath, fi.name); | ||
return this.convertJsonFileSync(filePath, options.converter) | ||
return this.convertJsonFileSync(filePath, options.converter, context) | ||
.onSuccess((payload) => { | ||
@@ -163,4 +163,4 @@ return (0, ts_utils_1.succeed)({ | ||
*/ | ||
convertJsonDirectoryToMapSync(srcPath, options) { | ||
return this.convertJsonDirectorySync(srcPath, options).onSuccess((items) => { | ||
convertJsonDirectoryToMapSync(srcPath, options, context) { | ||
return this.convertJsonDirectorySync(srcPath, options, context).onSuccess((items) => { | ||
var _a; | ||
@@ -167,0 +167,0 @@ const transformName = (_a = options.transformName) !== null && _a !== void 0 ? _a : defaultNameTransformer; |
{ | ||
"name": "@fgv/ts-json-base", | ||
"version": "4.1.0", | ||
"version": "4.2.0", | ||
"description": "Typescript types and basic functions for working with json", | ||
@@ -19,4 +19,4 @@ "main": "lib/index.js", | ||
"devDependencies": { | ||
"@fgv/ts-utils": "4.1.0", | ||
"@fgv/ts-utils-jest": "4.1.0", | ||
"@fgv/ts-utils": "4.2.0", | ||
"@fgv/ts-utils-jest": "4.2.0", | ||
"@types/jest": "^29.5.14", | ||
@@ -42,6 +42,6 @@ "@types/node": "^20.14.9", | ||
"@microsoft/api-documenter": "^7.26.5", | ||
"@fgv/ts-extras": "4.1.0" | ||
"@fgv/ts-extras": "4.2.0" | ||
}, | ||
"peerDependencies": { | ||
"@fgv/ts-utils": "4.1.0" | ||
"@fgv/ts-utils": "4.2.0" | ||
}, | ||
@@ -48,0 +48,0 @@ "scripts": { |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
138893
1810