{"id":49645,"library":"vfn","title":"vfn","description":"vfn is a lightweight Node.js module that creates variadic functions where the rest parameter can be placed at any position, not just at the end as required by native JavaScript rest parameters. It is at version 1.1.0, last updated in 2020, with no recent releases. Unlike alternatives that require wrapper libraries or manual argument handling, vfn provides a simple API to specify the index of the variadic parameter and optionally ignore a trailing options object. It supports Node.js 6.0.0+ and uses CommonJS.","status":"active","version":"1.1.0","language":"javascript","source_language":"en","source_url":"https://github.com/lamansky/vfn","tags":["javascript","variadic","function","rest parameter","parameters","arguments"],"install":[{"cmd":"npm install vfn","lang":"bash","label":"npm"},{"cmd":"yarn add vfn","lang":"bash","label":"yarn"},{"cmd":"pnpm add vfn","lang":"bash","label":"pnpm"}],"dependencies":[],"imports":[{"note":"vfn does not ship ESM; it uses CommonJS only. Using ESM imports will fail without a bundler or Node's --experimental-require-module flag.","wrong":"import vfn from 'vfn';","symbol":"default","correct":"const vfn = require('vfn');"},{"note":"The module exports a single function, not an object. Named destructuring will result in undefined.","wrong":"const { vfn } = require('vfn');","symbol":"vfn (as named import)","correct":"const vfn = require('vfn');"},{"note":"In ESM contexts, you must use createRequire to load CommonJS modules.","wrong":"import vfn from 'vfn';","symbol":"vfn (ESM via createRequire)","correct":"import { createRequire } from 'module';\nconst require = createRequire(import.meta.url);\nconst vfn = require('vfn');"}],"quickstart":{"code":"const vfn = require('vfn');\n\n// Create a function where the first parameter is variadic\nconst func = vfn(0, function (a, b, c) {\n  console.log('a:', a, 'b:', b, 'c:', c);\n});\n\nfunc(1, 2, 3, 4, 5); // a: [1, 2, 3] b: 4 c: 5\nfunc('test', 'example'); // a: [] b: 'test' c: 'example'\nfunc('hello world'); // a: [] b: 'hello world' c: undefined\n\n// With optional options argument\nconst func2 = vfn({ arg: 0, oo: true }, function (a, b, c, { option } = {}) {\n  console.log('a:', a, 'b:', b, 'c:', c, 'option:', option);\n});\n\nfunc2(1, 2, 3, 4, 5); // a: [1,2,3] b:4 c:5 option:undefined\nfunc2(1, 2, 3, 4, 5, { option: 123 }); // a: [1,2,3] b:4 c:5 option:123","lang":"javascript","description":"Demonstrates basic usage of vfn with a variadic first parameter and optional options handling."},"warnings":[{"fix":"Ensure that no other arguments are plain objects when using oo: true; otherwise, do not pass plain objects as arguments.","message":"The oo option only works if the last argument is a plain object used as an options parameter; any other plain object will be misinterpreted.","severity":"gotcha","affected_versions":"<=1.1.0"},{"fix":"Use require('vfn') or use createRequire in ESM context.","message":"vfn does not export ES modules; require is the only supported import method. Using ES import syntax will fail with ERR_REQUIRE_ESM or similar.","severity":"gotcha","affected_versions":">=0.0.0"},{"fix":"Upgrade Node.js to a supported LTS version.","message":"Node.js 6.0.0 is end-of-life; vfn may not work on newer Node.js versions that drop support for older engines.","severity":"deprecated","affected_versions":">=1.0.0"}],"env_vars":null,"search_vec":"'1.1.0':38 '2020':42 '6.0.0':80 'altern':48 'api':61 'argument':55,90 'commonj':83 'creat':9 'end':26 'function':11,86 'handl':56 'ignor':72 'index':65 'javascript':31,84 'last':39 'librari':52 'lightweight':5 'manual':54 'modul':7 'nativ':30 'node.js':6,79 'object':76 'option':71,75 'paramet':15,33,69,88,89 'place':18 'posit':21 'provid':58 'recent':45 'releas':46 'requir':28,50 'rest':14,32,87 'simpl':60 'specifi':63 'support':78 'trail':74 'unlik':47 'updat':40 'use':82 'variad':10,68,85 'version':37 'vfn':1,2,57 'wrapper':51","created_at":"2026-06-07T17:02:51.086857+00:00","updated_at":"2026-06-07T17:02:51.086857+00:00","problems":[{"fix":"Use `const vfn = require('vfn');`","cause":"Attempted named destructuring: `const { vfn } = require('vfn');`","error":"TypeError: vfn is not a function"},{"fix":"Use CommonJS require or use createRequire.","cause":"Using ESM import: `import vfn from 'vfn';`","error":"SyntaxError: The requested module 'vfn' does not provide an export named 'default'"}],"ecosystem":"npm","meta_description":null,"install_score":null,"quickstart_score":null,"quickstart_tag":null,"pypi_latest":null,"cli_name":null,"cli_version":null,"type":"library","homepage":"https://github.com/lamansky/vfn","github":"https://github.com/lamansky/vfn","docs":null,"changelog":null,"pypi":null,"npm":"vfn","openapi_spec":null,"status_page":null,"smithery":null,"categories":["testing"],"base_url":null,"auth_type":null,"provenance":{"verified_status":null,"verified_at":null,"last_verified":"2026-06-07","next_check":"2026-09-05","install_tag":null}}