You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Currently this is not possible as the this context is not bound to destructured methods, it is inherited from the executing context, in Node's case, module
Binding the methods automatically in the constructor effectively makes the prototype-sharing of the methods useless.
That opens up the path for using the factory-pattern to replace the module.exports function, or alternatively rename it to Metalsmith.create.
Modern (& TS-enabled) packages often allow access to enums & "static class methods" (~ functions that are properties of a constructor) like const { Metalsmith } = require('metalsmith'). Returning Metalsmith.create in 2.4 could be a bridge to that path.
But binding the methods as an opt-out (for the purists among us) in a factory func (in the current codebase Metalsmith func is actually a factory + a constructor in 1) looks cleaner as it allows the Metalsmith prototype to remain pure
The text was updated successfully, but these errors were encountered:
Please add a thumbs up if this is important to you
Allow metalsmith methods to be destructured like
Currently this is not possible as the
this
context is not bound to destructured methods, it is inherited from the executing context, in Node's case,module
Binding the methods automatically in the constructor effectively makes the prototype-sharing of the methods useless.
That opens up the path for using the factory-pattern to replace the
module.exports
function, or alternatively rename it toMetalsmith.create
.Modern (& TS-enabled) packages often allow access to enums & "static class methods" (~ functions that are properties of a constructor) like
const { Metalsmith } = require('metalsmith')
. ReturningMetalsmith.create
in 2.4 could be a bridge to that path.But binding the methods as an opt-out (for the purists among us) in a factory func (in the current codebase
Metalsmith
func is actually a factory + a constructor in 1) looks cleaner as it allows the Metalsmith prototype to remain pureThe text was updated successfully, but these errors were encountered: