Security News
RubyGems.org Adds New Maintainer Role
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.
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")
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)
})
Pushes every object
values to source
var values = extend({}, defaultValues)
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]
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]
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]
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]
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"
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"
Returns an array filled with collection
's keys.
getKeys({1:1,4:3}) // [1,4]
Returns an array filled with collection
's values.
getValues({1:1,4:3}) // [1,3]
Returns an array filled with collection
's keys/values pairs.
getPairs({1:1,4:3}) // [[1,1],[4,3]]
Returns collection
's size (number of values).
getSize({1:1,4:3}) // 2
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
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
Returns whether or not array
contains value
contains([1,2,3,2], 2) // true
contains([1,2,3,2], 4) // false
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]}
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]
Returns a function that returns the next element in the array every time it is called. Works with sparse arrays.
var array = [1,2,3]
, fn = iterator(array)
fn() // 1
fn() // 2
array.push(4)
fn() // 3
fn() // 4
fn() // null
Returns a array of arrays containing the values for their index in array1
, array2
etc.
zip(["foo", "bar"], [1, 2], [true, false])
// [["foo", 1, true], ["bar", 2, false]]
zip(["foo", 1, true], ["bar", 2, false])
// [["foo", "bar"], [1, 2], [true, false]]
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
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.
Security News
Research
Socket's threat research team has detected five malicious npm packages targeting Roblox developers, deploying malware to steal credentials and personal data.