New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

@optimal/arguments

Package Overview
Dependencies
Maintainers
1
Versions
1
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@optimal/arguments

Optimal conversion of arguments to an array (allows optimization, no leaked memory)

  • 0.1.0
  • unpublished
  • latest
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
0
Maintainers
1
Weekly downloads
 
Created
Source

@optimal/arguments

Build Status Dependency Status npm version Coverage Status

Optimal conversion of arguments to an array (allows optimization, no leaked memory).

Optimization is prevented when doing [].slice.call(arguments) or Array.prototype.slice.call(arguments).

It's a "leak" when the arguments is passed to another function or returned from a function.

So, we must create an array from the arguments. This would be an annoying bit of repetitive code.

This library takes care of this for you.

See article

Install

npm install @optimal/arguments --save

Usage

var arrayOf = require('@optimal/arguments')

function optimizable() {
  // these are bad:
  // [].slice.call(arguments)
  // [].slice.call(arguments, 1)
  // arguments[3] // when 3 is an invalid index
  // return arguments

  // this creates a new array without looping
  var args = arrayOf(arguments)

  // Or, select arguments with start/end like slice():
  var args = arrayOf(arguments, 1, 3)

  // now you can do this:
  callAnotherFunction(args)
  // or this:
  return args
}

MIT License

Keywords

FAQs

Package last updated on 30 Dec 2016

Did you know?

Socket

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
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc