Registry / testing / vfn
library1.1.0jsnpmunverified

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.

npm install vfn
INSTALL
IMPORT
SIG · VFN
V
vfn
testingjavascriptv1.1.0
harness data pending
Install & Compatibility
Where this runs

No compatibility data collected yet for this library.

Code
Verified usage

Verified import paths — ran on the pinned version, not inferred.

default
const vfn = require('vfn');
import vfn from 'vfn';
vfn does not ship ESM; it uses CommonJS only. Using ESM imports will fail without a bundler or Node's --experimental-require-module flag.
vfn (as named import)
const vfn = require('vfn');
const { vfn } = require('vfn');
The module exports a single function, not an object. Named destructuring will result in undefined.
vfn (ESM via createRequire)
import { createRequire } from 'module'; const require = createRequire(import.meta.url); const vfn = require('vfn');
import vfn from 'vfn';
In ESM contexts, you must use createRequire to load CommonJS modules.

Demonstrates basic usage of vfn with a variadic first parameter and optional options handling.

const vfn = require('vfn'); // Create a function where the first parameter is variadic const func = vfn(0, function (a, b, c) { console.log('a:', a, 'b:', b, 'c:', c); }); func(1, 2, 3, 4, 5); // a: [1, 2, 3] b: 4 c: 5 func('test', 'example'); // a: [] b: 'test' c: 'example' func('hello world'); // a: [] b: 'hello world' c: undefined // With optional options argument const func2 = vfn({ arg: 0, oo: true }, function (a, b, c, { option } = {}) { console.log('a:', a, 'b:', b, 'c:', c, 'option:', option); }); func2(1, 2, 3, 4, 5); // a: [1,2,3] b:4 c:5 option:undefined func2(1, 2, 3, 4, 5, { option: 123 }); // a: [1,2,3] b:4 c:5 option:123
Debug
Known issues
gotchaThe oo option only works if the last argument is a plain object used as an options parameter; any other plain object will be misinterpreted.
fix
Ensure that no other arguments are plain objects when using oo: true; otherwise, do not pass plain objects as arguments.
affects: <=1.1.0
gotchavfn does not export ES modules; require is the only supported import method. Using ES import syntax will fail with ERR_REQUIRE_ESM or similar.
fix
Use require('vfn') or use createRequire in ESM context.
affects: >=0.0.0
deprecatedNode.js 6.0.0 is end-of-life; vfn may not work on newer Node.js versions that drop support for older engines.
fix
Upgrade Node.js to a supported LTS version.
affects: >=1.0.0
Errors
Common errors & fixes
TypeError: vfn is not a function
Attempted named destructuring: `const { vfn } = require('vfn');`
fix
Use `const vfn = require('vfn');`
SyntaxError: The requested module 'vfn' does not provide an export named 'default'
Using ESM import: `import vfn from 'vfn';`
fix
Use CommonJS require or use createRequire.
Upgrade
Version history
1.1.0latest on npm
Audit
Dependencies

No dependency data recorded yet.

Agent activity
8 hits · last 30 days
node
8
Resources
packagevfn
vfn — npm install vfn · libregistry