@ganache/options
Advanced tools
Comparing version 0.8.0 to 0.9.0
@@ -13,3 +13,3 @@ "use strict"; | ||
}; | ||
var _OptionsConfig_defaults, _OptionsConfig_namespaces; | ||
var _OptionsConfig_defaults; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
@@ -29,16 +29,13 @@ exports.OptionsConfig = void 0; | ||
}; | ||
function fill(defaults, options, target, namespace) { | ||
const def = defaults[namespace]; | ||
function fill(options, target, def, namespace) { | ||
const config = (target[namespace] = target[namespace] || {}); | ||
const flavor = options.flavor; | ||
const suppliedOptions = new Set(); | ||
const keys = Object.keys(def); | ||
const entries = Object.entries(def); | ||
if ((0, utils_1.hasOwn)(options, namespace)) { | ||
const namespaceOptions = options[namespace]; | ||
for (let i = 0, l = keys.length; i < l; i++) { | ||
const key = keys[i]; | ||
const propDefinition = def[key]; | ||
for (const [key, propDefinition] of entries) { | ||
let value = namespaceOptions[key]; | ||
if (value !== undefined) { | ||
const normalized = propDefinition.normalize(namespaceOptions[key]); | ||
const normalized = propDefinition.normalize(value, config); | ||
if (normalized !== undefined) { | ||
@@ -54,3 +51,3 @@ checkForConflicts(key, namespace, suppliedOptions, propDefinition.conflicts); | ||
if (value !== undefined) { | ||
const normalized = propDefinition.normalize(value); | ||
const normalized = propDefinition.normalize(value, config); | ||
if (normalized !== undefined) { | ||
@@ -69,9 +66,7 @@ checkForConflicts(key, namespace, suppliedOptions, propDefinition.conflicts); | ||
else { | ||
for (let i = 0, l = keys.length; i < l; i++) { | ||
const key = keys[i]; | ||
const propDefinition = def[key]; | ||
for (const [key, propDefinition] of entries) { | ||
const legacyName = propDefinition.legacyName || key; | ||
const value = options[legacyName]; | ||
if (value !== undefined) { | ||
const normalized = propDefinition.normalize(value); | ||
const normalized = propDefinition.normalize(value, config); | ||
if (normalized !== undefined) { | ||
@@ -92,11 +87,8 @@ checkForConflicts(key, namespace, suppliedOptions, propDefinition.conflicts); | ||
_OptionsConfig_defaults.set(this, void 0); | ||
_OptionsConfig_namespaces.set(this, void 0); | ||
__classPrivateFieldSet(this, _OptionsConfig_defaults, defaults, "f"); | ||
__classPrivateFieldSet(this, _OptionsConfig_namespaces, Object.keys(defaults), "f"); | ||
} | ||
normalize(options) { | ||
const defaults = __classPrivateFieldGet(this, _OptionsConfig_defaults, "f"); | ||
const out = {}; | ||
__classPrivateFieldGet(this, _OptionsConfig_namespaces, "f").forEach(namespace => { | ||
fill(defaults, options, out, namespace); | ||
Object.entries(__classPrivateFieldGet(this, _OptionsConfig_defaults, "f")).forEach(([namespace, definition]) => { | ||
fill(options, out, definition, namespace); | ||
}); | ||
@@ -107,3 +99,3 @@ return out; | ||
exports.OptionsConfig = OptionsConfig; | ||
_OptionsConfig_defaults = new WeakMap(), _OptionsConfig_namespaces = new WeakMap(); | ||
_OptionsConfig_defaults = new WeakMap(); | ||
//# sourceMappingURL=create.js.map |
@@ -6,3 +6,3 @@ { | ||
}, | ||
"version": "0.8.0", | ||
"version": "0.9.0", | ||
"description": "Ganache's server/provider options TypeScript types", | ||
@@ -49,3 +49,3 @@ "author": "David Murdoch <david@trufflesuite.com> (https://davidmurdoch.com)", | ||
"dependencies": { | ||
"@ganache/utils": "0.8.0", | ||
"@ganache/utils": "0.9.0", | ||
"bip39": "3.0.4", | ||
@@ -61,3 +61,3 @@ "seedrandom": "3.0.5" | ||
}, | ||
"gitHead": "7cba77c07030f113ddad4258fdf3dd0150f8bcbf" | ||
"gitHead": "cb66fef410b40d628acfd97f32e6b300e6f9f562" | ||
} |
@@ -5,3 +5,3 @@ import { Base, CliTypeMap, CliTypes } from "./base"; | ||
import { UnionToIntersection } from "./types"; | ||
declare type Normalize<C extends Base.Config, N extends OptionName<C> = OptionName<C>> = (rawInput: OptionRawType<C, N>) => OptionType<C, N>; | ||
declare type Normalize<C extends Base.Config, N extends OptionName<C> = OptionName<C>> = (rawInput: OptionRawType<C, N>, config: Readonly<InternalConfig<C>>) => OptionType<C, N>; | ||
export declare type ExternalConfig<C extends Base.Config> = Partial<ExclusiveGroupUnionAndUnconstrainedPlus<C, "rawType">>; | ||
@@ -8,0 +8,0 @@ export declare type InternalConfig<C extends Base.Config> = ExclusiveGroupUnionAndUnconstrainedPlus<C, "type">; |
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
Sorry, the diff of this file is not supported yet
59495
283
+ Added@ganache/utils@0.9.0(transitive)
- Removed@ganache/utils@0.8.0(transitive)
Updated@ganache/utils@0.9.0