circularbuffer
Advanced tools
Comparing version 0.1.0 to 0.1.1
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
class CircularBuffer { | ||
constructor(capacity) { | ||
var CircularBuffer = (function () { | ||
function CircularBuffer(capacity) { | ||
this.capacity = capacity; | ||
this.buffer = []; | ||
} | ||
enq(...items) { | ||
items.forEach(item => { | ||
if (this.buffer.length + 1 > this.capacity) | ||
this.deq(); | ||
this.buffer.unshift(item); | ||
CircularBuffer.prototype.enq = function () { | ||
var _this = this; | ||
var items = []; | ||
for (var _i = 0; _i < arguments.length; _i++) { | ||
items[_i] = arguments[_i]; | ||
} | ||
items.forEach(function (item) { | ||
if (_this.buffer.length + 1 > _this.capacity) | ||
_this.deq(); | ||
_this.buffer.unshift(item); | ||
}); | ||
} | ||
deq() { | ||
}; | ||
CircularBuffer.prototype.deq = function () { | ||
return this.buffer.pop(); | ||
} | ||
replace(...items) { | ||
}; | ||
CircularBuffer.prototype.replace = function () { | ||
var _this = this; | ||
var items = []; | ||
for (var _i = 0; _i < arguments.length; _i++) { | ||
items[_i] = arguments[_i]; | ||
} | ||
this.buffer = []; | ||
items.forEach(item => this.enq(item)); | ||
} | ||
toArray() { | ||
return [...this.buffer].reverse(); | ||
} | ||
get size() { | ||
return this.buffer.length; | ||
} | ||
get length() { | ||
return this.size; | ||
} | ||
} | ||
items.forEach(function (item) { return _this.enq(item); }); | ||
}; | ||
CircularBuffer.prototype.toArray = function () { | ||
return this.buffer.slice().reverse(); | ||
}; | ||
Object.defineProperty(CircularBuffer.prototype, "size", { | ||
get: function () { | ||
return this.buffer.length; | ||
}, | ||
enumerable: true, | ||
configurable: true | ||
}); | ||
Object.defineProperty(CircularBuffer.prototype, "length", { | ||
get: function () { | ||
return this.size; | ||
}, | ||
enumerable: true, | ||
configurable: true | ||
}); | ||
return CircularBuffer; | ||
}()); | ||
exports.default = CircularBuffer; |
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
const CircularBuffer_1 = require("./CircularBuffer"); | ||
var CircularBuffer_1 = require("./CircularBuffer"); | ||
exports.CircularBuffer = CircularBuffer_1.default; | ||
exports.default = CircularBuffer_1.default; |
{ | ||
"name": "circularbuffer", | ||
"version": "0.1.0", | ||
"version": "0.1.1", | ||
"description": "A small circular/ring buffer implementation in TypeScript.", | ||
@@ -5,0 +5,0 @@ "keywords": ["buffer", "circular", "queue", "ring", "stack", "typescript"], |
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
5123
70