pub(crate) fn add_to_array_object(
        array_ptr: &Value,
        add_values: &[Value],
        context: &mut Context,
    ) -> Result<Value> {
        let orig_length = array_ptr.get_field("length", context)?.to_length(context)?;

        for (n, value) in add_values.iter().enumerate() {
            let new_index = orig_length.wrapping_add(n);
            array_ptr.set_property(
                new_index,
                PropertyDescriptor::builder()
                    .value(value)
                    .configurable(true)
                    .enumerable(true)
                    .writable(true),
            );
        }

        array_ptr.set_field(
            "length",
            Value::from(orig_length.wrapping_add(add_values.len())),
            false,
            context,
        )?;

        Ok(array_ptr.clone())
    }
/// Utility function which takes an existing array object and puts additional
/// values on the end, correctly rewriting the length
Utility function which takes an existing array object and puts additional
values on the end, correctly rewriting the length
Utility function which takes an existing array object and puts additional values on the end correctly rewriting the length
pub(crate) fn add_to_array_object(
        array_ptr: &Value,
        add_values: &[Value],
        context: &mut Context,
    ) -> Result<Value> {
        let orig_length = array_ptr.get_field("length", context)?.to_length(context)?;
        for (n, value) in add_values.iter().enumerate() {
            let new_index = orig_length.wrapping_add(n);
            array_ptr.set_property(
                new_index,
                PropertyDescriptor::builder()
                    .value(value)
                    .configurable(true)
                    .enumerable(true)
                    .writable(true),
            );
        }
        array_ptr.set_field(
            "length",
            Value::from(orig_length.wrapping_add(add_values.len())),
            false,
            context,
        )?;
        Ok(array_ptr.clone())
    }
pub ( crate ) fn add_to_array_object ( array_ptr : & Value , add_values : & [ Value ] , context : & mut Context , ) -> Result < Value > { let orig_length = array_ptr . get_field ( " " , context ) ? . to_length ( context ) ? ; for ( n , value ) in add_values . iter ( ) . enumerate ( ) { let new_index = orig_length . wrapping_add ( n ) ; array_ptr . set_property ( new_index , PropertyDescriptor :: builder ( ) . value ( value ) . configurable ( true ) . enumerable ( true ) . writable ( true ) , ) ; } array_ptr . set_field ( " " , Value :: from ( orig_length . wrapping_add ( add_values . len ( ) ) ) , false , context , ) ? ; Ok ( array_ptr . clone ( ) ) }
Utility function which takes an existing array object and puts additional
values on the end, correctly rewriting the length
Utility function which takes an existing array object and puts additional values on the end correctly rewriting the length
array_ptr
&Value
add_values
&[Value]
context
&mut Context
array_ptr
&Value
add_values
&[Value]
context
&mut Context