@zodash/to-path
Advanced tools
Comparing version 0.1.6 to 0.1.7
@@ -6,2 +6,10 @@ # Change Log | ||
## [0.1.7](https://github.com/zcorky/zodash/compare/@zodash/to-path@0.1.6...@zodash/to-path@0.1.7) (2022-01-06) | ||
**Note:** Version bump only for package @zodash/to-path | ||
## [0.1.6](https://github.com/zcorky/zodash/compare/@zodash/to-path@0.1.5...@zodash/to-path@0.1.6) (2021-09-22) | ||
@@ -8,0 +16,0 @@ |
@@ -20,3 +20,6 @@ /** | ||
* // => ['a', '[]', 'b', 'c'] | ||
* | ||
* toPath('SERVICE_CONFIG_ID', '_') | ||
* // => ['SERVICE', 'CONFIG', 'ID'] | ||
*/ | ||
export declare function toPath(pathString: string): string[]; | ||
export declare function toPath(pathString: string, separator?: string): string[]; |
@@ -23,11 +23,14 @@ "use strict"; | ||
* // => ['a', '[]', 'b', 'c'] | ||
* | ||
* toPath('SERVICE_CONFIG_ID', '_') | ||
* // => ['SERVICE', 'CONFIG', 'ID'] | ||
*/ | ||
function toPath(pathString) { | ||
function toPath(pathString, separator = '.') { | ||
if (!pathString) | ||
return []; | ||
return pathString | ||
.replace(/\[(\w+)\]/g, '.$1') | ||
.replace(/(\[\])/g, '.$1') | ||
.split('.'); | ||
.replace(/\[(\w+)\]/g, `${separator}$1`) | ||
.replace(/(\[\])/g, `${separator}$1`) | ||
.split(separator); | ||
} | ||
exports.toPath = toPath; |
{ | ||
"name": "@zodash/to-path", | ||
"version": "0.1.6", | ||
"version": "0.1.7", | ||
"description": "Transform path string to path array", | ||
@@ -70,3 +70,3 @@ "keywords": [ | ||
}, | ||
"gitHead": "94dc8d1577cd67a4cf89884b10c23eb9caeef9f7" | ||
"gitHead": "4ec13e4134583b9ce15b6b9b4eb2dbc1dabbc6ee" | ||
} |
6404
59