UNPKG

sharp-vibrant

Version:

Extract prominent colors from an image in a node environment using sharp.

53 lines 1.73 kB
"use strict"; var __classPrivateFieldSet = (this && this.__classPrivateFieldSet) || function (receiver, privateMap, value) { if (!privateMap.has(receiver)) { throw new TypeError("attempted to set private field on non-instance"); } privateMap.set(receiver, value); return value; }; var __classPrivateFieldGet = (this && this.__classPrivateFieldGet) || function (receiver, privateMap) { if (!privateMap.has(receiver)) { throw new TypeError("attempted to get private field on non-instance"); } return privateMap.get(receiver); }; var _sorted, _comparator; Object.defineProperty(exports, "__esModule", { value: true }); class PQueue { constructor(comparator) { _sorted.set(this, void 0); _comparator.set(this, void 0); __classPrivateFieldSet(this, _comparator, comparator); this.contents = []; __classPrivateFieldSet(this, _sorted, false); } sort() { if (!__classPrivateFieldGet(this, _sorted)) { this.contents.sort(__classPrivateFieldGet(this, _comparator)); __classPrivateFieldSet(this, _sorted, true); } } push(item) { this.contents.push(item); __classPrivateFieldSet(this, _sorted, false); } peek(index) { this.sort(); return this.contents[typeof index === 'number' ? index : this.contents.length - 1]; } pop() { this.sort(); return this.contents.pop(); } get size() { return this.contents.length; } map(mapper) { this.sort(); return this.contents.map(mapper); } } exports.default = PQueue; _sorted = new WeakMap(), _comparator = new WeakMap(); //# sourceMappingURL=pqueue.js.map