2010-11-15 23:44:15 -05:00
|
|
|
/**
|
|
|
|
* Contains utilities functions shared by modules
|
|
|
|
*
|
|
|
|
* Copyright (C) 2010 Mike Gerwitz
|
|
|
|
*
|
|
|
|
* This file is part of ease.js.
|
|
|
|
*
|
|
|
|
* ease.js is free software: you can redistribute it and/or modify it under the
|
|
|
|
* terms of the GNU Lesser General Public License as published by the Free
|
|
|
|
* Software Foundation, either version 3 of the License, or (at your option)
|
|
|
|
* any later version.
|
|
|
|
*
|
|
|
|
* This program is distributed in the hope that it will be useful, but WITHOUT
|
|
|
|
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
|
|
|
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License
|
|
|
|
* for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU Lesser General Public License
|
|
|
|
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|
|
|
*
|
|
|
|
* @author Mike Gerwitz
|
|
|
|
* @package core
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Whether getters/setters are supported
|
|
|
|
* @var {boolean}
|
|
|
|
*/
|
|
|
|
var getset = ( Object.prototype.__defineGetter__ === undefined )
|
|
|
|
? false
|
|
|
|
: true
|
|
|
|
;
|
|
|
|
|
2010-12-20 13:43:12 -05:00
|
|
|
/**
|
|
|
|
* Whether we can actually define secure properties, or we need to fall back
|
|
|
|
* @type {boolean}
|
|
|
|
*/
|
|
|
|
var secure_fallback = ( Object.defineProperty instanceof Function )
|
|
|
|
? false
|
|
|
|
: true;
|
|
|
|
|
2010-11-15 23:44:15 -05:00
|
|
|
|
2010-12-01 19:27:40 -05:00
|
|
|
/**
|
2010-12-01 20:41:54 -05:00
|
|
|
* Freezes an object if freezing is supported
|
2010-12-01 19:27:40 -05:00
|
|
|
*
|
2010-12-01 20:41:54 -05:00
|
|
|
* @param {Object} obj object to freeze
|
|
|
|
*
|
|
|
|
* @return {Object} object passed to function
|
2010-12-01 19:27:40 -05:00
|
|
|
*/
|
2010-12-01 20:41:54 -05:00
|
|
|
exports.freeze = function( obj )
|
2010-12-01 19:27:40 -05:00
|
|
|
{
|
2010-12-01 20:41:54 -05:00
|
|
|
// if freezing is not supported (ES5), do nothing
|
|
|
|
if ( Object.freeze === undefined )
|
|
|
|
{
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
Object.freeze( obj );
|
|
|
|
return obj;
|
2010-12-01 19:27:40 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2010-12-20 13:43:12 -05:00
|
|
|
/**
|
|
|
|
* Gets/sets whether the system needs to fall back to defining normal properties
|
|
|
|
* when a secure property is requested
|
|
|
|
*
|
|
|
|
* This will be set by default if the JS engine does not support the
|
|
|
|
* Object.defineProperty method from EcmaScript 5.
|
|
|
|
*
|
|
|
|
* @param {boolean=} val value, if used as setter
|
|
|
|
*
|
|
|
|
* @return {boolean|Object} current value if getter, self if setter
|
|
|
|
*/
|
|
|
|
exports.secureFallback = function( val )
|
|
|
|
{
|
|
|
|
if ( val === undefined )
|
|
|
|
{
|
|
|
|
return secure_fallback;
|
|
|
|
}
|
|
|
|
|
|
|
|
secure_fallback = !!val;
|
|
|
|
return exports;
|
|
|
|
};
|
|
|
|
|
|
|
|
|
2010-12-01 20:38:50 -05:00
|
|
|
/**
|
|
|
|
* Attempts to define a non-enumerable, non-writable and non-configurable
|
|
|
|
* property on the given object
|
|
|
|
*
|
|
|
|
* If the operation is unsupported, a normal property will be set.
|
|
|
|
*
|
|
|
|
* @param {Object} obj object to set property on
|
|
|
|
* @param {string} prop name of property to set
|
|
|
|
* @param {mixed} value value to set
|
|
|
|
*
|
|
|
|
* @return {undefined}
|
|
|
|
*/
|
|
|
|
exports.defineSecureProp = function( obj, prop, value )
|
|
|
|
{
|
2010-12-20 13:43:12 -05:00
|
|
|
if ( secure_fallback )
|
2010-12-01 20:38:50 -05:00
|
|
|
{
|
2010-12-20 10:04:11 -05:00
|
|
|
obj[ prop ] = value;
|
2010-12-01 20:38:50 -05:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2010-12-21 14:37:34 -05:00
|
|
|
try
|
2010-12-01 20:38:50 -05:00
|
|
|
{
|
2010-12-21 14:37:34 -05:00
|
|
|
Object.defineProperty( obj, prop,
|
|
|
|
{
|
|
|
|
value: value,
|
2010-12-01 20:38:50 -05:00
|
|
|
|
2010-12-21 14:37:34 -05:00
|
|
|
enumerable: false,
|
|
|
|
writable: false,
|
|
|
|
configurable: false,
|
|
|
|
});
|
|
|
|
}
|
|
|
|
catch ( e )
|
|
|
|
{
|
|
|
|
// if there's an error (ehem, IE8), fall back
|
|
|
|
obj[ prop ] = value;
|
|
|
|
}
|
2010-12-01 20:38:50 -05:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2010-12-16 23:15:42 -05:00
|
|
|
/**
|
|
|
|
* Clones an object
|
|
|
|
*
|
|
|
|
* @param {Object} data object to clone
|
|
|
|
*
|
|
|
|
* @return {Object} cloned object
|
|
|
|
*/
|
|
|
|
exports.clone = function( data )
|
|
|
|
{
|
|
|
|
if ( data instanceof Array )
|
|
|
|
{
|
|
|
|
// return a copy of the array
|
|
|
|
return data.slice( 0 );
|
|
|
|
}
|
|
|
|
else if ( data instanceof Object )
|
|
|
|
{
|
2010-12-21 10:09:18 -05:00
|
|
|
var newobj = {},
|
|
|
|
hasOwn = Object.prototype.hasOwnProperty;
|
2010-12-16 23:15:42 -05:00
|
|
|
|
|
|
|
// copy data to the new object
|
|
|
|
for ( prop in data )
|
|
|
|
{
|
2010-12-21 10:09:18 -05:00
|
|
|
if ( hasOwn.call( data, prop ) )
|
2010-12-16 23:15:42 -05:00
|
|
|
{
|
|
|
|
newobj[ prop ] = data[ prop ];
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return newobj;
|
|
|
|
}
|
|
|
|
|
|
|
|
// primitive type; cloning unnecessary
|
|
|
|
return data;
|
|
|
|
};
|
|
|
|
|
|
|
|
|
2010-12-04 13:59:06 -05:00
|
|
|
/**
|
|
|
|
* Parses object properties to determine how they should be interpreted in an
|
|
|
|
* Object Oriented manner
|
|
|
|
*
|
|
|
|
* @param {Object} data properties with names as the key
|
|
|
|
* @param {Object} options parser options and callbacks
|
|
|
|
*
|
|
|
|
* @return undefined
|
|
|
|
*/
|
2010-12-05 20:50:13 -05:00
|
|
|
exports.propParse = function( data, options )
|
2010-12-04 13:59:06 -05:00
|
|
|
{
|
2010-12-07 00:46:50 -05:00
|
|
|
var fvoid = function() {},
|
|
|
|
callback_each = options.each || undefined,
|
|
|
|
callback_prop = options.property || fvoid,
|
|
|
|
callback_method = options.method || fvoid,
|
|
|
|
callback_getter = options.getter || fvoid,
|
2010-12-21 10:09:18 -05:00
|
|
|
callback_setter = options.setter || fvoid,
|
|
|
|
|
|
|
|
hasOwn = Object.prototype.hasOwnProperty;
|
2010-12-04 13:59:06 -05:00
|
|
|
|
|
|
|
// for each of the given properties, determine what type of property we're
|
|
|
|
// dealing with (in the classic OO sense)
|
|
|
|
for ( prop in data )
|
|
|
|
{
|
2010-12-18 07:07:27 -05:00
|
|
|
// ignore properties of instance prototypes
|
2010-12-21 10:09:18 -05:00
|
|
|
if ( !( hasOwn.call( data, prop ) ) )
|
2010-12-18 07:07:27 -05:00
|
|
|
{
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
|
2010-12-05 20:50:13 -05:00
|
|
|
var value = data[ prop ],
|
|
|
|
getter = ( ( getset ) ? data.__lookupGetter__( prop ) : null ),
|
|
|
|
setter = ( ( getset ) ? data.__lookupSetter__( prop ) : null );
|
2010-12-04 13:59:06 -05:00
|
|
|
|
2010-12-07 00:39:25 -05:00
|
|
|
// if an 'each' callback was provided, pass the data before parsing it
|
|
|
|
if ( callback_each )
|
|
|
|
{
|
2010-12-16 23:49:52 -05:00
|
|
|
callback_each.call( callback_each, prop, value );
|
2010-12-07 00:39:25 -05:00
|
|
|
}
|
|
|
|
|
2010-12-05 20:50:13 -05:00
|
|
|
// getter/setter
|
|
|
|
if ( getter || setter )
|
|
|
|
{
|
2010-12-16 23:49:52 -05:00
|
|
|
callback_getter.call( callback_getter, prop, getter );
|
|
|
|
callback_setter.call( callback_setter, prop, setter );
|
2010-12-05 20:50:13 -05:00
|
|
|
}
|
|
|
|
// method
|
|
|
|
else if ( value instanceof Function )
|
2010-12-04 13:59:06 -05:00
|
|
|
{
|
2010-12-16 23:49:52 -05:00
|
|
|
callback_method.call(
|
|
|
|
callback_method,
|
2010-12-07 00:46:50 -05:00
|
|
|
prop,
|
|
|
|
value,
|
|
|
|
exports.isAbstractMethod( value )
|
|
|
|
);
|
2010-12-04 13:59:06 -05:00
|
|
|
}
|
2010-12-05 20:50:13 -05:00
|
|
|
// simple property
|
2010-12-04 13:59:06 -05:00
|
|
|
else
|
|
|
|
{
|
2010-12-16 23:49:52 -05:00
|
|
|
callback_prop.call( callback_prop, prop, value );
|
2010-12-04 13:59:06 -05:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2010-11-15 23:44:15 -05:00
|
|
|
/**
|
|
|
|
* Copies properties to the destination object
|
|
|
|
*
|
|
|
|
* If the method already exists, it will be overridden and accessible via either
|
|
|
|
* the parent prototype or by invoking this.__super().
|
|
|
|
*
|
|
|
|
* The destination object is directly modified.
|
|
|
|
*
|
|
|
|
* The result data will be populated with information from the copy that may be
|
|
|
|
* useful to the creation of the class (e.g. list of the abstract methods).
|
|
|
|
*
|
2010-12-19 00:11:39 -05:00
|
|
|
* @param {Object} props properties to copy
|
|
|
|
* @param {Object} dest destination object
|
|
|
|
* @param {Object} actions parser actions (see propParse())
|
2010-11-15 23:44:15 -05:00
|
|
|
*
|
|
|
|
* @return undefined
|
|
|
|
*/
|
2010-12-19 00:11:39 -05:00
|
|
|
exports.propCopy = function( props, dest, actions )
|
2010-11-15 23:44:15 -05:00
|
|
|
{
|
2010-12-16 21:11:07 -05:00
|
|
|
actions = actions || {};
|
2010-11-15 23:44:15 -05:00
|
|
|
|
2010-12-16 23:49:52 -05:00
|
|
|
var use_or = function( use, or )
|
|
|
|
{
|
|
|
|
if ( use instanceof Function )
|
|
|
|
{
|
|
|
|
// allow the override to invoke the default implementation
|
|
|
|
use.performDefault = or;
|
|
|
|
return use;
|
|
|
|
}
|
|
|
|
|
|
|
|
// use the default
|
|
|
|
return or;
|
|
|
|
};
|
|
|
|
|
2010-12-16 21:11:07 -05:00
|
|
|
// substitute default functionality if needed
|
2010-12-19 00:11:39 -05:00
|
|
|
var parse_actions = {
|
2010-12-16 23:49:52 -05:00
|
|
|
each: use_or( actions.each, function( name, value )
|
2010-12-07 00:41:30 -05:00
|
|
|
{
|
|
|
|
// methods can only be overridden with methods
|
|
|
|
if ( ( dest[ name ] instanceof Function )
|
|
|
|
&& ( !( value instanceof Function ) )
|
|
|
|
)
|
|
|
|
{
|
|
|
|
throw new TypeError( "Cannot override method with non-method" );
|
|
|
|
}
|
2010-12-16 23:49:52 -05:00
|
|
|
} ),
|
2010-12-07 00:41:30 -05:00
|
|
|
|
2010-12-16 23:49:52 -05:00
|
|
|
property: use_or( actions.property, function( name, value )
|
2010-12-07 00:38:51 -05:00
|
|
|
{
|
|
|
|
dest[ name ] = value;
|
2010-12-16 23:49:52 -05:00
|
|
|
} ),
|
2010-11-15 23:44:15 -05:00
|
|
|
|
2010-12-16 23:49:52 -05:00
|
|
|
getter: use_or( actions.getter, function( name, func )
|
2010-12-07 00:38:51 -05:00
|
|
|
{
|
|
|
|
dest.__defineGetter__( name, func );
|
2010-12-16 23:49:52 -05:00
|
|
|
} ),
|
2010-12-07 00:38:51 -05:00
|
|
|
|
2010-12-16 23:49:52 -05:00
|
|
|
setter: use_or( actions.setter, function( name, func )
|
2010-12-07 00:38:51 -05:00
|
|
|
{
|
|
|
|
dest.__defineSetter__( name, func );
|
2010-12-16 23:49:52 -05:00
|
|
|
} ),
|
2010-12-07 00:38:51 -05:00
|
|
|
|
2010-12-16 23:49:52 -05:00
|
|
|
method: use_or( actions.method, function( name, func, is_abstract )
|
2010-11-15 23:44:15 -05:00
|
|
|
{
|
2010-12-19 00:11:39 -05:00
|
|
|
var pre = dest[ name ];
|
2010-12-07 00:38:51 -05:00
|
|
|
|
|
|
|
// check for override
|
|
|
|
if ( pre !== undefined )
|
2010-11-15 23:44:15 -05:00
|
|
|
{
|
2010-12-07 00:49:00 -05:00
|
|
|
if ( pre instanceof Function )
|
|
|
|
{
|
2010-12-19 00:11:39 -05:00
|
|
|
// use provided method override action, or fall back to
|
|
|
|
// generic override
|
|
|
|
var override_func = use_or( actions.methodOverride,
|
|
|
|
function( name, pre, func )
|
|
|
|
{
|
2010-12-19 00:12:41 -05:00
|
|
|
return exports.overrideMethod( name, pre, func );
|
2010-12-19 00:11:39 -05:00
|
|
|
}
|
|
|
|
);
|
|
|
|
|
|
|
|
// use call(), passing self in as context, to ensure 'this'
|
|
|
|
// will reference the function itself
|
|
|
|
dest[ name ] = override_func.call(
|
|
|
|
override_func, name, pre, func
|
2010-12-07 00:49:00 -05:00
|
|
|
);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2010-12-10 00:00:47 -05:00
|
|
|
throw new TypeError(
|
2010-12-07 20:24:51 -05:00
|
|
|
"Cannot override property '" + name + "' with method"
|
|
|
|
);
|
2010-12-07 00:49:00 -05:00
|
|
|
}
|
2010-11-15 23:44:15 -05:00
|
|
|
}
|
2010-12-07 00:38:51 -05:00
|
|
|
else
|
|
|
|
{
|
|
|
|
// simply copy over the method
|
|
|
|
dest[ name ] = func;
|
|
|
|
}
|
2010-12-16 23:49:52 -05:00
|
|
|
} ),
|
2010-12-07 00:38:51 -05:00
|
|
|
};
|
2010-11-15 23:44:15 -05:00
|
|
|
|
2010-12-19 00:11:39 -05:00
|
|
|
exports.propParse( props, parse_actions );
|
2010-11-15 23:44:15 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2010-12-01 20:45:27 -05:00
|
|
|
/**
|
|
|
|
* Creates an abstract method
|
|
|
|
*
|
|
|
|
* Abstract methods must be implemented by a subclass and cannot be called
|
|
|
|
* directly. If a class contains a single abstract method, the class itself is
|
|
|
|
* considered to be abstract and cannot be instantiated. It may only be
|
|
|
|
* extended.
|
|
|
|
*
|
2010-12-01 21:13:51 -05:00
|
|
|
* @param {...string} definition function definition that concrete
|
|
|
|
* implementations must follow
|
2010-12-01 20:45:27 -05:00
|
|
|
*
|
|
|
|
* @return {Function}
|
|
|
|
*/
|
2010-12-01 21:13:51 -05:00
|
|
|
exports.createAbstractMethod = function()
|
2010-12-01 20:45:27 -05:00
|
|
|
{
|
2010-12-01 21:13:51 -05:00
|
|
|
var definition = Array.prototype.slice.call( arguments );
|
|
|
|
|
2010-12-01 20:45:27 -05:00
|
|
|
var method = function()
|
|
|
|
{
|
|
|
|
throw new Error( "Cannot call abstract method" );
|
|
|
|
};
|
|
|
|
|
|
|
|
exports.defineSecureProp( method, 'abstractFlag', true );
|
|
|
|
exports.defineSecureProp( method, 'definition', definition );
|
|
|
|
|
|
|
|
return method;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2010-12-01 21:00:15 -05:00
|
|
|
/**
|
|
|
|
* Determines if the given function is an abstract method
|
|
|
|
*
|
|
|
|
* @param {Function} function function to inspect
|
|
|
|
*
|
|
|
|
* @return {boolean} true if function is an abstract method, otherwise false
|
|
|
|
*/
|
|
|
|
exports.isAbstractMethod = function( func )
|
|
|
|
{
|
|
|
|
return ( ( func instanceof Function ) && ( func.abstractFlag === true ) )
|
|
|
|
? true
|
|
|
|
: false
|
|
|
|
;
|
|
|
|
}
|
|
|
|
|
2010-12-01 20:45:27 -05:00
|
|
|
|
2010-11-15 23:44:15 -05:00
|
|
|
/**
|
|
|
|
* Overrides a method
|
|
|
|
*
|
|
|
|
* The given method must be a function or an exception will be thrown.
|
|
|
|
*
|
2010-12-19 00:12:41 -05:00
|
|
|
* @param {string} name method name
|
2010-12-19 00:11:39 -05:00
|
|
|
* @param {Function} super_method method to override
|
|
|
|
* @param {Function} new_method method to override with
|
|
|
|
* @param {Array.<string>=} abstract_methods list of abstract methods
|
2010-11-15 23:44:15 -05:00
|
|
|
*
|
|
|
|
* @return {Function} overridden method
|
|
|
|
*/
|
2010-12-19 00:11:39 -05:00
|
|
|
exports.overrideMethod = function(
|
2010-12-19 00:12:41 -05:00
|
|
|
name, super_method, new_method, abstract_methods
|
2010-11-15 23:44:15 -05:00
|
|
|
)
|
|
|
|
{
|
2010-12-19 00:11:39 -05:00
|
|
|
abstract_methods = abstract_methods || [];
|
|
|
|
|
2010-12-18 10:57:00 -05:00
|
|
|
// it's much faster to lookup a hash than it is to iterate through an entire
|
|
|
|
// array each time we need to find an existing abstract method
|
|
|
|
var abstract_map = {};
|
|
|
|
for ( var i = 0, len = abstract_methods.length; i < len; i++ )
|
|
|
|
{
|
|
|
|
var method = abstract_methods[ i ];
|
|
|
|
abstract_map[ method ] = i;
|
|
|
|
}
|
|
|
|
|
2010-12-01 21:34:57 -05:00
|
|
|
if ( abstract_map[ name ] !== undefined )
|
2010-11-15 23:44:15 -05:00
|
|
|
{
|
2010-12-01 21:34:57 -05:00
|
|
|
var is_abstract = exports.isAbstractMethod( new_method );
|
|
|
|
|
2010-12-01 21:13:51 -05:00
|
|
|
if ( super_method.definition instanceof Array )
|
2010-11-15 23:44:15 -05:00
|
|
|
{
|
2010-12-01 21:34:57 -05:00
|
|
|
var arg_len = ( is_abstract )
|
|
|
|
? new_method.definition.length
|
|
|
|
: new_method.length;
|
|
|
|
|
2010-11-15 23:44:15 -05:00
|
|
|
// ensure the concrete definition is compatible with
|
|
|
|
// that of its supertype
|
2010-12-01 21:34:57 -05:00
|
|
|
if ( arg_len < super_method.definition.length )
|
2010-11-15 23:44:15 -05:00
|
|
|
{
|
2010-12-10 00:00:47 -05:00
|
|
|
throw new TypeError(
|
2010-12-01 23:04:22 -05:00
|
|
|
"Declaration of " + name + " must be compatiable " +
|
2010-11-15 23:44:15 -05:00
|
|
|
"with that of its supertype"
|
|
|
|
);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2010-12-01 21:34:57 -05:00
|
|
|
// if this was a concrete method, then it should no longer be marked as
|
|
|
|
// abstract
|
|
|
|
if ( is_abstract === false )
|
|
|
|
{
|
|
|
|
delete abstract_methods[ abstract_map[ name ] ];
|
|
|
|
}
|
2010-11-15 23:44:15 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
// this is the method that will be invoked when the requested
|
|
|
|
// method is called, so note that in the context of this
|
|
|
|
// function, `this` will represent the current class instance
|
|
|
|
return function()
|
|
|
|
{
|
|
|
|
var tmp = this.__super;
|
|
|
|
|
|
|
|
// assign _super temporarily for the method invocation so
|
|
|
|
// that the method can call the parent method
|
|
|
|
this.__super = super_method;
|
2010-12-19 00:11:39 -05:00
|
|
|
var retval = new_method.apply( this, arguments );
|
2010-11-15 23:44:15 -05:00
|
|
|
this.__super = tmp;
|
|
|
|
|
|
|
|
return retval;
|
|
|
|
}
|
2010-12-19 00:11:39 -05:00
|
|
|
};
|
2010-11-15 23:44:15 -05:00
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Shrinks an array, removing undefined elements
|
|
|
|
*
|
|
|
|
* Pushes all items onto a new array, removing undefined elements. This ensures
|
|
|
|
* that the length of the array represents correctly the number of elements in
|
|
|
|
* the array.
|
|
|
|
*
|
|
|
|
* @param {Array} items array to shrink
|
|
|
|
*
|
|
|
|
* @return {Array} shrunken array
|
|
|
|
*/
|
2010-12-18 09:38:58 -05:00
|
|
|
exports.arrayShrink = function( items )
|
2010-11-15 23:44:15 -05:00
|
|
|
{
|
|
|
|
// copy the methods into a new array by pushing them onto it, to ensure
|
|
|
|
// the length property of the array will work properly
|
|
|
|
var arr_new = [];
|
|
|
|
for ( var i = 0, len = items.length; i < len; i++ )
|
|
|
|
{
|
|
|
|
var item = items[ i ];
|
|
|
|
if ( item === undefined )
|
|
|
|
{
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
|
|
|
|
arr_new.push( item );
|
|
|
|
}
|
|
|
|
|
|
|
|
return arr_new;
|
|
|
|
}
|
|
|
|
|