'use strict';

/**
* Allocate a buffer from an `ArrayBuffer`.
*
* @module @stdlib/buffer/from-arraybuffer
*
* @example
* var ArrayBuffer = require( '@stdlib/array/buffer' );
* var arraybuffer2buffer = require( '@stdlib/type/buffer/from-arraybuffer' );
*
* var ab = new ArrayBuffer( 10 );
* var buf = arraybuffer2buffer( ab );
* // returns <Buffer>
*/

// MODULES //

var hasFrom = require( './has_from.js' );


// MAIN //

var arraybuffer2buffer;
if ( hasFrom ) {
	arraybuffer2buffer = require( './main.js' );
} else {
	arraybuffer2buffer = require( './polyfill.js' );
}


// EXPORTS //

module.exports = arraybuffer2buffer;

'use strict';

/**
* Allocate a buffer from an `ArrayBuffer`.
*
* @module @stdlib/buffer/from-arraybuffer
*
* @example
* var ArrayBuffer = require( '@stdlib/array/buffer' );
* var arraybuffer2buffer = require( '@stdlib/type/buffer/from-arraybuffer' );
*
* var ab = new ArrayBuffer( 10 );
* var buf = arraybuffer2buffer( ab );
* // returns <Buffer>
*/

// MODULES //

var hasFrom = require( './has_from.js' );
var main = require( './main.js' );
var polyfill = require( './polyfill.js' );


// MAIN //

var arraybuffer2buffer;
if ( hasFrom ) {
	arraybuffer2buffer = main;
} else {
	arraybuffer2buffer = polyfill;
}


// EXPORTS //

module.exports = arraybuffer2buffer;

Refactor to avoid dynamic module resolution
Refactor to avoid dynamic module resolution
