Skip to content

Commit

Permalink
Merge pull request #3 from brutalchrist/return_statement
Browse files Browse the repository at this point in the history
Add return statement
  • Loading branch information
brutalchrist committed Aug 6, 2018
2 parents cbaa0d5 + 53f3ae4 commit 90eaae7
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 6 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "angular-hashtable",
"version": "0.0.6",
"version": "0.0.7",
"description": "An HashTable for Angular",
"main": "./dist/angular-hashtable/bundles/angular-hashtable.umd.js",
"typings": "./dist/angular-hashtable.d.ts",
Expand Down
14 changes: 9 additions & 5 deletions src/lib/angular-hashtable.class.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,9 @@ export class HashTable<T, L> {
this.table = {};
}

public put(key: T, value: L): void {
public put(key: T, value: L): HashTable<T, L> {
this.table['v_' + key] = value;
return this;
}

public get(key: T): L {
Expand All @@ -34,15 +35,17 @@ export class HashTable<T, L> {
return false;
}

public remove(key: T): void {
public remove(key: T): HashTable<T, L> {
delete this.table['v_' + key];
return this;
}

public putArray(key: T, value: L): void {
public putArray(key: T, value: L): HashTable<T, L> {
if (typeof this.table['a_' + key] === 'undefined') {
this.table['a_' + key] = [];
}
this.table['a_' + key].push(value);
return this;
}

public getArray(key: T): L {
Expand All @@ -52,10 +55,11 @@ export class HashTable<T, L> {
return this.table['a_' + key];
}

public removeArray(key: T, value: L): void {
public removeArray(key: T, value: L): HashTable<T, L> {
if (typeof this.table['a_' + key] !== 'undefined') {
this.table['a_' + key].splice(this.table['a_' + key].indexOf(value), 1);
}
return this;
}

public hasArray(key: T): boolean {
Expand Down Expand Up @@ -89,7 +93,7 @@ export class HashTable<T, L> {
// Iterate all objects Hashtable
// A used like arguments in the callback function
/***************************************************/
public forEach(callback) {
public forEach(callback): void {
for (let key in this.table) {
callback(key.substring(2), this.table[key]);
}
Expand Down

0 comments on commit 90eaae7

Please sign in to comment.