Comparing version 1.5.8 to 1.5.9
{ | ||
"name": "lc2", | ||
"version": "1.5.8", | ||
"version": "1.5.9", | ||
"description": "browser automation library", | ||
@@ -34,3 +34,3 @@ "main": "src/index.js", | ||
"angular": "^1.5.8", | ||
"ava": "^0.15.2", | ||
"ava": "^0.16.0", | ||
"babel-core": "^6.13.2", | ||
@@ -37,0 +37,0 @@ "babel-loader": "^6.2.4", |
@@ -224,10 +224,2 @@ ![http://lemonce.github.io/lemoncase2](assets/header.png) | ||
`[[property:string]:[selector:string]]` - beta | ||
Get the value of a specific prop/attribute of an element that matches the selector. | ||
`{[cssAttr:string]:[selector:string]}` - beta | ||
Get the style of the element that matches the selector. | ||
### Compare operator | ||
@@ -245,2 +237,11 @@ | ||
### filter operator | ||
Filter a expression, usually a string. | ||
`exp|filter(arg1, arg2, ...)[|filter(arg1, arg2, ...)...]` | ||
example: | ||
``` | ||
"string" | substr(1, -1) | slice(0, 2); | ||
``` | ||
# Scope | ||
@@ -247,0 +248,0 @@ |
@@ -161,3 +161,3 @@ const tt = require('./tokentype').types; | ||
if (this.eat(tt.parenL)) { | ||
var node = { | ||
let node = { | ||
type: 'CallExpr', | ||
@@ -170,2 +170,14 @@ callee: base | ||
return node; | ||
} else if (this.eat(tt.pipe)) { | ||
let node = { | ||
type: 'FilterExpr', | ||
object: base, | ||
filter: this.parseIndent().name | ||
}; | ||
this.expect(tt.parenL); | ||
node.params = this.parseExprList(tt.parenR, false, false); | ||
base = node; | ||
} else { | ||
@@ -274,2 +286,21 @@ return base; | ||
pp.parseExprList = function (close, allowEmpty, allowTrailingComma) { | ||
let elts = [], first = true; | ||
while(!this.eat(close)) { | ||
if (first) first = false; | ||
else this.expect(tt.comma); | ||
if (allowEmpty && this.type === tt.comma) { | ||
elts.push(null); | ||
} else { | ||
var elem = this.parseMaybeAssign(); | ||
elts.push(elem); | ||
} | ||
} | ||
return elts; | ||
} | ||
pp.parseIndent = function () { | ||
@@ -276,0 +307,0 @@ var name; |
@@ -9,3 +9,4 @@ const reserve = ['in', 'by', 'to']; | ||
const keywords = ['wait', 'assert', 'log', 'console', 'var', 'process', | ||
'return', 'true', 'false'].concat(reserve).concat(actions); | ||
'return', 'true', 'false', 'if', 'else', | ||
'while'].concat(reserve).concat(actions); | ||
@@ -12,0 +13,0 @@ const keywordRegexp = new RegExp('^(' + keywords.join('|') + ')$'); |
@@ -180,2 +180,9 @@ const tt = require('./tokentype').types; | ||
return this.parseExprStatement(node); | ||
case tt._if: | ||
return this.parseIfStatement(node); | ||
case tt._while: | ||
return this.parseWhileStatement(node); | ||
case tt.braceL: | ||
return this.parseBlock(); | ||
default: | ||
@@ -420,2 +427,19 @@ return this.parseEvaluation(node); | ||
pp.parseIfStatement = function (node) { | ||
this.next(); | ||
node.test = this.parseExpression(); | ||
node.consequent = this.parseBlock(); | ||
node.alternate = this.eat(tt._else) ? this.parseStatement() : null; | ||
return this.finishNode(node, 'If'); | ||
}; | ||
pp.parseWhileStatement = function (node) { | ||
this.next(); | ||
node.test = this.parseExpression(); | ||
node.body = this.parseStatement(); | ||
return this.finishNode(node, 'While'); | ||
}; | ||
pp.startNode = function () { | ||
@@ -422,0 +446,0 @@ return { |
@@ -142,3 +142,7 @@ const identifier = require('./identifier'); | ||
this.raise(this.pos, 'bitwise operator is not allowed'); | ||
if (code === 124) { | ||
return this.finishOp(tt.pipe, 1); | ||
} else { | ||
this.raise(this.pos, 'bitwise operator is not allowed'); | ||
} | ||
}; | ||
@@ -145,0 +149,0 @@ |
@@ -55,2 +55,3 @@ // The assignment of fine-grained, information-carrying type objects | ||
tagR: new TokenType('/>'), | ||
pipe: new TokenType('|'), | ||
@@ -119,2 +120,5 @@ // Operators. These carry several kinds of properties to help the | ||
kw('false'); | ||
kw('if'); | ||
kw('else'); | ||
kw('while'); | ||
kw('jumpto'); | ||
@@ -121,0 +125,0 @@ kw('refresh'); |
@@ -34,6 +34,15 @@ // walk a javascript style tree and transform it into a function | ||
}, | ||
FilterExpr: function (node, c) { | ||
let bindingList = c(node.object); | ||
node.params.forEach(function (expr) { | ||
bindingList += ',' + c(expr); | ||
}); | ||
return 'f.' + node.filter + '(' + bindingList + ')'; | ||
}, | ||
// end point node | ||
literal: function (node) { | ||
return node.raw.replace('\\', '\\\\'); | ||
return node.raw.replace(/\\/g, '\\\\'); | ||
}, | ||
@@ -40,0 +49,0 @@ regexp: function (node) { |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
226647
4940
344