babel-plugin-transform-function-bind weekly downloads statistics
By babel (206 listings) · npm · Babel plugins
Compile function bind operator to ES5
babel-plugin-transform-function-bind has 273,092 recorded weekly downloads on npm, a decrease of 4.2% over the past 30 days, ranking #481 of 3,247 tracked listings.
About babel-plugin-transform-function-bind
babel-plugin-transform-function-bind
Compile the new function bind operator
::to ES5.
Detail
obj::func
// is equivalent to:
func.bind(obj)
obj::func(val)
// is equivalent to:
func.call(obj, val)
::obj.func(val)
// is equivalent to:
func.call(obj, val)
Example
Basic
const box = {
weight: 2,
getWeight() { return this.weight; },
};
const { getWeight } = box;
console.log(box.getWeight()); // prints '2'
const bigBox = { weight: 10 };
console.log(bigBox::getWeight()); // prints '10'
// Can be chained:
function add(val) { return this + val; }
console.log(bigBox::getWeight()::add(5)); // prints '15'
Using with document.querySelectorAll
It can be very handy when used with document.querySelectorAll:
const { map, filter } = Array.prototype;
let sslUrls = document.querySelectorAll('a')
::map(node => node.href)
::filter(href => href.substring(0, 5) === 'https');
console.log(sslUrls);
document.querySelectorAll returns a NodeList element which is not a plain array, so you normally can't use the map function on it, and have to use it this way: Array.prototype.map.call(document.querySelectorAll(...), node => { ... }). The above code using the :: will work because it is equivalent to:
const { map, filter } = Array.prototype;
let sslUrls = document.querySelectorAll('a');
sslUrls = map.call(sslUrls, node => node.href);
sslUrls = filter.call(sslUrls, href => href.substring(0, 5) === 'https');
console.log(sslUrls);
Auto self binding
When nothing is specified before the :: operator, the function is bound to its object:
$('.some-link').on('click', ::view.reset);
// is equivalent to:
$('.some-link').on('click', view.reset.bind(view));
Installation
npm install --save-dev babel-plugin-transform-function-bind
Usage
Via .babelrc (Recommended)
.babelrc
{
"plugins": ["transform-function-bind"]
}
Via CLI
babel --plugins transform-function-bind script.js
Via Node API
require("babel-core").transform("code", {
plugins: ["transform-function-bind"]
});
References
Description from the npm listing.
- babel-plugin
README badge
Show your rank in a README or on your website. The badge updates automatically.
Charts
Images: 30d · 1y · all time · 1600×900 dark
Adoption over time
7/30/90-day growth
Ranking history
Listing placement
Listing placement
Filled points are observed values; hollow points come from Internet Archive snapshots of the listing page. Dashed segments span periods with no observations — values between points are not interpolated.
Each band is one page of 20. Weekly downloads on a linear scale. Placement is projected from weekly downloads, so it can differ from the marketplace's own sort order. Hover a dot to see the listing.
Recent observations
Full history (170)Similar npm Babel plugins plugins
All 20 babel-plugin-transform-function-bind alternativesData source
Weekly downloads (trailing 7 complete days) come from the official npm downloads API. Downloads include CI and mirrors and are not equivalent to installs or users. npm publishes no ratings.
Listing: https://www.npmjs.com/package/babel-plugin-transform-function-bind. First seen Oct 16, 2026; last successful collection Dec 6, 2026. See the methodology.