Research
Security News
Quasar RAT Disguised as an npm Package for Detecting Vulnerabilities in Ethereum Smart Contracts
Socket researchers uncover a malicious npm package posing as a tool for detecting vulnerabilities in Etherium smart contracts.
This micro library encourages functional programming by making native methods available as partially applied functions.
This micro library encourages functional programming by making native methods available as partially applied functions.
//typical receiver-method-arguments pattern
[1,2,3].map( function (n) { return n + 1; } ); // [2,3,4]
The "left-part" functions prepend the method name with an underscore and expect the receiver as the first argument in the first invocation.
_map( [1,2,3] )( function (n) { return n + 1; } ); // [2,3,4]
The "right-part" functions suffix the method name with an underscore and expect the receiver as the first argument in the function returned by the first invocation.
map_( function (n) { return n + 1; } )( [1,2,3] ); // [2,3,4]
See the docs.
Try the live demo.
See the following examples of how to include _part_.
// NodeJS example
var _part_ = require( "part" );
var util = {};
_part_._borrow( util )( Array.prototype, "reduce" );
function add( a, b ) { return +a + +b; }
util.sum = util.reduce_( add );
module.exports = util;
<!-- Browser example -->
<script src="build/src/part.min.js">
<script>
(function (global, util) {
function add( a, b ) { return +a + +b; }
_part_._borrow( util )( Array.prototype, "reduce" );
util.sum = util.reduce_( add );
global.util = util;
}(this, {}));
</script>
// NodeJS example
var _part_ = require( "part" );
_part_._borrow( util )( Array.prototype, "reduce" );
function add( a, b ) { return +a + +b; }
var sum = util.reduce_( add );
<!-- Browser example -->
<script src="build/src/part.min.js">
<script>
function add( a, b ) { return +a + +b; }
_part_.borrow( Array.prototype, "reduce" );
var sum = _part_.reduce_( add );
</script>
// NodeJS example
var _part_ = require("part");
var reduce_ = _part_.create_(Array.prototype.reduce);
function add( a, b ) { return +a + +b; }
var sum = reduce_( add );
<!-- Browser example -->
<script src="build/src/part.min.js">
<script>
function add( a, b ) { return +a + +b; }
_part_._borrow( this )( Array.prototype, "reduce" );
var sum = reduce_( add );
</script>
papply
to the _part_
namespace.FAQs
This micro library encourages functional programming by making native methods available as partially applied functions.
The npm package part receives a total of 27 weekly downloads. As such, part popularity was classified as not popular.
We found that part 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 researchers uncover a malicious npm package posing as a tool for detecting vulnerabilities in Etherium smart contracts.
Security News
Research
A supply chain attack on Rspack's npm packages injected cryptomining malware, potentially impacting thousands of developers.
Research
Security News
Socket researchers discovered a malware campaign on npm delivering the Skuld infostealer via typosquatted packages, exposing sensitive data.