mirror of
https://github.com/flynx/object.js.git
synced 2025-11-02 12:30:10 +00:00
added function methods to non-function callables...
Signed-off-by: Alex A. Naanou <alex.nanou@gmail.com>
This commit is contained in:
parent
74fc255b12
commit
e6014f3c98
34
object.js
34
object.js
@ -20,12 +20,26 @@
|
|||||||
((typeof define)[0]=='u'?function(f){module.exports=f(require)}:define)
|
((typeof define)[0]=='u'?function(f){module.exports=f(require)}:define)
|
||||||
(function(require){ var module={} // make module AMD/node compatible...
|
(function(require){ var module={} // make module AMD/node compatible...
|
||||||
/*********************************************************************/
|
/*********************************************************************/
|
||||||
|
|
||||||
|
|
||||||
|
// Function methods to link into a constructor producing a callable
|
||||||
|
// defined via .__call__(..)
|
||||||
|
//
|
||||||
|
// see: Constructor(..) for details.
|
||||||
|
module.LINK_FUNCTION_METHODS = [
|
||||||
|
'call',
|
||||||
|
'apply',
|
||||||
|
'bind',
|
||||||
|
]
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
//---------------------------------------------------------------------
|
||||||
// Helpers...
|
// Helpers...
|
||||||
|
|
||||||
var TAB_SIZE =
|
|
||||||
module.TAB_SIZE = 4
|
module.TAB_SIZE = 4
|
||||||
|
|
||||||
var LEADING_TABS =
|
|
||||||
module.LEADING_TABS = 1
|
module.LEADING_TABS = 1
|
||||||
|
|
||||||
|
|
||||||
@ -58,10 +72,10 @@ var normalizeIndent =
|
|||||||
module.normalizeIndent =
|
module.normalizeIndent =
|
||||||
function(text, tab_size, leading_tabs){
|
function(text, tab_size, leading_tabs){
|
||||||
tab_size = tab_size == null ?
|
tab_size = tab_size == null ?
|
||||||
TAB_SIZE
|
module.TAB_SIZE
|
||||||
: tab_size
|
: tab_size
|
||||||
leading_tabs = (leading_tabs == null ?
|
leading_tabs = (leading_tabs == null ?
|
||||||
LEADING_TABS
|
module.LEADING_TABS
|
||||||
: leading_tabs)
|
: leading_tabs)
|
||||||
* tab_size
|
* tab_size
|
||||||
// prepare text...
|
// prepare text...
|
||||||
@ -819,6 +833,9 @@ function(context, constructor, ...args){
|
|||||||
// values are ignored.
|
// values are ignored.
|
||||||
// XXX this may get removed in future versions.
|
// XXX this may get removed in future versions.
|
||||||
//
|
//
|
||||||
|
// If true do not link function methods if .__call__(..) is defined
|
||||||
|
// .__skip_call_attrs__ = bool
|
||||||
|
//
|
||||||
//
|
//
|
||||||
// Special methods (constructor):
|
// Special methods (constructor):
|
||||||
//
|
//
|
||||||
@ -1015,6 +1032,15 @@ function Constructor(name, a, b, c){
|
|||||||
&& constructor_mixin.__proto__ !== Object.prototype
|
&& constructor_mixin.__proto__ !== Object.prototype
|
||||||
&& (_constructor.__proto__ = constructor_mixin.__proto__)
|
&& (_constructor.__proto__ = constructor_mixin.__proto__)
|
||||||
|
|
||||||
|
// link function stuff for convenience...
|
||||||
|
proto.__call__ && !(proto instanceof Function)
|
||||||
|
&& _constructor.__skip_call_attrs__ !== true
|
||||||
|
&& module.LINK_FUNCTION_METHODS
|
||||||
|
.forEach(function(n){
|
||||||
|
proto[n]
|
||||||
|
|| Object.defineProperty(proto, n,
|
||||||
|
Object.getOwnPropertyDescriptor(Function.prototype, n)) })
|
||||||
|
|
||||||
return _constructor }
|
return _constructor }
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "ig-object",
|
"name": "ig-object",
|
||||||
"version": "5.0.12",
|
"version": "5.0.13",
|
||||||
"description": "",
|
"description": "",
|
||||||
"main": "object.js",
|
"main": "object.js",
|
||||||
"scripts": {
|
"scripts": {
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user