Comparing version 1.0.1 to 1.1.0
@@ -45,118 +45,4 @@ 'use strict'; | ||
// export module | ||
var local = module.exports = function () {}; | ||
var local = module.exports = {}; | ||
// allow class to be instantiated without `new` | ||
local.export = function (y_class, f_operator) { | ||
var h_static = arguments.length <= 2 || arguments[2] === undefined ? false : arguments[2]; | ||
// cover class with `new`-less function | ||
var f_cover = function f_cover() { | ||
for (var _len = arguments.length, a_args = Array(_len), _key = 0; _key < _len; _key++) { | ||
a_args[_key] = arguments[_key]; | ||
} | ||
// create class instance | ||
var k_instance = new (Function.prototype.bind.apply(y_class, [null].concat(a_args)))(); | ||
// use operator | ||
if ('function' === typeof f_operator) { | ||
// bind instance to operator | ||
f_operator = Function.prototype.bind.apply(f_operator, [k_instance]); | ||
// set operator prototype chain to instance prototype chain | ||
Object.setPrototypeOf(f_operator, Object.getPrototypeOf(k_instance)); | ||
// build prototype chain array | ||
var a_inverse_prototype_chain = []; | ||
var d_pc_node = k_instance; | ||
do { | ||
// add this prototype object to the chain | ||
a_inverse_prototype_chain.unshift(d_pc_node); | ||
// advance up the prototype chain | ||
d_pc_node = Object.getPrototypeOf(d_pc_node); | ||
} while (d_pc_node !== Object.prototype); | ||
// override operator's own properties with all from prototype chain | ||
a_inverse_prototype_chain.forEach(function (d_ipc_node) { | ||
// bind all own properties of protoype to function | ||
Object.getOwnPropertyNames(d_ipc_node).forEach(function (s_property) { | ||
// ref property descriptor | ||
var h_property_descriptor = Object.getOwnPropertyDescriptor(d_ipc_node, s_property); | ||
// property value is a function | ||
if ('function' === typeof h_property_descriptor.value) { | ||
// define method on operator's own property | ||
Object.defineProperty(f_operator, s_property, | ||
// except, override descriptor | ||
Object.assign(h_property_descriptor, { | ||
// by binding instance to the function | ||
value: d_ipc_node[s_property].bind(k_instance) | ||
})); | ||
} | ||
// property is something else | ||
else { | ||
// it has a [[Getter]] function | ||
if ('function' === typeof h_property_descriptor.get) { | ||
// bind the instance to the getter function definition | ||
h_property_descriptor.get = h_property_descriptor.get.bind(k_instance); | ||
} | ||
// it has a [[Setter]] function | ||
if ('function' === typeof h_property_descriptor.set) { | ||
// bind the instance to the setter function definition | ||
h_property_descriptor.set = h_property_descriptor.set.bind(k_instance); | ||
} | ||
// use the descriptor to mirror the property on the operator | ||
Object.defineProperty(f_operator, s_property, h_property_descriptor); | ||
} | ||
}); | ||
}); | ||
// return operator/instance handle | ||
return f_operator; | ||
} | ||
// return instance | ||
return k_instance; | ||
}; | ||
// copy-assign public static members from class onto class cover | ||
Object.getOwnPropertyNames(y_class).forEach(function (s_property) { | ||
Object.defineProperty(f_cover, s_property, Object.getOwnPropertyDescriptor(y_class, s_property)); | ||
}); | ||
// ammend public static members | ||
Object.keys(h_static).forEach(function (s_property) { | ||
// ref public static member descriptor | ||
var h_psm_descriptor = Object.getOwnPropertyDescriptor(h_static, s_property); | ||
// define actual property on class | ||
Object.defineProperty(y_class, s_property, h_psm_descriptor); | ||
// define proxy property on class cover (getters/setters for class ref to access/mutate public static members) | ||
Object.defineProperty(f_cover, s_property, { | ||
// inherit from actual property | ||
configurable: h_psm_descriptor.configurable, | ||
enumerable: h_psm_descriptor.enumerable, | ||
// define proxy getter | ||
get: function get() { | ||
return y_class[s_property]; | ||
}, | ||
// define proxy setter | ||
set: function set(z_value) { | ||
y_class[s_property] = z_value; | ||
} | ||
}); | ||
}); | ||
// return cover | ||
return f_cover; | ||
}; | ||
// create a logger instance | ||
@@ -197,4 +83,4 @@ local.logger = function (y_class) { | ||
for (var _len2 = arguments.length, a_args = Array(_len2 > 1 ? _len2 - 1 : 0), _key2 = 1; _key2 < _len2; _key2++) { | ||
a_args[_key2 - 1] = arguments[_key2]; | ||
for (var _len = arguments.length, a_args = Array(_len > 1 ? _len - 1 : 0), _key = 1; _key < _len; _key++) { | ||
a_args[_key - 1] = arguments[_key]; | ||
} | ||
@@ -210,4 +96,4 @@ | ||
for (var _len3 = arguments.length, a_args = Array(_len3 > 1 ? _len3 - 1 : 0), _key3 = 1; _key3 < _len3; _key3++) { | ||
a_args[_key3 - 1] = arguments[_key3]; | ||
for (var _len2 = arguments.length, a_args = Array(_len2 > 1 ? _len2 - 1 : 0), _key2 = 1; _key2 < _len2; _key2++) { | ||
a_args[_key2 - 1] = arguments[_key2]; | ||
} | ||
@@ -232,4 +118,4 @@ | ||
for (var _len4 = arguments.length, a_args = Array(_len4 > 1 ? _len4 - 1 : 0), _key4 = 1; _key4 < _len4; _key4++) { | ||
a_args[_key4 - 1] = arguments[_key4]; | ||
for (var _len3 = arguments.length, a_args = Array(_len3 > 1 ? _len3 - 1 : 0), _key3 = 1; _key3 < _len3; _key3++) { | ||
a_args[_key3 - 1] = arguments[_key3]; | ||
} | ||
@@ -245,4 +131,4 @@ | ||
for (var _len5 = arguments.length, a_args = Array(_len5 > 1 ? _len5 - 1 : 0), _key5 = 1; _key5 < _len5; _key5++) { | ||
a_args[_key5 - 1] = arguments[_key5]; | ||
for (var _len4 = arguments.length, a_args = Array(_len4 > 1 ? _len4 - 1 : 0), _key4 = 1; _key4 < _len4; _key4++) { | ||
a_args[_key4 - 1] = arguments[_key4]; | ||
} | ||
@@ -259,2 +145,194 @@ | ||
}; | ||
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJzb3VyY2VzIjpbImluZGV4LmpzIl0sIm5hbWVzIjpbXSwibWFwcGluZ3MiOiI7Ozs7OztBQUlBLElBQU0sa0JBQWtCLFlBQWxCOzs7QUFHTixJQUFNLGlCQUFpQjtBQUN0QixPQUFNO0FBQ0wsWUFBVSxrQkFBVjtBQUNBLFNBQU8sS0FBUDtBQUNBLFdBQVMsT0FBVDtFQUhEO0FBS0EsUUFBTztBQUNOLFlBQVUsWUFBVjtBQUNBLFdBQVMsT0FBVDtFQUZEO0FBSUEsT0FBTTtBQUNMLFlBQVUsa0JBQVY7QUFDQSxXQUFTLE1BQVQ7RUFGRDtBQUlBLE9BQU07QUFDTCxZQUFVLFlBQVY7QUFDQSxXQUFTLE1BQVQ7RUFGRDtBQUlBLE9BQU07Q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SouMDAxKS50b0ZpeGVkKDMpXG5cdFx0XHRcdFx0XHR9cy8gJWMke3NfbXNnfVxcbiR7XG5cdFx0XHRcdFx0XHRcdHNfc3RhY2tcblx0XHRcdFx0XHRcdH1gLCAnY29sb3I6Jyt0aGlzLmNvbG9yLCAnY29sb3I6aW5oZXJpdCcsIC4uLmFfYXJncywgJ2NvbG9yOicrdGhpcy5jb2xvcik7XG5cdFx0XHRcdFx0ZV90aHJvdy5zdGFjayA9IGBFcnJvclxcbiR7c19zdGFja31gO1xuXHRcdFx0XHRcdHRocm93IGVfdGhyb3c7XG5cdFx0XHRcdH0pLmJpbmQoSF9MRVZFTF9DT0xPUlNbc19sZXZlbF0pO1xuXHRcdFx0fVxuXHRcdFx0ZWxzZSB7XG5cdFx0XHRcdGhfbG9jYWxbc19sZXZlbF0gPSAoZnVuY3Rpb24oc19tc2csIC4uLmFfYXJncykge1xuXHRcdFx0XHRcdGNvbnNvbGVbdGhpcy5jaGFubmVsXShcblx0XHRcdFx0XHRcdGBbJWMke3NfY2xhc3NfbmFtZX0lY10rJHtcblx0XHRcdFx0XHRcdFx0KChEYXRlLm5vdygpIC0gd2luZG93LnBlcmZvcm1hbmNlLnRpbWluZy5kb21Db250ZW50TG9hZGVkRXZlbnRTdGFydCkqLjAwMSkudG9GaXhlZCgzKVxuXHRcdFx0XHRcdFx0fXMvICVjJHtzX21zZ31gLCAnY29sb3I6Jyt0aGlzLmNvbG9yLCAnY29sb3I6aW5oZXJpdCcsIC4uLmFfYXJncywgJ2NvbG9yOicrdGhpcy5jb2xvcik7XG5cdFx0XHRcdH0pLmJpbmQoSF9MRVZFTF9DT0xPUlNbc19sZXZlbF0pO1xuXHRcdFx0fVxuXHRcdH1cblx0fVxuXG5cdC8vIHJldHVybiBsb2dnZXJcblx0cmV0dXJuIGhfbG9jYWw7XG59O1xuXG4iXSwic291cmNlUm9vdCI6Ii9zb3VyY2UvIn0= | ||
// override operator's property to mirror prototype property | ||
var bind_property = function bind_property(f_operator, s_property, d_ipc_node, k_instance) { | ||
// ref property descriptor | ||
var h_property_descriptor = Object.getOwnPropertyDescriptor(d_ipc_node, s_property); | ||
// property value is a function | ||
if ('function' === typeof h_property_descriptor.value) { | ||
// define method on operator's own property | ||
Object.defineProperty(f_operator, s_property, | ||
// except, override descriptor | ||
Object.assign(h_property_descriptor, { | ||
// by binding instance to the function | ||
value: d_ipc_node[s_property].bind(k_instance) | ||
})); | ||
} | ||
// property is something else | ||
else { | ||
// it has a [[Getter]] function | ||
if ('function' === typeof h_property_descriptor.get) { | ||
// bind the instance to the getter function definition | ||
h_property_descriptor.get = h_property_descriptor.get.bind(k_instance); | ||
} | ||
// it has a [[Setter]] function | ||
if ('function' === typeof h_property_descriptor.set) { | ||
// bind the instance to the setter function definition | ||
h_property_descriptor.set = h_property_descriptor.set.bind(k_instance); | ||
} | ||
// use the descriptor to mirror the property on the operator | ||
Object.defineProperty(f_operator, s_property, h_property_descriptor); | ||
} | ||
}; | ||
// set prototype of operator to instance and override function's own properties | ||
var bind_operator_proxy = function bind_operator_proxy(f_operator, k_instance) { | ||
// bind instance to operator | ||
f_operator = Function.prototype.bind.apply(f_operator, [k_instance]); | ||
// set prototype of operator to the instance itself | ||
Object.setPrototypeOf(f_operator, k_instance); | ||
// build prototype chain array | ||
var a_inverse_prototype_chain = []; | ||
var d_pc_node = k_instance; | ||
do { | ||
// add this prototype object to the chain | ||
a_inverse_prototype_chain.unshift(d_pc_node); | ||
// advance up the prototype chain | ||
d_pc_node = Object.getPrototypeOf(d_pc_node); | ||
} while (d_pc_node !== Object.prototype); | ||
// override operator's own 'length' and 'name' properties with those from prototype chain if they exist | ||
a_inverse_prototype_chain.forEach(function (d_ipc_node) { | ||
// override length property | ||
if (d_ipc_node.hasOwnProperty('length')) { | ||
bind_property(f_operator, 'length', d_ipc_node, k_instance); | ||
} | ||
// override name property | ||
if (d_ipc_node.hasOwnProperty('name')) { | ||
bind_property(f_operator, 'name', d_ipc_node, k_instance); | ||
} | ||
}); | ||
// return operator/instance handle | ||
return f_operator; | ||
}; | ||
// extend class with static members, proxy members on cover object | ||
var copy_assign_static_proxy = function copy_assign_static_proxy(f_cover, y_class, h_static) { | ||
// copy-assign public static members from class onto class cover | ||
Object.getOwnPropertyNames(y_class).forEach(function (s_property) { | ||
Object.defineProperty(f_cover, s_property, Object.getOwnPropertyDescriptor(y_class, s_property)); | ||
}); | ||
// ammend public static members | ||
Object.keys(h_static).forEach(function (s_property) { | ||
// ref public static member descriptor | ||
var h_psm_descriptor = Object.getOwnPropertyDescriptor(h_static, s_property); | ||
// define actual property on class | ||
Object.defineProperty(y_class, s_property, h_psm_descriptor); | ||
// define proxy property on class cover (getters/setters for class ref to access/mutate public static members) | ||
Object.defineProperty(f_cover, s_property, { | ||
// inherit from actual property | ||
configurable: h_psm_descriptor.configurable, | ||
enumerable: h_psm_descriptor.enumerable, | ||
// define proxy getter | ||
get: function get() { | ||
return y_class[s_property]; | ||
}, | ||
// define proxy setter | ||
set: function set(z_value) { | ||
y_class[s_property] = z_value; | ||
} | ||
}); | ||
}); | ||
// return cover | ||
return f_cover; | ||
}; | ||
// allow class to be instantiated without `new` | ||
local.export = function (y_class, f_operator) { | ||
var h_static = arguments.length <= 2 || arguments[2] === undefined ? {} : arguments[2]; | ||
// cover class with `new`-less function | ||
var f_cover = function f_cover() { | ||
for (var _len5 = arguments.length, a_args = Array(_len5), _key5 = 0; _key5 < _len5; _key5++) { | ||
a_args[_key5] = arguments[_key5]; | ||
} | ||
// create class instance | ||
var k_instance = new (Function.prototype.bind.apply(y_class, [null].concat(a_args)))(); | ||
// use operator | ||
if ('function' === typeof f_operator) { | ||
// called with `new` | ||
if (new.target) { | ||
throw 'cannot return operator function when using \'new\' keyword'; | ||
} | ||
// bind operator proxy | ||
return bind_operator_proxy(f_operator, k_instance); | ||
} | ||
// return instance | ||
return k_instance; | ||
}; | ||
// assign static members | ||
return copy_assign_static_proxy(f_cover, y_class, h_static); | ||
}; | ||
// allow class to be instantiated asynchronously | ||
local.exportAsync = function (y_class, f_operator) { | ||
var h_static = arguments.length <= 2 || arguments[2] === undefined ? {} : arguments[2]; | ||
// constructor cover | ||
var f_cover = function f_cover() { | ||
for (var _len6 = arguments.length, a_args = Array(_len6), _key6 = 0; _key6 < _len6; _key6++) { | ||
a_args[_key6] = arguments[_key6]; | ||
} | ||
// ref callback at end | ||
var f_okay_instance = a_args[a_args.length - 1]; | ||
// prep instance | ||
var k_instance = void 0; | ||
// async callback function | ||
if ('function' === typeof f_okay_instance) { | ||
// asynchronously return instance to caller | ||
var f_okay_constructor = function f_okay_constructor() { | ||
// use operator | ||
if ('function' === typeof f_operator) { | ||
// bind operator proxy | ||
f_okay_instance(bind_operator_proxy(f_operator, k_instance)); | ||
} | ||
// no operator | ||
else { | ||
// all done :) | ||
f_okay_instance(k_instance); | ||
} | ||
}; | ||
// replace last arg | ||
a_args[a_args.length - 1] = f_okay_constructor; | ||
// create instance | ||
k_instance = new (Function.prototype.bind.apply(y_class, [null].concat(a_args)))(); | ||
} | ||
// no callback given | ||
else { | ||
throw 'class ' + y_class.name + ' requires asynchronous construction. expected last argument to be callback function'; | ||
} | ||
}; | ||
// assign static members | ||
return copy_assign_static_proxy(f_cover, y_class, h_static); | ||
}; | ||
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJzb3VyY2VzIjpbImluZGV4LmpzIl0sIm5hbWVzIjpbXSwibWFwcGluZ3MiOiI7Ozs7OztBQUlBLElBQU0sa0JBQWtCLFlBQWxCOzs7QUFHTixJQUFNLGlCQUFpQjtBQUN0QixPQUFNO0FBQ0wsWUFBVSxrQkFBVjtBQUNBLFNBQU8sS0FBUDtBQUNBLFdBQVMsT0FBVDtFQUhEO0FBS0EsUUFBTztBQUNOLFlBQVUsWUFBVjtBQUNBLFdBQVMsT0FBVDtFQUZEO0FBSUEsT0FBTTtBQUNMLFlBQVUsa0JBQVY7QUFDQSxXQUFTLE1BQVQ7RUFGRDtBQUlBLE9BQU07QUFDTCxZQU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0XHRcdC8vIGFsbCBkb25lIDopXG5cdFx0XHRcdFx0Zl9va2F5X2luc3RhbmNlKGtfaW5zdGFuY2UpO1xuXHRcdFx0XHR9XG5cdFx0XHR9O1xuXG5cdFx0XHQvLyByZXBsYWNlIGxhc3QgYXJnXG5cdFx0XHRhX2FyZ3NbYV9hcmdzLmxlbmd0aC0xXSA9IGZfb2theV9jb25zdHJ1Y3RvcjtcblxuXHRcdFx0Ly8gY3JlYXRlIGluc3RhbmNlXG5cdFx0XHRrX2luc3RhbmNlID0gbmV3IHlfY2xhc3MoLi4uYV9hcmdzKTtcblx0XHR9XG5cdFx0Ly8gbm8gY2FsbGJhY2sgZ2l2ZW5cblx0XHRlbHNlIHtcblx0XHRcdHRocm93IGBjbGFzcyAke3lfY2xhc3MubmFtZX0gcmVxdWlyZXMgYXN5bmNocm9ub3VzIGNvbnN0cnVjdGlvbi4gZXhwZWN0ZWQgbGFzdCBhcmd1bWVudCB0byBiZSBjYWxsYmFjayBmdW5jdGlvbmA7XG5cdFx0fVxuXHR9O1xuXG5cdC8vIGFzc2lnbiBzdGF0aWMgbWVtYmVyc1xuXHRyZXR1cm4gY29weV9hc3NpZ25fc3RhdGljX3Byb3h5KGZfY292ZXIsIHlfY2xhc3MsIGhfc3RhdGljKTtcbn07XG4iXSwic291cmNlUm9vdCI6Ii9zb3VyY2UvIn0= |
@@ -43,112 +43,5 @@ /*eslint-env node, browser*/ | ||
// export module | ||
const local = module.exports = function(){}; | ||
const local = module.exports = {}; | ||
// allow class to be instantiated without `new` | ||
local.export = function(y_class, f_operator, h_static=false) { | ||
// cover class with `new`-less function | ||
let f_cover = function(...a_args) { | ||
// create class instance | ||
let k_instance = new y_class(...a_args); | ||
// use operator | ||
if('function' === typeof f_operator) { | ||
// bind instance to operator | ||
f_operator = Function.prototype.bind.apply(f_operator, [k_instance]); | ||
// set operator prototype chain to instance prototype chain | ||
Object.setPrototypeOf(f_operator, Object.getPrototypeOf(k_instance)); | ||
// build prototype chain array | ||
let a_inverse_prototype_chain = []; | ||
let d_pc_node = k_instance; | ||
do { | ||
// add this prototype object to the chain | ||
a_inverse_prototype_chain.unshift(d_pc_node); | ||
// advance up the prototype chain | ||
d_pc_node = Object.getPrototypeOf(d_pc_node); | ||
} while(d_pc_node !== Object.prototype); | ||
// override operator's own properties with all from prototype chain | ||
a_inverse_prototype_chain.forEach((d_ipc_node) => { | ||
// bind all own properties of protoype to function | ||
Object.getOwnPropertyNames(d_ipc_node).forEach((s_property) => { | ||
// ref property descriptor | ||
let h_property_descriptor = Object.getOwnPropertyDescriptor(d_ipc_node, s_property); | ||
// property value is a function | ||
if('function' === typeof h_property_descriptor.value) { | ||
// define method on operator's own property | ||
Object.defineProperty(f_operator, s_property, | ||
// except, override descriptor | ||
Object.assign(h_property_descriptor, { | ||
// by binding instance to the function | ||
value: d_ipc_node[s_property].bind(k_instance), | ||
})); | ||
} | ||
// property is something else | ||
else { | ||
// it has a [[Getter]] function | ||
if('function' === typeof h_property_descriptor.get) { | ||
// bind the instance to the getter function definition | ||
h_property_descriptor.get = h_property_descriptor.get.bind(k_instance); | ||
} | ||
// it has a [[Setter]] function | ||
if('function' === typeof h_property_descriptor.set) { | ||
// bind the instance to the setter function definition | ||
h_property_descriptor.set = h_property_descriptor.set.bind(k_instance); | ||
} | ||
// use the descriptor to mirror the property on the operator | ||
Object.defineProperty(f_operator, s_property, h_property_descriptor); | ||
} | ||
}); | ||
}); | ||
// return operator/instance handle | ||
return f_operator; | ||
} | ||
// return instance | ||
return k_instance; | ||
}; | ||
// copy-assign public static members from class onto class cover | ||
Object.getOwnPropertyNames(y_class).forEach((s_property) => { | ||
Object.defineProperty(f_cover, s_property, Object.getOwnPropertyDescriptor(y_class, s_property)); | ||
}); | ||
// ammend public static members | ||
Object.keys(h_static).forEach((s_property) => { | ||
// ref public static member descriptor | ||
let h_psm_descriptor = Object.getOwnPropertyDescriptor(h_static, s_property); | ||
// define actual property on class | ||
Object.defineProperty(y_class, s_property, h_psm_descriptor); | ||
// define proxy property on class cover (getters/setters for class ref to access/mutate public static members) | ||
Object.defineProperty(f_cover, s_property, { | ||
// inherit from actual property | ||
configurable: h_psm_descriptor.configurable, | ||
enumerable: h_psm_descriptor.enumerable, | ||
// define proxy getter | ||
get() { | ||
return y_class[s_property]; | ||
}, | ||
// define proxy setter | ||
set(z_value) { | ||
y_class[s_property] = z_value; | ||
}, | ||
}); | ||
}); | ||
// return cover | ||
return f_cover; | ||
}; | ||
// create a logger instance | ||
@@ -238,1 +131,184 @@ local.logger = function(y_class, h_static={}) { | ||
// override operator's property to mirror prototype property | ||
const bind_property = (f_operator, s_property, d_ipc_node, k_instance) => { | ||
// ref property descriptor | ||
let h_property_descriptor = Object.getOwnPropertyDescriptor(d_ipc_node, s_property); | ||
// property value is a function | ||
if('function' === typeof h_property_descriptor.value) { | ||
// define method on operator's own property | ||
Object.defineProperty(f_operator, s_property, | ||
// except, override descriptor | ||
Object.assign(h_property_descriptor, { | ||
// by binding instance to the function | ||
value: d_ipc_node[s_property].bind(k_instance), | ||
})); | ||
} | ||
// property is something else | ||
else { | ||
// it has a [[Getter]] function | ||
if('function' === typeof h_property_descriptor.get) { | ||
// bind the instance to the getter function definition | ||
h_property_descriptor.get = h_property_descriptor.get.bind(k_instance); | ||
} | ||
// it has a [[Setter]] function | ||
if('function' === typeof h_property_descriptor.set) { | ||
// bind the instance to the setter function definition | ||
h_property_descriptor.set = h_property_descriptor.set.bind(k_instance); | ||
} | ||
// use the descriptor to mirror the property on the operator | ||
Object.defineProperty(f_operator, s_property, h_property_descriptor); | ||
} | ||
}; | ||
// set prototype of operator to instance and override function's own properties | ||
const bind_operator_proxy = (f_operator, k_instance) => { | ||
// bind instance to operator | ||
f_operator = Function.prototype.bind.apply(f_operator, [k_instance]); | ||
// set prototype of operator to the instance itself | ||
Object.setPrototypeOf(f_operator, k_instance); | ||
// build prototype chain array | ||
let a_inverse_prototype_chain = []; | ||
let d_pc_node = k_instance; | ||
do { | ||
// add this prototype object to the chain | ||
a_inverse_prototype_chain.unshift(d_pc_node); | ||
// advance up the prototype chain | ||
d_pc_node = Object.getPrototypeOf(d_pc_node); | ||
} while(d_pc_node !== Object.prototype); | ||
// override operator's own 'length' and 'name' properties with those from prototype chain if they exist | ||
a_inverse_prototype_chain.forEach((d_ipc_node) => { | ||
// override length property | ||
if(d_ipc_node.hasOwnProperty('length')) { | ||
bind_property(f_operator, 'length', d_ipc_node, k_instance); | ||
} | ||
// override name property | ||
if(d_ipc_node.hasOwnProperty('name')) { | ||
bind_property(f_operator, 'name', d_ipc_node, k_instance); | ||
} | ||
}); | ||
// return operator/instance handle | ||
return f_operator; | ||
}; | ||
// extend class with static members, proxy members on cover object | ||
const copy_assign_static_proxy = (f_cover, y_class, h_static) => { | ||
// copy-assign public static members from class onto class cover | ||
Object.getOwnPropertyNames(y_class).forEach((s_property) => { | ||
Object.defineProperty(f_cover, s_property, Object.getOwnPropertyDescriptor(y_class, s_property)); | ||
}); | ||
// ammend public static members | ||
Object.keys(h_static).forEach((s_property) => { | ||
// ref public static member descriptor | ||
let h_psm_descriptor = Object.getOwnPropertyDescriptor(h_static, s_property); | ||
// define actual property on class | ||
Object.defineProperty(y_class, s_property, h_psm_descriptor); | ||
// define proxy property on class cover (getters/setters for class ref to access/mutate public static members) | ||
Object.defineProperty(f_cover, s_property, { | ||
// inherit from actual property | ||
configurable: h_psm_descriptor.configurable, | ||
enumerable: h_psm_descriptor.enumerable, | ||
// define proxy getter | ||
get() { | ||
return y_class[s_property]; | ||
}, | ||
// define proxy setter | ||
set(z_value) { | ||
y_class[s_property] = z_value; | ||
}, | ||
}); | ||
}); | ||
// return cover | ||
return f_cover; | ||
}; | ||
// allow class to be instantiated without `new` | ||
local.export = function(y_class, f_operator, h_static={}) { | ||
// cover class with `new`-less function | ||
let f_cover = function(...a_args) { | ||
// create class instance | ||
let k_instance = new y_class(...a_args); | ||
// use operator | ||
if('function' === typeof f_operator) { | ||
// called with `new` | ||
if(new.target) { | ||
throw `cannot return operator function when using 'new' keyword`; | ||
} | ||
// bind operator proxy | ||
return bind_operator_proxy(f_operator, k_instance); | ||
} | ||
// return instance | ||
return k_instance; | ||
}; | ||
// assign static members | ||
return copy_assign_static_proxy(f_cover, y_class, h_static); | ||
}; | ||
// allow class to be instantiated asynchronously | ||
local.exportAsync = function(y_class, f_operator, h_static={}) { | ||
// constructor cover | ||
let f_cover = function(...a_args) { | ||
// ref callback at end | ||
let f_okay_instance = a_args[a_args.length-1]; | ||
// prep instance | ||
let k_instance; | ||
// async callback function | ||
if('function' === typeof f_okay_instance) { | ||
// asynchronously return instance to caller | ||
const f_okay_constructor = () => { | ||
// use operator | ||
if('function' === typeof f_operator) { | ||
// bind operator proxy | ||
f_okay_instance(bind_operator_proxy(f_operator, k_instance)); | ||
} | ||
// no operator | ||
else { | ||
// all done :) | ||
f_okay_instance(k_instance); | ||
} | ||
}; | ||
// replace last arg | ||
a_args[a_args.length-1] = f_okay_constructor; | ||
// create instance | ||
k_instance = new y_class(...a_args); | ||
} | ||
// no callback given | ||
else { | ||
throw `class ${y_class.name} requires asynchronous construction. expected last argument to be callback function`; | ||
} | ||
}; | ||
// assign static members | ||
return copy_assign_static_proxy(f_cover, y_class, h_static); | ||
}; |
11
index.js
@@ -1,13 +0,8 @@ | ||
var a_version = process.versions.node.split(/\./g); | ||
var n_major = ~~a_version[0]; | ||
var n_minor = ~~a_version[1]; | ||
var n_patch = ~~a_version[2]; | ||
// only for node >= v6.2.1 (prior releases of 6 cause debugging errors) | ||
if(n_major > 6 || (n_major === 6 && (n_minor > 2 || (n_minor === 2 && n_patch >= 1)))) { | ||
// only for node >= v6 (prior releases do not stably support es6) | ||
if(~~process.versions.node.split(/\./g)[0] >= 6) { | ||
module.exports = require('./dist.es6/main/index.js'); | ||
} | ||
// default to es5 version | ||
// otherwise, default to es5 version | ||
else { | ||
module.exports = require('./dist.es5/main/index.js'); | ||
} |
{ | ||
"name": "classer", | ||
"version": "1.0.1", | ||
"version": "1.1.0", | ||
"description": "A dependent-less module utility to create `new`-less class instances that double as operator functions", | ||
@@ -5,0 +5,0 @@ "author": { |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
Major refactor
Supply chain riskPackage has recently undergone a major refactor. It may be unstable or indicate significant internal changes. Use caution when updating to versions that include significant changes.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
41098
621
1