login/node_modules/asyncc/lib/PrioArray.js
Amruta Kawade 45b10ffd19
Adding node_modules for dependabot (#67)
* Bump lodash from 4.17.15 to 4.17.19 (#52)

Bumps [lodash](https://github.com/lodash/lodash) from 4.17.15 to 4.17.19.
- [Release notes](https://github.com/lodash/lodash/releases)
- [Commits](https://github.com/lodash/lodash/compare/4.17.15...4.17.19)

Signed-off-by: dependabot[bot] <support@github.com>

Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
Co-authored-by: Amruta Kawade <65217380+AmrutaKawade@users.noreply.github.com>

* Bump @actions/core from 1.1.3 to 1.2.6 (#60)

Bumps [@actions/core](https://github.com/actions/toolkit/tree/HEAD/packages/core) from 1.1.3 to 1.2.6.
- [Release notes](https://github.com/actions/toolkit/releases)
- [Changelog](https://github.com/actions/toolkit/blob/main/packages/core/RELEASES.md)
- [Commits](https://github.com/actions/toolkit/commits/HEAD/packages/core)

Signed-off-by: dependabot[bot] <support@github.com>

Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
Co-authored-by: Amruta Kawade <65217380+AmrutaKawade@users.noreply.github.com>

* updating node_nodules

* updated package-lock

Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2020-10-12 14:58:40 +05:30

91 lines
No EOL
1.5 KiB
JavaScript

"use strict";
Object.defineProperty(exports, "__esModule", {
value: true
});
exports["default"] = PrioArray;
/**
* Creates an Array which adds items by priority
*/
function PrioArray() {
this.reset();
}
PrioArray.prototype = {
/**
* length of Array
*/
get length() {
return this.items.length;
},
/**
* shift item from array
* @return {Any} item
*/
shift: function shift() {
return (this.items.shift() ||
/* istanbul ignore next */
{}).item;
},
/**
* push `item` to Array using priority
* @param {Any} item
* @param {Number} [prio=Infinity] - priority `0 ... Infinity` - lower values have higher priority
*/
push: function push(item, prio) {
var items = this.items;
if (typeof prio !== 'number') {
prio = Infinity;
items.push({
prio: prio,
item: item
});
} else {
var found;
prio = Math.abs(prio);
for (var i = 0; i < items.length; i++) {
if (prio < items[i].prio) {
items.splice(i, 0, {
prio: prio,
item: item
});
found = true;
break;
}
}
if (!found) {
items.push({
prio: prio,
item: item
});
}
}
return this;
},
/**
* unshift `item` to Array using priority
* @param {Any} item
*/
unshift: function unshift(item) {
this.items.unshift({
prio: 0,
item: item
});
return this;
},
/**
* removes all items in the Array
*/
reset: function reset() {
this.items = [];
}
};