-
Notifications
You must be signed in to change notification settings - Fork 17
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
refactor(ast): followup changes for YAML 1.2 Nodes
Refs #3481
- Loading branch information
Showing
11 changed files
with
95 additions
and
90 deletions.
There are no files selected for viewing
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,9 +1,14 @@ | ||
export const isNodeType = (type: string, node: any): boolean => node?.type === type; | ||
import type Literal from './Literal'; | ||
import Position, { Point } from './Position'; | ||
import ParseResult from './ParseResult'; | ||
|
||
export const isLiteral = isNodeType.bind(undefined, 'literal'); | ||
export const isNodeType = (type: string, node: unknown): boolean => | ||
node != null && typeof node === 'object' && 'type' in node && node.type === type; | ||
|
||
export const isPosition = isNodeType.bind(undefined, 'position'); | ||
export const isLiteral = (node: unknown): node is Literal => isNodeType('literal', node); | ||
export const isPosition = (node: unknown): node is Position => isNodeType('position', node); | ||
|
||
export const isPoint = isNodeType.bind(undefined, 'point'); | ||
export const isPoint = (node: unknown): node is Point => isNodeType('point', node); | ||
|
||
export const isParseResult = isNodeType.bind(undefined, 'parseResult'); | ||
export const isParseResult = (node: unknown): node is ParseResult => | ||
isNodeType('parseResult', node); |
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
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
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
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
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,21 +1,32 @@ | ||
import type YamlStream from './YamlStream'; | ||
import type YamlDocument from './YamlDocument'; | ||
import type YamlMapping from './YamlMapping'; | ||
import type YamlSequence from './YamlSequence'; | ||
import type YamlKeyValuePair from './YamlKeyValuePair'; | ||
import type YamlTag from './YamlTag'; | ||
import type YamlScalar from './YamlScalar'; | ||
import type YamlAlias from './YamlAlias'; | ||
import type YamlDirective from './YamlDirective'; | ||
import type YamlComment from './YamlComment'; | ||
import { isNodeType } from '../../predicates'; | ||
|
||
export const isStream = isNodeType.bind(undefined, 'stream'); | ||
export const isStream = (node: unknown): node is YamlStream => isNodeType('stream', node); | ||
|
||
export const isDocument = isNodeType.bind(undefined, 'document'); | ||
export const isDocument = (node: unknown): node is YamlDocument => isNodeType('document', node); | ||
|
||
export const isMapping = isNodeType.bind(undefined, 'mapping'); | ||
export const isMapping = (node: unknown): node is YamlMapping => isNodeType('mapping', node); | ||
|
||
export const isSequence = isNodeType.bind(undefined, 'sequence'); | ||
export const isSequence = (node: unknown): node is YamlSequence => isNodeType('sequence', node); | ||
|
||
export const isKeyValuePair = isNodeType.bind(undefined, 'keyValuePair'); | ||
export const isKeyValuePair = (node: unknown): node is YamlKeyValuePair => | ||
isNodeType('keyValuePair', node); | ||
|
||
export const isTag = isNodeType.bind(undefined, 'tag'); | ||
export const isTag = (node: unknown): node is YamlTag => isNodeType('tag', node); | ||
|
||
export const isScalar = isNodeType.bind(undefined, 'scalar'); | ||
export const isScalar = (node: unknown): node is YamlScalar => isNodeType('scalar', node); | ||
|
||
export const isAlias = isNodeType.bind(undefined, 'alias'); | ||
export const isAlias = (node: unknown): node is YamlAlias => isNodeType('alias', node); | ||
|
||
export const isDirective = isNodeType.bind(undefined, 'directive'); | ||
export const isDirective = (node: unknown): node is YamlDirective => isNodeType('directive', node); | ||
|
||
export const isComment = isNodeType.bind(undefined, 'comment'); | ||
export const isComment = (node: unknown): node is YamlComment => isNodeType('comment', node); |
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