Security News
GitHub Removes Malicious Pull Requests Targeting Open Source Repositories
GitHub removed 27 malicious pull requests attempting to inject harmful code across multiple open source repositories, in another round of low-effort attacks.
bloody-collections
Advanced tools
[![browser support](https://ci.testling.com/bloodyowl/collections.png)](https://ci.testling.com/bloodyowl/collections)
$ npm install bloody-collections
var collections = require("bloody-collections")
// or
var each = require("bloody-collections/each")
each(collection, fn[, thisValue])
Executes fn
with [item, index, collection]
as arguments (and an optional thisValue
) for each item in collection
.
each([1,2,3], function(item){
console.log(item)
})
extend(source, object)
-> source
Pushes every object
values to source
var values = extend({}, defaultValues)
filter(collection, fn[, thisValue])
-> new collection
Executes fn
with [item, index, collection]
as arguments (and an optional thisValue
) for each item in collection
, and returns an collection filled with item with which fn
returned a truthy value.
filter([1,2,3], function(item){
return !(item % 2)
}) // [2]
reject(collection, fn[, thisValue])
-> new collection
Executes fn
with [item, index, collection]
as arguments (and an optional thisValue
) for each item in collection
, and returns an collection filled with item with which fn
returned a falsy value.
reject([1,2,3], function(item){
return !(item % 2)
}) // [1,3]
map(collection, fn[, thisValue])
-> new collection
Executes fn
with [item, index, collection]
as arguments (and an optional thisValue
) for each item in collection
, and returns an collection filled with the returned values of fn
.
map([1,2,3], function(item){
return item * 2
}) // [2,4,6]
pluck(collection, property)
-> new collection
Return a collection filled with item[property]
or null
for each item
in collection
pluck([{1:1},{1:2},void 0,{1:3}], 1) // [1,2,null,3]
reduce(collection, fn[, defaultValue[, thisValue]])
-> any
Executes fn
with [lastReturnedValue, item, index, collection]
as arguments (and an optional thisValue
) for each item in collection
. Returns lastReturnedValue
reduce([1,3,4], function(previous, actual){
return previous + actual
}, "") // "134"
reduceRight(collection, fn[, defaultValue[, thisValue]])
-> any
Executes fn
with [lastReturnedValue, item, index, collection]
as arguments (and an optional thisValue
) for each item in collection
. Returns lastReturnedValue
; like reduce
but loops from the end to the start.
reduceRight([1,3,4], function(previous, actual){
return previous + actual
}, "") // "431"
getKeys(collection)
-> array
Returns an array filled with collection
's keys.
getKeys({1:1,4:3}) // [1,4]
getValues(collection)
-> array
Returns an array filled with collection
's values.
getValues({1:1,4:3}) // [1,3]
getPairs(collection)
-> array
Returns an array filled with collection
's keys/values pairs.
getPairs({1:1,4:3}) // [[1,1],[4,3]]
getSize(collection)
-> number
Returns collection
's size (number of values).
getSize({1:1,4:3}) // 2
indexOf(array, value)
-> number
Returns first value
's index in array
or -1
if not found.
indexOf([1,2,3,2], 2) // 1
indexOf([1,2,3,2], 4) // -1
lastIndexOf(array, value)
-> number
Returns first value
's index in array
or -1
if not found.
lastIndexOf([1,2,3,2], 2) // 3
lastIndexOf([1,2,3,2], 4) // -1
contains(array, value)
-> boolean
Returns whether or not array
contains value
contains([1,2,3,2], 2) // true
contains([1,2,3,2], 4) // false
clone(value[, deep=false])
-> clonedObject
Clones value
(optionaly deep
).
clone([1,2,3,2]) // [1,2,3,2]
clone({foo:"bar", bar:[1,2]}, true) // {foo:"bar", bar:[1,2]}
range([start=0,] end[, step=1]) -> array
Creates an array filled with values from start
to end
, separated with step
.
range(0) // []
range(5) // [0,1,2,3,4]
range(5, 9) // [5,6,7,8]
range(9, 5, -1) // [9,8,7,6]
range(0, 20, 5) // [0,5,10,15]
FAQs
[![browser support](https://ci.testling.com/bloodyowl/collections.png)](https://ci.testling.com/bloodyowl/collections)
The npm package bloody-collections receives a total of 1 weekly downloads. As such, bloody-collections popularity was classified as not popular.
We found that bloody-collections demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
GitHub removed 27 malicious pull requests attempting to inject harmful code across multiple open source repositories, in another round of low-effort attacks.
Security News
RubyGems.org has added a new "maintainer" role that allows for publishing new versions of gems. This new permission type is aimed at improving security for gem owners and the service overall.
Security News
Node.js will be enforcing stricter semver-major PR policies a month before major releases to enhance stability and ensure reliable release candidates.