joinPath

Serialize an array of path segments into a single path string, the inverse of toPath for building dot and bracket accessors.

Usage

joinPath serializes an array of path segments into a path string.

import { joinPath } from '@movk/core'

const p = joinPath(['a', 'x.y', 0, 'space key'])
// p: "a['x.y'][0]['space key']"
// Round-trips with toPath: toPath(p) => ['a', 'x.y', 0, 'space key']

API

joinPath(segments)

Serialize an array of path segments into a path string.

Parameters

segments
[string | number]() required
An array of path segments.

Returns

returns
string
The serialized path string.

Changelog

No recent changes
Copyright © 2024 - 2026 YiXuan - MIT License