source: imaps-frontend/node_modules/react-use/lib/useQueue.js@ d565449

main
Last change on this file since d565449 was d565449, checked in by stefan toskovski <stefantoska84@…>, 4 weeks ago

Update repo after prototype presentation

  • Property mode set to 100644
File size: 950 bytes
Line 
1"use strict";
2Object.defineProperty(exports, "__esModule", { value: true });
3var tslib_1 = require("tslib");
4var react_1 = require("react");
5var useQueue = function (initialValue) {
6 if (initialValue === void 0) { initialValue = []; }
7 var _a = react_1.useState(initialValue), state = _a[0], set = _a[1];
8 return {
9 add: function (value) {
10 set(function (queue) { return tslib_1.__spreadArrays(queue, [value]); });
11 },
12 remove: function () {
13 var result;
14 set(function (_a) {
15 var first = _a[0], rest = _a.slice(1);
16 result = first;
17 return rest;
18 });
19 return result;
20 },
21 get first() {
22 return state[0];
23 },
24 get last() {
25 return state[state.length - 1];
26 },
27 get size() {
28 return state.length;
29 },
30 };
31};
32exports.default = useQueue;
Note: See TracBrowser for help on using the repository browser.