-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Start removing wildcard combined with others
- Loading branch information
Showing
3 changed files
with
46 additions
and
62 deletions.
There are no files selected for viewing
24 changes: 3 additions & 21 deletions
24
src/config/normalize/lib/star_dot_path/parsing/normalize.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,26 +1,8 @@ | ||
import { ANY_TOKEN } from './special.js' | ||
|
||
// Normalize a path of tokens | ||
export const normalizePath = function (path) { | ||
return path.map(normalizeNode) | ||
} | ||
|
||
// Nodes can be both arrays and not arrays (if they have a single element) but | ||
// we encourage the latter since it is simpler | ||
const normalizeNode = function (node) { | ||
const nodeA = node.length === 1 ? node[0] : node | ||
validateComplexNode(nodeA) | ||
return nodeA | ||
} | ||
|
||
const validateComplexNode = function (node) { | ||
if (Array.isArray(node)) { | ||
node.forEach(validateComplexToken) | ||
} | ||
return path.map(normalizeToken) | ||
} | ||
|
||
const validateComplexToken = function (token) { | ||
if (typeof token === 'symbol' && token !== ANY_TOKEN) { | ||
throw new TypeError(`${String(token)} must not be in a nested array.`) | ||
} | ||
const normalizeToken = function (token) { | ||
return token | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters