Security News
PyPI’s New Archival Feature Closes a Major Security Gap
PyPI now allows maintainers to archive projects, improving security and helping users make informed decisions about their dependencies.
func-to-classes
Advanced tools
prototype
prototype
prototype
defineProperty
prototype
npm i -g jscodeshift
git clone --depth=1 https://github.com/dhruvdutt/es5-function-to-class-codemod codemod && cd codemod
jscodeshift -t func-to-class.js example/input.js
function Controller(param1, param2) {
const name = "dhruvdutt";
let age = 21;
}
Controller.prototype.name = "Dhruvdutt";
Controller.prototype.contributeTo = function(param) {
var foo = "webpack";
};
Controller.staticMethod = function(param) {
var bar = "webpack-cli";
};
Object.defineProperty(Controller.prototype, "hello", {
get: function () {
return "world";
},
set: function (name) {
console.log("Do anything with " + name);
},
});
Object.defineProperty(Controller.prototype, "lastname", {
get: function () {
return "Jadhav";
},
});
class Controller {
constructor(param1, param2) {
const name = "dhruvdutt";
let age = 21;
this.name = "Dhruvdutt";
}
contributeTo(param) {
var foo = "webpack";
}
static staticMethod(param) {
var bar = "webpack-cli";
}
get hello() {
return "world";
}
set hello(name) {
console.log("Do anything with " + name);
}
get lastname() {
return "Jadhav";
}
}
Complex example: Multiple functions in same file with one of the functions having same name.
Also, featured on awesome-jscodeshift.
FAQs
Transform ES5 Functions to ES6 Classes
We found that func-to-classes demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
PyPI now allows maintainers to archive projects, improving security and helping users make informed decisions about their dependencies.
Research
Security News
Malicious npm package postcss-optimizer delivers BeaverTail malware, targeting developer systems; similarities to past campaigns suggest a North Korean connection.
Security News
CISA's KEV data is now on GitHub, offering easier access, API integration, commit history tracking, and automated updates for security teams and researchers.