| 
									
										
										
										
											2016-08-20 23:45:54 +03:00
										 |  |  | /********************************************************************** | 
					
						
							|  |  |  | *  | 
					
						
							| 
									
										
										
										
											2020-05-02 00:41:33 +03:00
										 |  |  | * object.js | 
					
						
							|  |  |  | * | 
					
						
							|  |  |  | * Repo and docs: | 
					
						
							|  |  |  | * 	https://github.com/flynx/object.js
 | 
					
						
							| 
									
										
										
										
											2016-08-20 23:45:54 +03:00
										 |  |  | * | 
					
						
							|  |  |  | * | 
					
						
							| 
									
										
										
										
											2020-04-25 01:14:00 +03:00
										 |  |  | * XXX should this extend Object??? | 
					
						
							| 
									
										
										
										
											2020-04-30 20:04:42 +03:00
										 |  |  | * 		...if yes then it would also be logical to move Object.run(..)  | 
					
						
							|  |  |  | * 		here... | 
					
						
							| 
									
										
										
										
											2020-04-25 01:14:00 +03:00
										 |  |  | * | 
					
						
							| 
									
										
										
										
											2016-08-20 23:45:54 +03:00
										 |  |  | **********************************************************************/ | 
					
						
							| 
									
										
										
										
											2020-04-29 21:15:46 +03:00
										 |  |  | ((typeof define)[0]=='u'?function(f){module.exports=f(require)}:define) | 
					
						
							|  |  |  | (function(require){ var module={} // make module AMD/node compatible...
 | 
					
						
							| 
									
										
										
										
											2016-08-20 23:45:54 +03:00
										 |  |  | /*********************************************************************/ | 
					
						
							| 
									
										
										
										
											2018-08-21 02:27:54 +03:00
										 |  |  | // Helpers...
 | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2020-04-23 20:12:27 +03:00
										 |  |  | var TAB_SIZE = | 
					
						
							|  |  |  | module.TAB_SIZE = 4 | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2020-04-23 20:31:42 +03:00
										 |  |  | 
 | 
					
						
							|  |  |  | // Normalize indent...
 | 
					
						
							|  |  |  | //
 | 
					
						
							|  |  |  | // 	normalizeIndent(text)
 | 
					
						
							|  |  |  | // 		-> text
 | 
					
						
							|  |  |  | //
 | 
					
						
							| 
									
										
										
										
											2020-04-27 01:31:42 +03:00
										 |  |  | //
 | 
					
						
							| 
									
										
										
										
											2020-04-23 20:31:42 +03:00
										 |  |  | // This will remove common indent from each like of text, this is useful 
 | 
					
						
							| 
									
										
										
										
											2020-04-30 20:04:42 +03:00
										 |  |  | // for printing function code of functions that were defined at deep 
 | 
					
						
							|  |  |  | // levels of indent.
 | 
					
						
							| 
									
										
										
										
											2020-04-23 20:31:42 +03:00
										 |  |  | //
 | 
					
						
							| 
									
										
										
										
											2020-04-30 20:04:42 +03:00
										 |  |  | // NOTE: this will trim out both leading and trailing white-space.
 | 
					
						
							| 
									
										
										
										
											2020-04-25 01:14:00 +03:00
										 |  |  | //
 | 
					
						
							| 
									
										
										
										
											2018-08-21 02:27:54 +03:00
										 |  |  | // XXX is this the right place for this???
 | 
					
						
							|  |  |  | // 		...when moving take care that ImageGrid's core.doc uses this...
 | 
					
						
							|  |  |  | var normalizeIndent = | 
					
						
							|  |  |  | module.normalizeIndent = | 
					
						
							| 
									
										
										
										
											2020-04-23 20:12:27 +03:00
										 |  |  | function(text, tab_size){ | 
					
						
							| 
									
										
										
										
											2020-04-23 20:25:05 +03:00
										 |  |  | 	tab_size = tab_size || TAB_SIZE | 
					
						
							|  |  |  | 	text = tab_size > 0 ? | 
					
						
							|  |  |  | 		text.replace(/\t/g, ' '.repeat(tab_size)) | 
					
						
							| 
									
										
										
										
											2020-04-23 20:12:27 +03:00
										 |  |  | 		: text | 
					
						
							| 
									
										
										
										
											2018-08-21 02:27:54 +03:00
										 |  |  | 	var lines = text.split(/\n/) | 
					
						
							|  |  |  | 	var l = lines  | 
					
						
							|  |  |  | 		.reduce(function(l, e, i){ | 
					
						
							|  |  |  | 			var indent = e.length - e.trimLeft().length | 
					
						
							|  |  |  | 			return e.trim().length == 0  | 
					
						
							|  |  |  | 					// ignore 0 indent of first line...
 | 
					
						
							|  |  |  | 					|| (i == 0 && indent == 0) ? l  | 
					
						
							|  |  |  | 				: l < 0 ?  | 
					
						
							|  |  |  | 					indent  | 
					
						
							|  |  |  | 				: Math.min(l, indent) | 
					
						
							|  |  |  | 		}, -1) | 
					
						
							|  |  |  | 	return lines | 
					
						
							|  |  |  | 		.map(function(line, i){  | 
					
						
							| 
									
										
										
										
											2020-04-23 20:12:27 +03:00
										 |  |  | 			return i == 0 ?  | 
					
						
							|  |  |  | 				line  | 
					
						
							|  |  |  | 				: line.slice(l) }) | 
					
						
							|  |  |  | 		.join('\n') | 
					
						
							|  |  |  | 		.trim() } | 
					
						
							| 
									
										
										
										
											2016-08-20 23:45:54 +03:00
										 |  |  | 
 | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2018-12-24 21:32:47 +03:00
										 |  |  | 
 | 
					
						
							|  |  |  | //---------------------------------------------------------------------
 | 
					
						
							| 
									
										
										
										
											2020-04-30 19:50:19 +03:00
										 |  |  | // Prototype chain content access...
 | 
					
						
							| 
									
										
										
										
											2018-12-24 21:32:47 +03:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2020-04-30 17:50:29 +03:00
										 |  |  | // Get a list of source objects for a prop/attr name...
 | 
					
						
							| 
									
										
										
										
											2020-04-15 00:42:20 +03:00
										 |  |  | //
 | 
					
						
							|  |  |  | // 	sources(obj, name)
 | 
					
						
							|  |  |  | // 	sources(obj, name, callback)
 | 
					
						
							|  |  |  | // 		-> list
 | 
					
						
							| 
									
										
										
										
											2020-04-30 17:50:29 +03:00
										 |  |  | // 		-> []
 | 
					
						
							|  |  |  | // 		
 | 
					
						
							|  |  |  | // 	callback(obj)
 | 
					
						
							|  |  |  | // 		-> true | 'stop'
 | 
					
						
							|  |  |  | // 		-> ..
 | 
					
						
							|  |  |  | // 		
 | 
					
						
							|  |  |  | // 		
 | 
					
						
							|  |  |  | // The callback(..) is called with each matching object.
 | 
					
						
							|  |  |  | // 
 | 
					
						
							|  |  |  | // The callback(..) can be used to break/stop the search, returning 
 | 
					
						
							|  |  |  | // a partial list og matcges up untill and including the object 
 | 
					
						
							|  |  |  | // triggering the stop.
 | 
					
						
							| 
									
										
										
										
											2020-04-15 00:42:20 +03:00
										 |  |  | //
 | 
					
						
							|  |  |  | //
 | 
					
						
							| 
									
										
										
										
											2020-04-30 17:50:29 +03:00
										 |  |  | // NOTE: this go up the prototype chain, not caring about any role (
 | 
					
						
							|  |  |  | // 		instance/class or instance/prototype) bounderies and depends 
 | 
					
						
							|  |  |  | // 		only on the object given as the starting point.
 | 
					
						
							|  |  |  | // 		It is possible to start the search from this, thus checking
 | 
					
						
							|  |  |  | // 		for any overloading in the instance, though this approach is 
 | 
					
						
							|  |  |  | // 		not very reusable....
 | 
					
						
							| 
									
										
										
										
											2020-04-30 16:41:19 +03:00
										 |  |  | // NOTE: this will not trigger any props...
 | 
					
						
							| 
									
										
										
										
											2020-04-15 00:42:20 +03:00
										 |  |  | var sources = | 
					
						
							|  |  |  | module.sources = | 
					
						
							| 
									
										
										
										
											2020-04-16 01:49:24 +03:00
										 |  |  | function(obj, name, callback){ | 
					
						
							| 
									
										
										
										
											2020-04-15 00:42:20 +03:00
										 |  |  | 	var stop | 
					
						
							|  |  |  | 	var res = [] | 
					
						
							|  |  |  | 	do { | 
					
						
							| 
									
										
										
										
											2020-04-16 01:49:24 +03:00
										 |  |  | 		if(obj.hasOwnProperty(name)){ | 
					
						
							| 
									
										
										
										
											2020-04-30 02:01:00 +03:00
										 |  |  | 			res.push(obj)  | 
					
						
							| 
									
										
										
										
											2020-04-15 00:42:20 +03:00
										 |  |  | 			// handle callback...
 | 
					
						
							|  |  |  | 			stop = callback | 
					
						
							| 
									
										
										
										
											2020-04-16 01:49:24 +03:00
										 |  |  | 				&& callback(obj) | 
					
						
							| 
									
										
										
										
											2020-04-15 00:42:20 +03:00
										 |  |  | 			// stop requested by callback...
 | 
					
						
							| 
									
										
										
										
											2020-04-30 02:01:00 +03:00
										 |  |  | 			if(stop === true || stop == 'stop'){ | 
					
						
							|  |  |  | 				return res }  | 
					
						
							|  |  |  | 		} | 
					
						
							| 
									
										
										
										
											2020-04-16 01:49:24 +03:00
										 |  |  | 		obj = obj.__proto__ | 
					
						
							|  |  |  | 	} while(obj !== null) | 
					
						
							| 
									
										
										
										
											2020-04-15 00:42:20 +03:00
										 |  |  | 	return res } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2020-04-27 04:16:35 +03:00
										 |  |  | // Find the next parent attribute in the prototype chain.
 | 
					
						
							| 
									
										
										
										
											2018-12-24 21:32:47 +03:00
										 |  |  | //
 | 
					
						
							| 
									
										
										
										
											2020-04-27 04:16:35 +03:00
										 |  |  | // 	Get parent attribute value...
 | 
					
						
							| 
									
										
										
										
											2020-04-30 02:01:00 +03:00
										 |  |  | // 	parent(proto, name)
 | 
					
						
							| 
									
										
										
										
											2020-04-30 17:50:29 +03:00
										 |  |  | // 		-> value
 | 
					
						
							| 
									
										
										
										
											2020-04-27 04:16:35 +03:00
										 |  |  | // 		-> undefined
 | 
					
						
							|  |  |  | //
 | 
					
						
							|  |  |  | // 	Get parent method...
 | 
					
						
							| 
									
										
										
										
											2020-04-30 17:50:29 +03:00
										 |  |  | // 	parent(method, this)
 | 
					
						
							| 
									
										
										
										
											2020-04-27 17:02:22 +03:00
										 |  |  | // 		-> meth
 | 
					
						
							| 
									
										
										
										
											2020-04-27 04:16:35 +03:00
										 |  |  | // 		-> undefined
 | 
					
						
							|  |  |  | //
 | 
					
						
							| 
									
										
										
										
											2020-04-30 17:50:29 +03:00
										 |  |  | // 
 | 
					
						
							|  |  |  | // The two forms differ in:
 | 
					
						
							|  |  |  | // 	- in parent(method, ..) a method's .name attr is used for name.
 | 
					
						
							|  |  |  | // 	- in parent(method, ..) the containing prototype is inferred.
 | 
					
						
							|  |  |  | //
 | 
					
						
							|  |  |  | // NOTE: there are cases where method.name is not set (e.g. anonymous 
 | 
					
						
							|  |  |  | // 		function), so there a name should be passed explicitly...
 | 
					
						
							|  |  |  | // NOTE: when passing a method it is recommended to pass an explicit 
 | 
					
						
							|  |  |  | // 		reference to it relative to the constructor, i.e.:
 | 
					
						
							|  |  |  | // 			Constructor.prototype.method
 | 
					
						
							|  |  |  | // 		this will avoid relative resolution loops, for example: 
 | 
					
						
							|  |  |  | // 			this.method 
 | 
					
						
							|  |  |  | // 		deep in a chain will resolve to the first .method value visible 
 | 
					
						
							|  |  |  | // 		from 'this', i.e. the top most value and not the value visible
 | 
					
						
							|  |  |  | // 		from that particular level...
 | 
					
						
							|  |  |  | //
 | 
					
						
							| 
									
										
										
										
											2020-04-27 04:16:35 +03:00
										 |  |  | //
 | 
					
						
							|  |  |  | // Example:
 | 
					
						
							|  |  |  | // 		var X = object.Constructor('X', {
 | 
					
						
							|  |  |  | //			__proto__: Y.prototype,
 | 
					
						
							|  |  |  | //
 | 
					
						
							|  |  |  | //			attr: 123,
 | 
					
						
							|  |  |  | //
 | 
					
						
							|  |  |  | // 			method: function(){
 | 
					
						
							|  |  |  | // 				// get attribute...
 | 
					
						
							| 
									
										
										
										
											2020-04-30 02:01:00 +03:00
										 |  |  | // 				var a = object.parent(X.prototype, 'attr')
 | 
					
						
							| 
									
										
										
										
											2020-04-27 04:16:35 +03:00
										 |  |  | //
 | 
					
						
							|  |  |  | // 				// get method...
 | 
					
						
							| 
									
										
										
										
											2020-04-30 20:04:42 +03:00
										 |  |  | // 				var ret = object.parent(X.prototype.method, this)
 | 
					
						
							|  |  |  | // 					.call(this, ...arguments)
 | 
					
						
							| 
									
										
										
										
											2020-04-27 04:16:35 +03:00
										 |  |  | //
 | 
					
						
							|  |  |  | // 				// ...
 | 
					
						
							|  |  |  | // 			}
 | 
					
						
							|  |  |  | // 		})
 | 
					
						
							| 
									
										
										
										
											2018-12-24 21:32:47 +03:00
										 |  |  | //
 | 
					
						
							|  |  |  | //
 | 
					
						
							| 
									
										
										
										
											2020-04-30 16:41:19 +03:00
										 |  |  | // NOTE: in the general case this will get the value of the returned 
 | 
					
						
							|  |  |  | // 		property/attribute, the rest of the way passive to props.
 | 
					
						
							|  |  |  | // 		The method case will get the value of every method from 'this' 
 | 
					
						
							|  |  |  | // 		and to the method after the match.
 | 
					
						
							| 
									
										
										
										
											2020-04-30 17:50:29 +03:00
										 |  |  | // NOTE: this is super(..) replacement, usable in any context without 
 | 
					
						
							|  |  |  | // 		restriction -- super(..) is restricted to class methods only...
 | 
					
						
							| 
									
										
										
										
											2020-04-30 02:01:00 +03:00
										 |  |  | var parent = | 
					
						
							| 
									
										
										
										
											2018-12-24 21:32:47 +03:00
										 |  |  | module.parent = | 
					
						
							| 
									
										
										
										
											2020-04-30 02:01:00 +03:00
										 |  |  | function(proto, name){ | 
					
						
							| 
									
										
										
										
											2020-04-27 04:16:35 +03:00
										 |  |  | 	// special case: method...
 | 
					
						
							| 
									
										
										
										
											2020-04-30 02:01:00 +03:00
										 |  |  | 	if(typeof(name) != typeof('str')){ | 
					
						
							|  |  |  | 		that = name | 
					
						
							|  |  |  | 		name = proto.name | 
					
						
							|  |  |  | 		// get first matching source...
 | 
					
						
							|  |  |  | 		proto = sources(that, name,  | 
					
						
							|  |  |  | 				function(obj){ return obj[name] === proto }) | 
					
						
							|  |  |  | 			.pop() } | 
					
						
							|  |  |  | 	// get first source...
 | 
					
						
							|  |  |  | 	var res = sources(proto, name,  | 
					
						
							|  |  |  | 			function(obj){ return 'stop' }) | 
					
						
							|  |  |  | 		.pop()  | 
					
						
							|  |  |  | 	return res ? | 
					
						
							| 
									
										
										
										
											2020-04-30 02:20:29 +03:00
										 |  |  | 		// get next value...
 | 
					
						
							| 
									
										
										
										
											2020-04-30 02:01:00 +03:00
										 |  |  | 		res.__proto__[name]  | 
					
						
							|  |  |  | 		: undefined } | 
					
						
							| 
									
										
										
										
											2018-12-24 21:32:47 +03:00
										 |  |  | 
 | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2020-04-30 16:41:19 +03:00
										 |  |  | // Find the next parent property descriptor in the prototype chain...
 | 
					
						
							|  |  |  | //
 | 
					
						
							|  |  |  | // 	parentProperty(proto, name)
 | 
					
						
							|  |  |  | // 		-> prop-descriptor
 | 
					
						
							|  |  |  | //
 | 
					
						
							|  |  |  | //
 | 
					
						
							|  |  |  | // This is like parent(..) but will get a property descriptor...
 | 
					
						
							|  |  |  | //
 | 
					
						
							|  |  |  | var parentProperty = | 
					
						
							|  |  |  | module.parentProperty = | 
					
						
							|  |  |  | function(proto, name){ | 
					
						
							|  |  |  | 	// get second source...
 | 
					
						
							|  |  |  | 	var c = 0 | 
					
						
							|  |  |  | 	var res = sources(proto, name,  | 
					
						
							|  |  |  | 			function(obj){ return c++ == 1 }) | 
					
						
							|  |  |  | 		.pop()  | 
					
						
							|  |  |  | 	return res ? | 
					
						
							|  |  |  | 		// get next value...
 | 
					
						
							|  |  |  | 		Object.getOwnPropertyDescriptor(res, name) | 
					
						
							|  |  |  | 		: undefined } | 
					
						
							| 
									
										
										
										
											2018-12-24 21:32:47 +03:00
										 |  |  | 
 | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2020-04-27 01:17:42 +03:00
										 |  |  | // Find the next parent method and call it...
 | 
					
						
							|  |  |  | //
 | 
					
						
							| 
									
										
										
										
											2020-04-27 17:02:22 +03:00
										 |  |  | // 	parentCall(proto, name, this, ...)
 | 
					
						
							| 
									
										
										
										
											2020-04-30 02:10:01 +03:00
										 |  |  | // 	parentCall(meth, this, ...)
 | 
					
						
							| 
									
										
										
										
											2020-04-27 17:02:22 +03:00
										 |  |  | // 		-> res
 | 
					
						
							| 
									
										
										
										
											2020-04-27 04:16:35 +03:00
										 |  |  | // 		-> undefined
 | 
					
						
							|  |  |  | //
 | 
					
						
							| 
									
										
										
										
											2020-04-27 01:17:42 +03:00
										 |  |  | //
 | 
					
						
							| 
									
										
										
										
											2020-04-27 04:16:35 +03:00
										 |  |  | // This also gracefully handles the case when no higher level definition 
 | 
					
						
							| 
									
										
										
										
											2020-04-30 02:20:29 +03:00
										 |  |  | // is found, i.e. the corresponding parent(..) call will return undefined
 | 
					
						
							|  |  |  | // or a non-callable.
 | 
					
						
							| 
									
										
										
										
											2020-04-27 01:31:42 +03:00
										 |  |  | //
 | 
					
						
							| 
									
										
										
										
											2020-04-27 01:17:42 +03:00
										 |  |  | // NOTE: this is just like parent(..) but will call the retrieved method,
 | 
					
						
							|  |  |  | // 		essentially this is a shorthand to:
 | 
					
						
							| 
									
										
										
										
											2020-04-30 17:50:29 +03:00
										 |  |  | // 			parent(proto, name).call(this, ...)
 | 
					
						
							| 
									
										
										
										
											2020-04-27 01:17:42 +03:00
										 |  |  | // 		or:
 | 
					
						
							|  |  |  | // 			parent(method, this).call(this, ...)
 | 
					
						
							|  |  |  | // NOTE: for more docs see parent(..)
 | 
					
						
							|  |  |  | var parentCall = | 
					
						
							|  |  |  | module.parentCall = | 
					
						
							| 
									
										
										
										
											2020-04-27 04:16:35 +03:00
										 |  |  | function(proto, name, that, ...args){ | 
					
						
							| 
									
										
										
										
											2020-04-30 02:10:01 +03:00
										 |  |  | 	var meth = parent(proto, name) | 
					
						
							| 
									
										
										
										
											2020-04-27 04:16:35 +03:00
										 |  |  | 	return meth instanceof Function ? | 
					
						
							| 
									
										
										
										
											2020-04-30 02:10:01 +03:00
										 |  |  | 		meth.call(...( typeof(name) == typeof('str') ? | 
					
						
							|  |  |  | 			[...arguments].slice(2) | 
					
						
							|  |  |  | 			: [...arguments].slice(1) )) | 
					
						
							| 
									
										
										
										
											2020-04-27 04:16:35 +03:00
										 |  |  | 		: undefined } | 
					
						
							| 
									
										
										
										
											2020-04-27 01:17:42 +03:00
										 |  |  | 
 | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2018-12-24 21:32:47 +03:00
										 |  |  | 
 | 
					
						
							|  |  |  | //---------------------------------------------------------------------
 | 
					
						
							| 
									
										
										
										
											2020-04-30 19:50:19 +03:00
										 |  |  | // Mixin utils...
 | 
					
						
							|  |  |  | // XXX should we add mixout(..) and friends ???
 | 
					
						
							| 
									
										
										
										
											2018-12-24 21:32:47 +03:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2020-04-12 01:13:09 +03:00
										 |  |  | // Mix a set of methods/props/attrs into an object...
 | 
					
						
							| 
									
										
										
										
											2018-12-24 21:32:47 +03:00
										 |  |  | // 
 | 
					
						
							| 
									
										
										
										
											2020-04-12 01:13:09 +03:00
										 |  |  | //	mixinFlat(root, object, ...)
 | 
					
						
							|  |  |  | //		-> root
 | 
					
						
							|  |  |  | //
 | 
					
						
							| 
									
										
										
										
											2019-07-06 00:34:54 +03:00
										 |  |  | //
 | 
					
						
							|  |  |  | // NOTE: essentially this is just like Object.assign(..) but copies 
 | 
					
						
							|  |  |  | // 		properties directly rather than copying property values...
 | 
					
						
							| 
									
										
										
										
											2019-07-05 20:34:19 +03:00
										 |  |  | var mixinFlat =  | 
					
						
							|  |  |  | module.mixinFlat =  | 
					
						
							|  |  |  | function(root, ...objects){ | 
					
						
							|  |  |  | 	return objects | 
					
						
							|  |  |  | 		.reduce(function(root, cur){ | 
					
						
							|  |  |  | 			Object.keys(cur) | 
					
						
							|  |  |  | 				.map(function(k){ | 
					
						
							|  |  |  | 					Object.defineProperty(root, k, | 
					
						
							|  |  |  | 						Object.getOwnPropertyDescriptor(cur, k)) }) | 
					
						
							|  |  |  | 			return root }, root) } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2018-12-24 21:32:47 +03:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2020-04-12 01:13:09 +03:00
										 |  |  | // Mix sets of methods/props/attrs into an object as prototypes...
 | 
					
						
							|  |  |  | //
 | 
					
						
							|  |  |  | // 	mixin(root, object, ...)
 | 
					
						
							|  |  |  | // 		-> root
 | 
					
						
							|  |  |  | //
 | 
					
						
							|  |  |  | //
 | 
					
						
							|  |  |  | // This will create a new object per set of methods given and 
 | 
					
						
							|  |  |  | // mixinFlat(..) the method set into this object leaving the 
 | 
					
						
							|  |  |  | // original objects intact.
 | 
					
						
							|  |  |  | // 
 | 
					
						
							|  |  |  | // 		root <-- object1_copy <-- .. <-- objectN_copy
 | 
					
						
							|  |  |  | // 				
 | 
					
						
							|  |  |  | var mixin =  | 
					
						
							|  |  |  | module.mixin =  | 
					
						
							|  |  |  | function(root, ...objects){ | 
					
						
							|  |  |  | 	return objects | 
					
						
							|  |  |  | 		.reduce(function(res, cur){ | 
					
						
							| 
									
										
										
										
											2020-04-12 02:01:49 +03:00
										 |  |  | 			return module.mixinFlat(Object.create(res), cur) }, root) } | 
					
						
							| 
									
										
										
										
											2020-04-12 01:13:09 +03:00
										 |  |  | 
 | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2018-12-24 21:32:47 +03:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2018-08-21 02:27:54 +03:00
										 |  |  | //---------------------------------------------------------------------
 | 
					
						
							| 
									
										
										
										
											2020-04-30 19:50:19 +03:00
										 |  |  | // Constructor...
 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | // Make an uninitialized instance object...
 | 
					
						
							| 
									
										
										
										
											2020-04-26 19:30:49 +03:00
										 |  |  | //
 | 
					
						
							| 
									
										
										
										
											2020-04-27 17:02:22 +03:00
										 |  |  | // 	makeRawInstance(context, constructor, ...)
 | 
					
						
							| 
									
										
										
										
											2020-04-26 19:30:49 +03:00
										 |  |  | // 		-> instance
 | 
					
						
							|  |  |  | //
 | 
					
						
							|  |  |  | //
 | 
					
						
							|  |  |  | // This will:
 | 
					
						
							|  |  |  | // 	- construct an object
 | 
					
						
							|  |  |  | // 		- if .__new__(..) is defined
 | 
					
						
							|  |  |  | // 			-> call and use its return value
 | 
					
						
							|  |  |  | //		- if prototype is a function or if .__call__(..) is defined
 | 
					
						
							|  |  |  | //			-> use a wrapper function
 | 
					
						
							|  |  |  | //		- else
 | 
					
						
							|  |  |  | //			-> use {}
 | 
					
						
							|  |  |  | // 	- link the object into the prototype chain
 | 
					
						
							|  |  |  | //
 | 
					
						
							| 
									
										
										
										
											2016-08-20 23:45:54 +03:00
										 |  |  | //
 | 
					
						
							| 
									
										
										
										
											2020-04-26 19:30:49 +03:00
										 |  |  | // This will not call .__init__(..)
 | 
					
						
							|  |  |  | //
 | 
					
						
							| 
									
										
										
										
											2020-04-30 17:50:29 +03:00
										 |  |  | //
 | 
					
						
							| 
									
										
										
										
											2020-04-30 21:13:28 +03:00
										 |  |  | // NOTE: context is only used when passeding to .__new__(..) if defined, 
 | 
					
						
							|  |  |  | // 		and is ignored otherwise...
 | 
					
						
							|  |  |  | // NOTE: as this is simply an extension to the base JavaScript protocol this
 | 
					
						
							|  |  |  | // 		can be used to construct any object...
 | 
					
						
							| 
									
										
										
										
											2020-04-26 20:05:30 +03:00
										 |  |  | // 		Example:
 | 
					
						
							|  |  |  | // 			var O = function(){}
 | 
					
						
							|  |  |  | // 			// new is optional...
 | 
					
						
							|  |  |  | // 			var o = new makeRawInstance(null, O)
 | 
					
						
							| 
									
										
										
										
											2020-04-27 01:17:42 +03:00
										 |  |  | // NOTE: .__new__(..) is intentionaly an instance method (contary to 
 | 
					
						
							|  |  |  | // 		Python) this is done because there are no classes in JS and 
 | 
					
						
							|  |  |  | // 		adding and instance constructor as a class method would create 
 | 
					
						
							| 
									
										
										
										
											2020-04-30 21:13:28 +03:00
										 |  |  | // 		unneccessary restrictions both on the "class" object and on the 
 | 
					
						
							| 
									
										
										
										
											2020-04-27 01:17:42 +03:00
										 |  |  | // 		instance...
 | 
					
						
							| 
									
										
										
										
											2020-05-02 00:41:33 +03:00
										 |  |  | // 
 | 
					
						
							|  |  |  | // XXX Q: should the context (this) in .__new__(..) be _constructor or 
 | 
					
						
							|  |  |  | // 		.prototype???
 | 
					
						
							|  |  |  | // 		... .prototype seems to be needed more often but through it we 
 | 
					
						
							|  |  |  | // 		can't reach the actual constructor... but on the other hand we 
 | 
					
						
							|  |  |  | // 		can (should?) always explicitly use it -- .__new__(..) is usually 
 | 
					
						
							|  |  |  | // 		in the same scope + this makes it more reusable for chaining
 | 
					
						
							|  |  |  | // 		.__new__(..) calls...
 | 
					
						
							|  |  |  | // 		...currently it's .prototype...
 | 
					
						
							| 
									
										
										
										
											2020-04-26 19:30:49 +03:00
										 |  |  | var makeRawInstance =  | 
					
						
							|  |  |  | module.makeRawInstance = | 
					
						
							|  |  |  | function(context, constructor, ...args){ | 
					
						
							| 
									
										
										
										
											2020-04-26 20:05:30 +03:00
										 |  |  | 	var _mirror_doc = function(func, target){ | 
					
						
							| 
									
										
										
										
											2020-04-26 19:30:49 +03:00
										 |  |  | 		Object.defineProperty(func, 'toString', { | 
					
						
							|  |  |  | 			value: function(...args){ | 
					
						
							|  |  |  | 				return target.toString(...args) }, | 
					
						
							|  |  |  | 			enumerable: false, | 
					
						
							|  |  |  | 		}) | 
					
						
							|  |  |  | 		return func } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 	var obj = | 
					
						
							|  |  |  | 		// prototype defines .__new__(..)...
 | 
					
						
							|  |  |  | 		constructor.prototype.__new__ instanceof Function ? | 
					
						
							|  |  |  | 			constructor.prototype.__new__(context, ...args) | 
					
						
							|  |  |  | 		// callable instance -- prototype is a function...
 | 
					
						
							|  |  |  | 		// NOTE: we need to isolate the .prototype from instances...
 | 
					
						
							|  |  |  | 		: constructor.prototype instanceof Function ? | 
					
						
							|  |  |  | 			_mirror_doc( | 
					
						
							|  |  |  | 				function(){ | 
					
						
							| 
									
										
										
										
											2020-04-30 20:04:42 +03:00
										 |  |  | 					return constructor.prototype | 
					
						
							|  |  |  | 						.call(obj, this, ...arguments) }, | 
					
						
							| 
									
										
										
										
											2020-04-26 19:30:49 +03:00
										 |  |  | 				constructor.prototype) | 
					
						
							|  |  |  | 		// callable instance -- prototype defines .__call__(..)...
 | 
					
						
							|  |  |  | 		// NOTE: we need to isolate the .__call__ from instances...
 | 
					
						
							|  |  |  | 		: constructor.prototype.__call__ instanceof Function ? | 
					
						
							|  |  |  | 			_mirror_doc( | 
					
						
							|  |  |  | 				function(){ | 
					
						
							| 
									
										
										
										
											2020-04-30 20:04:42 +03:00
										 |  |  | 					return constructor.prototype.__call__ | 
					
						
							|  |  |  | 						.call(obj, this, ...arguments) }, | 
					
						
							| 
									
										
										
										
											2020-04-26 19:30:49 +03:00
										 |  |  | 				constructor.prototype.__call__) | 
					
						
							|  |  |  | 		// default object base...
 | 
					
						
							|  |  |  | 		: {}  | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 	// link to prototype chain...
 | 
					
						
							|  |  |  | 	obj.__proto__ = constructor.prototype | 
					
						
							|  |  |  | 	Object.defineProperty(obj, 'constructor', { | 
					
						
							|  |  |  | 		value: constructor, | 
					
						
							|  |  |  | 		enumerable: false, | 
					
						
							|  |  |  | 	}) | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 	return obj } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2020-04-30 19:50:19 +03:00
										 |  |  | // Make an object constructor function...
 | 
					
						
							| 
									
										
										
										
											2016-08-20 23:45:54 +03:00
										 |  |  | //
 | 
					
						
							|  |  |  | // 	Make a constructor with an object prototype...
 | 
					
						
							| 
									
										
										
										
											2020-04-27 17:02:22 +03:00
										 |  |  | // 		Constructor(name, proto)
 | 
					
						
							| 
									
										
										
										
											2016-08-20 23:45:54 +03:00
										 |  |  | // 			-> constructor
 | 
					
						
							|  |  |  | //
 | 
					
						
							|  |  |  | // 	Make a constructor with a prototype (object/function) and a class
 | 
					
						
							|  |  |  | // 	prototype...
 | 
					
						
							| 
									
										
										
										
											2020-04-27 17:02:22 +03:00
										 |  |  | // 		Constructor(name, class-proto, proto)
 | 
					
						
							| 
									
										
										
										
											2016-08-20 23:45:54 +03:00
										 |  |  | // 			-> constructor
 | 
					
						
							|  |  |  | // 			NOTE: the <class-proto> defines a set of class methods and 
 | 
					
						
							|  |  |  | // 					attributes.
 | 
					
						
							|  |  |  | //
 | 
					
						
							|  |  |  | //
 | 
					
						
							|  |  |  | // The resulting constructor can produce objects in one of these ways:
 | 
					
						
							|  |  |  | //
 | 
					
						
							| 
									
										
										
										
											2020-04-28 02:42:31 +03:00
										 |  |  | // 	Create instance...
 | 
					
						
							|  |  |  | // 		constructor(..)
 | 
					
						
							| 
									
										
										
										
											2016-08-20 23:45:54 +03:00
										 |  |  | // 		new constructor
 | 
					
						
							| 
									
										
										
										
											2020-04-28 02:42:31 +03:00
										 |  |  | // 		new constructor(..)
 | 
					
						
							| 
									
										
										
										
											2016-08-20 23:45:54 +03:00
										 |  |  | // 			-> instance
 | 
					
						
							|  |  |  | //
 | 
					
						
							| 
									
										
										
										
											2020-04-28 02:42:31 +03:00
										 |  |  | //	Create raw/uninitialized instance...
 | 
					
						
							|  |  |  | //		constructor.__rawinstance__(..)
 | 
					
						
							|  |  |  | //		makeRawInstance(null, constructor, ..)
 | 
					
						
							|  |  |  | //			-> raw-instance
 | 
					
						
							| 
									
										
										
										
											2016-08-20 23:45:54 +03:00
										 |  |  | //
 | 
					
						
							|  |  |  | //
 | 
					
						
							|  |  |  | // All produced objects are instances of the constructor
 | 
					
						
							|  |  |  | // 		instance instanceof constructor
 | 
					
						
							|  |  |  | // 			-> true
 | 
					
						
							|  |  |  | //
 | 
					
						
							|  |  |  | //
 | 
					
						
							|  |  |  | //
 | 
					
						
							| 
									
										
										
										
											2020-04-28 02:42:31 +03:00
										 |  |  | // Create and initialization protocol:
 | 
					
						
							| 
									
										
										
										
											2020-04-27 18:14:39 +03:00
										 |  |  | // 	1) raw instance is created:
 | 
					
						
							|  |  |  | // 		a) constructor.__rawinstance__(..) / makeRawInstance(..) called:
 | 
					
						
							| 
									
										
										
										
											2020-04-28 02:42:31 +03:00
										 |  |  | // 			- call .__new__(..) if defined and get return value as 
 | 
					
						
							|  |  |  | // 				instance, or
 | 
					
						
							|  |  |  | // 			- if .__call__(..) defined or prototype is a function, wrap 
 | 
					
						
							|  |  |  | // 				it and use the wrapper function as instance, or
 | 
					
						
							| 
									
										
										
										
											2020-04-27 18:14:39 +03:00
										 |  |  | // 			- create an empty object
 | 
					
						
							|  |  |  | // 		b) instance linked to prototype chain
 | 
					
						
							|  |  |  | // 			set .__proto__ to constructor.prototype
 | 
					
						
							|  |  |  | // 	2) instance is initialized: 
 | 
					
						
							|  |  |  | // 		call .__init__(..) if defined
 | 
					
						
							|  |  |  | // 
 | 
					
						
							| 
									
										
										
										
											2020-04-28 02:42:31 +03:00
										 |  |  | //
 | 
					
						
							| 
									
										
										
										
											2020-04-27 18:14:39 +03:00
										 |  |  | // 
 | 
					
						
							|  |  |  | // Special methods (constructor):
 | 
					
						
							| 
									
										
										
										
											2020-04-28 02:42:31 +03:00
										 |  |  | //
 | 
					
						
							|  |  |  | //  Handle uninitialized instance construction
 | 
					
						
							| 
									
										
										
										
											2020-04-27 18:14:39 +03:00
										 |  |  | // 	.__rawinstance__(context, ...)
 | 
					
						
							| 
									
										
										
										
											2020-04-28 02:42:31 +03:00
										 |  |  | // 		-> instance
 | 
					
						
							|  |  |  | // 		NOTE: This is a shorthand to makeRawInstance(..) see it for 
 | 
					
						
							|  |  |  | // 			details.
 | 
					
						
							| 
									
										
										
										
											2020-04-27 18:14:39 +03:00
										 |  |  | // 
 | 
					
						
							|  |  |  | // 
 | 
					
						
							|  |  |  | // Special methods (.prototype):
 | 
					
						
							| 
									
										
										
										
											2020-04-28 02:42:31 +03:00
										 |  |  | //
 | 
					
						
							|  |  |  | // 	Create new instance object...
 | 
					
						
							| 
									
										
										
										
											2020-04-27 18:14:39 +03:00
										 |  |  | // 	.__new__(context, ..)
 | 
					
						
							| 
									
										
										
										
											2020-04-28 02:42:31 +03:00
										 |  |  | // 		-> object
 | 
					
						
							|  |  |  | //
 | 
					
						
							|  |  |  | // 	Handle instance call...
 | 
					
						
							| 
									
										
										
										
											2020-04-27 18:14:39 +03:00
										 |  |  | // 	.__call__(context, ..)
 | 
					
						
							| 
									
										
										
										
											2020-04-28 02:42:31 +03:00
										 |  |  | // 		-> ..
 | 
					
						
							|  |  |  | //
 | 
					
						
							|  |  |  | // 	Initialize instance object...
 | 
					
						
							| 
									
										
										
										
											2020-04-27 18:14:39 +03:00
										 |  |  | // 	.__init__(..)
 | 
					
						
							| 
									
										
										
										
											2020-04-28 02:42:31 +03:00
										 |  |  | // 		-> ..
 | 
					
						
							|  |  |  | //
 | 
					
						
							|  |  |  | //
 | 
					
						
							|  |  |  | // NOTE: raw instance creation is defined by makeRawInstance(..) so see 
 | 
					
						
							|  |  |  | // 		it for more info.
 | 
					
						
							|  |  |  | // NOTE: raw instance creation can be completely overloaded by defining
 | 
					
						
							| 
									
										
										
										
											2020-05-02 00:41:33 +03:00
										 |  |  | // 		.__rawinstance__(..) on the constructor.
 | 
					
						
							| 
									
										
										
										
											2016-08-20 23:45:54 +03:00
										 |  |  | //
 | 
					
						
							|  |  |  | //
 | 
					
						
							|  |  |  | //
 | 
					
						
							|  |  |  | // Inheritance:
 | 
					
						
							|  |  |  | // 	A simple way to build C -> B -> A chain would be:
 | 
					
						
							|  |  |  | //
 | 
					
						
							| 
									
										
										
										
											2019-07-16 23:49:32 +03:00
										 |  |  | // 		// NOTE: new is optional...
 | 
					
						
							| 
									
										
										
										
											2020-04-27 01:31:42 +03:00
										 |  |  | // 		var A = new Constructor('A')
 | 
					
						
							|  |  |  | //
 | 
					
						
							|  |  |  | // 		// NOTE: in a prototype chain the prototypes are "inherited"
 | 
					
						
							|  |  |  | // 		// NOTE: JS has no classes and the prototype is just another 
 | 
					
						
							|  |  |  | // 		//		object, the only difference is that it's used by the 
 | 
					
						
							|  |  |  | // 		//		constructor to link other objects i.e. "instances" to...
 | 
					
						
							|  |  |  | // 		var B = Constructor('B', {__proto__: A.prototype})
 | 
					
						
							|  |  |  | //
 | 
					
						
							|  |  |  | // 		var C = Constructor('C', Objec.create(B.prototype))
 | 
					
						
							| 
									
										
										
										
											2016-08-20 23:45:54 +03:00
										 |  |  | //
 | 
					
						
							|  |  |  | // 		var c = C()
 | 
					
						
							|  |  |  | //
 | 
					
						
							|  |  |  | // 		c instanceof C		// -> true
 | 
					
						
							|  |  |  | // 		c instanceof B		// -> true
 | 
					
						
							|  |  |  | // 		c instanceof A		// -> true
 | 
					
						
							|  |  |  | //
 | 
					
						
							|  |  |  | // 		A.prototype.x = 123
 | 
					
						
							|  |  |  | //
 | 
					
						
							|  |  |  | // 		c.x 				// -> 123
 | 
					
						
							|  |  |  | //
 | 
					
						
							|  |  |  | //
 | 
					
						
							|  |  |  | //
 | 
					
						
							|  |  |  | // Motivation:
 | 
					
						
							| 
									
										
										
										
											2020-04-30 20:04:42 +03:00
										 |  |  | // 	The general motivation here is to standardise the constructor 
 | 
					
						
							|  |  |  | // 	protocol and make a single simple way to go with minimal variation. 
 | 
					
						
							|  |  |  | // 	This is due to the JavaScript base protocol though quite simple, 
 | 
					
						
							|  |  |  | // 	being too flexible making it very involved to produce objects in a 
 | 
					
						
							|  |  |  | // 	consistent manner by hand, especially in long running projects, 
 | 
					
						
							|  |  |  | // 	in turn spreading all the refactoring over multiple sites and styles.
 | 
					
						
							| 
									
										
										
										
											2016-08-20 23:45:54 +03:00
										 |  |  | //
 | 
					
						
							|  |  |  | // 	This removes part of the flexibility and in return gives us:
 | 
					
						
							|  |  |  | // 		- single, well defined protocol
 | 
					
						
							|  |  |  | // 		- one single spot where all the "magic" happens
 | 
					
						
							|  |  |  | // 		- full support for existing JavaScript ways of doing things
 | 
					
						
							|  |  |  | // 		- easy refactoring without touching the client code
 | 
					
						
							|  |  |  | //
 | 
					
						
							|  |  |  | //
 | 
					
						
							| 
									
										
										
										
											2020-04-27 01:31:42 +03:00
										 |  |  | // NOTE: this sets the proto's .constructor attribute, thus rendering it
 | 
					
						
							| 
									
										
										
										
											2020-04-30 20:04:42 +03:00
										 |  |  | // 		not reusable, to use the same prototype for multiple objects 
 | 
					
						
							|  |  |  | // 		clone it via. Object.create(..) or copy it...
 | 
					
						
							| 
									
										
										
										
											2020-04-27 16:54:44 +03:00
										 |  |  | // NOTE: to disable .__rawinstance__(..) handling set it to false in the 
 | 
					
						
							| 
									
										
										
										
											2020-05-02 00:41:33 +03:00
										 |  |  | // 		class prototype...
 | 
					
						
							| 
									
										
										
										
											2019-07-16 23:49:32 +03:00
										 |  |  | var Constructor =  | 
					
						
							|  |  |  | module.Constructor = | 
					
						
							|  |  |  | // shorthand...
 | 
					
						
							|  |  |  | module.C = | 
					
						
							|  |  |  | function Constructor(name, a, b){ | 
					
						
							| 
									
										
										
										
											2016-08-20 23:45:54 +03:00
										 |  |  | 	var proto = b == null ? a : b | 
					
						
							|  |  |  | 	var cls_proto = b == null ? b : a | 
					
						
							| 
									
										
										
										
											2020-04-15 00:42:20 +03:00
										 |  |  | 	proto = proto || {} | 
					
						
							| 
									
										
										
										
											2016-08-20 23:45:54 +03:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2020-04-26 19:30:49 +03:00
										 |  |  | 	// the actual constructor...
 | 
					
						
							| 
									
										
										
										
											2016-08-20 23:45:54 +03:00
										 |  |  | 	var _constructor = function Constructor(){ | 
					
						
							| 
									
										
										
										
											2020-04-27 16:42:31 +03:00
										 |  |  | 		// create raw instance...
 | 
					
						
							|  |  |  | 		var obj = _constructor.__rawinstance__ ?  | 
					
						
							| 
									
										
										
										
											2020-04-27 16:54:44 +03:00
										 |  |  | 				_constructor.__rawinstance__(this, ...arguments) | 
					
						
							| 
									
										
										
										
											2020-04-27 16:42:31 +03:00
										 |  |  | 			: makeRawInstance(this, _constructor, ...arguments) | 
					
						
							|  |  |  | 		// initialize...
 | 
					
						
							| 
									
										
										
										
											2019-07-16 23:49:32 +03:00
										 |  |  | 		obj.__init__ instanceof Function | 
					
						
							|  |  |  | 			&& obj.__init__(...arguments) | 
					
						
							| 
									
										
										
										
											2020-04-26 19:30:49 +03:00
										 |  |  | 		return obj } | 
					
						
							| 
									
										
										
										
											2016-08-20 23:45:54 +03:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2020-04-26 19:30:49 +03:00
										 |  |  | 	_constructor.name = name | 
					
						
							|  |  |  | 	// just in case the browser refuses to change the name, we'll make
 | 
					
						
							|  |  |  | 	// it a different offer ;)
 | 
					
						
							| 
									
										
										
										
											2019-07-16 23:49:32 +03:00
										 |  |  | 	_constructor.name == 'Constructor' | 
					
						
							| 
									
										
										
										
											2020-04-26 19:30:49 +03:00
										 |  |  | 		// NOTE: this eval(..) should not be a risk as its inputs are
 | 
					
						
							|  |  |  | 		// 		static and never infuenced by external inputs...
 | 
					
						
							| 
									
										
										
										
											2019-07-16 23:49:32 +03:00
										 |  |  | 		&& eval('_constructor = '+ _constructor | 
					
						
							| 
									
										
										
										
											2016-08-20 23:45:54 +03:00
										 |  |  | 				.toString() | 
					
						
							|  |  |  | 				.replace(/Constructor/g, name)) | 
					
						
							| 
									
										
										
										
											2020-04-26 19:59:56 +03:00
										 |  |  | 	// set .toString(..)...
 | 
					
						
							| 
									
										
										
										
											2018-08-20 16:01:37 +03:00
										 |  |  | 	// NOTE: do this only if .toString(..) is not defined by user...
 | 
					
						
							| 
									
										
										
										
											2019-07-16 23:49:32 +03:00
										 |  |  | 	;((cls_proto || {}).toString() == ({}).toString()) | 
					
						
							|  |  |  | 		&& Object.defineProperty(_constructor, 'toString', { | 
					
						
							| 
									
										
										
										
											2018-08-20 16:01:37 +03:00
										 |  |  | 			value: function(){  | 
					
						
							|  |  |  | 				var args = proto.__init__ ? | 
					
						
							|  |  |  | 					proto.__init__ | 
					
						
							|  |  |  | 						.toString() | 
					
						
							| 
									
										
										
										
											2020-04-30 20:04:42 +03:00
										 |  |  | 						.split(/\n/)[0] | 
					
						
							|  |  |  | 							.replace(/function\(([^)]*)\){.*/, '$1') | 
					
						
							| 
									
										
										
										
											2018-08-20 16:01:37 +03:00
										 |  |  | 					: '' | 
					
						
							|  |  |  | 				var code = proto.__init__ ? | 
					
						
							|  |  |  | 					proto.__init__ | 
					
						
							|  |  |  | 						.toString() | 
					
						
							|  |  |  | 						.replace(/[^{]*{/, '{') | 
					
						
							|  |  |  | 					: '{ .. }' | 
					
						
							| 
									
										
										
										
											2020-04-26 19:30:49 +03:00
										 |  |  | 				return `${this.name}(${args})${normalizeIndent(code)}` }, | 
					
						
							| 
									
										
										
										
											2018-08-20 16:01:37 +03:00
										 |  |  | 			enumerable: false, | 
					
						
							|  |  |  | 		}) | 
					
						
							| 
									
										
										
										
											2018-08-19 16:10:23 +03:00
										 |  |  | 	_constructor.__proto__ = cls_proto | 
					
						
							| 
									
										
										
										
											2016-08-20 23:45:54 +03:00
										 |  |  | 	_constructor.prototype = proto | 
					
						
							| 
									
										
										
										
											2020-04-27 16:42:31 +03:00
										 |  |  | 	// generic raw instance constructor...
 | 
					
						
							| 
									
										
										
										
											2020-04-27 16:54:44 +03:00
										 |  |  | 	_constructor.__rawinstance__ instanceof Function | 
					
						
							| 
									
										
										
										
											2020-04-27 16:42:31 +03:00
										 |  |  | 		|| (_constructor.__rawinstance__ =  | 
					
						
							|  |  |  | 			function(context, ...args){ | 
					
						
							|  |  |  | 				return makeRawInstance(context, this, ...args) }) | 
					
						
							| 
									
										
										
										
											2020-04-26 19:59:56 +03:00
										 |  |  | 
 | 
					
						
							|  |  |  | 	// set .prototype.constructor
 | 
					
						
							| 
									
										
										
										
											2019-07-16 23:49:32 +03:00
										 |  |  | 	Object.defineProperty(_constructor.prototype, 'constructor', { | 
					
						
							|  |  |  | 		value: _constructor, | 
					
						
							|  |  |  | 		enumerable: false, | 
					
						
							|  |  |  | 	}) | 
					
						
							| 
									
										
										
										
											2016-08-20 23:45:54 +03:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2020-04-29 21:15:46 +03:00
										 |  |  | 	return _constructor } | 
					
						
							| 
									
										
										
										
											2016-08-20 23:45:54 +03:00
										 |  |  | 
 | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2018-12-24 21:20:38 +03:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2016-08-20 23:45:54 +03:00
										 |  |  | /********************************************************************** | 
					
						
							|  |  |  | * vim:set ts=4 sw=4 :                               */ return module }) |