不要怂,就是干,撸起袖子干!

Commit 6de822be by Sascha Depold

some array methods

1 parent 46b2cd73
Showing with 18 additions and 1 deletions
...@@ -22,7 +22,7 @@ SequelizeHelper = { ...@@ -22,7 +22,7 @@ SequelizeHelper = {
}, },
addPrefix: function(prefix, string) { addPrefix: function(prefix, string) {
return prefix + string[0].toUpperCase() + string.replace(/^./, "").replace(/s$/, "") return prefix + string[0].toUpperCase() + string.replace(/^./, "")
}, },
asTableName: function(name) { asTableName: function(name) {
...@@ -133,5 +133,21 @@ SequelizeHelper = { ...@@ -133,5 +133,21 @@ SequelizeHelper = {
}) })
return target return target
} }
},
Array: {
map: function(array, func) {
var result = []
array.forEach(function(element) {
result.push(func(element))
})
return result
},
without: function(array, func) {
var result = []
array.forEach(function(element) {
if(!func(element)) result.push(element)
})
return result
}
} }
} }
\ No newline at end of file
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!