bind-operator

raw JSON →
1.0.0 verified Fri May 01 auth: no javascript deprecated

Transpiler that enables the ECMAScript bind operator (::) syntax, allowing functions to be called with a context object using a pipeline-style operator. Version 1.0.0, last updated in 2015. This package is an experimental implementation of a deprecated proposal and is not actively maintained. It transforms :: syntax into .call() or .bind() calls. Compared to alternatives like Babel's plugin, it is standalone and minimal, but lacks updates and broader ecosystem support.

error SyntaxError: Unexpected token :
cause The :: operator is not valid JavaScript without transpilation.
fix
Use bind-operator to transpile the code before running, or use a runtime that supports it.
deprecated The bind operator syntax is a deprecated ECMAScript proposal and is not part of any standard.
fix Use standard function methods (.call, .bind, .apply) or switch to Babel with @babel/plugin-proposal-bind-operator.
gotcha The package is unmaintained since 2015 and may have compatibility issues with modern Node.js versions.
fix Consider using alternative transpilers like Babel or TypeScript with appropriate plugins.
npm install bind-operator
yarn add bind-operator
pnpm add bind-operator

Shows how to use the bind-operator transpiler programmatically to transform a file containing :: syntax.

const bindOperator = require('bind-operator');
const fs = require('fs');
const input = fs.readFileSync('input.js', 'utf8');
const output = bindOperator.compile(input);
fs.writeFileSync('output.js', output, 'utf8');