Security News
Supply Chain Attack Detected in Solana's web3.js Library
A supply chain attack has been detected in versions 1.95.6 and 1.95.7 of the popular @solana/web3.js library.
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 0 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
A supply chain attack has been detected in versions 1.95.6 and 1.95.7 of the popular @solana/web3.js library.
Research
Security News
A malicious npm package targets Solana developers, rerouting funds in 2% of transactions to a hardcoded address.
Security News
Research
Socket researchers have discovered malicious npm packages targeting crypto developers, stealing credentials and wallet data using spyware delivered through typosquats of popular cryptographic libraries.