Comparing version 2.0.0 to 2.1.0
@@ -9,2 +9,4 @@ 'use strict'; | ||
var _lodash = require('lodash'); | ||
var _puppeteer = require('puppeteer'); | ||
@@ -21,18 +23,21 @@ | ||
var Engine = function () { | ||
function Engine() { | ||
function Engine(options) { | ||
_classCallCheck(this, Engine); | ||
this.browser = null; | ||
this.gotoOptions = { | ||
this.gotoOptions = (0, _lodash.merge)({ | ||
waitUntil: 'load' | ||
}; | ||
this.launchOptions = { | ||
}, (0, _lodash.get)(options, 'gotoOptions')); | ||
this.launchOptions = (0, _lodash.merge)({ | ||
headless: true, | ||
ignoreHTTPSErrors: true | ||
}; | ||
this.viewportOptions = { | ||
}, (0, _lodash.get)(options, 'launchOptions')); | ||
this.viewportOptions = (0, _lodash.merge)({ | ||
height: 720, | ||
isLandscape: true, | ||
width: 1280 | ||
}; | ||
}, (0, _lodash.get)(options, 'viewportOptions')); | ||
} | ||
@@ -39,0 +44,0 @@ |
@@ -17,2 +17,4 @@ 'use strict'; | ||
var _lodash = require('lodash'); | ||
var _os = require('os'); | ||
@@ -43,6 +45,3 @@ | ||
function OhScrap() { | ||
var concurrency = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : _os2.default.cpus().length; | ||
var retry = arguments[1]; | ||
function OhScrap(options) { | ||
_classCallCheck(this, OhScrap); | ||
@@ -52,4 +51,4 @@ | ||
_this.concurrency = concurrency; | ||
_this.engine = new _engine2.default(); | ||
_this.concurrency = (0, _lodash.get)(options, 'concurrency', _os2.default.cpus().length); | ||
_this.engine = new _engine2.default((0, _lodash.get)(options, 'engine')); | ||
_this.metrics = { | ||
@@ -59,6 +58,6 @@ end: 0, | ||
}; | ||
_this.retry = retry || { | ||
_this.retry = (0, _lodash.merge)({ | ||
interval: 1500, | ||
times: 5 | ||
}; | ||
}, (0, _lodash.get)(options, 'retry')); | ||
return _this; | ||
@@ -228,3 +227,3 @@ } | ||
return function (_x4, _x5) { | ||
return function (_x3, _x4) { | ||
return _ref4.apply(this, arguments); | ||
@@ -273,3 +272,3 @@ }; | ||
function until(_x2, _x3) { | ||
function until(_x, _x2) { | ||
return _ref3.apply(this, arguments); | ||
@@ -361,3 +360,3 @@ } | ||
return function (_x8, _x9) { | ||
return function (_x7, _x8) { | ||
return _ref7.apply(this, arguments); | ||
@@ -375,3 +374,3 @@ }; | ||
function start(_x6, _x7) { | ||
function start(_x5, _x6) { | ||
return _ref6.apply(this, arguments); | ||
@@ -378,0 +377,0 @@ } |
{ | ||
"name": "oh-scrap", | ||
"version": "2.0.0", | ||
"version": "2.1.0", | ||
"description": "Node Module skeleton", | ||
@@ -5,0 +5,0 @@ "main": "lib/index.js", |
@@ -0,18 +1,22 @@ | ||
import { get, merge } from 'lodash'; | ||
import puppeteer from 'puppeteer'; | ||
export default class Engine { | ||
constructor() { | ||
constructor(options) { | ||
this.browser = null; | ||
this.gotoOptions = { | ||
this.gotoOptions = merge({ | ||
waitUntil: 'load', | ||
}; | ||
this.launchOptions = { | ||
}, get(options, 'gotoOptions')); | ||
this.launchOptions = merge({ | ||
headless: true, | ||
ignoreHTTPSErrors: true, | ||
}; | ||
this.viewportOptions = { | ||
}, get(options, 'launchOptions')); | ||
this.viewportOptions = merge({ | ||
height: 720, | ||
isLandscape: true, | ||
width: 1280, | ||
}; | ||
}, get(options, 'viewportOptions')); | ||
} | ||
@@ -19,0 +23,0 @@ |
@@ -6,2 +6,3 @@ import 'babel-polyfill'; | ||
import EventEmitter from 'events'; | ||
import { get, merge } from 'lodash'; | ||
import os from 'os'; | ||
@@ -16,7 +17,7 @@ | ||
class OhScrap extends EventEmitter { | ||
constructor(concurrency = os.cpus().length, retry) { | ||
constructor(options) { | ||
super(); | ||
this.concurrency = concurrency; | ||
this.engine = new Engine(); | ||
this.concurrency = get(options, 'concurrency', os.cpus().length); | ||
this.engine = new Engine(get(options, 'engine')); | ||
this.metrics = { | ||
@@ -26,6 +27,6 @@ end: 0, | ||
}; | ||
this.retry = retry || { | ||
this.retry = merge({ | ||
interval: 1500, | ||
times: 5, | ||
}; | ||
}, get(options, 'retry')); | ||
} | ||
@@ -32,0 +33,0 @@ |
@@ -74,3 +74,3 @@ import os from 'os'; | ||
beforeEach(() => { | ||
ohscrap = new OhScrap(CONCURRENCY); | ||
ohscrap = new OhScrap({ concurrency: CONCURRENCY }); | ||
}); | ||
@@ -77,0 +77,0 @@ |
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
171509
1161