Research
Security News
Malicious npm Packages Inject SSH Backdoors via Typosquatted Libraries
Socket’s threat research team has detected six malicious npm packages typosquatting popular libraries to insert SSH backdoors.
Event emitting collections with iterators (like Backbone.Collection).
Warning: Developer preview release. Lots of broken stuff, I'm sure.
Checks if collection contains value.
contains({a: 1, b: 2, c: 'bar'}, 2); // true
contains([1, 2, 3], 'foo'); // false
Tests whether all values in the collection pass the test implemented by the provided callback.
var obj = {
a: 1,
b: 2,
c: 3,
d: 'string'
};
every(obj, isNumber); // false
Filter collection properties.
Loops through all the values in the collection and returns the first one that passes a truth test (callback).
Important: loop order over objects properties isn't guaranteed to be the same on all environments.
find({a: 'foo', b: 12}, isString); // 'foo'
find(['foo', 12], isNumber); // 12
Loop through all values of the collection.
Returns a new collection where the properties values are the result of calling the callback for each property in the original collection.
Returns maximum value inside collection or use a custom iterator to define how items should be compared.
max({a: 100, b: 2, c: 1, d: 3, e: 200}); // 200
max(['foo', 'lorem', 'amet'], function(val){
return val.length;
}); // 'lorem'
Returns minimum value inside collection or use a custom iterator to define how items should be compared.
min([10, 2, 7]); // 2
min({a: 'foo', b: 'lorem', c: 'amet'}, function(val){
return val.length;
}); // 'foo'
Extract a list of property values.
var users = [
{
name : 'John',
age : 21
},
{
name : 'Jane',
age : 27
}
];
pluck(users, 'name'); // ["John", "Jane"]
pluck(users, 'age'); // [21, 27]
users = {
first: {
name : 'John',
age : 21
},
second: {
name : 'Mary',
age : 25
}
};
pluck(users, 'name'); // ['John', 'Mary']
Apply a function against an accumulator and each value in the collection as to reduce it to a single value.
var obj = {a: 1, b: 2, c: 3, d: 4};
function sum(prev, cur, key, list) {
return prev + cur;
}
reduce(obj, sum); // 10
Returns a new object containing all properties where callback returns true, similar to Array/reject. It does not use properties from the object's prototype. Opposite of filter().
var obj = {a: 1, b: 2, c: 3, d: 4, e: 5};
reject(obj, function(x) { return (x % 2) !== 0; }); // {b: 2, d: 4}
Returns the number of values in the collection.
var obj = {
foo : 1,
bar : 2,
lorem : 3
};
size(obj); // 3
size([1,2,3]); // 3
size(null); // 0
Tests whether any values in the collection pass the test implemented by the provided callback.
var obj = {
a: 1,
b: 2,
c: 3,
d: 'string'
};
some(obj, isNumber); // true
some(obj, isString); // true
var co = require('./clctr.js');
var c = co();
c.on('set', function () { console.log([].slice.call(arguments)); });
c.set('bar', 'baz');
// [ { name: 'bar', value: 'baz', previousValue: undefined } ]
FAQs
Event emitting collections with iterators (like Backbone.Collection).
The npm package clctr receives a total of 1 weekly downloads. As such, clctr popularity was classified as not popular.
We found that clctr 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.
Research
Security News
Socket’s threat research team has detected six malicious npm packages typosquatting popular libraries to insert SSH backdoors.
Security News
MITRE's 2024 CWE Top 25 highlights critical software vulnerabilities like XSS, SQL Injection, and CSRF, reflecting shifts due to a refined ranking methodology.
Security News
In this segment of the Risky Business podcast, Feross Aboukhadijeh and Patrick Gray discuss the challenges of tracking malware discovered in open source softare.