add lik.Objectmap.isEmpty()

This commit is contained in:
2016-11-19 23:54:52 +01:00
parent bb3b02ed74
commit cfbc47e365
3 changed files with 52 additions and 26 deletions

View File

@ -56,6 +56,17 @@ export class Objectmap<T> {
}
}
/**
* finds a specific element and then removes it
*/
findOneAndRemove(findFunction): T {
let foundElement = this.find(findFunction)
if (foundElement) {
this.remove(foundElement)
}
return foundElement
}
/**
* run function for each item in Objectmap
*/
@ -70,17 +81,6 @@ export class Objectmap<T> {
return this.objectArray.shift()
}
/**
* finds a specific element and then removes it
*/
findOneAndRemove(findFunction): T {
let foundElement = this.find(findFunction)
if (foundElement) {
this.remove(foundElement)
}
return foundElement
}
/**
* returns a cloned array of all the objects currently in the Objectmap
*/
@ -88,6 +88,17 @@ export class Objectmap<T> {
return plugins.lodash.cloneDeep(this.objectArray)
}
/**
* check if Objectmap ist empty
*/
isEmpty(): boolean {
if (this.objectArray.length === 0) {
return true
} else {
return false
}
}
/**
* remove object from Objectmap
*/