Skip to content

Commit

Permalink
Improve serialization
Browse files Browse the repository at this point in the history
  • Loading branch information
ehmicky committed Mar 6, 2022
1 parent a072b87 commit 4524a92
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 10 deletions.
5 changes: 2 additions & 3 deletions src/config/normalize/lib/star_dot_path/parsing/parse.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,11 +21,10 @@ import { ESCAPE, SEPARATOR, ANY, SPECIAL_CHARS, ANY_TOKEN } from './special.js'
// - `Symbol.for('*')` for wildcards
// - We use symbols as it allows using dynamic strings without injection
// risk
// - An array of the above
// We allow passing an array of tokens instead of a query string:
// - This is sometimes more convenient
// - Also, this allows property names to include special characters (dots,
// brackets, star) or to be symbols
// - Also, this allows property names to include special characters or to be
// symbols
// - This removes the need for escaping
// Exceptions are thrown on syntax errors:
// - I.e. query or path syntax errors, or wrong arguments
Expand Down
8 changes: 1 addition & 7 deletions src/config/normalize/lib/star_dot_path/parsing/serialize.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,7 @@ import { SEPARATOR, ANY, ANY_TOKEN, SPECIAL_CHARS_REGEXP } from './special.js'

// Inverse of `parse()`
export const serialize = function (path) {
return path.map(serializeNode).join(SEPARATOR)
}

const serializeNode = function (node, index) {
return Array.isArray(node)
? node.map((token) => serializeToken(token, index)).join('')
: serializeToken(node, 0)
return path.map(serializeToken).join(SEPARATOR)
}

const serializeToken = function (token, index) {
Expand Down

0 comments on commit 4524a92

Please sign in to comment.