<commit_before>( function _fLong_s_() {

'use strict';

let _ArrayIndexOf = Array.prototype.indexOf;
let _ArrayIncludes = Array.prototype.includes;
if( !_ArrayIncludes )
_ArrayIncludes = function( e ){ _ArrayIndexOf.call( this, e ) }

let _global = _global_;
let _ = _global_.wTools;
let Self = _global_.wTools;

/*
               |  can grow   |  can shrink  |   range
grow                +                -         positive
select              -                +         positive
relength            +                +         positive
but                 -                +         negative
*/

/* array / long / buffer */
/* - / inplace */

// --
// arguments array
// --

function argumentsArrayMake( src )
{
  _.assert( arguments.length === 1 );
  _.assert( _.numberIs( src ) || _.longLike( src ) );
  if( _.numberIs( src ) )
  return _argumentsArrayMake.apply( _, Array( src ) );
  else
  return _argumentsArrayMake.apply( _, src );
}

//

function _argumentsArrayMake()
{
  return arguments;
}

//

function argumentsArrayFrom( src )
{
  _.assert( arguments.length === 1, 'Expects single argument' );
  if( _.argumentsArrayIs( src ) )
  return src;
  return _.argumentsArrayMake( src );
}

// --
// long
// --

function _longMake_functor( onMake )
{

  _.assert( _.routineIs( onMake ) );

  return function _longMake( src, ins )
  {
    let result;

    /* */

    let length = ins;

    if( _.longLike( length ) )
    length = length.length;

    if( length === undefined || length === null )
    {
      if( src === null )
      {
        length = 0;
      }
      else if( _.longLike( src ) )
      {
        length = src.length;
      }
      else if( _.numberIs( src ) )
      {
        length = src;
        src = null;
      }
      else if( _.routineIs( src ) )
      {
        length = 0;
      }
      else _.assert( 0 );
    }

    if( !length )
    length = 0;

    /* */

    if( ins === undefined || ins === null )
    {
      if( _.longLike( src ) )
      {
        if( ins === null )
        {
          ins = src;
        }
        else
        {
          ins = src;
          src = null;
        }
      }
      else
      {
        ins = null;
      }
    }
    else if( !_.longLike( ins ) )
    {
      if( _.longIs( src ) )
      ins = src;
      else
      ins = null;
    }

    /**/

    let minLength;
    if( ins )
    minLength = Math.min( ins.length, length );
    else
    minLength = 0;

    /**/

    if( _.argumentsArrayIs( src ) )
    src = null;

    if( src === null )
    src = this.longDescriptor.make;

    _.assert( arguments.length === 1 || arguments.length === 2 );
    _.assert( _.numberIsFinite( length ) );
    _.assert( _.routineIs( src ) || _.longLike( src ), () => 'Expects long, but got ' + _.strType( src ) );

    result = onMake.call( this, src, ins, length, minLength );

    _.assert( _.longLike( result ) );

    return result;
  }

}

//

/**
 * The routine longMake() returns a new Long with the same type as source Long (src). New Long makes from inserted Long (ins)
 * or if (ins) is number, the Long makes from (src) with length equal to (ins). If (ins) is not provided, routine returns copy of (src).
 *
 * @param { Long } src - Instance of Long or constructor, defines type of returned Long. If null is provided, routine returns empty array.
 * @param { Number|Long } ins - Defines length of new Long. If Long is provided, routine makes new Long from {-ins-} with {-src-} type.
 *
 * @example
 * _.longMake( null );
 * // returns []
 *
 * @example
 * _.longMake( [ 1, 2, 3, 4 ] );
 * // returns [ 1, 2, 3, 4 ];
 *
 * @example
 * let src = _.unrollMake( [] );
 * let got = _.longMake( src, [ 1, 2, 3 ] );
 * console.log( got );
 * // log [ 1, 2, 3 ];
 * console.log( _.unrollIs( got ) );
 * // log true
 *
 * @example
 * let src = new F32x( [ 1, 2, 3, 4, 5 ] );
 * let got = _.longMake( src, 2 );
 * console.log( got );
 * // log Float32Array[ 1, 2 ];
 * console.log( _.bufferTypedIs( got ) );
 * // log true
 *
 * @returns { Long } Returns a Long with type of source Long which makes from ins.
 * @function longMake
 * @throws { Error } If arguments.length is less than two or more then two.
 * @throws { Error } If {-ins-} is not a number and not a Long.
 * @throws { Error } If {-src-} is not a Long or not a constructor.
 * @throws { Error } If {-ins-} or ins.length has a not finite value.
 * @memberof wTools
 */

/* aaa : extend coverage and documentation of longMake */
/* Dmytro : extended coverage and documentation of routine longMake */
/* aaa : longMake does not create unrolls, but should */
/* Dmytro : longMake creates unrolls */

let longMake = _longMake_functor( function( src, ins, length, minLength )
{
  let result;

  if( _.routineIs( src ) )
  {
    if( ins && ins.length === length )
    {
      if( src === Array )
      {
        if( _.longLike( ins ) )
        {
          if( ins.length === 1 )
          result = [ ins[ 0 ] ];
          else if( !_.arrayLike( ins ) )
          result = new( _.constructorJoin( src, [ ... ins ] ) );
          else
          result = new( _.constructorJoin( src, ins ) );
        }
        else
        {
          result = new src( ins );
        }
      }
      else
      {
        result = new src( ins );
      }
    }
    else
    {
      result = new src( length );
      // let minLength = Math.min( length, ins.length );
      // if( !ins && minLength )
      // debugger;
      for( let i = 0 ; i < minLength ; i++ )
      result[ i ] = ins[ i ];
    }
  }
  else if( _.arrayIs( src ) )
  {
    if( ins && length === ins.length )
    {
      result = _.unrollIs( src ) ? _.unrollMake( ins ) : new( _.constructorJoin( src.constructor, ins ) );
    }
    else
    {
      _.assert( length >= 0 );
      result = _.unrollIs( src ) ? _.unrollMake( length ) : new src.constructor( length );
      // let minLength = Math.min( length, ins.length );
      for( let i = 0 ; i < minLength ; i++ )
      result[ i ] = ins[ i ];
    }
  }
  else
  {
    if( ins && length === ins.length )
    {
      result = new src.constructor( ins );
    }
    else
    {
      result = new src.constructor( length );
      // let minLength = Math.min( length, ins.length );
      for( let i = 0 ; i < minLength ; i++ )
      result[ i ] = ins[ i ];
    }
  }

  return result;
});

// function longMake( src, ins )
// {
//   let result;
//   let length = ins;
//
//   if( _.longLike( length ) )
//   length = length.length;
//
//   if( length === undefined )
//   {
//     if( src === null )
//     {
//       length = 0;
//     }
//     else if( _.longLike( src ) )
//     {
//       length = src.length;
//     }
//     else if( _.numberIs( src ) )
//     {
//       length = src;
//       src = null;
//     }
//     else _.assert( 0 );
//   }
//
//   // if( !_.longLike( ins ) )
//   // {
//   //   if( _.longLike( src ) )
//   //   ins = src;
//   //   else
//   //   ins = [];
//   // }
//
//   if( !_.longLike( ins ) )
//   {
//     if( _.longLike( src ) )
//     {
//       ins = src;
//       src = null;
//     }
//     else
//     {
//       ins = [];
//     }
//   }
//
//   if( !length )
//   length = 0;
//
//   if( _.argumentsArrayIs( src ) )
//   src = null;
//
//   if( src === null )
//   src = this.longDescriptor.make;
//
//   _.assert( arguments.length === 1 || arguments.length === 2 );
//   _.assert( _.numberIsFinite( length ) );
//   _.assert( _.routineIs( src ) || _.longLike( src ), () => 'Expects long, but got ' + _.strType( src ) );
//
//   if( _.routineIs( src ) )
//   {
//     if( ins.length === length )
//     {
//       if( src === Array )
//       {
//         if( _.longLike( ins ) )
//         {
//           if( ins.length === 1 )
//           result = [ ins[ 0 ] ];
//           else if( !_.arrayLike( ins ) )
//           result = new( _.constructorJoin( src, [ ... ins ] ) );
//           else
//           result = new( _.constructorJoin( src, ins ) );
//         }
//         else
//         {
//           result = new src( ins );
//         }
//       }
//       else
//       {
//         result = new src( ins );
//       }
//     }
//     else
//     {
//       result = new src( length );
//       let minLen = Math.min( length, ins.length );
//       for( let i = 0 ; i < minLen ; i++ )
//       result[ i ] = ins[ i ];
//     }
//   }
//   else if( _.arrayIs( src ) )
//   {
//     if( length === ins.length )
//     {
//       result = _.unrollIs( src ) ? _.unrollMake( ins ) : new( _.constructorJoin( src.constructor, ins ) );
//     }
//     else
//     {
//       _.assert( length >= 0 );
//       result = _.unrollIs( src ) ? _.unrollMake( length ) : new src.constructor( length );
//       let minLen = Math.min( length, ins.length );
//       for( let i = 0 ; i < minLen ; i++ )
//       result[ i ] = ins[ i ];
//     }
//   }
//   else
//   {
//     if( length === ins.length )
//     {
//       result = new src.constructor( ins );
//     }
//     else
//     {
//       result = new src.constructor( length );
//       let minLen = Math.min( length, ins.length );
//       for( let i = 0 ; i < minLen ; i++ )
//       result[ i ] = ins[ i ];
//     }
//   }
//
//   _.assert( result instanceof this.longDescriptor.type );
//   // _.assert( _.longLike( result ) );
//
//   return result;
// }

//

/* aaa : implement test */
/* Dmytro : implemented */

function longMakeEmpty( src )
{
  if( arguments.length === 0 )
  return this.longDescriptor.make( 0 );

  _.assert( arguments.length === 1 );

  if( _.unrollIs( src ) )
  return _.unrollMake( 0 );
  else if( src === null || _.argumentsArrayIs( src ) )
  return this.longDescriptor.make( 0 );
  else if( _.arrayIs( src ) || _.bufferTypedIs( src ) )
  return new src.constructor();
  else if( _.routineIs( src ) )
  {
    let result = new src.constructor();
    _.assert( _.longIs( result ) && result.length === 0, 'Constructor should return empty long' );
    return result;
  }
  _.assert( 0, 'Unknown how to construct long' );
}

// function longMakeEmpty( src )
// {
//   let result;
//   let length = 0;
//
//   if( src === null )
//   src = [];
//
//   if( _.argumentsArrayIs( src ) )
//   src = [];
//
//   _.assert( arguments.length === 1 );
//
//   result = new src.constructor();
//
//   _.assert( _.longIs( result ) );
//   _.assert( result.length === 0 );
//
//   return result;
// }

//

let _longMakeOfLength = _longMake_functor( function( src, ins, length, minLength )
{
  let result;

  if( _.routineIs( src ) )
  {
    result = new src( length );
  }
  else if( _.arrayIs( src ) )
  {
    if( length === src.length )
    {
      result = new( _.constructorJoin( src.constructor, src ) );
    }
    else if( length < src.length )
    {
      result = src.slice( 0, length );
    }
    else
    {
      result = new src.constructor( length );
      for( let i = 0 ; i < minLength ; i++ )
      result[ i ] = src[ i ];
    }
  }
  else
  {
    if( length === src.length )
    {
      result = new src.constructor( length );
    }
    else
    {
      result = new src.constructor( length );
      for( let i = 0 ; i < minLength ; i++ )
      result[ i ] = src[ i ];
    }
  }

  return result;
});

// function _longMakeOfLength( src, len )
// {
//   let result;
// 
//   // if( src === null )
//   // src = [];
// 
//   if( _.longLike( len ) )
//   len = len.length;
// 
//   if( len === undefined )
//   {
//     if( src === null )
//     {
//       len = 0;
//     }
//     else if( _.longLike( src ) )
//     {
//       len = src.length;
//     }
//     else if( _.numberIs( src ) )
//     {
//       len = src;
//       src = null;
//     }
//     else _.assert( 0 );
//   }
// 
//   if( !len )
//   len = 0;
// 
//   if( _.argumentsArrayIs( src ) )
//   src = this.longDescriptor.name === 'ArgumentsArray' ? this.longDescriptor.make : this.longDescriptor.make( src );
// 
//   if( src === null )
//   src = this.longDescriptor.make;
// 
//   _.assert( arguments.length === 1 || arguments.length === 2 );
//   _.assert( _.numberIsFinite( len ) );
//   _.assert( _.routineIs( src ) || _.longLike( src ), () => 'Expects long, but got ' + _.strType( src ) );
// 
//   if( _.routineIs( src ) )
//   {
//     result = new src( len );
//   }
//   else if( _.arrayIs( src ) )
//   {
//     if( len === src.length )
//     {
//       result = new( _.constructorJoin( src.constructor, src ) );
//     }
//     else if( len < src.length )
//     {
//       result = src.slice( 0, len );
//     }
//     else
//     {
//       result = new src.constructor( len );
//       let minLen = Math.min( len, src.length );
//       for( let i = 0 ; i < minLen ; i++ )
//       result[ i ] = src[ i ];
//     }
//   }
//   else
//   {
//     if( len === src.length )
//     {
//       result = new src.constructor( len );
//     }
//     else
//     {
//       result = new src.constructor( len );
//       let minLen = Math.min( len, src.length );
//       for( let i = 0 ; i < minLen ; i++ )
//       result[ i ] = src[ i ];
//     }
//   }
// 
//   _.assert( _.longLike( result ), 'Instance should be a long' );
// 
//   return result;
// }

//

/**
 * The routine longMakeUndefined() returns a new Long with the same type as source Long {-src-}. New Long has length equal to {-len-}
 * or it has length of source Long {-src-} if second argument is not provided.
 *
 * @param { Long } ins - Long or constructor, defines type of returned Long. If null is provided, routine returns empty array.
 * @param { Number|Long } len - Defines length of new Long. If Long is provided, routine makes new Long with length equal to ins.length.
 *
 * @example
 * _.longMakeUndefined( null );
 * // returns []
 *
 * @example
 * _.longMakeUndefined( [ 1, 2, 3, 4 ] );
 * // returns [ undefined, undefined, undefined, undefined ];
 *
 * @example
 * let src = _.unrollMake( [] )
 * let got = _.longMakeUndefined( src, [ 1, 2, 3 ] );
 * console.log( got );
 * // log [ undefined, undefined, undefined ];
 * console.log( _.unrollIs( got ) );
 * // log true
 *
 * @example
 * let src = new F32x( [ 1, 2, 3, 4, 5] )
 * let got = _.longMakeUndefined( src, 2 );
 * console.log( got );
 * // log Float32Array[ undefined, undefined ];
 * console.log( _.bufferTypedIs( got ) );
 * // log true
 *
 * @returns { Long } - Returns a Long with type of source Long with a certain length.
 * @function longMakeUndefined
 * @throws { Error } If arguments.length is less than one or more then two.
 * @throws { Error } If the {-ins-} is not a Long or not a constructor.
 * @throws { Error } If the {-len-} is not a number or not a Long.
 * @throws { Error } If the {-len-} or ins.length has a not finite value.
 * @throws { Error } If the {-len-} is undefined and ins.length is not a number.
 * @memberof wTools
 */

/*
qqq : extend coverage and documentation of longMakeUndefined | Dmytro : routine is covered and documented
qqq : longMakeUndefined does not create unrolls, but should | Dmytro : longMakeUndefined creates unrolls.
*/

let longMakeUndefined = _longMake_functor( function( src, ins, length, minLength )
{
  let result;

  if( _.routineIs( src ) )
  result = new src( length );
  else if( _.unrollIs( src ) )
  result = _.unrollMake( length );
  else if( src === null )
  result = this.longDescriptor.make( length );
  else
  result = new src.constructor( length );

  return result;
})

// function longMakeUndefined( ins, len )
// {
//   let result, length;
//
//   /* aaa3 : ask. use default long container */
//   /* Dmytro : explained, used this.longDescriptor */
//   // if( ins === null )
//   // result = [];
//
//   if( len === undefined )
//   {
//     if( ins === null )
//     {
//       length = 0;
//     }
//     else if( _.numberIs( ins ) )
//     {
//       length = ins;
//       ins = null;
//     }
//     else
//     {
//       length = ins.length;
//     }
//   }
//   else
//   {
//     if( _.longLike( len ) )
//     length = len.length;
//     else if( _.numberIs( len ) )
//     length = len;
//     else _.assert( 0 );
//   }
//
//   if( _.argumentsArrayIs( ins ) )
//   ins = null;
//
//   _.assert( arguments.length === 1 || arguments.length === 2 );
//   _.assert( _.numberIsFinite( length ) );
//   _.assert( _.routineIs( ins ) || _.longLike( ins ) || ins === null, () => 'Expects long, but got ' + _.strType( ins ) );
//
//   if( _.routineIs( ins ) )
//   result = new ins( length );
//   else if( _.unrollIs( ins ) )
//   result = _.unrollMake( length );
//   else if( ins === null ) /* aaa3 : ask */
//   result = this.longDescriptor.make( length );
//   else
//   result = new ins.constructor( length );
//
//   return result;
// }

//

/* qqq3 : teach to accept only length */
/* qqq3 : use default long type if type is not clear */
/* qqq3 : allow buffers which are long */
/* qqq3 : relevant to all routines longMake* of such kind */

let longMakeZeroed = _longMake_functor( function( src, ins, length, minLength )
{
  let result;

  if( _.routineIs( src ) )
  result = new src( length );
  else if( _.unrollIs( src ) )
  result = _.unrollMake( length );
  else if( src === null )
  result = this.longDescriptor.make( length );
  else
  result = new src.constructor( length );

  if( !_.bufferTypedIs( result ) )
  for( let i = 0 ; i < length ; i++ )
  result[ i ] = 0;

  return result;
})

// function longMakeZeroed( ins, src )
// {
//   let result, length;
//
//   if( _.routineIs( ins ) )
//   _.assert( arguments.length === 2, 'Expects exactly two arguments' );
//
//   if( src === undefined )
//   {
//     length = ins.length;
//   }
//   else
//   {
//     if( _.longLike( src ) )
//     length = src.length;
//     else if( _.numberIs( src ) )
//     length = src;
//     else _.assert( 0, 'Expects long or number as the second argument, got', _.strType( src ) );
//   }
//
//   if( _.argumentsArrayIs( ins ) )
//   ins = [];
//
//   _.assert( arguments.length === 1 || arguments.length === 2 );
//   _.assert( _.numberIsFinite( length ) );
//   _.assert( _.routineIs( ins ) || _.longLike( ins ), () => 'Expects long, but got ' + _.strType( ins ) );
//
//   if( _.routineIs( ins ) )
//   result = new ins( length );
//   else if( _.unrollIs( ins ) )
//   result = _.unrollMake( length );
//   else
//   result = new ins.constructor( length );
//
//   if( !_.bufferTypedIs( result ) )
//   for( let i = 0 ; i < length ; i++ )
//   result[ i ] = 0;
//
//   return result;
// }

//

/*
aaa : find and let me know what is _.buffer* analog of _longClone |
aaa Dmytro : module has not _.buffer* analog of routine _longClone. The closest functionality has routine bufferMake( ins, src )
zzz
*/

function _longClone( src )
{

  _.assert( arguments.length === 1, 'Expects single argument' );
  _.assert( _.longLike( src ) || _.bufferAnyIs( src ) );
  // _.assert( !_.bufferNodeIs( src ), 'not tested' );

  if( _.bufferViewIs( src ) )
  debugger;

  if( _.unrollIs( src ) )
  return _.unrollMake( src );
  else if( _.arrayIs( src ) )
  return src.slice();
  else if( _.argumentsArrayIs( src ) )
  return Array.prototype.slice.call( src );
  else if( _.bufferRawIs( src ) )
  return new U8x( new U8x( src ) ).buffer;
  else if( _.bufferTypedIs( src ) || _.bufferNodeIs( src ) )
  return new src.constructor( src );
  else if( _.bufferViewIs( src ) )
  return new src.constructor( src.buffer, src.byteOffset, src.byteLength );

  _.assert( 0, 'unknown kind of buffer', _.strType( src ) );
}

//

/**
 * The routine longShallowClone() makes new container with type defined by first argument. Routine clones content of provided arguments
 * into created container.
 *
 * @param { Long|Buffer } arguments[ 0 ] - Long or Buffer, defines type of returned container. If provided only {-arguments[ 0 ]-}, then
 * routine makes shallow copy of it.
 * @param { * } ... - Arguments to make copy into new container. Can have any types exclude undefined.
 *
 * @example
 * let src = [];
 * let got = _.longShallowClone( src );
 * console.log( got );
 * // log []
 * console.log( src === got );
 * // log false
 *
 * @example
 * var src = new U8x( [ 1, 2, 3, 4 ] );
 * var got = _.longShallowClone( src );
 * console.log( got );
 * // log Uint8Array [ 1, 2, 3, 4 ];
 * console.log( src === got );
 * // log false
 *
 * @example
 * let src = _.unrollMake( [] );
 * let got = _.longShallowClone( src, 1, 'str', new F32x( [ 3 ] ) );
 * console.log( got );
 * // log [ 1, 'str', 3 ]
 * console.log( _.unrollIs( got ) );
 * // log true
 * console.log( src === got );
 * // log false
 *
 * @example
 * let src = new BufferRaw( 3 );
 * let got = _.longShallowClone( src, 1, 2, _.argumentsArrayMake( [ 3, 4 ] ) );
 * console.log( got );
 * // log ArrayBuffer { [Uint8Contents]: <00 00 00 01 02 03 04>, byteLength: 7 }
 * console.log( src === got );
 * // log false
 *
 * @returns { Long|Buffer } - Returns a Long or a Buffer with type of first argument. Returned container filled by content of provided arguments.
 * @function longShallowClone
 * @throws { Error } If arguments.length is less than one.
 * @throws { Error } If the {-arguments[ 0 ]-} is not a Long or not a Buffer.
 * @throws { Error } If {-arguments-} has undefined value.
 * @memberof wTools
 */

/* zzz : review longShallowClone */

function longShallowClone()
{
  _.assert( arguments.length >= 1, 'Expects at least one argument' );

  if( arguments.length === 1 )
  {
    return _._longClone( arguments[ 0 ] );
  }

  /* eval length */

  let length = 0;

  for( let a = 0 ; a < arguments.length ; a++ )
  {
    let argument = arguments[ a ];

    _.assert( argument !== undefined, 'argument is not defined' );
    // if( argument === undefined )
    // throw _.err( 'argument is not defined' );

    if( _.longLike( argument ) || _.bufferNodeIs( argument ) )
    length += argument.length;
    else if( _.bufferRawIs( argument ) || _.bufferViewIs( argument ) )
    length += argument.byteLength;
    else
    length += 1;
  }

  /* make result */

  let result;
  let bufferDst;
  let offset = 0;

  if( _.bufferRawIs( arguments[ 0 ] ) )
  {
    result = new BufferRaw( length );
    bufferDst = new U8x( result );
  }
  else if( _.bufferViewIs( arguments[ 0 ] ) )
  {
    result = new BufferView( new BufferRaw( length ) );
    bufferDst = new U8x( result.buffer );
  }
  else
  {
    if( _.arrayIs( arguments[ 0 ] ) || _.bufferTypedIs( arguments[ 0 ] ) || _.argumentsArrayIs( arguments[ 0 ] ) )
    result = _.longMakeUndefined( arguments[ 0 ], length );
    else if( _.bufferNodeIs( arguments[ 0 ] ) )
    result = BufferNode.alloc( length );
    else
    _.assert( 0, 'Unexpected data type' );

    bufferDst = result;
  }

  /* copy */

  for( let a = 0; a < arguments.length ; a++ )
  {
    let srcTyped;
    let argument = arguments[ a ];
    if( _.bufferRawIs( argument ) )
    srcTyped = new U8x( argument );
    else if( _.bufferViewIs( argument ) )
    srcTyped = new U8x( argument.buffer );
    else if( _.bufferTypedIs( argument ) )
    srcTyped = argument;
    else if( _.longLike( argument ) || _.bufferNodeIs( argument ) )
    srcTyped = argument;
    else
    srcTyped = [ argument ];

    for( let i = 0; i < srcTyped.length; i++ )
    bufferDst[ i + offset ] = srcTyped[ i ];

    offset += srcTyped.length;
  }

  // for( let a = 0, c = 0 ; a < arguments.length ; a++ )
  // {
  //   let argument = arguments[ a ];
  //   if( _.bufferRawIs( argument ) )
  //   {
  //     bufferDst.set( new U8x( argument ), offset );
  //     offset += argument.byteLength;
  //   }
  //   else if( _.bufferTypedIs( arguments[ 0 ] ) )
  //   {
  //     result.set( argument, offset );
  //     offset += argument.length;
  //   }
  //   else if( _.longLike( argument ) )
  //   for( let i = 0 ; i < argument.length ; i++ )
  //   {
  //     result[ c ] = argument[ i ];
  //     c += 1;
  //   }
  //   else
  //   {
  //     result[ c ] = argument;
  //     c += 1;
  //   }
  // }

  return result;
}

//

/* aaa : add good coverage for longFrom. */
/* Dmytro : covered, two test routines implemented */

function longFrom( src )
{
  _.assert( arguments.length === 1 );
  if( src instanceof this.longDescriptor.type )
  if( !_.unrollIs( src ) )
  return src;
  return this.longMake.call( this, src );
}

//

/**
 * The longFromCoercing() routine converts an object-like {-srcMap-} into Array.
 *
 * @param { * } src - To convert into Array.
 *
 * @example
 * _.longFromCoercing( [ 3, 7, 13, 'abc', false, undefined, null, {} ] );
 * // returns [ 3, 7, 13, 'abc', false, undefined, null, {} ]
 *
 * @example
 * _.longFromCoercing( { a : 3, b : 7, c : 13 } );
 * // returns [ [ 'a', 3 ], [ 'b', 7 ], [ 'c', 13 ] ]
 *
 * @example
 * _.longFromCoercing( "3, 7, 13, 3.5abc, 5def, 7.5ghi, 13jkl" );
 * // returns [ 3, 7, 13, 3.5, 5, 7.5, 13 ]
 *
 * @example
 * let args = ( function() {
 *   return arguments;
 * } )( 3, 7, 13, 'abc', false, undefined, null, { greeting: 'Hello there!' } );
 * _.longFromCoercing( args );
 * // returns [ 3, 7, 13, 'abc', false, undefined, null, { greeting: 'Hello there!' } ]
 *
 * @returns { Array } Returns an Array.
 * @function longFromCoercing
 * @throws { Error } Will throw an Error if {-srcMap-} is not an object-like.
 * @memberof wTools
 */

function longFromCoercing( src )
{

  _.assert( arguments.length === 1, 'Expects single argument' );

  if( src instanceof this.longDescriptor.type && _.longIs( src ) )
  return src;

  /* Dmytro : this condition make recursive call with array, it's like next condition but without recursive call */
  // if( _.argumentsArrayIs( src ) )
  // return this.longFromCoercing( Array.prototype.slice.call( src ) );

  if( _.longIs( src ) )
  return this.longDescriptor.from( src );

  if( _.objectIs( src ) )
  return this.longFromCoercing( _.mapToArray( src ) );

  /* aaa : cover */
  /* Dmytro : covered */
  if( _.strIs( src ) )
  return this.longFromCoercing( this.arrayFromStr( src ) );

  _.assert( 0, `Unknown data type : ${ _.strType( src ) }` );
}

//

/**
 * The longRepresent() routine returns a shallow copy of a portion of an array
 * or a new TypedArray that contains
 * the elements from (begin) index to the (end) index,
 * but not including (end).
 *
 * @param { Array } src - Source array.
 * @param { Number } begin - Index at which to begin extraction.
 * @param { Number } end - Index at which to end extraction.<commit_msg>Fix routine `longFrom`, routine does not return not longs<commit_after>( function _fLong_s_() {

'use strict';

let _ArrayIndexOf = Array.prototype.indexOf;
let _ArrayIncludes = Array.prototype.includes;
if( !_ArrayIncludes )
_ArrayIncludes = function( e ){ _ArrayIndexOf.call( this, e ) }

let _global = _global_;
let _ = _global_.wTools;
let Self = _global_.wTools;

/*
               |  can grow   |  can shrink  |   range
grow                +                -         positive
select              -                +         positive
relength            +                +         positive
but                 -                +         negative
*/

/* array / long / buffer */
/* - / inplace */

// --
// arguments array
// --

function argumentsArrayMake( src )
{
  _.assert( arguments.length === 1 );
  _.assert( _.numberIs( src ) || _.longLike( src ) );
  if( _.numberIs( src ) )
  return _argumentsArrayMake.apply( _, Array( src ) );
  else
  return _argumentsArrayMake.apply( _, src );
}

//

function _argumentsArrayMake()
{
  return arguments;
}

//

function argumentsArrayFrom( src )
{
  _.assert( arguments.length === 1, 'Expects single argument' );
  if( _.argumentsArrayIs( src ) )
  return src;
  return _.argumentsArrayMake( src );
}

// --
// long
// --

function _longMake_functor( onMake )
{

  _.assert( _.routineIs( onMake ) );

  return function _longMake( src, ins )
  {
    let result;

    /* */

    let length = ins;

    if( _.longLike( length ) )
    length = length.length;

    if( length === undefined || length === null )
    {
      if( src === null )
      {
        length = 0;
      }
      else if( _.longLike( src ) )
      {
        length = src.length;
      }
      else if( _.numberIs( src ) )
      {
        length = src;
        src = null;
      }
      else if( _.routineIs( src ) )
      {
        length = 0;
      }
      else _.assert( 0 );
    }

    if( !length )
    length = 0;

    /* */

    if( ins === undefined || ins === null )
    {
      if( _.longLike( src ) )
      {
        if( ins === null )
        {
          ins = src;
        }
        else
        {
          ins = src;
          src = null;
        }
      }
      else
      {
        ins = null;
      }
    }
    else if( !_.longLike( ins ) )
    {
      if( _.longIs( src ) )
      ins = src;
      else
      ins = null;
    }

    /**/

    let minLength;
    if( ins )
    minLength = Math.min( ins.length, length );
    else
    minLength = 0;

    /**/

    if( _.argumentsArrayIs( src ) )
    src = null;

    if( src === null )
    src = this.longDescriptor.make;

    _.assert( arguments.length === 1 || arguments.length === 2 );
    _.assert( _.numberIsFinite( length ) );
    _.assert( _.routineIs( src ) || _.longLike( src ), () => 'Expects long, but got ' + _.strType( src ) );

    result = onMake.call( this, src, ins, length, minLength );

    _.assert( _.longLike( result ) );

    return result;
  }

}

//

/**
 * The routine longMake() returns a new Long with the same type as source Long (src). New Long makes from inserted Long (ins)
 * or if (ins) is number, the Long makes from (src) with length equal to (ins). If (ins) is not provided, routine returns copy of (src).
 *
 * @param { Long } src - Instance of Long or constructor, defines type of returned Long. If null is provided, routine returns empty array.
 * @param { Number|Long } ins - Defines length of new Long. If Long is provided, routine makes new Long from {-ins-} with {-src-} type.
 *
 * @example
 * _.longMake( null );
 * // returns []
 *
 * @example
 * _.longMake( [ 1, 2, 3, 4 ] );
 * // returns [ 1, 2, 3, 4 ];
 *
 * @example
 * let src = _.unrollMake( [] );
 * let got = _.longMake( src, [ 1, 2, 3 ] );
 * console.log( got );
 * // log [ 1, 2, 3 ];
 * console.log( _.unrollIs( got ) );
 * // log true
 *
 * @example
 * let src = new F32x( [ 1, 2, 3, 4, 5 ] );
 * let got = _.longMake( src, 2 );
 * console.log( got );
 * // log Float32Array[ 1, 2 ];
 * console.log( _.bufferTypedIs( got ) );
 * // log true
 *
 * @returns { Long } Returns a Long with type of source Long which makes from ins.
 * @function longMake
 * @throws { Error } If arguments.length is less than two or more then two.
 * @throws { Error } If {-ins-} is not a number and not a Long.
 * @throws { Error } If {-src-} is not a Long or not a constructor.
 * @throws { Error } If {-ins-} or ins.length has a not finite value.
 * @memberof wTools
 */

/* aaa : extend coverage and documentation of longMake */
/* Dmytro : extended coverage and documentation of routine longMake */
/* aaa : longMake does not create unrolls, but should */
/* Dmytro : longMake creates unrolls */

let longMake = _longMake_functor( function( src, ins, length, minLength )
{
  let result;

  if( _.routineIs( src ) )
  {
    if( ins && ins.length === length )
    {
      if( src === Array )
      {
        if( _.longLike( ins ) )
        {
          if( ins.length === 1 )
          result = [ ins[ 0 ] ];
          else if( !_.arrayLike( ins ) )
          result = new( _.constructorJoin( src, [ ... ins ] ) );
          else
          result = new( _.constructorJoin( src, ins ) );
        }
        else
        {
          result = new src( ins );
        }
      }
      else
      {
        result = new src( ins );
      }
    }
    else
    {
      result = new src( length );
      // let minLength = Math.min( length, ins.length );
      // if( !ins && minLength )
      // debugger;
      for( let i = 0 ; i < minLength ; i++ )
      result[ i ] = ins[ i ];
    }
  }
  else if( _.arrayIs( src ) )
  {
    if( ins && length === ins.length )
    {
      result = _.unrollIs( src ) ? _.unrollMake( ins ) : new( _.constructorJoin( src.constructor, ins ) );
    }
    else
    {
      _.assert( length >= 0 );
      result = _.unrollIs( src ) ? _.unrollMake( length ) : new src.constructor( length );
      // let minLength = Math.min( length, ins.length );
      for( let i = 0 ; i < minLength ; i++ )
      result[ i ] = ins[ i ];
    }
  }
  else
  {
    if( ins && length === ins.length )
    {
      result = new src.constructor( ins );
    }
    else
    {
      result = new src.constructor( length );
      // let minLength = Math.min( length, ins.length );
      for( let i = 0 ; i < minLength ; i++ )
      result[ i ] = ins[ i ];
    }
  }

  return result;
});

// function longMake( src, ins )
// {
//   let result;
//   let length = ins;
//
//   if( _.longLike( length ) )
//   length = length.length;
//
//   if( length === undefined )
//   {
//     if( src === null )
//     {
//       length = 0;
//     }
//     else if( _.longLike( src ) )
//     {
//       length = src.length;
//     }
//     else if( _.numberIs( src ) )
//     {
//       length = src;
//       src = null;
//     }
//     else _.assert( 0 );
//   }
//
//   // if( !_.longLike( ins ) )
//   // {
//   //   if( _.longLike( src ) )
//   //   ins = src;
//   //   else
//   //   ins = [];
//   // }
//
//   if( !_.longLike( ins ) )
//   {
//     if( _.longLike( src ) )
//     {
//       ins = src;
//       src = null;
//     }
//     else
//     {
//       ins = [];
//     }
//   }
//
//   if( !length )
//   length = 0;
//
//   if( _.argumentsArrayIs( src ) )
//   src = null;
//
//   if( src === null )
//   src = this.longDescriptor.make;
//
//   _.assert( arguments.length === 1 || arguments.length === 2 );
//   _.assert( _.numberIsFinite( length ) );
//   _.assert( _.routineIs( src ) || _.longLike( src ), () => 'Expects long, but got ' + _.strType( src ) );
//
//   if( _.routineIs( src ) )
//   {
//     if( ins.length === length )
//     {
//       if( src === Array )
//       {
//         if( _.longLike( ins ) )
//         {
//           if( ins.length === 1 )
//           result = [ ins[ 0 ] ];
//           else if( !_.arrayLike( ins ) )
//           result = new( _.constructorJoin( src, [ ... ins ] ) );
//           else
//           result = new( _.constructorJoin( src, ins ) );
//         }
//         else
//         {
//           result = new src( ins );
//         }
//       }
//       else
//       {
//         result = new src( ins );
//       }
//     }
//     else
//     {
//       result = new src( length );
//       let minLen = Math.min( length, ins.length );
//       for( let i = 0 ; i < minLen ; i++ )
//       result[ i ] = ins[ i ];
//     }
//   }
//   else if( _.arrayIs( src ) )
//   {
//     if( length === ins.length )
//     {
//       result = _.unrollIs( src ) ? _.unrollMake( ins ) : new( _.constructorJoin( src.constructor, ins ) );
//     }
//     else
//     {
//       _.assert( length >= 0 );
//       result = _.unrollIs( src ) ? _.unrollMake( length ) : new src.constructor( length );
//       let minLen = Math.min( length, ins.length );
//       for( let i = 0 ; i < minLen ; i++ )
//       result[ i ] = ins[ i ];
//     }
//   }
//   else
//   {
//     if( length === ins.length )
//     {
//       result = new src.constructor( ins );
//     }
//     else
//     {
//       result = new src.constructor( length );
//       let minLen = Math.min( length, ins.length );
//       for( let i = 0 ; i < minLen ; i++ )
//       result[ i ] = ins[ i ];
//     }
//   }
//
//   _.assert( result instanceof this.longDescriptor.type );
//   // _.assert( _.longLike( result ) );
//
//   return result;
// }

//

/* aaa : implement test */
/* Dmytro : implemented */

function longMakeEmpty( src )
{
  if( arguments.length === 0 )
  return this.longDescriptor.make( 0 );

  _.assert( arguments.length === 1 );

  if( _.unrollIs( src ) )
  return _.unrollMake( 0 );
  else if( src === null || _.argumentsArrayIs( src ) )
  return this.longDescriptor.make( 0 );
  else if( _.arrayIs( src ) || _.bufferTypedIs( src ) )
  return new src.constructor();
  else if( _.routineIs( src ) )
  {
    let result = new src.constructor();
    _.assert( _.longIs( result ) && result.length === 0, 'Constructor should return empty long' );
    return result;
  }
  _.assert( 0, 'Unknown how to construct long' );
}

// function longMakeEmpty( src )
// {
//   let result;
//   let length = 0;
//
//   if( src === null )
//   src = [];
//
//   if( _.argumentsArrayIs( src ) )
//   src = [];
//
//   _.assert( arguments.length === 1 );
//
//   result = new src.constructor();
//
//   _.assert( _.longIs( result ) );
//   _.assert( result.length === 0 );
//
//   return result;
// }

//

let _longMakeOfLength = _longMake_functor( function( src, ins, length, minLength )
{
  let result;

  if( _.routineIs( src ) )
  {
    result = new src( length );
  }
  else if( _.arrayIs( src ) )
  {
    if( length === src.length )
    {
      result = new( _.constructorJoin( src.constructor, src ) );
    }
    else if( length < src.length )
    {
      result = src.slice( 0, length );
    }
    else
    {
      result = new src.constructor( length );
      for( let i = 0 ; i < minLength ; i++ )
      result[ i ] = src[ i ];
    }
  }
  else
  {
    if( length === src.length )
    {
      result = new src.constructor( length );
    }
    else
    {
      result = new src.constructor( length );
      for( let i = 0 ; i < minLength ; i++ )
      result[ i ] = src[ i ];
    }
  }

  return result;
});

// function _longMakeOfLength( src, len )
// {
//   let result;
// 
//   // if( src === null )
//   // src = [];
// 
//   if( _.longLike( len ) )
//   len = len.length;
// 
//   if( len === undefined )
//   {
//     if( src === null )
//     {
//       len = 0;
//     }
//     else if( _.longLike( src ) )
//     {
//       len = src.length;
//     }
//     else if( _.numberIs( src ) )
//     {
//       len = src;
//       src = null;
//     }
//     else _.assert( 0 );
//   }
// 
//   if( !len )
//   len = 0;
// 
//   if( _.argumentsArrayIs( src ) )
//   src = this.longDescriptor.name === 'ArgumentsArray' ? this.longDescriptor.make : this.longDescriptor.make( src );
// 
//   if( src === null )
//   src = this.longDescriptor.make;
// 
//   _.assert( arguments.length === 1 || arguments.length === 2 );
//   _.assert( _.numberIsFinite( len ) );
//   _.assert( _.routineIs( src ) || _.longLike( src ), () => 'Expects long, but got ' + _.strType( src ) );
// 
//   if( _.routineIs( src ) )
//   {
//     result = new src( len );
//   }
//   else if( _.arrayIs( src ) )
//   {
//     if( len === src.length )
//     {
//       result = new( _.constructorJoin( src.constructor, src ) );
//     }
//     else if( len < src.length )
//     {
//       result = src.slice( 0, len );
//     }
//     else
//     {
//       result = new src.constructor( len );
//       let minLen = Math.min( len, src.length );
//       for( let i = 0 ; i < minLen ; i++ )
//       result[ i ] = src[ i ];
//     }
//   }
//   else
//   {
//     if( len === src.length )
//     {
//       result = new src.constructor( len );
//     }
//     else
//     {
//       result = new src.constructor( len );
//       let minLen = Math.min( len, src.length );
//       for( let i = 0 ; i < minLen ; i++ )
//       result[ i ] = src[ i ];
//     }
//   }
// 
//   _.assert( _.longLike( result ), 'Instance should be a long' );
// 
//   return result;
// }

//

/**
 * The routine longMakeUndefined() returns a new Long with the same type as source Long {-src-}. New Long has length equal to {-len-}
 * or it has length of source Long {-src-} if second argument is not provided.
 *
 * @param { Long } ins - Long or constructor, defines type of returned Long. If null is provided, routine returns empty array.
 * @param { Number|Long } len - Defines length of new Long. If Long is provided, routine makes new Long with length equal to ins.length.
 *
 * @example
 * _.longMakeUndefined( null );
 * // returns []
 *
 * @example
 * _.longMakeUndefined( [ 1, 2, 3, 4 ] );
 * // returns [ undefined, undefined, undefined, undefined ];
 *
 * @example
 * let src = _.unrollMake( [] )
 * let got = _.longMakeUndefined( src, [ 1, 2, 3 ] );
 * console.log( got );
 * // log [ undefined, undefined, undefined ];
 * console.log( _.unrollIs( got ) );
 * // log true
 *
 * @example
 * let src = new F32x( [ 1, 2, 3, 4, 5] )
 * let got = _.longMakeUndefined( src, 2 );
 * console.log( got );
 * // log Float32Array[ undefined, undefined ];
 * console.log( _.bufferTypedIs( got ) );
 * // log true
 *
 * @returns { Long } - Returns a Long with type of source Long with a certain length.
 * @function longMakeUndefined
 * @throws { Error } If arguments.length is less than one or more then two.
 * @throws { Error } If the {-ins-} is not a Long or not a constructor.
 * @throws { Error } If the {-len-} is not a number or not a Long.
 * @throws { Error } If the {-len-} or ins.length has a not finite value.
 * @throws { Error } If the {-len-} is undefined and ins.length is not a number.
 * @memberof wTools
 */

/*
qqq : extend coverage and documentation of longMakeUndefined | Dmytro : routine is covered and documented
qqq : longMakeUndefined does not create unrolls, but should | Dmytro : longMakeUndefined creates unrolls.
*/

let longMakeUndefined = _longMake_functor( function( src, ins, length, minLength )
{
  let result;

  if( _.routineIs( src ) )
  result = new src( length );
  else if( _.unrollIs( src ) )
  result = _.unrollMake( length );
  else if( src === null )
  result = this.longDescriptor.make( length );
  else
  result = new src.constructor( length );

  return result;
})

// function longMakeUndefined( ins, len )
// {
//   let result, length;
//
//   /* aaa3 : ask. use default long container */
//   /* Dmytro : explained, used this.longDescriptor */
//   // if( ins === null )
//   // result = [];
//
//   if( len === undefined )
//   {
//     if( ins === null )
//     {
//       length = 0;
//     }
//     else if( _.numberIs( ins ) )
//     {
//       length = ins;
//       ins = null;
//     }
//     else
//     {
//       length = ins.length;
//     }
//   }
//   else
//   {
//     if( _.longLike( len ) )
//     length = len.length;
//     else if( _.numberIs( len ) )
//     length = len;
//     else _.assert( 0 );
//   }
//
//   if( _.argumentsArrayIs( ins ) )
//   ins = null;
//
//   _.assert( arguments.length === 1 || arguments.length === 2 );
//   _.assert( _.numberIsFinite( length ) );
//   _.assert( _.routineIs( ins ) || _.longLike( ins ) || ins === null, () => 'Expects long, but got ' + _.strType( ins ) );
//
//   if( _.routineIs( ins ) )
//   result = new ins( length );
//   else if( _.unrollIs( ins ) )
//   result = _.unrollMake( length );
//   else if( ins === null ) /* aaa3 : ask */
//   result = this.longDescriptor.make( length );
//   else
//   result = new ins.constructor( length );
//
//   return result;
// }

//

/* qqq3 : teach to accept only length */
/* qqq3 : use default long type if type is not clear */
/* qqq3 : allow buffers which are long */
/* qqq3 : relevant to all routines longMake* of such kind */

let longMakeZeroed = _longMake_functor( function( src, ins, length, minLength )
{
  let result;

  if( _.routineIs( src ) )
  result = new src( length );
  else if( _.unrollIs( src ) )
  result = _.unrollMake( length );
  else if( src === null )
  result = this.longDescriptor.make( length );
  else
  result = new src.constructor( length );

  if( !_.bufferTypedIs( result ) )
  for( let i = 0 ; i < length ; i++ )
  result[ i ] = 0;

  return result;
})

// function longMakeZeroed( ins, src )
// {
//   let result, length;
//
//   if( _.routineIs( ins ) )
//   _.assert( arguments.length === 2, 'Expects exactly two arguments' );
//
//   if( src === undefined )
//   {
//     length = ins.length;
//   }
//   else
//   {
//     if( _.longLike( src ) )
//     length = src.length;
//     else if( _.numberIs( src ) )
//     length = src;
//     else _.assert( 0, 'Expects long or number as the second argument, got', _.strType( src ) );
//   }
//
//   if( _.argumentsArrayIs( ins ) )
//   ins = [];
//
//   _.assert( arguments.length === 1 || arguments.length === 2 );
//   _.assert( _.numberIsFinite( length ) );
//   _.assert( _.routineIs( ins ) || _.longLike( ins ), () => 'Expects long, but got ' + _.strType( ins ) );
//
//   if( _.routineIs( ins ) )
//   result = new ins( length );
//   else if( _.unrollIs( ins ) )
//   result = _.unrollMake( length );
//   else
//   result = new ins.constructor( length );
//
//   if( !_.bufferTypedIs( result ) )
//   for( let i = 0 ; i < length ; i++ )
//   result[ i ] = 0;
//
//   return result;
// }

//

/*
aaa : find and let me know what is _.buffer* analog of _longClone |
aaa Dmytro : module has not _.buffer* analog of routine _longClone. The closest functionality has routine bufferMake( ins, src )
zzz
*/

function _longClone( src )
{

  _.assert( arguments.length === 1, 'Expects single argument' );
  _.assert( _.longLike( src ) || _.bufferAnyIs( src ) );
  // _.assert( !_.bufferNodeIs( src ), 'not tested' );

  if( _.bufferViewIs( src ) )
  debugger;

  if( _.unrollIs( src ) )
  return _.unrollMake( src );
  else if( _.arrayIs( src ) )
  return src.slice();
  else if( _.argumentsArrayIs( src ) )
  return Array.prototype.slice.call( src );
  else if( _.bufferRawIs( src ) )
  return new U8x( new U8x( src ) ).buffer;
  else if( _.bufferTypedIs( src ) || _.bufferNodeIs( src ) )
  return new src.constructor( src );
  else if( _.bufferViewIs( src ) )
  return new src.constructor( src.buffer, src.byteOffset, src.byteLength );

  _.assert( 0, 'unknown kind of buffer', _.strType( src ) );
}

//

/**
 * The routine longShallowClone() makes new container with type defined by first argument. Routine clones content of provided arguments
 * into created container.
 *
 * @param { Long|Buffer } arguments[ 0 ] - Long or Buffer, defines type of returned container. If provided only {-arguments[ 0 ]-}, then
 * routine makes shallow copy of it.
 * @param { * } ... - Arguments to make copy into new container. Can have any types exclude undefined.
 *
 * @example
 * let src = [];
 * let got = _.longShallowClone( src );
 * console.log( got );
 * // log []
 * console.log( src === got );
 * // log false
 *
 * @example
 * var src = new U8x( [ 1, 2, 3, 4 ] );
 * var got = _.longShallowClone( src );
 * console.log( got );
 * // log Uint8Array [ 1, 2, 3, 4 ];
 * console.log( src === got );
 * // log false
 *
 * @example
 * let src = _.unrollMake( [] );
 * let got = _.longShallowClone( src, 1, 'str', new F32x( [ 3 ] ) );
 * console.log( got );
 * // log [ 1, 'str', 3 ]
 * console.log( _.unrollIs( got ) );
 * // log true
 * console.log( src === got );
 * // log false
 *
 * @example
 * let src = new BufferRaw( 3 );
 * let got = _.longShallowClone( src, 1, 2, _.argumentsArrayMake( [ 3, 4 ] ) );
 * console.log( got );
 * // log ArrayBuffer { [Uint8Contents]: <00 00 00 01 02 03 04>, byteLength: 7 }
 * console.log( src === got );
 * // log false
 *
 * @returns { Long|Buffer } - Returns a Long or a Buffer with type of first argument. Returned container filled by content of provided arguments.
 * @function longShallowClone
 * @throws { Error } If arguments.length is less than one.
 * @throws { Error } If the {-arguments[ 0 ]-} is not a Long or not a Buffer.
 * @throws { Error } If {-arguments-} has undefined value.
 * @memberof wTools
 */

/* zzz : review longShallowClone */

function longShallowClone()
{
  _.assert( arguments.length >= 1, 'Expects at least one argument' );

  if( arguments.length === 1 )
  {
    return _._longClone( arguments[ 0 ] );
  }

  /* eval length */

  let length = 0;

  for( let a = 0 ; a < arguments.length ; a++ )
  {
    let argument = arguments[ a ];

    _.assert( argument !== undefined, 'argument is not defined' );
    // if( argument === undefined )
    // throw _.err( 'argument is not defined' );

    if( _.longLike( argument ) || _.bufferNodeIs( argument ) )
    length += argument.length;
    else if( _.bufferRawIs( argument ) || _.bufferViewIs( argument ) )
    length += argument.byteLength;
    else
    length += 1;
  }

  /* make result */

  let result;
  let bufferDst;
  let offset = 0;

  if( _.bufferRawIs( arguments[ 0 ] ) )
  {
    result = new BufferRaw( length );
    bufferDst = new U8x( result );
  }
  else if( _.bufferViewIs( arguments[ 0 ] ) )
  {
    result = new BufferView( new BufferRaw( length ) );
    bufferDst = new U8x( result.buffer );
  }
  else
  {
    if( _.arrayIs( arguments[ 0 ] ) || _.bufferTypedIs( arguments[ 0 ] ) || _.argumentsArrayIs( arguments[ 0 ] ) )
    result = _.longMakeUndefined( arguments[ 0 ], length );
    else if( _.bufferNodeIs( arguments[ 0 ] ) )
    result = BufferNode.alloc( length );
    else
    _.assert( 0, 'Unexpected data type' );

    bufferDst = result;
  }

  /* copy */

  for( let a = 0; a < arguments.length ; a++ )
  {
    let srcTyped;
    let argument = arguments[ a ];
    if( _.bufferRawIs( argument ) )
    srcTyped = new U8x( argument );
    else if( _.bufferViewIs( argument ) )
    srcTyped = new U8x( argument.buffer );
    else if( _.bufferTypedIs( argument ) )
    srcTyped = argument;
    else if( _.longLike( argument ) || _.bufferNodeIs( argument ) )
    srcTyped = argument;
    else
    srcTyped = [ argument ];

    for( let i = 0; i < srcTyped.length; i++ )
    bufferDst[ i + offset ] = srcTyped[ i ];

    offset += srcTyped.length;
  }

  // for( let a = 0, c = 0 ; a < arguments.length ; a++ )
  // {
  //   let argument = arguments[ a ];
  //   if( _.bufferRawIs( argument ) )
  //   {
  //     bufferDst.set( new U8x( argument ), offset );
  //     offset += argument.byteLength;
  //   }
  //   else if( _.bufferTypedIs( arguments[ 0 ] ) )
  //   {
  //     result.set( argument, offset );
  //     offset += argument.length;
  //   }
  //   else if( _.longLike( argument ) )
  //   for( let i = 0 ; i < argument.length ; i++ )
  //   {
  //     result[ c ] = argument[ i ];
  //     c += 1;
  //   }
  //   else
  //   {
  //     result[ c ] = argument;
  //     c += 1;
  //   }
  // }

  return result;
}

//

/* aaa : add good coverage for longFrom. */
/* Dmytro : covered, two test routines implemented */

function longFrom( src )
{
  _.assert( arguments.length === 1 );
  if( src instanceof this.longDescriptor.type )
  if( !_.unrollIs( src ) && _.longIs( src ) )
  return src;
  return this.longMake.call( this, src );
}

//

/**
 * The longFromCoercing() routine converts an object-like {-srcMap-} into Array.
 *
 * @param { * } src - To convert into Array.
 *
 * @example
 * _.longFromCoercing( [ 3, 7, 13, 'abc', false, undefined, null, {} ] );
 * // returns [ 3, 7, 13, 'abc', false, undefined, null, {} ]
 *
 * @example
 * _.longFromCoercing( { a : 3, b : 7, c : 13 } );
 * // returns [ [ 'a', 3 ], [ 'b', 7 ], [ 'c', 13 ] ]
 *
 * @example
 * _.longFromCoercing( "3, 7, 13, 3.5abc, 5def, 7.5ghi, 13jkl" );
 * // returns [ 3, 7, 13, 3.5, 5, 7.5, 13 ]
 *
 * @example
 * let args = ( function() {
 *   return arguments;
 * } )( 3, 7, 13, 'abc', false, undefined, null, { greeting: 'Hello there!' } );
 * _.longFromCoercing( args );
 * // returns [ 3, 7, 13, 'abc', false, undefined, null, { greeting: 'Hello there!' } ]
 *
 * @returns { Array } Returns an Array.
 * @function longFromCoercing
 * @throws { Error } Will throw an Error if {-srcMap-} is not an object-like.
 * @memberof wTools
 */

function longFromCoercing( src )
{

  _.assert( arguments.length === 1, 'Expects single argument' );

  if( src instanceof this.longDescriptor.type && _.longIs( src ) )
  return src;

  /* Dmytro : this condition make recursive call with array from argumentsArray. But first condition return any long object
     ( ArgumentsArray.type is  Object ), and next make other long types without recursive call */
  // if( _.argumentsArrayIs( src ) )
  // return this.longFromCoercing( Array.prototype.slice.call( src ) );

  if( _.longIs( src ) )
  return this.longDescriptor.from( src );

  if( _.objectIs( src ) )
  return this.longFromCoercing( _.mapToArray( src ) );

  /* aaa : cover */
  /* Dmytro : covered */
  if( _.strIs( src ) )
  return this.longFromCoercing( this.arrayFromStr( src ) );

  _.assert( 0, `Unknown data type : ${ _.strType( src ) }` );
}

//

/**
 * The longRepresent() routine returns a shallow copy of a portion of an array
 * or a new TypedArray that contains
 * the elements from (begin) index to the (end) index,
 * but not including (end).
 *
 * @param { Array } src - Source array.
 * @param { Number } begin - Index at which to begin extraction.
 * @param { Number } end - Index at which to end extraction.
{'fraction_non_alphanumeric': 0.17090784697542713, 'fraction_numerical': 0.00870408027518577, 'mean_word_length': 1.953359151372285, 'pattern_counts': {'":': 0, '<': 43, '<?xml version=': 0, '>': 21, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 14, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '6794608', 'n_tokens_mistral': 18010, 'n_tokens_neox': 17476, 'n_words': 5324}