/usr/lib/nodejs/auto-bind/index.js is in node-auto-bind 1.2.0-1.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 | 'use strict';
module.exports = (self, options) => {
options = Object.assign({}, options);
const filter = key => {
const match = pattern => typeof pattern === 'string' ? key === pattern : pattern.test(key);
if (options.include) {
return options.include.some(match);
}
if (options.exclude) {
return !options.exclude.some(match);
}
return true;
};
for (const key of Object.getOwnPropertyNames(self.constructor.prototype)) {
const val = self[key];
if (key !== 'constructor' && typeof val === 'function' && filter(key)) {
self[key] = val.bind(self);
}
}
return self;
};
const excludedReactMethods = [
'componentWillMount',
'render',
'componentDidMount',
'componentWillReceiveProps',
'shouldComponentUpdate',
'componentWillUpdate',
'componentDidUpdate',
'componentWillUnmount',
'componentDidCatch',
'setState',
'forceUpdate'
];
module.exports.react = (self, options) => {
options = Object.assign({}, options);
options.exclude = (options.exclude || []).concat(excludedReactMethods);
return module.exports(self, options);
};
|