Comparing version 4.0.0-revert-119-revert-113-dali-typed.3542 to 4.0.0-uncase.4125
@@ -23,10 +23,3 @@ import { ASTContent, ASTNode } from '@stridespark/model-core'; | ||
export declare function filter(node: ASTContent, predicate: (node: ASTNode) => boolean): ASTNode[]; | ||
export declare function retagNodes(node: ASTNode, replace: string, replaceWith: string): ASTNode; | ||
/** | ||
* Returns an array of ASTs, each of which represents a condition sufficient for the expression to evaluate true. | ||
* The array of ASTs comprise the input node, split on "or"s. | ||
* For example, "a and (b or c)" will not be split, but "a or (b or c) or d" will be split into an array of 4 ASTs. | ||
* @param node | ||
*/ | ||
export declare function splitOnOr(node: ASTContent): ASTContent[]; | ||
export declare function retagNodes(node: ASTNode, replace: string[], replaceWith: string): ASTNode; | ||
//# sourceMappingURL=index.d.ts.map |
@@ -82,3 +82,3 @@ "use strict"; | ||
} | ||
if (node.tag === replace) { | ||
if (replace.indexOf(node.tag) !== -1) { | ||
node.tag = replaceWith; | ||
@@ -90,18 +90,2 @@ } | ||
} | ||
/** | ||
* Returns an array of ASTs, each of which represents a condition sufficient for the expression to evaluate true. | ||
* The array of ASTs comprise the input node, split on "or"s. | ||
* For example, "a and (b or c)" will not be split, but "a or (b or c) or d" will be split into an array of 4 ASTs. | ||
* @param node | ||
*/ | ||
function splitOnOr(node) { | ||
if (node == undefined) { | ||
throw new Error('Invalid ASTContent passed into function splitOnOr'); | ||
} | ||
if (typeof node === 'string' || node.tag !== 'or' || node.content === null) { | ||
return [node]; | ||
} | ||
return Array.prototype.concat.apply([], node.content.map(splitOnOr)); | ||
} | ||
exports.splitOnOr = splitOnOr; | ||
//# sourceMappingURL=index.js.map |
{ | ||
"name": "ast-ts", | ||
"version": "4.0.0-revert-119-revert-113-dali-typed.3542", | ||
"version": "4.0.0-uncase.4125", | ||
"description": "ast representation and transform function with typescript definitions", | ||
@@ -5,0 +5,0 @@ "main": "lib/src/index.js", |
@@ -82,3 +82,3 @@ import { ASTContent, ASTNode } from '@stridespark/model-core'; | ||
export function retagNodes(node: ASTNode, replace: string, replaceWith: string): ASTNode { | ||
export function retagNodes(node: ASTNode, replace: string[], replaceWith: string): ASTNode { | ||
const copy = JSON.parse(JSON.stringify(node)); | ||
@@ -89,7 +89,7 @@ _retagInner(copy, replace, replaceWith); | ||
function _retagInner(node: ASTContent, replace: string, replaceWith: string) { | ||
function _retagInner(node: ASTContent, replace: string[], replaceWith: string) { | ||
if (typeof node === 'string') { | ||
return; | ||
} | ||
if (node.tag === replace) { | ||
if (replace.indexOf(node.tag) !== -1) { | ||
node.tag = replaceWith; | ||
@@ -101,17 +101,1 @@ } | ||
} | ||
/** | ||
* Returns an array of ASTs, each of which represents a condition sufficient for the expression to evaluate true. | ||
* The array of ASTs comprise the input node, split on "or"s. | ||
* For example, "a and (b or c)" will not be split, but "a or (b or c) or d" will be split into an array of 4 ASTs. | ||
* @param node | ||
*/ | ||
export function splitOnOr(node: ASTContent): ASTContent[] { | ||
if (node == undefined) { | ||
throw new Error('Invalid ASTContent passed into function splitOnOr'); | ||
} | ||
if (typeof node === 'string' || node.tag !== 'or' || node.content === null) { | ||
return [node]; | ||
} | ||
return Array.prototype.concat.apply([], node.content.map(splitOnOr)); | ||
} |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
12581
9
230