goose-parser
Advanced tools
Comparing version 0.3.0-alpha.2 to 0.3.0-alpha.3
@@ -201,3 +201,3 @@ 'use strict'; | ||
actionPromise = actionInstance.perform(); | ||
actionPromise = vow.resolve(actionInstance.perform()); | ||
@@ -276,5 +276,5 @@ if (action.transform) { | ||
debug('scroll %s px', interval); | ||
return this._env.evaluateJs(interval, /* @covignore */ function(interval) { | ||
return vow.resolve(this._env.evaluateJs(interval, /* @covignore */ function(interval) { | ||
document.body.scrollTop += interval; | ||
}); | ||
})); | ||
} | ||
@@ -281,0 +281,0 @@ }; |
@@ -185,6 +185,5 @@ var debug = require('debug')('Paginator'), | ||
var previousHeight; | ||
return this._env | ||
.evaluateJs(/* @covignore */ function () { | ||
return vow.resolve(this._env.evaluateJs(/* @covignore */ function () { | ||
return document.body.scrollHeight; | ||
}) | ||
})) | ||
.then(function (height) { | ||
@@ -217,3 +216,3 @@ previousHeight = height; | ||
_getRealNextPageIndex: function () { | ||
return this._env.evaluateJs(this._scope, /* @covignore */ function (selector) { | ||
return vow.resolve(this._env.evaluateJs(this._scope, /* @covignore */ function (selector) { | ||
var nodes = Sizzle(selector); | ||
@@ -223,3 +222,3 @@ return nodes.map(function (node) { | ||
}); | ||
}).then(function (pages) { | ||
})).then(function (pages) { | ||
var pageIndex; | ||
@@ -247,3 +246,3 @@ if (!Array.isArray(pages) || (pageIndex = pages.indexOf(this._currentPage + 1)) === -1) { | ||
.then(function () { | ||
return this._env.evaluateJs(this._pageScope, this._getPaginatePageHtml); | ||
return vow.resolve(this._env.evaluateJs(this._pageScope, this._getPaginatePageHtml)); | ||
}, this) | ||
@@ -257,3 +256,3 @@ .then(function (html) { | ||
case this.STRATEGY.NEW_PAGE: | ||
paginationPromise = this._env.waitForPage(this._timeout); | ||
paginationPromise = vow.resolve(this._env.waitForPage(this._timeout)); | ||
break; | ||
@@ -265,3 +264,3 @@ case this.STRATEGY.AJAX: | ||
paginationPromise = vow.any([ | ||
this._env.waitForPage(this._timeout).then(function () { | ||
vow.resolve(this._env.waitForPage(this._timeout)).then(function () { | ||
this._strategy = this.STRATEGY.NEW_PAGE; | ||
@@ -302,3 +301,3 @@ debug('Set strategy to %s', this._strategy); | ||
var previousPageHtml; | ||
return this._env.evaluateJs(this._pageScope, this._getPaginatePageHtml) | ||
return vow.resolve(this._env.evaluateJs(this._pageScope, this._getPaginatePageHtml)) | ||
.then(html => { | ||
@@ -305,0 +304,0 @@ previousPageHtml = html; |
@@ -152,3 +152,3 @@ 'use strict'; | ||
var results; | ||
return this._env.prepare() | ||
return vow.resolve(this._env.prepare()) | ||
.then(() => { | ||
@@ -173,5 +173,4 @@ if (this._preActions) { | ||
.then( | ||
() => this._env.tearDown(), | ||
e => this._env | ||
.snapshot('error') | ||
() => vow.resolve(this._env.tearDown()), | ||
e => vow.resolve(this._env.snapshot('error')) | ||
.always(this._env.tearDown, this._env) | ||
@@ -198,4 +197,3 @@ .then(() => { | ||
return this._env | ||
.prepare() | ||
return vow.resolve(this._env.prepare()) | ||
.then(() => milestones.reduce((promise, milestone) => { | ||
@@ -205,6 +203,5 @@ return promise.then(() => this.passMilestone(milestone, edgeCases)); | ||
.then( | ||
() => this._env.tearDown(), | ||
e => this._env | ||
.snapshot('error') | ||
.always(() => this._env.tearDown()) | ||
() => vow.resolve(this._env.tearDown()), | ||
e => vow.resolve(this._env.snapshot('error')) | ||
.always(() => vow.resolve(this._env.tearDown())) | ||
.then(() => { | ||
@@ -583,6 +580,5 @@ throw e | ||
var collection = rule.collection[0]; | ||
return this._env | ||
.evaluateJs(this._getSelector(), /* @covignore */ function(selector) { | ||
return vow.resolve(this._env.evaluateJs(this._getSelector(), /* @covignore */ function(selector) { | ||
return Sizzle(selector).length; | ||
}) | ||
})) | ||
.then((nodesCount) => { | ||
@@ -647,3 +643,3 @@ debug('parsing %s nodes', nodesCount); | ||
debug('clear parsed dom for %s', selector); | ||
return this._env.evaluateJs(selector, /* @covignore */ function(selector) { | ||
return vow.resolve(this._env.evaluateJs(selector, /* @covignore */ function(selector) { | ||
var parsedElement = Sizzle(selector)[0]; | ||
@@ -658,3 +654,3 @@ if (!parsedElement) { | ||
parsedElement.style.width = boundingRect.width + 'px'; | ||
}).then(function() { | ||
})).then(function() { | ||
return results; | ||
@@ -670,4 +666,3 @@ }); | ||
let internalGooseResults, internalGooseError; | ||
return this._env | ||
.injectBrowserEnv() | ||
return vow.resolve(this._env.injectBrowserEnv()) | ||
.then(() => this._env.evaluateJs(rule, offset, this._scopes, function(rule, offset, scopes) { | ||
@@ -758,3 +753,3 @@ __gooseParse(rule, offset, scopes); | ||
debug('._parseSimpleRule() has called for selector %s with filter %o', selector, filter); | ||
return this._env.evaluateJs(selector, filter, /* @covignore */ function(selector, filter) { | ||
return vow.resolve(this._env.evaluateJs(selector, filter, /* @covignore */ function(selector, filter) { | ||
var nodes = Sizzle(selector); | ||
@@ -780,3 +775,3 @@ return nodes.map(function(node) { | ||
}); | ||
}).then(function(results) { | ||
})).then(function(results) { | ||
if (!results) { | ||
@@ -783,0 +778,0 @@ throw new Error('Error during querying selector: ' + selector); |
'use strict'; | ||
const Promise = require('vow').Promise; | ||
const vow = require('vow'); | ||
const Promise = vow.Promise; | ||
@@ -42,4 +43,3 @@ /** | ||
var intervalId = setInterval(() => { | ||
env.evaluateJs | ||
.apply(env, evalArgs) | ||
vow.resolve(env.evaluateJs.apply(env, evalArgs)) | ||
.then(function() { | ||
@@ -46,0 +46,0 @@ if (checkerFunction.apply(null, arguments)) { |
{ | ||
"name": "goose-parser", | ||
"version": "0.3.0-alpha.2", | ||
"version": "0.3.0-alpha.3", | ||
"description": "PhantomJS/Browser lib which allows to parse a webpage", | ||
@@ -5,0 +5,0 @@ "author": { |
Sorry, the diff of this file is not supported yet
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
1167658
24598