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'));
}
}
}