{"id":15353,"library":"lodash.restparam","title":"lodash.restparam","description":"This package provides a modular build of Lodash's `_.restParam` function, designed to create a new function that collects arguments from a specified position into an array. While `lodash.restparam` is at version 3.6.1, the broader Lodash ecosystem has progressed to version 4.x. In Lodash v4.0.0, the `_.restParam` function was renamed to `_.rest`. Furthermore, all individual, per-method `lodash.*` packages, including `lodash.restparam`, are officially discouraged by the Lodash team and are slated for removal in Lodash v5. Modern JavaScript (ES6+) introduced native rest parameters (`...args`), which largely supersede the functionality provided by `_.restParam`. The package is unmaintained and should generally be avoided in favor of native features or direct imports from the main `lodash` package.","status":"deprecated","version":"3.6.1","language":"javascript","source_language":"en","source_url":"https://github.com/lodash/lodash","tags":["javascript","lodash","lodash-modularized","stdlib","util"],"install":[{"cmd":"npm install lodash.restparam","lang":"bash","label":"npm"},{"cmd":"yarn add lodash.restparam","lang":"bash","label":"yarn"},{"cmd":"pnpm add lodash.restparam","lang":"bash","label":"pnpm"}],"dependencies":[],"imports":[{"note":"This package is an old, unmaintained CommonJS module, but bundlers often provide ESM interoperability. Named imports are incorrect for this module's export style.","wrong":"import { restParam } from 'lodash.restparam';","symbol":"restParam","correct":"import restParam from 'lodash.restparam';"},{"note":"This is the documented and intended way to import this module.","symbol":"restParam (CommonJS)","correct":"const restParam = require('lodash.restparam');"},{"note":"In modern Lodash (v4+), the function is named `rest`, not `restParam`. The dedicated `lodash.restparam` package is deprecated; prefer importing `rest` from the main `lodash` package or using native rest parameters.","wrong":"import { restParam } from 'lodash';","symbol":"Rest parameter (modern Lodash)","correct":"import { rest } from 'lodash';"}],"quickstart":{"code":"import restParam from 'lodash.restparam';\n\nconst greetWithManyNames = restParam(function(greeting, ...names) {\n  return `${greeting} ${names.join(', ')}!`;\n}, 1); // Collect all arguments from index 1 (the second argument) onwards\n\nconsole.log(greetWithManyNames('Hello', 'Alice', 'Bob', 'Charlie'));\n// Expected output: \"Hello Alice, Bob, Charlie!\"\n\n// Demonstrating the equivalent with native rest parameters, preferred in modern JS:\nfunction modernGreet(greeting, ...names) {\n  return `${greeting} ${names.join(', ')}!`;\n}\nconsole.log(modernGreet('Hi', 'David', 'Eve'));\n// Expected output: \"Hi David, Eve!\"","lang":"javascript","description":"Demonstrates the usage of `lodash.restparam` to create a function that handles a variable number of arguments, alongside its modern native JavaScript equivalent."},"warnings":[{"fix":"Use `_.rest` from the main `lodash` package or, preferably, native JavaScript rest parameters (`...args`). If you must use `_.restParam`, stick to Lodash v3.x or this specific modular package.","message":"The `_.restParam` function was renamed to `_.rest` in Lodash v4.0.0. This `lodash.restparam` package is locked at version 3.x, meaning it will not provide the updated function name or any features from Lodash v4+.","severity":"breaking","affected_versions":">=4.0.0 (for main lodash, this package is unaffected as it's v3.x)"},{"fix":"Migrate to using native JavaScript rest parameters (`...args`) or import `_.rest` directly from the main `lodash` package (e.g., `import { rest } from 'lodash';`). Lodash provides a `jscodeshift` transform to assist with this migration.","message":"All individual, per-method `lodash.*` packages (like `lodash.restparam`) are officially discouraged by the Lodash team and are scheduled for removal in Lodash v5. They often lead to larger bundle sizes compared to importing specific functions from the main `lodash` package.","severity":"deprecated","affected_versions":"All versions of `lodash.restparam`"},{"fix":"Favor native JavaScript rest parameters (`function foo(arg1, ...restArgs)`) over `lodash.restparam`. This reduces bundle size and avoids external dependencies for a standard language feature.","message":"Native JavaScript introduced rest parameters (`...args`) in ES6 (ES2015), providing equivalent functionality to `_.restParam` and `_.rest`. Using this `lodash.restparam` package often introduces unnecessary dependency and bundle size.","severity":"gotcha","affected_versions":"<6.0.0 (for Node.js), prior to ES2015 for browsers"},{"fix":"Discontinue use of this package and migrate to native JavaScript rest parameters or the `_.rest` function from the actively maintained `lodash` main package.","message":"As an unmaintained, older modular package, `lodash.restparam` will not receive security updates. The main `lodash` package has had security advisories (e.g., prototype pollution fixes in v4.18.0) which would not be patched in this specific module.","severity":"gotcha","affected_versions":"All versions of `lodash.restparam`"}],"env_vars":null,"last_verified":"2026-04-21T00:00:00.000Z","next_check":"2026-07-20T00:00:00.000Z","problems":[{"fix":"Update your code to use `_.rest` instead of `_.restParam`, or use native JavaScript rest parameters (`...args`). If you are directly importing `lodash.restparam`, ensure your project does not implicitly rely on a newer version of Lodash.","cause":"You are likely trying to use `_.restParam` with a version of Lodash v4.0.0 or higher where the function was renamed to `_.rest`.","error":"TypeError: _.restParam is not a function"},{"fix":"Replace `lodash.restparam` with native JavaScript rest parameters (`...args`). For other Lodash functions, prefer importing specific methods directly from the main `lodash` package (e.g., `import { someMethod } from 'lodash';`) and leverage modern bundlers for tree-shaking, or use `babel-plugin-lodash`.","cause":"Modular `lodash.*` packages like `lodash.restparam` bundle their internal dependencies. If multiple such packages are used, or if the main `lodash` package is also present, it can lead to duplicated code in your final bundle, circumventing potential tree-shaking benefits.","error":"Bundle size unexpectedly large despite only using a few Lodash functions."}],"ecosystem":"npm"}