New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

vehicles

Package Overview
Dependencies
Maintainers
1
Versions
167
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

vehicles - npm Package Compare versions

Comparing version 2.2.19 to 2.2.20

446

build/es5/bundle.js
(function (global, factory) {
typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports, require('babel-runtime/regenerator'), require('babel-runtime/helpers/classCallCheck'), require('babel-runtime/helpers/createClass'), require('tslib'), require('decimal.js')) :
typeof define === 'function' && define.amd ? define(['exports', 'babel-runtime/regenerator', 'babel-runtime/helpers/classCallCheck', 'babel-runtime/helpers/createClass', 'tslib', 'decimal.js'], factory) :
(factory((global.vehicles = {}),global._regeneratorRuntime,global._classCallCheck,global._createClass,global.tslib_1,global.Decimal));
typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports, require('babel-runtime/regenerator'), require('babel-runtime/helpers/classCallCheck'), require('babel-runtime/helpers/createClass'), require('tslib'), require('decimal.js')) :
typeof define === 'function' && define.amd ? define(['exports', 'babel-runtime/regenerator', 'babel-runtime/helpers/classCallCheck', 'babel-runtime/helpers/createClass', 'tslib', 'decimal.js'], factory) :
(factory((global.vehicles = {}),global._regeneratorRuntime,global._classCallCheck,global._createClass,global.tslib_1,global.Decimal));
}(this, (function (exports,_regeneratorRuntime,_classCallCheck,_createClass,tslib_1,Decimal) { 'use strict';
_regeneratorRuntime = _regeneratorRuntime && _regeneratorRuntime.hasOwnProperty('default') ? _regeneratorRuntime['default'] : _regeneratorRuntime;
_classCallCheck = _classCallCheck && _classCallCheck.hasOwnProperty('default') ? _classCallCheck['default'] : _classCallCheck;
_createClass = _createClass && _createClass.hasOwnProperty('default') ? _createClass['default'] : _createClass;
Decimal = Decimal && Decimal.hasOwnProperty('default') ? Decimal['default'] : Decimal;
_regeneratorRuntime = _regeneratorRuntime && _regeneratorRuntime.hasOwnProperty('default') ? _regeneratorRuntime['default'] : _regeneratorRuntime;
_classCallCheck = _classCallCheck && _classCallCheck.hasOwnProperty('default') ? _classCallCheck['default'] : _classCallCheck;
_createClass = _createClass && _createClass.hasOwnProperty('default') ? _createClass['default'] : _createClass;
Decimal = Decimal && Decimal.hasOwnProperty('default') ? Decimal['default'] : Decimal;
var MAX_SAFE_INTEGER = Number.MAX_SAFE_INTEGER || Math.pow(2, 53) - 1;
var DeLorean = function () {
function DeLorean() {
_classCallCheck(this, DeLorean);
var MAX_SAFE_INTEGER = Number.MAX_SAFE_INTEGER || Math.pow(2, 53) - 1;
var DeLorean = function () {
function DeLorean() {
_classCallCheck(this, DeLorean);
this._definitions = [];
this._definitions = [];
this._ongoingJourney = null;
this._position = 0;
}
_createClass(DeLorean, [{
key: 'cancel',
value: function cancel(ticket) {
var index = this._definitions.findIndex(function (_ref) {
var tckt = _ref.ticket;
return ticket === tckt;
});
if (index > -1) {
this._definitions.splice(index, 1);
}
}
}, {
key: 'reset',
value: function reset() {
this._definitions.length = 0;
this._definitions = [];
this._definitions = [];
this._ongoingJourney = null;
this._position = 0;
}
}, {
key: 'schedule',
value: function schedule(position, func) {
var ticket = this._generateTicket();
this._definitions.push({ func: func, position: position, ticket: ticket });
this._definitions.sort(function (a, b) {
return a.position - b.position;
});
return ticket;
}
}, {
key: 'travel',
value: function travel(distance) {
return tslib_1.__awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime.mark(function _callee() {
var journey, position, _definitions$shift, func, pstn, functions;
return _regeneratorRuntime.wrap(function _callee$(_context) {
while (1) {
switch (_context.prev = _context.next) {
case 0:
if (!(this._ongoingJourney !== null)) {
_context.next = 2;
break;
}
_createClass(DeLorean, [{
key: 'cancel',
value: function cancel(ticket) {
var index = this._definitions.findIndex(function (_ref) {
var tckt = _ref.ticket;
return ticket === tckt;
});
if (index > -1) {
this._definitions.splice(index, 1);
}
}
}, {
key: 'reset',
value: function reset() {
this._definitions.length = 0;
this._ongoingJourney = null;
this._position = 0;
}
}, {
key: 'schedule',
value: function schedule(position, func) {
var ticket = this._generateTicket();
this._definitions.push({ func: func, position: position, ticket: ticket });
this._definitions.sort(function (a, b) {
return a.position - b.position;
});
return ticket;
}
}, {
key: 'travel',
value: function travel(distance) {
return tslib_1.__awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime.mark(function _callee() {
var journey, position, _definitions$shift, func, pstn, functions;
throw new Error('There is currently another journey going on.');
return _regeneratorRuntime.wrap(function _callee$(_context) {
while (1) {
switch (_context.prev = _context.next) {
case 0:
if (!(this._ongoingJourney !== null)) {
_context.next = 2;
break;
}
case 2:
journey = Symbol();
position = new Decimal(this._position).plus(distance).toNumber();
throw new Error('There is currently another journey going on.');
this._ongoingJourney = journey;
case 2:
journey = Symbol();
position = new Decimal(this._position).plus(distance).toNumber();
case 5:
if (!(this._ongoingJourney === journey && this._definitions.length > 0 && this._definitions[0].position <= position)) {
_context.next = 14;
break;
}
this._ongoingJourney = journey;
// TypeScript needs to be convinced that the definition is not undefined.
_definitions$shift = this._definitions.shift(), func = _definitions$shift.func, pstn = _definitions$shift.position;
functions = [func];
case 5:
if (!(this._ongoingJourney === journey && this._definitions.length > 0 && this._definitions[0].position <= position)) {
_context.next = 14;
break;
}
while (this._definitions.length > 0 && this._definitions[0].position === pstn) {
// TypeScript needs to be convinced that the definition is not undefined.
functions.push(this._definitions.shift().func);
}
this._position = pstn;
_context.next = 12;
return Promise.all(functions.map(function (fnc) {
return Promise.race([new Promise(function (_, reject) {
return setTimeout(function () {
reject(new Error("Sorry, it's not allowed to initialize a promise within a scheduled function."));
});
}), fnc()]);
}));
_definitions$shift = this._definitions.shift(), func = _definitions$shift.func, pstn = _definitions$shift.position;
functions = [func];
case 12:
_context.next = 5;
break;
while (this._definitions.length > 0 && this._definitions[0].position === pstn) {
// TypeScript needs to be convinced that the definition is not undefined.
functions.push(this._definitions.shift().func);
}
this._position = pstn;
_context.next = 12;
return Promise.all(functions.map(function (fnc) {
return Promise.race([new Promise(function (_, reject) {
return setTimeout(function () {
reject(new Error("Sorry, it's not allowed to initialize a promise within a scheduled function."));
});
}), fnc()]);
}));
case 14:
if (this._ongoingJourney === journey) {
this._ongoingJourney = null;
this._position = position;
}
case 12:
_context.next = 5;
break;
case 15:
case 'end':
return _context.stop();
case 14:
if (this._ongoingJourney === journey) {
this._ongoingJourney = null;
this._position = position;
}
case 15:
case 'end':
return _context.stop();
}
}
}
}, _callee, this);
}));
}
}, {
key: '_generateTicket',
value: function _generateTicket() {
var ticket = void 0;
do {
ticket = Math.round(Math.random() * MAX_SAFE_INTEGER);
} while (this._definitions.some(function (_ref2) {
var tckt = _ref2.ticket;
return ticket === tckt;
}));
return ticket;
}
}, {
key: 'nextStopover',
get: function get() {
var nextDefinition = this._definitions[0];
return nextDefinition === undefined ? Number.POSITIVE_INFINITY : nextDefinition.position;
}
}, {
key: 'position',
get: function get() {
return this._position;
}
}]);
}, _callee, this);
}));
}
}, {
key: '_generateTicket',
value: function _generateTicket() {
var ticket = void 0;
do {
ticket = Math.round(Math.random() * MAX_SAFE_INTEGER);
} while (this._definitions.some(function (_ref2) {
var tckt = _ref2.ticket;
return ticket === tckt;
}));
return ticket;
}
}, {
key: 'nextStopover',
get: function get() {
var nextDefinition = this._definitions[0];
return nextDefinition === undefined ? Number.POSITIVE_INFINITY : nextDefinition.position;
}
}, {
key: 'position',
get: function get() {
return this._position;
}
}]);
return DeLorean;
}();
return DeLorean;
}();
var Platoon = function () {
function Platoon() {
_classCallCheck(this, Platoon);
var Platoon = function () {
function Platoon() {
_classCallCheck(this, Platoon);
this._ongoingJourney = null;
this._ongoingJourney = null;
for (var _len = arguments.length, vehicles = Array(_len), _key = 0; _key < _len; _key++) {
vehicles[_key] = arguments[_key];
for (var _len = arguments.length, vehicles = Array(_len), _key = 0; _key < _len; _key++) {
vehicles[_key] = arguments[_key];
}
this._vehicles = vehicles;
}
this._vehicles = vehicles;
}
_createClass(Platoon, [{
key: 'join',
value: function join(deLorean, scale) {
this._vehicles.push({ deLorean: deLorean, scale: scale });
}
}, {
key: 'leave',
value: function leave(deLorean) {
var index = this._vehicles.findIndex(function (_ref) {
var dLrn = _ref.deLorean;
return deLorean === dLrn;
});
if (index > -1) {
this._vehicles.splice(index, 1);
_createClass(Platoon, [{
key: 'join',
value: function join(deLorean, scale) {
this._vehicles.push({ deLorean: deLorean, scale: scale });
}
}
}, {
key: 'reset',
value: function reset() {
this._ongoingJourney = null;
this._vehicles.forEach(function (_ref2) {
var deLorean = _ref2.deLorean;
return deLorean.reset();
});
}
}, {
key: 'travel',
value: function travel(distance) {
return tslib_1.__awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime.mark(function _callee() {
var _this = this;
}, {
key: 'leave',
value: function leave(deLorean) {
var index = this._vehicles.findIndex(function (_ref) {
var dLrn = _ref.deLorean;
return deLorean === dLrn;
});
if (index > -1) {
this._vehicles.splice(index, 1);
}
}
}, {
key: 'reset',
value: function reset() {
this._ongoingJourney = null;
this._vehicles.forEach(function (_ref2) {
var deLorean = _ref2.deLorean;
return deLorean.reset();
});
}
}, {
key: 'travel',
value: function travel(distance) {
return tslib_1.__awaiter(this, void 0, void 0, /*#__PURE__*/_regeneratorRuntime.mark(function _callee() {
var _this = this;
var journey, distanceAsDecimal, _loop;
var journey, distanceAsDecimal, _loop;
return _regeneratorRuntime.wrap(function _callee$(_context2) {
while (1) {
switch (_context2.prev = _context2.next) {
case 0:
if (!(this._ongoingJourney !== null)) {
_context2.next = 2;
break;
}
return _regeneratorRuntime.wrap(function _callee$(_context2) {
while (1) {
switch (_context2.prev = _context2.next) {
case 0:
if (!(this._ongoingJourney !== null)) {
_context2.next = 2;
break;
}
throw new Error('There is currently another journey going on.');
throw new Error('There is currently another journey going on.');
case 2:
journey = Symbol();
case 2:
journey = Symbol();
this._ongoingJourney = journey;
distanceAsDecimal = new Decimal(distance);
_loop = /*#__PURE__*/_regeneratorRuntime.mark(function _loop() {
var distanceToNextStopover;
return _regeneratorRuntime.wrap(function _loop$(_context) {
while (1) {
switch (_context.prev = _context.next) {
case 0:
distanceToNextStopover = _this._vehicles.reduce(function (dstncSDcml, _ref3) {
var deLorean = _ref3.deLorean,
scale = _ref3.scale;
this._ongoingJourney = journey;
distanceAsDecimal = new Decimal(distance);
_loop = /*#__PURE__*/_regeneratorRuntime.mark(function _loop() {
var distanceToNextStopover;
return _regeneratorRuntime.wrap(function _loop$(_context) {
while (1) {
switch (_context.prev = _context.next) {
case 0:
distanceToNextStopover = _this._vehicles.reduce(function (dstncSDcml, _ref3) {
var deLorean = _ref3.deLorean,
scale = _ref3.scale;
var nextStopoverAsDecimal = new Decimal(deLorean.nextStopover);
return Decimal.min(nextStopoverAsDecimal.minus(deLorean.position).dividedBy(scale), dstncSDcml);
}, distanceAsDecimal);
_context.next = 3;
return Promise.all(_this._vehicles.map(function (_ref4) {
var deLorean = _ref4.deLorean,
scale = _ref4.scale;
var nextStopoverAsDecimal = new Decimal(deLorean.nextStopover);
return Decimal.min(nextStopoverAsDecimal.minus(deLorean.position).dividedBy(scale), dstncSDcml);
}, distanceAsDecimal);
_context.next = 3;
return Promise.all(_this._vehicles.map(function (_ref4) {
var deLorean = _ref4.deLorean,
scale = _ref4.scale;
return deLorean.travel(distanceToNextStopover.times(scale).toNumber());
}));
return deLorean.travel(distanceToNextStopover.times(scale).toNumber());
}));
case 3:
distanceAsDecimal = distanceAsDecimal.minus(distanceToNextStopover);
case 3:
distanceAsDecimal = distanceAsDecimal.minus(distanceToNextStopover);
case 4:
case 'end':
return _context.stop();
case 4:
case 'end':
return _context.stop();
}
}
}
}, _loop, _this);
});
}, _loop, _this);
});
case 6:
return _context2.delegateYield(_loop(), 't0', 7);
case 6:
return _context2.delegateYield(_loop(), 't0', 7);
case 7:
if (this._ongoingJourney === journey && distanceAsDecimal.greaterThan(0)) {
_context2.next = 6;
break;
}
case 7:
if (this._ongoingJourney === journey && distanceAsDecimal.greaterThan(0)) {
_context2.next = 6;
break;
}
case 8:
if (this._ongoingJourney === journey) {
this._ongoingJourney = null;
}
case 8:
if (this._ongoingJourney === journey) {
this._ongoingJourney = null;
}
case 9:
case 'end':
return _context2.stop();
case 9:
case 'end':
return _context2.stop();
}
}
}
}, _callee, this);
}));
}
}]);
}, _callee, this);
}));
}
}]);
return Platoon;
}();
return Platoon;
}();
exports.DeLorean = DeLorean;
exports.Platoon = Platoon;
exports.DeLorean = DeLorean;
exports.Platoon = Platoon;
Object.defineProperty(exports, '__esModule', { value: true });
Object.defineProperty(exports, '__esModule', { value: true });
})));

@@ -31,4 +31,4 @@ {

"cz-conventional-changelog": "^2.1.0",
"eslint": "^4.18.2",
"eslint-config-holy-grail": "^25.1.0",
"eslint": "^4.19.0",
"eslint-config-holy-grail": "^26.0.0",
"greenkeeper-lockfile": "^1.14.0",

@@ -56,10 +56,10 @@ "grunt": "^1.0.2",

"mocha": "^5.0.4",
"rollup": "^0.56.5",
"rollup": "^0.57.1",
"rollup-plugin-babel": "^3.0.3",
"sinon": "^4.4.2",
"sinon": "^4.4.6",
"sinon-chai": "^3.0.0",
"ts-loader": "^4.0.1",
"ts-loader": "^4.1.0",
"tsconfig-holy-grail": "^4.0.1",
"tslint": "^5.9.1",
"tslint-config-holy-grail": "^22.0.9",
"tslint-config-holy-grail": "^23.0.3",
"typescript": "^2.7.2",

@@ -99,3 +99,3 @@ "webpack": "^4.1.1"

"types": "build/es2015/module.d.ts",
"version": "2.2.19"
"version": "2.2.20"
}
SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc