Comparing version
@@ -36,5 +36,5 @@ 'use strict'; | ||
/** | ||
* Initialize `auction` object. | ||
* Auction constructor method. | ||
* | ||
* @param {Object} options | ||
* @param {Object} data | ||
* @param {Function} fn | ||
@@ -45,3 +45,3 @@ * @return {Auction} this | ||
constructor(data = {}, fn) { | ||
constructor(data, fn) { | ||
super(); | ||
@@ -51,2 +51,15 @@ this.writable = predefine(this, predefine.WRITABLE); | ||
this.predefineProperties(); | ||
this.init(data, fn); | ||
} | ||
/** | ||
* Initialize `auction` object. | ||
* | ||
* @param {Object} data | ||
* @param {Function} fn | ||
* @return {Auction} this | ||
* @api private | ||
*/ | ||
init(data = {}, fn) { | ||
let error = this.check(data); | ||
@@ -64,2 +77,3 @@ if (error) { | ||
if (fn) setImmediate(fn.bind(null, null, this.data)); | ||
return this; | ||
} | ||
@@ -66,0 +80,0 @@ |
@@ -66,5 +66,5 @@ 'use strict'; | ||
/** | ||
* Initialize `auction` object. | ||
* Auction constructor method. | ||
* | ||
* @param {Object} options | ||
* @param {Object} data | ||
* @param {Function} fn | ||
@@ -76,4 +76,2 @@ * @return {Auction} this | ||
function _default(data, fn) { | ||
if (data === undefined) data = {}; | ||
_classCallCheck(this, _default); | ||
@@ -85,19 +83,11 @@ | ||
this.predefineProperties(); | ||
var error = this.check(data); | ||
if (error) { | ||
if (!this.listeners('error', true) && !fn) throw error; | ||
if (fn) setImmediate(fn.bind(null, error)); | ||
this.emit('error', error); | ||
return this; | ||
} | ||
this.id = data.id; | ||
this.reset(); | ||
this.mergeProperties(data); | ||
debug('auction initialized %j', this.data); | ||
if (fn) setImmediate(fn.bind(null, null, this.data)); | ||
this.init(data, fn); | ||
} | ||
/** | ||
* Set predefined properties. | ||
* | ||
* Initialize `auction` object. | ||
* | ||
* @param {Object} data | ||
* @param {Function} fn | ||
* @return {Auction} this | ||
* @api private | ||
@@ -107,2 +97,28 @@ */ | ||
_createClass(_default, [{ | ||
key: 'init', | ||
value: function init(data, fn) { | ||
if (data === undefined) data = {}; | ||
var error = this.check(data); | ||
if (error) { | ||
if (!this.listeners('error', true) && !fn) throw error; | ||
if (fn) setImmediate(fn.bind(null, error)); | ||
this.emit('error', error); | ||
return this; | ||
} | ||
this.id = data.id; | ||
this.reset(); | ||
this.mergeProperties(data); | ||
debug('auction initialized %j', this.data); | ||
if (fn) setImmediate(fn.bind(null, null, this.data)); | ||
return this; | ||
} | ||
/** | ||
* Set predefined properties. | ||
* | ||
* @api private | ||
*/ | ||
}, { | ||
key: 'predefineProperties', | ||
@@ -109,0 +125,0 @@ value: function predefineProperties() { |
{ | ||
"name": "auction", | ||
"version": "0.1.6", | ||
"version": "0.1.7", | ||
"description": "Easy way to create auctions", | ||
@@ -5,0 +5,0 @@ "author": { |
46383
1.11%1512
1.75%