@scalar/helpers
Advanced tools
| /** | ||
| * Deep-merges `override` onto `base` and returns a new object. | ||
| * | ||
| * Designed for layering partial overrides on top of a complete base (for example, merging | ||
| * user-provided configuration onto defaults): | ||
| * | ||
| * - Nested plain objects are merged recursively. | ||
| * - `undefined` values in `override` are skipped, so an override never clears a base value. | ||
| * - Any non-plain-object value (including arrays) replaces the base value outright. | ||
| * | ||
| * The `base` is never mutated. | ||
| * | ||
| * Unlike a generic deep merge, this intentionally preserves base values for `undefined` overrides | ||
| * and replaces (rather than concatenates) arrays, which is the behavior config-style merges expect. | ||
| */ | ||
| export declare const mergeObjects: <T extends Record<string, unknown>>(base: T, override?: unknown) => T; | ||
| //# sourceMappingURL=merge-objects.d.ts.map |
| {"version":3,"file":"merge-objects.d.ts","sourceRoot":"","sources":["../../src/object/merge-objects.ts"],"names":[],"mappings":"AAEA;;;;;;;;;;;;;;GAcG;AACH,eAAO,MAAM,YAAY,GAAI,CAAC,SAAS,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,EAAE,MAAM,CAAC,EAAE,WAAW,OAAO,KAAG,CAiB7F,CAAA"} |
| import { isObject } from './is-object.js'; | ||
| /** | ||
| * Deep-merges `override` onto `base` and returns a new object. | ||
| * | ||
| * Designed for layering partial overrides on top of a complete base (for example, merging | ||
| * user-provided configuration onto defaults): | ||
| * | ||
| * - Nested plain objects are merged recursively. | ||
| * - `undefined` values in `override` are skipped, so an override never clears a base value. | ||
| * - Any non-plain-object value (including arrays) replaces the base value outright. | ||
| * | ||
| * The `base` is never mutated. | ||
| * | ||
| * Unlike a generic deep merge, this intentionally preserves base values for `undefined` overrides | ||
| * and replaces (rather than concatenates) arrays, which is the behavior config-style merges expect. | ||
| */ | ||
| export const mergeObjects = (base, override) => { | ||
| if (!override || !isObject(override)) { | ||
| return { ...base }; | ||
| } | ||
| const result = { ...base }; | ||
| for (const [key, value] of Object.entries(override)) { | ||
| if (value === undefined) { | ||
| continue; | ||
| } | ||
| const baseValue = result[key]; | ||
| result[key] = isObject(baseValue) && isObject(value) ? mergeObjects(baseValue, value) : value; | ||
| } | ||
| return result; | ||
| }; |
+10
-0
| # @scalar/helpers | ||
| ## 0.9.0 | ||
| ### Minor Changes | ||
| - [#9597](https://github.com/scalar/scalar/pull/9597): Add API Reference UI localization configuration with built-in English, Russian, Spanish, French, German, Simplified Chinese and Arabic translations, including automatic RTL direction for Arabic locales. | ||
| Update the shared theme reset so text inputs align to the logical start by default for RTL documents. | ||
| Add a `mergeObjects` deep-merge helper to `@scalar/helpers`, used by the localization layer to merge translation overrides onto the built-in locale. | ||
| ## 0.8.2 | ||
@@ -4,0 +14,0 @@ |
+2
-2
@@ -17,3 +17,3 @@ { | ||
| ], | ||
| "version": "0.8.2", | ||
| "version": "0.9.0", | ||
| "engines": { | ||
@@ -131,3 +131,3 @@ "node": ">=22" | ||
| "vitest": "4.1.0", | ||
| "@scalar/themes": "0.16.0" | ||
| "@scalar/themes": "0.16.2" | ||
| }, | ||
@@ -134,0 +134,0 @@ "scripts": { |
URL strings
Supply chain riskPackage contains fragments of external URLs or IP addresses, which the package may be accessing at runtime.
URL strings
Supply chain riskPackage contains fragments of external URLs or IP addresses, which the package may be accessing at runtime.
276727
1.03%237
1.28%5875
0.79%