use super::{HelperDef, HelperName};
pub const DEF: HelperDef = HelperDef {
name: HelperName::construct,
local: "_construct",
import_path: "@swc/helpers/_/_construct",
#[cfg(feature = "inline-helpers")]
source: r#"function _construct(Parent, args, Class) {
if (_is_native_reflect_construct()) _construct = Reflect.construct;
else {
_construct = function construct(Parent, args, Class) {
var a = [null];
a.push.apply(a, args);
var Constructor = Function.bind.apply(Parent, a);
var instance = new Constructor();
if (Class) _set_prototype_of(instance, Class.prototype);
return instance;
};
}
return _construct.apply(null, arguments);
}
"#,
#[cfg(feature = "inline-helpers")]
deps: super::HelperBitmap::from_bits(0x00000000000020002000008000000000),
};
#[cfg(feature = "inline-helpers")]
pub fn stmts() -> &'static [swc_ecma_ast::Stmt] {
static STMTS: once_cell::sync::Lazy<Vec<swc_ecma_ast::Stmt>> =
once_cell::sync::Lazy::new(|| super::super::parse(DEF.source, DEF.import_path));
&STMTS
}