-*/
-function hasArrayBufferSupport() {
- var bool;
- var view;
- var buf;
-
- if ( typeof GlobalArrayBuffer !== 'function' ) {
- return false;
- }
- // Test basic support...
- try {
- buf = new GlobalArrayBuffer( 16 );
- bool = ( isArrayBuffer( buf ) && typeof GlobalArrayBuffer.isView === 'function' );
- if ( bool ) {
- view = new Float64Array( buf );
- view[ 0 ] = -3.14;
- view[ 1 ] = NaN;
- bool = (
- bool &&
- GlobalArrayBuffer.isView( view ) &&
- buf.byteLength === 16 &&
- view[ 0 ] === -3.14 &&
- view[ 1 ] !== view[ 1 ]
- );
- }
- } catch ( err ) { // eslint-disable-line no-unused-vars
- bool = false;
- }
- return bool;
-}
-
-
-// EXPORTS //
-
-module.exports = hasArrayBufferSupport;
diff --git a/package.json b/package.json
index 941ad1a..3d74fa9 100644
--- a/package.json
+++ b/package.json
@@ -3,34 +3,7 @@
"version": "0.2.2",
"description": "Detect native ArrayBuffer support.",
"license": "Apache-2.0",
- "author": {
- "name": "The Stdlib Authors",
- "url": "https://github.com/stdlib-js/stdlib/graphs/contributors"
- },
- "contributors": [
- {
- "name": "The Stdlib Authors",
- "url": "https://github.com/stdlib-js/stdlib/graphs/contributors"
- }
- ],
- "bin": {
- "has-arraybuffer-support": "./bin/cli"
- },
- "main": "./lib",
- "directories": {
- "benchmark": "./benchmark",
- "doc": "./docs",
- "example": "./examples",
- "lib": "./lib",
- "test": "./test"
- },
- "types": "./docs/types",
- "scripts": {
- "test": "make test",
- "test-cov": "make test-cov",
- "examples": "make examples",
- "benchmark": "make benchmark"
- },
+ "main": "./index.js",
"homepage": "https://stdlib.io",
"repository": {
"type": "git",
@@ -39,38 +12,6 @@
"bugs": {
"url": "https://github.com/stdlib-js/stdlib/issues"
},
- "dependencies": {
- "@stdlib/array-float64": "^0.2.2",
- "@stdlib/assert-is-arraybuffer": "^0.2.2",
- "@stdlib/cli-ctor": "^0.2.2",
- "@stdlib/fs-read-file": "^0.2.2"
- },
- "devDependencies": {
- "@stdlib/assert-is-boolean": "^0.2.2",
- "@stdlib/assert-is-browser": "^0.2.2",
- "@stdlib/assert-is-windows": "^0.2.2",
- "@stdlib/process-exec-path": "^0.2.2",
- "proxyquire": "^2.0.0",
- "tape": "git+https://github.com/kgryte/tape.git#fix/globby",
- "istanbul": "^0.4.1",
- "tap-min": "git+https://github.com/Planeshifter/tap-min.git",
- "@stdlib/bench-harness": "^0.2.2"
- },
- "engines": {
- "node": ">=0.10.0",
- "npm": ">2.7.0"
- },
- "os": [
- "aix",
- "darwin",
- "freebsd",
- "linux",
- "macos",
- "openbsd",
- "sunos",
- "win32",
- "windows"
- ],
"keywords": [
"stdlib",
"stdutils",
diff --git a/stats_browser.html b/stats_browser.html
new file mode 100644
index 0000000..bec005a
--- /dev/null
+++ b/stats_browser.html
@@ -0,0 +1,4842 @@
+
+
+
+
+
+
+
+ Rollup Visualizer
+
+
+
+
+
+
+
+
+
diff --git a/stats_node.html b/stats_node.html
new file mode 100644
index 0000000..6e3a6c4
--- /dev/null
+++ b/stats_node.html
@@ -0,0 +1,4842 @@
+
+
+
+
+
+
+
+ Rollup Visualizer
+
+
+
+
+
+
+
+
+
diff --git a/test/dist/test.js b/test/dist/test.js
deleted file mode 100644
index a8a9c60..0000000
--- a/test/dist/test.js
+++ /dev/null
@@ -1,33 +0,0 @@
-/**
-* @license Apache-2.0
-*
-* Copyright (c) 2023 The Stdlib Authors.
-*
-* Licensed under the Apache License, Version 2.0 (the "License");
-* you may not use this file except in compliance with the License.
-* You may obtain a copy of the License at
-*
-* http://www.apache.org/licenses/LICENSE-2.0
-*
-* Unless required by applicable law or agreed to in writing, software
-* distributed under the License is distributed on an "AS IS" BASIS,
-* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-* See the License for the specific language governing permissions and
-* limitations under the License.
-*/
-
-'use strict';
-
-// MODULES //
-
-var tape = require( 'tape' );
-var main = require( './../../dist' );
-
-
-// TESTS //
-
-tape( 'main export is defined', function test( t ) {
- t.ok( true, __filename );
- t.strictEqual( main !== void 0, true, 'main export is defined' );
- t.end();
-});
diff --git a/test/test.cli.js b/test/test.cli.js
deleted file mode 100644
index ef52c4f..0000000
--- a/test/test.cli.js
+++ /dev/null
@@ -1,163 +0,0 @@
-/**
-* @license Apache-2.0
-*
-* Copyright (c) 2018 The Stdlib Authors.
-*
-* Licensed under the Apache License, Version 2.0 (the "License");
-* you may not use this file except in compliance with the License.
-* You may obtain a copy of the License at
-*
-* http://www.apache.org/licenses/LICENSE-2.0
-*
-* Unless required by applicable law or agreed to in writing, software
-* distributed under the License is distributed on an "AS IS" BASIS,
-* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-* See the License for the specific language governing permissions and
-* limitations under the License.
-*/
-
-'use strict';
-
-// MODULES //
-
-var resolve = require( 'path' ).resolve;
-var exec = require( 'child_process' ).exec;
-var tape = require( 'tape' );
-var IS_BROWSER = require( '@stdlib/assert-is-browser' );
-var IS_WINDOWS = require( '@stdlib/assert-is-windows' );
-var readFileSync = require( '@stdlib/fs-read-file' ).sync;
-var EXEC_PATH = require( '@stdlib/process-exec-path' );
-
-
-// VARIABLES //
-
-var fpath = resolve( __dirname, '..', 'bin', 'cli' );
-var opts = {
- 'skip': IS_BROWSER || IS_WINDOWS
-};
-
-
-// FIXTURES //
-
-var PKG_VERSION = require( './../package.json' ).version;
-
-
-// TESTS //
-
-tape( 'command-line interface', function test( t ) {
- t.ok( true, __filename );
- t.end();
-});
-
-tape( 'when invoked with a `--help` flag, the command-line interface prints the help text to `stderr`', opts, function test( t ) {
- var expected;
- var cmd;
-
- expected = readFileSync( resolve( __dirname, '..', 'docs', 'usage.txt' ), {
- 'encoding': 'utf8'
- });
- cmd = [
- EXEC_PATH,
- fpath,
- '--help'
- ];
-
- exec( cmd.join( ' ' ), done );
-
- function done( error, stdout, stderr ) {
- if ( error ) {
- t.fail( error.message );
- } else {
- t.strictEqual( stdout.toString(), '', 'does not print to `stdout`' );
- t.strictEqual( stderr.toString(), expected+'\n', 'expected value' );
- }
- t.end();
- }
-});
-
-tape( 'when invoked with a `-h` flag, the command-line interface prints the help text to `stderr`', opts, function test( t ) {
- var expected;
- var cmd;
-
- expected = readFileSync( resolve( __dirname, '..', 'docs', 'usage.txt' ), {
- 'encoding': 'utf8'
- });
- cmd = [
- EXEC_PATH,
- fpath,
- '-h'
- ];
-
- exec( cmd.join( ' ' ), done );
-
- function done( error, stdout, stderr ) {
- if ( error ) {
- t.fail( error.message );
- } else {
- t.strictEqual( stdout.toString(), '', 'does not print to `stdout`' );
- t.strictEqual( stderr.toString(), expected+'\n', 'expected value' );
- }
- t.end();
- }
-});
-
-tape( 'when invoked with a `--version` flag, the command-line interface prints the version to `stderr`', opts, function test( t ) {
- var cmd = [
- EXEC_PATH,
- fpath,
- '--version'
- ];
-
- exec( cmd.join( ' ' ), done );
-
- function done( error, stdout, stderr ) {
- if ( error ) {
- t.fail( error.message );
- } else {
- t.strictEqual( stdout.toString(), '', 'does not print to `stdout`' );
- t.strictEqual( stderr.toString(), PKG_VERSION+'\n', 'expected value' );
- }
- t.end();
- }
-});
-
-tape( 'when invoked with a `-V` flag, the command-line interface prints the version to `stderr`', opts, function test( t ) {
- var cmd = [
- EXEC_PATH,
- fpath,
- '-V'
- ];
-
- exec( cmd.join( ' ' ), done );
-
- function done( error, stdout, stderr ) {
- if ( error ) {
- t.fail( error.message );
- } else {
- t.strictEqual( stdout.toString(), '', 'does not print to `stdout`' );
- t.strictEqual( stderr.toString(), PKG_VERSION+'\n', 'expected value' );
- }
- t.end();
- }
-});
-
-tape( 'the command-line interface prints either `true` or `false` to `stdout` indicating whether an environment provides native `ArrayBuffer` support', opts, function test( t ) {
- var cmd = [
- EXEC_PATH,
- fpath
- ];
-
- exec( cmd.join( ' ' ), done );
-
- function done( error, stdout, stderr ) {
- var str;
- if ( error ) {
- t.fail( error.message );
- } else {
- str = stdout.toString();
- t.strictEqual( str === 'true\n' || str === 'false\n', true, 'prints either `true` or `false` to `stdout`' );
- t.strictEqual( stderr.toString(), '', 'does not print to `stderr`' );
- }
- t.end();
- }
-});
diff --git a/test/test.js b/test/test.js
deleted file mode 100644
index 5e94eeb..0000000
--- a/test/test.js
+++ /dev/null
@@ -1,157 +0,0 @@
-/**
-* @license Apache-2.0
-*
-* Copyright (c) 2018 The Stdlib Authors.
-*
-* Licensed under the Apache License, Version 2.0 (the "License");
-* you may not use this file except in compliance with the License.
-* You may obtain a copy of the License at
-*
-* http://www.apache.org/licenses/LICENSE-2.0
-*
-* Unless required by applicable law or agreed to in writing, software
-* distributed under the License is distributed on an "AS IS" BASIS,
-* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-* See the License for the specific language governing permissions and
-* limitations under the License.
-*/
-
-'use strict';
-
-// MODULES //
-
-var tape = require( 'tape' );
-var proxyquire = require( 'proxyquire' );
-var detect = require( './../lib' );
-
-
-// VARIABLES //
-
-var hasArrayBuffer = ( typeof ArrayBuffer === 'function' ); // eslint-disable-line stdlib/require-globals
-
-
-// TESTS //
-
-tape( 'main export is a function', function test( t ) {
- t.ok( true, __filename );
- t.strictEqual( typeof detect, 'function', 'main export is a function' );
- t.end();
-});
-
-tape( 'feature detection result is a boolean', function test( t ) {
- t.strictEqual( typeof detect(), 'boolean', 'detection result is a boolean' );
- t.end();
-});
-
-tape( 'if `ArrayBuffer` is supported, detection result is `true`', function test( t ) {
- var mocked;
- if ( hasArrayBuffer ) {
- t.strictEqual( detect(), true, 'detection result is `true`' );
- } else {
- t.strictEqual( detect(), false, 'detection result is `false`' );
- }
- function Mock( len ) {
- var out;
- var i;
-
- out = new Array( len/8 ); // we assume evenly divisible
- for ( i = 0; i < out.length; i++ ) {
- out[ i ] = 0;
- }
- out.byteLength = len;
- return out;
- }
-
- Mock.isView = isView;
-
- mocked = proxyquire( './../lib/main.js', {
- './arraybuffer.js': Mock,
- '@stdlib/assert-is-arraybuffer': isBuffer
- });
- t.strictEqual( mocked(), true, 'detection result is `true` (mocked)' );
-
- t.end();
-
- function isBuffer() {
- return true;
- }
-
- function isView() {
- return true;
- }
-});
-
-tape( 'if `ArrayBuffer` is not supported, detection result is `false` (no ArrayBuffer global function)', function test( t ) {
- var mocked;
- if ( hasArrayBuffer ) {
- t.strictEqual( detect(), true, 'detection result is `true`' );
- } else {
- t.strictEqual( detect(), false, 'detection result is `false`' );
- }
- mocked = proxyquire( './../lib/main.js', {
- './arraybuffer.js': {}
- });
- t.strictEqual( mocked(), false, 'detection result is `false`' );
- t.end();
-});
-
-tape( 'if `ArrayBuffer` is not supported, detected result is `false` (constructor throws)', function test( t ) {
- var mocked;
- if ( hasArrayBuffer ) {
- t.strictEqual( detect(), true, 'detection result is `true`' );
- } else {
- t.strictEqual( detect(), false, 'detection result is `false`' );
- }
- mocked = proxyquire( './../lib/main.js', {
- './arraybuffer.js': mock
- });
- t.strictEqual( mocked(), false, 'detection result is `false`' );
- t.end();
-
- function mock() {
- throw new Error( 'beep' );
- }
-});
-
-tape( 'if `ArrayBuffer` is not supported, detected result is `false` (constructor has no static `isView` method)', function test( t ) {
- var mocked;
- if ( hasArrayBuffer ) {
- t.strictEqual( detect(), true, 'detection result is `true`' );
- } else {
- t.strictEqual( detect(), false, 'detection result is `false`' );
- }
- function mock( len ) {
- return new ArrayBuffer( len ); // eslint-disable-line stdlib/require-globals
- }
-
- mock.isView = null;
-
- mocked = proxyquire( './../lib/main.js', {
- './arraybuffer.js': mock
- });
- t.strictEqual( mocked(), false, 'detection result is `false`' );
- t.end();
-});
-
-tape( 'if `ArrayBuffer` is not supported, detected result is `false` (isView)', function test( t ) {
- var mocked;
- if ( hasArrayBuffer ) {
- t.strictEqual( detect(), true, 'detection result is `true`' );
- } else {
- t.strictEqual( detect(), false, 'detection result is `false`' );
- }
- function mock( len ) {
- return new ArrayBuffer( len ); // eslint-disable-line stdlib/require-globals
- }
- mock.isView = isView;
-
- mocked = proxyquire( './../lib/main.js', {
- './arraybuffer.js': mock
- });
- t.strictEqual( mocked(), false, 'detection result is `false`' );
- t.end();
-
- function isView() {
- return false;
- }
-});
pFad - Phonifier reborn
Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.
Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.
Alternative Proxies:
Alternative Proxy
pFad Proxy
pFad v3 Proxy
pFad v4 Proxy