@fto-consult/expo-ui
Version:
Bibliothèque de composants UI Expo,react-native
29 lines • 535 B
JavaScript
export default class Queue {
constructor() {
this.data = [];
}
get firstItem() {
if (!this.isEmpty) {
return this.data[0];
}
return null;
}
get size() {
return this.data.length;
}
get isEmpty() {
return this.size === 0;
}
enqueue(item) {
this.data.push(item);
}
dequeue() {
if (!this.isEmpty) {
return this.data.shift();
}
return null;
}
clear() {
this.data = [];
}
}