@app-config/extension-utils
Advanced tools
Comparing version 2.4.6 to 2.5.0
@@ -5,2 +5,3 @@ import type { ParsingExtension, ParsingExtensionKey, ParsingExtensionTransform } from '@app-config/core'; | ||
export declare function composeExtensions(extensions: ParsingExtension[]): ParsingExtension; | ||
export declare function named(name: string, parsingExtension: ParsingExtension): ParsingExtension; | ||
export declare function forKey(key: string | string[], parsingExtension: ParsingExtension): ParsingExtension; | ||
@@ -7,0 +8,0 @@ export declare function keysToPath(keys: ParsingExtensionKey[]): string; |
import { parseValue, Root, AppConfigError } from '@app-config/core'; | ||
import { SchemaBuilder } from '@serafin/schema-builder'; | ||
export function composeExtensions(extensions) { | ||
return (value, [k]) => { | ||
const composed = (value, [k]) => { | ||
// only applies to the root - override the parsing extensions | ||
if (k !== Root) | ||
return false; | ||
return (_, __, source) => parseValue(value, source, extensions, { shouldFlatten: true }); | ||
return (_, __, source, baseExtensions) => | ||
// restart the parse tree, but with additional extensions included | ||
parseValue(value, source, | ||
// ensures that a recursion doesn't happen | ||
baseExtensions.concat(extensions).filter((v) => v !== composed), { shouldFlatten: true }); | ||
}; | ||
return composed; | ||
} | ||
export function named(name, parsingExtension) { | ||
Object.defineProperty(parsingExtension, 'extensionName', { value: name }); | ||
return parsingExtension; | ||
} | ||
export function forKey(key, parsingExtension) { | ||
@@ -11,0 +21,0 @@ const shouldApply = ([_, k]) => { |
@@ -5,2 +5,3 @@ import type { ParsingExtension, ParsingExtensionKey, ParsingExtensionTransform } from '@app-config/core'; | ||
export declare function composeExtensions(extensions: ParsingExtension[]): ParsingExtension; | ||
export declare function named(name: string, parsingExtension: ParsingExtension): ParsingExtension; | ||
export declare function forKey(key: string | string[], parsingExtension: ParsingExtension): ParsingExtension; | ||
@@ -7,0 +8,0 @@ export declare function keysToPath(keys: ParsingExtensionKey[]): string; |
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.validationFunction = exports.validateOptions = exports.ParsingExtensionInvalidOptions = exports.keysToPath = exports.forKey = exports.composeExtensions = void 0; | ||
exports.validationFunction = exports.validateOptions = exports.ParsingExtensionInvalidOptions = exports.keysToPath = exports.forKey = exports.named = exports.composeExtensions = void 0; | ||
const core_1 = require("@app-config/core"); | ||
const schema_builder_1 = require("@serafin/schema-builder"); | ||
function composeExtensions(extensions) { | ||
return (value, [k]) => { | ||
const composed = (value, [k]) => { | ||
// only applies to the root - override the parsing extensions | ||
if (k !== core_1.Root) | ||
return false; | ||
return (_, __, source) => core_1.parseValue(value, source, extensions, { shouldFlatten: true }); | ||
return (_, __, source, baseExtensions) => | ||
// restart the parse tree, but with additional extensions included | ||
core_1.parseValue(value, source, | ||
// ensures that a recursion doesn't happen | ||
baseExtensions.concat(extensions).filter((v) => v !== composed), { shouldFlatten: true }); | ||
}; | ||
return composed; | ||
} | ||
exports.composeExtensions = composeExtensions; | ||
function named(name, parsingExtension) { | ||
Object.defineProperty(parsingExtension, 'extensionName', { value: name }); | ||
return parsingExtension; | ||
} | ||
exports.named = named; | ||
function forKey(key, parsingExtension) { | ||
@@ -15,0 +26,0 @@ const shouldApply = ([_, k]) => { |
{ | ||
"name": "@app-config/extension-utils", | ||
"description": "Utilities for writing @app-config parsing extensions", | ||
"version": "2.4.6", | ||
"version": "2.5.0", | ||
"license": "MPL-2.0", | ||
@@ -33,3 +33,3 @@ "author": { | ||
"dependencies": { | ||
"@app-config/core": "^2.4.6", | ||
"@app-config/core": "^2.5.0", | ||
"@serafin/schema-builder": "0.14" | ||
@@ -36,0 +36,0 @@ }, |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
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
14870
194
Updated@app-config/core@^2.5.0