Security News
tea.xyz Spam Plagues npm and RubyGems Package Registries
Tea.xyz, a crypto project aimed at rewarding open source contributions, is once again facing backlash due to an influx of spam packages flooding public package registries.
fulcrum
Advanced tools
Readme
A utility to generate pivot tables from an array of objects:
var pivot = require('fulcrum');
var data = [{
name: 'John',
coin: '5ct',
number: 30
},{
name: 'John',
coin: '5ct',
number: 2
},{
name: 'John',
coin: '10ct',
number: 3
},{
name: 'Jane',
coin: '10ct',
number: 15
},{
name: 'Jane',
coin: '5ct',
number: 6
}];
In this data model, John has 32 5ct and 3 10ct coins, Jane has 6 5ct and 15 10ct coins.
var res = pivot(data,'name','coin',pivot.sum('number'));
[{
"name": "John",
"5ct": 32,
"10ct": 3
},{
"name": "Jane",
"5ct": 6,
"10ct": 15
}]
pivot(array,rows,cols,reducer);
array: an array of objects
rows: a string for the field for rows
cols: a string for the field for columns
reducer (optional): an object describing how to calculate the cell value from the matched objects:
{
callback: Function,
initialValue: Object
}
These are the same arguments as passed into Array.reduce: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/Reduce.
If the reducer is omitted, an array of objects is returned in the cell
field
For all these reducers, when no objects are present in the cell, null
is returned, except for count()
If you wish, you can attach a convenience method to Array.prototype:
var pivot = require('fulcrum').attach();
var res = data.pivot('name','coin',pivot.sum('number'));
It can also be detached:
pivot.detach();
FAQs
Array pivot table
The npm package fulcrum receives a total of 3 weekly downloads. As such, fulcrum popularity was classified as not popular.
We found that fulcrum 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
Tea.xyz, a crypto project aimed at rewarding open source contributions, is once again facing backlash due to an influx of spam packages flooding public package registries.
Security News
As cyber threats become more autonomous, AI-powered defenses are crucial for businesses to stay ahead of attackers who can exploit software vulnerabilities at scale.
Security News
UnitedHealth Group disclosed that the ransomware attack on Change Healthcare compromised protected health information for millions in the U.S., with estimated costs to the company expected to reach $1 billion.