availability
Advanced tools
Comparing version 2.1.3 to 2.1.4
@@ -56,2 +56,4 @@ module.exports = | ||
var _srcDisjunctiveAvailabilityIteratorJs = __webpack_require__(11); | ||
var _srcStatusJs = __webpack_require__(5); | ||
@@ -64,2 +66,3 @@ | ||
exports.AvailabilityIterator = _srcAvailabilityIteratorJs.AvailabilityIterator; | ||
exports.DisjunctiveAvailabilityIterator = _srcDisjunctiveAvailabilityIteratorJs.DisjunctiveAvailabilityIterator; | ||
exports.Status = Status; | ||
@@ -895,4 +898,149 @@ | ||
/***/ }, | ||
/* 11 */ | ||
/***/ function(module, exports, __webpack_require__) { | ||
Object.defineProperty(exports, "__esModule", { | ||
value: true | ||
}); | ||
var _createClass = (function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; })(); | ||
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } | ||
var _AvailabilityIteratorJs = __webpack_require__(1); | ||
var _MergingStatusIteratorJs = __webpack_require__(2); | ||
var _DateTimeWindowsUtilsJs = __webpack_require__(10); | ||
"use strict"; | ||
var DisjunctiveTimeWindowsIterator = (function () { | ||
function DisjunctiveTimeWindowsIterator(_ref) { | ||
var _this = this; | ||
var availabilities = _ref.availabilities; | ||
var cal = _ref.cal; | ||
_classCallCheck(this, DisjunctiveTimeWindowsIterator); | ||
availabilities = availabilities || []; // List<availability.Availability> | ||
cal = cal || null; // Moment with tz | ||
this._now = cal.valueOf(); | ||
this._nextStatus = null; | ||
this._wrapped = []; | ||
availabilities.forEach(function (availability) { | ||
var it = new _AvailabilityIteratorJs.AvailabilityIterator({ availability: availability, cal: cal }); | ||
_this._wrapped.push({ | ||
it: it, | ||
nextStatus: it.next() // There's always at least one status | ||
}); | ||
}); | ||
this._advanceNextStatus(); | ||
} | ||
/** @return Boolean */ | ||
_createClass(DisjunctiveTimeWindowsIterator, [{ | ||
key: "hasNext", | ||
value: function hasNext() { | ||
return this._nextStatus !== null; | ||
} | ||
/** @return Status */ | ||
}, { | ||
key: "next", | ||
value: function next() { | ||
var nextStatus = this._nextStatus; | ||
this._advanceNextStatus(); | ||
return nextStatus; | ||
} | ||
}, { | ||
key: "_advanceNextStatus", | ||
value: function _advanceNextStatus() { | ||
// Last status? | ||
if (this._nextStatus !== null && this._nextStatus.until === null) { | ||
this._nextStatus = null; | ||
return; | ||
} | ||
// Advance | ||
var earliestUnavailableUntil = null; | ||
for (var i = 0, l = this._wrapped.length; i < l; ++i) { | ||
var wrapped = this._wrapped[i]; | ||
while (wrapped.nextStatus !== null && (0, _DateTimeWindowsUtilsJs.strictlyBefore)(wrapped.nextStatus.until, this._now)) { | ||
wrapped.nextStatus = wrapped.it.hasNext() ? wrapped.it.next() : null; | ||
} | ||
if (wrapped.nextStatus !== null) { | ||
if (wrapped.nextStatus.status === "available") { | ||
this._now = wrapped.nextStatus.until; | ||
this._nextStatus = wrapped.nextStatus; | ||
return; | ||
} else { | ||
if (wrapped.nextStatus.until !== null) { | ||
earliestUnavailableUntil = earliestUnavailableUntil !== null ? Math.min(earliestUnavailableUntil, wrapped.nextStatus.until) : wrapped.nextStatus.until; | ||
} | ||
} | ||
} | ||
} | ||
this._now = earliestUnavailableUntil; | ||
this._nextStatus = { | ||
status: "unavailable", | ||
until: earliestUnavailableUntil | ||
}; | ||
} | ||
}]); | ||
return DisjunctiveTimeWindowsIterator; | ||
})(); | ||
exports.DisjunctiveTimeWindowsIterator = DisjunctiveTimeWindowsIterator; | ||
var DisjunctiveAvailabilityIterator = (function () { | ||
function DisjunctiveAvailabilityIterator(_ref2) { | ||
var availabilities = _ref2.availabilities; | ||
var cal = _ref2.cal; | ||
_classCallCheck(this, DisjunctiveAvailabilityIterator); | ||
availabilities = availabilities || []; // List<availability.Availability> | ||
cal = cal || null; // Moment with tz | ||
this._it = new _MergingStatusIteratorJs.MergingStatusIterator({ | ||
it: new DisjunctiveTimeWindowsIterator({ availabilities: availabilities, cal: cal }), | ||
maxIterations: 1000 | ||
}); | ||
} | ||
/** @return Boolean */ | ||
_createClass(DisjunctiveAvailabilityIterator, [{ | ||
key: "hasNext", | ||
value: function hasNext() { | ||
return this._it.hasNext(); | ||
} | ||
/** @return Status */ | ||
}, { | ||
key: "next", | ||
value: function next() { | ||
return this._it.next(); | ||
} | ||
}]); | ||
return DisjunctiveAvailabilityIterator; | ||
})(); | ||
exports.DisjunctiveAvailabilityIterator = DisjunctiveAvailabilityIterator; | ||
/***/ } | ||
/******/ ]); | ||
//# sourceMappingURL=index.js.map |
"use strict" | ||
import {AvailabilityIterator} from "./src/AvailabilityIterator.js" | ||
import {DisjunctiveAvailabilityIterator} from "./src/DisjunctiveAvailabilityIterator.js" | ||
import * as Status from "./src/Status.js" | ||
export {AvailabilityIterator as AvailabilityIterator} | ||
export {DisjunctiveAvailabilityIterator as DisjunctiveAvailabilityIterator} | ||
export {Status as Status} |
{ | ||
"name": "availability", | ||
"version": "2.1.3", | ||
"version": "2.1.4", | ||
"description": "Wix Restaurants Availability Utils Module", | ||
@@ -5,0 +5,0 @@ "main": "dist/index.js", |
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
116847
2266