Sha256: 51e3d0e248596f0529a5f21dc3c082d0c9286a651c930e3a99087b43ec53880f

Contents?: true

Size: 1.32 KB

Versions: 27

Compression:

Stored size: 1.32 KB

Contents

'use strict';

var test = require('tape');
var inspect = require('object-inspect');
var forEach = require('for-each');
var v = require('es-value-fixtures');
var availableTypedArrays = require('available-typed-arrays')();

var isArrayBuffer = require('..');

test('isArrayBuffer', function (t) {
	t.equal(typeof isArrayBuffer, 'function', 'is a function');

	var nonABs = v.primitives.concat(
		v.objects,
		typeof SharedArrayBuffer === 'function' ? new SharedArrayBuffer() : []
	);
	forEach(nonABs, function (nonAB) {
		t.equal(isArrayBuffer(nonAB), false, inspect(nonAB) + ' is not an ArrayBuffer');
	});

	t.test('actual ArrayBuffer instances', { skip: typeof ArrayBuffer === 'undefined' }, function (st) {
		var ab = new ArrayBuffer();
		st.equal(isArrayBuffer(ab), true, inspect(ab) + ' is an ArrayBuffer');

		var ab42 = new ArrayBuffer(42);
		st.equal(isArrayBuffer(ab42), true, inspect(ab42) + ' is an ArrayBuffer');

		st.end();
	});

	t.test('Typed Arrays', { skip: availableTypedArrays.length === 0 }, function (st) {
		forEach(availableTypedArrays, function (TypedArray) {
			var ta = new global[TypedArray](0);
			st.equal(isArrayBuffer(ta.buffer), true, inspect(ta.buffer) + ', the TA\'s buffer, is an ArrayBuffer');
			st.equal(isArrayBuffer(ta), false, inspect(ta) + ' is not an ArrayBuffer');
		});

		st.end();
	});

	t.end();
});

Version data entries

27 entries across 27 versions & 2 rubygems

Version Path
immosquare-cleaner-0.1.32 node_modules/is-array-buffer/test/index.js
immosquare-cleaner-0.1.31 node_modules/is-array-buffer/test/index.js
immosquare-cleaner-0.1.30 node_modules/is-array-buffer/test/index.js
immosquare-cleaner-0.1.29 node_modules/is-array-buffer/test/index.js
immosquare-cleaner-0.1.28 node_modules/is-array-buffer/test/index.js
immosquare-cleaner-0.1.27 node_modules/is-array-buffer/test/index.js
immosquare-cleaner-0.1.26 node_modules/is-array-buffer/test/index.js
immosquare-cleaner-0.1.25 node_modules/is-array-buffer/test/index.js
immosquare-cleaner-0.1.24 node_modules/is-array-buffer/test/index.js
immosquare-cleaner-0.1.23 node_modules/is-array-buffer/test/index.js
immosquare-cleaner-0.1.22 node_modules/is-array-buffer/test/index.js
immosquare-cleaner-0.1.21 node_modules/is-array-buffer/test/index.js
immosquare-cleaner-0.1.20 node_modules/is-array-buffer/test/index.js
immosquare-cleaner-0.1.19 node_modules/is-array-buffer/test/index.js
immosquare-cleaner-0.1.18 node_modules/is-array-buffer/test/index.js
immosquare-cleaner-0.1.17 node_modules/is-array-buffer/test/index.js
immosquare-cleaner-0.1.16 node_modules/is-array-buffer/test/index.js
immosquare-cleaner-0.1.14 node_modules/is-array-buffer/test/index.js
immosquare-cleaner-0.1.13 node_modules/is-array-buffer/test/index.js
immosquare-cleaner-0.1.12 node_modules/is-array-buffer/test/index.js