experimenting...

Signed-off-by: Alex A. Naanou <alex.nanou@gmail.com>
This commit is contained in:
Alex A. Naanou 2021-07-04 17:54:28 +03:00
parent f86c34a865
commit f02adb73b7

View File

@ -1003,22 +1003,32 @@ module.Constructor =
// shorthand... // shorthand...
module.C = module.C =
function Constructor(name, a, b, c){ function Constructor(name, a, b, c){
var args = [...arguments].slice(1, 4)
// sanity check... // sanity check...
if(!/^[a-zA-Z_][a-zA-Z0-9_]*$/.test(name.trim())){ if(!/^[a-zA-Z_][a-zA-Z0-9_]*$/.test(name.trim())){
throw new Error(`Constructor(..): invalid name: "${name}"`) } throw new Error(`Constructor(..): invalid name: "${name}"`) }
// parse args... // parse args...
var args = [...arguments].slice(1, 4)
// Constructor(name[[, constructor[, mixin]], proto]) // Constructor(name[[, constructor[, mixin]], proto])
var proto = args.pop() || {} var proto = args.pop() || {}
var constructor_proto = typeof(args[0]) == 'function' ? var constructor_proto =
typeof(args[0]) == 'function' ?
args.shift() args.shift()
: undefined : undefined
var constructor_mixin = args.pop() var constructor_mixin = args.pop()
// handle: /* XXX EXPERIMENTAL...
// Constructor(name, constructor, ..) // handle: Constructor(name[, constructor], { prototype: { .. }, .. })
//
if(proto.hasOwnProperty('prototype')
&& proto.prototype){
console.log('>>>>', name)
constructor_mixin = proto
proto = proto.prototype }
//*/
// handle: Constructor(name, constructor, ..)
// //
// NOTE: this is a bit too functional in style by an if-tree would // NOTE: this is a bit too functional in style by an if-tree would
// be more bulky and less readable... // be more bulky and less readable...