Skip to content

Commit

Permalink
Move file
Browse files Browse the repository at this point in the history
  • Loading branch information
ehmicky committed Feb 27, 2022
1 parent edf6e8b commit 51c9c32
Show file tree
Hide file tree
Showing 7 changed files with 31 additions and 28 deletions.
2 changes: 1 addition & 1 deletion src/config/normalize/lib/star_dot_path/entries/main.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import isPlainObj from 'is-plain-obj'

import { isAnyPart } from '../parsing/special.js'
import { isAnyPart } from '../parsing/token.js'

import { getComplexEntries } from './complex.js'

Expand Down
3 changes: 2 additions & 1 deletion src/config/normalize/lib/star_dot_path/get.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,8 @@ import { listEntries } from './entries/main.js'
import { maybeParse } from './parsing/parse.js'
import { pathToTokens } from './parsing/path.js'
import { serialize } from './parsing/serialize.js'
import { ANY, isAnyTokens } from './parsing/special.js'
import { ANY } from './parsing/special.js'
import { isAnyTokens } from './parsing/token.js'

// Retrieve all properties in `target` matching a query string.
// The return value is an object where the key is the path to each value.
Expand Down
3 changes: 2 additions & 1 deletion src/config/normalize/lib/star_dot_path/parsing/parse.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import { pathToTokens } from './path.js'
import { ESCAPE, SEPARATOR, ANY, createAnyPart } from './special.js'
import { ESCAPE, SEPARATOR, ANY } from './special.js'
import { createAnyPart } from './token.js'

// Parse a query string into an array of tokens.
// This is similar to JSON paths but:
Expand Down
3 changes: 2 additions & 1 deletion src/config/normalize/lib/star_dot_path/parsing/path.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import { ANY, isAnyToken } from './special.js'
import { ANY } from './special.js'
import { isAnyToken } from './token.js'

// From an array of property names to an array to tokens
export const pathToTokens = function (path) {
Expand Down
3 changes: 2 additions & 1 deletion src/config/normalize/lib/star_dot_path/parsing/serialize.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import { SEPARATOR, ANY, SPECIAL_CHARS_REGEXP, isAnyPart } from './special.js'
import { SEPARATOR, ANY, SPECIAL_CHARS_REGEXP } from './special.js'
import { isAnyPart } from './token.js'

// Inverse of `parse()`
export const serialize = function (tokens) {
Expand Down
23 changes: 0 additions & 23 deletions src/config/normalize/lib/star_dot_path/parsing/special.js
Original file line number Diff line number Diff line change
@@ -1,26 +1,3 @@
import isPlainObj from 'is-plain-obj'

// Check if at least one token has some ANY parts
export const isAnyTokens = function (tokens) {
return tokens.some(isAnyToken)
}

// Check if a token has some ANY parts
export const isAnyToken = function (token) {
return token.some(isAnyPart)
}

// Check if a token part is ANY
export const isAnyPart = function (part) {
return isPlainObj(part) && part.type === ANY_TYPE
}

export const createAnyPart = function () {
return { type: ANY_TYPE }
}

const ANY_TYPE = 'any'

// All special characters
export const ESCAPE = '\\'
export const SEPARATOR = '.'
Expand Down
22 changes: 22 additions & 0 deletions src/config/normalize/lib/star_dot_path/parsing/token.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
import isPlainObj from 'is-plain-obj'

// Check if at least one token has some ANY parts
export const isAnyTokens = function (tokens) {
return tokens.some(isAnyToken)
}

// Check if a token has some ANY parts
export const isAnyToken = function (token) {
return token.some(isAnyPart)
}

// Check if a token part is ANY
export const isAnyPart = function (part) {
return isPlainObj(part) && part.type === ANY_TYPE
}

export const createAnyPart = function () {
return { type: ANY_TYPE }
}

const ANY_TYPE = 'any'

0 comments on commit 51c9c32

Please sign in to comment.