Socket
Socket
Sign inDemoInstall

arg1

Package Overview
Dependencies
0
Maintainers
1
Versions
1
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

    arg1

Function wrapper that only passes 1st argument to function


Version published
Weekly downloads
1
decreased by-50%
Maintainers
1
Install size
3.10 kB
Created
Weekly downloads
 

Readme

Source

Function wrapper that only passes 1st argument to function

Build Status

Synopsis

The module is just a couple lines of code

function arg1(func, obj) {
  if (obj) func = func.bind(obj);
  return function(arg) { return func(arg); };
}

The library allows more compact code as seen below :

// this code
list.forEach(function(el) {
  console.log(el);
});

// becomes
list.forEach(arg1(console.log));

// this code
regex = /foo/;
filtered = list.filter(function(el) {
  return regex.test(el);
});

//becomes
regex = /foo/;
filtered = list.filter(arg1(regex.test,regex));

This function could be part of a callback utilities module - I wasn't able to find it in npm

#Description Using this module:

var arg1 = require('arg1');
['Hello','World','!'].map(arg1(console.log));

Installation

Installing the module

npm install arg1

Keywords

FAQs

Last updated on 15 Dec 2013

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.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc