An HashTable for Angular
const table = new HashTable<string, any>();
table.put('hi', {
msg: 'Hello World',
from: '🛸'
});
const table = new HashTable<string, any>();
table.put('hi', {
msg: 'Hello World',
from: '🛸'
});
// {msg: "Hello World", emoji: "🛸"}
console.log(table.get('hi'));
const table = new HashTable<string, any>();
table.put('hi', {
msg: 'Hello World',
from: '🛸'
});
// [0: {msg: "Hello World", emoji: "🛸"}]
console.log(table.getAll());
const table = new HashTable<string, any>();
table.put('hi', {
msg: 'Hello World',
from: '🛸'
});
// ['hi']
console.log(table.getKeys());
const table = new HashTable<string, any>();
table.put('hi', {
msg: 'Hello World',
from: '🛸'
});
// true
console.log(table.has('hi'));
const table = new HashTable<string, any>();
table.put('hi', {
msg: 'Hello World',
from: '🛸'
});
table.remove('hi');
// []
console.log(this.table.getAll());
const table = new HashTable<string, any>();
table.putArray('hi', {
msg: 'Hello World',
from: '🛸'
});
table.putArray('hi', {
msg: 'Hello Space',
from: '🌎'
});
const table = new HashTable<string, any>();
table.putArray('hi', {
msg: 'Hello World',
from: '🛸'
});
table.putArray('hi', {
msg: 'Hello Space',
from: '🌎'
});
// [
// 0: {msg: "Hello World", emoji: "🛸"}
// 1: {msg: "Hello Space", emoji: "🌍"}
// ]
console.log(this.table.getArray('hi'));
const table = new HashTable<string, any>();
table.putArray('hi', {
msg: 'Hello World',
from: '🛸'
});
table.putArray('hi', {
msg: 'Hello Space',
from: '🌎'
});
table.remove('hi', 0);
// [0: {msg: "Hello Space", emoji: "🌍"}]
console.log(this.table.getArray('hi'));
const table = new HashTable<string, any>();
table.putArray('hi', {
msg: 'Hello World',
from: '🛸'
});
// true
console.log(this.table.hasArray('hi'));
const table = new HashTable<string, any>();
table.put('hi', {
msg: 'Hello World',
from: '🛸'
});
// 1
console.log(this.table.size());
const table = new HashTable<string, any>();
table.put('hi', {
msg: 'Hello World',
emoji: '🛸'
});
table.putArray('bye', {
msg: 'Bye World',
emoji: '🛸'
});
table.putArray('bye', {
msg: 'Bye Space',
emoji: '🌎'
});
// hi => : {msg: "Hello World", emoji: "🛸"}
// bye => : [
// 0: {msg: "Bye World", emoji: "🛸"}
// 1: {msg: "Bye Space", emoji: "🌎"}
// ]
table.forEach((key, value) => {
console.log(`${key} => :`, value);
});
import { Component } from '@angular/core';
import { HashTable } from 'angular-hashtable';
@Component({
selector: 'app-root',
templateUrl: './app.component.html',
styleUrls: ['./app.component.css']
})
export class AppComponent {
title = 'app';
table: HashTable<string, any>;
constructor() {
this.table = new HashTable<string, any>();
this.table.put('hi', {
msg: 'Hello World',
from: '🛸'
});
if (this.table.has('hi')) {
console.table(this.table.get('hi'));
}
}
}