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
24
object.js
24
object.js
@ -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 =
|
||||||
args.shift()
|
typeof(args[0]) == 'function' ?
|
||||||
: undefined
|
args.shift()
|
||||||
|
: 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...
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user