mirror of
https://github.com/flynx/object.js.git
synced 2025-10-29 02:20:08 +00:00
experimenting...
Signed-off-by: Alex A. Naanou <alex.nanou@gmail.com>
This commit is contained in:
parent
f86c34a865
commit
f02adb73b7
20
object.js
20
object.js
@ -1003,22 +1003,32 @@ module.Constructor =
|
||||
// shorthand...
|
||||
module.C =
|
||||
function Constructor(name, a, b, c){
|
||||
var args = [...arguments].slice(1, 4)
|
||||
|
||||
// sanity check...
|
||||
if(!/^[a-zA-Z_][a-zA-Z0-9_]*$/.test(name.trim())){
|
||||
throw new Error(`Constructor(..): invalid name: "${name}"`) }
|
||||
|
||||
// parse args...
|
||||
var args = [...arguments].slice(1, 4)
|
||||
|
||||
// Constructor(name[[, constructor[, mixin]], proto])
|
||||
var proto = args.pop() || {}
|
||||
var constructor_proto = typeof(args[0]) == 'function' ?
|
||||
var constructor_proto =
|
||||
typeof(args[0]) == 'function' ?
|
||||
args.shift()
|
||||
: undefined
|
||||
var constructor_mixin = args.pop()
|
||||
|
||||
// handle:
|
||||
// Constructor(name, constructor, ..)
|
||||
/* XXX EXPERIMENTAL...
|
||||
// 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
|
||||
// be more bulky and less readable...
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user