Comparing version 1.4.0 to 1.5.0
{ | ||
"name": "ast-ts", | ||
"version": "1.4.0", | ||
"version": "1.5.0", | ||
"description": "ast representation and transform function with typescript definitions", | ||
@@ -5,0 +5,0 @@ "main": "src/index.js", |
@@ -24,1 +24,8 @@ import { ASTContent, ASTNode } from '@stridespark/model-core'; | ||
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[]; |
@@ -89,2 +89,18 @@ "use strict"; | ||
} | ||
/** | ||
* 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 |
6542
134