### Full CLI Example Source: https://github.com/stdlib-js/stdlib/blob/develop/lib/node_modules/@stdlib/cli/ctor/README.md An example demonstrating the setup and execution of a command-line interface using @stdlib/cli, including loading configuration, defining options, and running a main function. ```javascript var join = require( 'path' ).join; var readFileSync = require( '@stdlib/fs/read-file' ).sync; var CLI = require( '@stdlib/cli/ctor' ); var main = require( './examples/fixtures/main.js' ); // Load help text: var fopts = { 'encoding': 'utf8' }; var help = readFileSync( join( __dirname, 'examples', 'fixtures', 'usage.txt' ), fopts ); // Set the command-line interface options: var opts = { 'pkg': require( './package.json' ), 'options': require( './examples/fixtures/opts.json' ), 'help': help, 'title': true, 'updates': true }; // Create a new command-line interface: var cli = new CLI( opts ); // Run main: main( 'beep' ); // Close: cli.close( 0 ); ``` -------------------------------- ### RPM Installation Example Source: https://github.com/stdlib-js/stdlib/blob/develop/lib/node_modules/@stdlib/datasets/spam-assassin/data/easy-ham-1/01072.81ed44b31e111f9c1e47e53f4dfbefe3.txt This example demonstrates the process of installing an RPM package using the `rpm -ivh` command, showing the progress indicator. ```bash rpm -ivh apg-1.2.13-fr1.i386.rpm Preparing... ########################################### [100%] 1:apg ########################################### [100%] ``` -------------------------------- ### Full example with custom options and directory creation Source: https://github.com/stdlib-js/stdlib/blob/develop/lib/node_modules/@stdlib/_tools/docs/www/benchmark-bundles/README.md An example demonstrating the creation of benchmark bundles with custom directory, package patterns, ignored files, and ensuring the output directory exists before building. ```javascript var mkdir = require( 'fs' ).mkdirSync; var resolve = require( 'path' ).resolve; var exists = require( '@stdlib/fs/exists' ).sync; var build = require( '@stdlib/_tools/docs/www/benchmark-bundles' ); var dpath = resolve( __dirname, 'build' ); var opts = { 'dir': './lib/node_modules', 'packages_pattern': '**/base/special/sin/package.json', 'ignore': [ 'benchmark/**', 'bin/**', 'build/**', 'docs/**', 'etc/**', 'examples/**', 'reports/**', 'scripts/**', 'test/**', '**/_tools/**' ] }; if ( !exists( dpath ) ) { mkdir( dpath ); } build( dpath, opts, done ); function done( error ) { if ( error ) { throw error; } console.log( 'Finished!' ); } ``` -------------------------------- ### C API Example Source: https://github.com/stdlib-js/stdlib/blob/develop/lib/node_modules/@stdlib/strided/base/binary/README.md Example demonstrating the usage of the STDLIB_STRIDED_BINARY_LOOP_CLBK_MIXED_ARG_CAST macro in a C program. ```C #include "stdlib/strided/base/binary.h" #include #include #include // Define a callback: static double add( double x, double y ) { return x + y; } int main( void ) { // Create underlying byte arrays: uint8_t x[] = { 1, 4, 7 }; uint8_t y[] = { 101, 104, 107 }; uint8_t out[] = { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 }; // Define a pointer to an array containing pointers to strided arrays: uint8_t *arrays[] = { x, y, out }; // Define the strides: int64_t strides[] = { 1, 1, 8 }; // 1 byte per uint8, 8 bytes per double // Define the number of elements over which to iterate: int64_t shape[] = { 3 }; // Apply the callback: stdlib_strided_bb_d_as_dd_d( arrays, shape, strides, (void *)add ); // Print the contents of the output array: uint8_t *op1 = out; for ( int64_t i = 0; i < shape[0]; i++, op1 += strides[2] ) { const double v = *(double *)op1; printf( "out[ %\"PRId64\" ] = %lf\n", i, v ); } return 0; } ``` -------------------------------- ### List Example Files Source: https://github.com/stdlib-js/stdlib/blob/develop/tools/make/README.md To list all example files in the project, use the `make list-examples` command. ```bash $ make list-examples ``` -------------------------------- ### Install and Setup Playwright Source: https://github.com/stdlib-js/stdlib/blob/develop/lib/node_modules/@stdlib/_tools/scripts/templates/workflow_test_bundles.yml.txt Installs Playwright and its browser dependencies for headless browser testing. ```bash # Install playwright for headless browser testing: - name: 'Install playwright' run: | npm install playwright npx playwright install --with-deps chromium ``` -------------------------------- ### Example Usage with Random Arrays Source: https://github.com/stdlib-js/stdlib/blob/develop/lib/node_modules/@stdlib/strided/base/binary/README.md An example demonstrating the use of `binary.ndarray` with randomly generated input arrays and custom strides and offsets. This showcases a more complex scenario with varied indexing. ```javascript var discreteUniform = require( '@stdlib/random/base/discrete-uniform' ).factory; var filledarrayBy = require( '@stdlib/array/filled-by' ); var filledarray = require( '@stdlib/array/filled' ); var binary = require( '@stdlib/strided/base/binary' ); function add( x, y ) { return x + y; } var N = 10; var x = filledarrayBy( N, 'generic', discreteUniform( -100, 100 ) ); console.log( x ); var y = filledarrayBy( N, 'generic', discreteUniform( -100, 100 ) ); console.log( y ); var z = filledarray( 0.0, N, 'generic' ); console.log( z ); var shape = [ N ]; var strides = [ 1, 1, -1 ]; var offsets = [ 0, 0, N-1 ]; binary.ndarray( [ x, y, z ], shape, strides, offsets, add ); console.log( z ); ``` -------------------------------- ### Get Slice Start Index Source: https://github.com/stdlib-js/stdlib/blob/develop/lib/node_modules/@stdlib/slice/ctor/README.md Access the 'start' property to retrieve the starting index of a Slice instance. Returns null if not explicitly set. ```javascript var s = new Slice( 10 ); // returns var start = s.start; // returns null s = new Slice( 2, 10 ); // returns start = s.start; // returns 2 ``` -------------------------------- ### Strided Binary Operation Example Source: https://github.com/stdlib-js/stdlib/blob/develop/lib/node_modules/@stdlib/strided/base/binary/README.md Demonstrates how to apply a binary callback to strided input array elements and assign results to a strided output array using stdlib_strided_bb_b. ```c #include "stdlib/strided/base/binary.h" #include // Create underlying byte arrays: uint8_t x[] = { 0, 0, 0 }; uint8_t y[] = { 0, 0, 0 }; uint8_t out[] = { 0, 0, 0 }; // Define a pointer to an array containing pointers to strided arrays: uint8_t *arrays[] = { x, y, out }; // Define the strides: int64_t strides[] = { 1, 1, 1 }; // Define the number of elements over which to iterate: int64_t shape[] = { 3 }; // Define a callback: static uint8_t fcn( uint8_t x, uint8_t y ) { return x + y; } // Apply the callback: stdlib_strided_bb_b( arrays, shape, strides, (void *)fcn ); ``` -------------------------------- ### Function Naming Convention Example Source: https://github.com/stdlib-js/stdlib/blob/develop/lib/node_modules/@stdlib/strided/base/binary/README.md Illustrates the naming convention for C functions in stdlib, where the suffix encodes input and output data types. ```c void stdlib_strided_dd_d(...){...} ``` ```c void stdlib_strided_ff_f_as_dd_d(...){...} ``` ```c void stdlib_strided_ff_d(...){...} ``` -------------------------------- ### Apply binary function with offset views Source: https://github.com/stdlib-js/stdlib/blob/develop/lib/node_modules/@stdlib/strided/base/binary/README.md Apply a binary 'add' function using offset views of typed arrays. This example creates views 'x1', 'y1', and 'z1' that start at different elements of the original arrays 'x0', 'y0', and 'z0', demonstrating how to introduce offsets without modifying the original arrays. ```javascript var Float64Array = require( '@stdlib/array/float64' ); function add( x, y ) { return x + y; } // Initial arrays... var x0 = new Float64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ] ); var y0 = new Float64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ] ); var z0 = new Float64Array( [ 0.0, 0.0, 0.0, 0.0, 0.0, 0.0 ] ); // Create offset views... var x1 = new Float64Array( x0.buffer, x0.BYTES_PER_ELEMENT*1 ); // start at 2nd element var y1 = new Float64Array( y0.buffer, y0.BYTES_PER_ELEMENT*1 ); // start at 2nd element var z1 = new Float64Array( z0.buffer, z0.BYTES_PER_ELEMENT*3 ); // start at 4th element var N = 3; binary( [ x1, y1, z1 ], [ N ], [ -2, -2, 1 ], add ); // z0 => [ 0.0, 0.0, 0.0, 12.0, 8.0, 4.0 ] ``` -------------------------------- ### Callback Type Casting Example Source: https://github.com/stdlib-js/stdlib/blob/develop/lib/node_modules/@stdlib/strided/base/binary/README.md Shows how to cast input and output values when a callback function's data types differ from the strided array data types. ```c // Convert each input array element to double-precision: double in1 = (double)x[ i ]; double in2 = (double)y[ i ]; // Evaluate the callback: double out = f( in1, in2 ); // Convert the callback return value to single-precision: z[ i ] = (float)out; ``` ```c // Retrieve each input array element as single-precision: float in1 = (float)x[ i ]; float in2 = (float)y[ i ]; // Evaluate the callback: float out = f( in1, in2 ); // Convert the callback return value to double-precision: z[ i ] = (double)out; ``` -------------------------------- ### Start a Tutorial Source: https://github.com/stdlib-js/stdlib/blob/develop/lib/node_modules/@stdlib/repl/docs/commands/tutorial.txt Starts a tutorial with the specified name. If no name is provided, a list of available tutorials is printed. Existing workspaces are cleared by default. ```javascript var id = tutorial( 'repl' ); ``` -------------------------------- ### Example: Get GitHub User Rate Limit Status with Custom User Agent Source: https://github.com/stdlib-js/stdlib/blob/develop/lib/node_modules/@stdlib/_tools/github/user-rate-limit/README.md An example demonstrating how to get the GitHub user rate limit status with a custom user agent and handle potential errors. Note that a valid GitHub token is required to run this example. ```javascript var ratelimit = require( '@stdlib/_tools/github/user-rate-limit' ); var opts = { 'token': 'tkjorjk34ek3nj4!', 'useragent': 'beep-boop-bop' }; ratelimit( opts, clbk ); function clbk( error, status ) { if ( error ) { if ( error instanceof Error ) { throw error; } console.error( error.message ); } else { console.log( status ); } } ``` -------------------------------- ### Apply Binary Callback to Strided Arrays (int32, different strides) Source: https://github.com/stdlib-js/stdlib/blob/develop/lib/node_modules/@stdlib/strided/base/binary/README.md Applies a binary callback to strided input array elements and assigns results to elements in a strided output array. This example uses different stride values compared to the first example. Ensure the callback function signature matches. ```c #include // Create underlying byte arrays: uint8_t x[] = { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 }; uint8_t y[] = { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 }; uint8_t out[] = { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 }; // Define a pointer to an array containing pointers to strided arrays: uint8_t *arrays[] = { x, y, out }; // Define the strides: int64_t strides[] = { 4, 4, 4 }; // Define the number of elements over which to iterate: int64_t shape[] = { 3 }; // Define a callback: static int32_t fcn( int32_t x, int32_t y ) { return x + y; } // Apply the callback: stdlib_strided_ii_i( arrays, shape, strides, (void *)fcn ); ``` ```c void stdlib_strided_ii_i( uint8_t *arrays[], const int64_t *shape, const int64_t *strides, void *fcn ); ``` -------------------------------- ### Example Usage of STDLIB_STRIDED_BINARY_LOOP_CLBK_MIXED_ARG_CAST Source: https://github.com/stdlib-js/stdlib/blob/develop/lib/node_modules/@stdlib/strided/base/binary/README.md Demonstrates applying a binary callback with mixed argument type casting using the STDLIB_STRIDED_BINARY_LOOP_CLBK_MIXED_ARG_CAST macro. Ensure correct array, shape, and stride definitions for the operation. ```c #include "stdlib/strided/base/binary.h" #include #include #include // Define a callback: static double add( double x, double y ) { return x + y; } int main( void ) { // Create underlying byte arrays: uint8_t x[] = { 1, 4, 7 }; uint8_t y[] = { 101, 104, 107 }; uint8_t out[] = { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 }; // Define a pointer to an array containing pointers to strided arrays: uint8_t *arrays[] = { x, y, out }; // Define the strides: int64_t strides[] = { 1, 1, 8 }; // 1 byte per uint8, 8 bytes per double // Define the number of elements over which to iterate: int64_t shape[] = { 3 }; // Apply the callback: stdlib_strided_bb_d_as_dd_d( arrays, shape, strides, (void *)add ); // Print the contents of the output array: uint8_t *op1 = out; for ( int64_t i = 0; i < shape[0]; i++, op1 += strides[2] ) { const double v = *(double *)op1; printf( "out[ %"PRId64" ] = %lf\n", i, v ); } } ``` -------------------------------- ### Get Uint32Array.prototype.byteOffset Source: https://github.com/stdlib-js/stdlib/blob/develop/lib/node_modules/@stdlib/array/uint32/README.md Access the byteOffset property of a Uint32Array instance to get its offset from the start of its ArrayBuffer. ```javascript var arr = new Uint32Array( 5 ); var byteOffset = arr.byteOffset; // returns 0 ``` -------------------------------- ### Boot Menu Language Example Source: https://github.com/stdlib-js/stdlib/blob/develop/lib/node_modules/@stdlib/datasets/spam-assassin/data/easy-ham-2/00164.9e2e72c2afac966e790a7ab09ef24937.txt This example demonstrates a simple one-liner in a pascal-ish language for writing boot menus, specifically for booting from a partition. ```pascal boot /dev/hda1 ``` -------------------------------- ### Custom Indexing with Offsets and Strides Source: https://github.com/stdlib-js/stdlib/blob/develop/lib/node_modules/@stdlib/strided/base/binary/README.md Demonstrates custom indexing semantics using `offsets` and `strides` to access array elements. This example indexes every other value starting from the second element and the last N elements in the output array. ```javascript var Float64Array = require( '@stdlib/array/float64' ); function add( x, y ) { return x + y; } var x = new Float64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ] ); var y = new Float64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ] ); var z = new Float64Array( [ 0.0, 0.0, 0.0, 0.0, 0.0, 0.0 ] ); var N = 3; binary.ndarray( [ x, y, z ], [ N ], [ 2, 2, -1 ], [ 1, 1, z.length-1 ], add ); // z => [ 0.0, 0.0, 0.0, 12.0, 8.0, 4.0 ] ``` -------------------------------- ### Apply Double Callback to Strided Arrays (C) Source: https://github.com/stdlib-js/stdlib/blob/develop/lib/node_modules/@stdlib/strided/base/binary/README.md Applies a binary double callback to strided input arrays and assigns results to a strided output array. Requires setup for arrays, shape, strides, and the callback function. ```c #include // Create underlying byte arrays: uint8_t x[] = { 0, 0, 0 }; uint8_t y[] = { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 }; uint8_t out[] = { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 }; // Define a pointer to an array containing pointers to strided arrays: uint8_t *arrays[] = { x, y, out }; // Define the strides: int64_t strides[] = { 1, 4, 8 }; // Define the number of elements over which to iterate: int64_t shape[] = { 3 }; // Define a callback: static double fcn( double x, double y ) { return x + y; } // Apply the callback: stdlib_strided_bf_d_as_dd_d( arrays, shape, strides, (void *)fcn ); ``` ```c void stdlib_strided_bf_d_as_dd_d( uint8_t *arrays[], const int64_t *shape, const int64_t *strides, void *fcn ); ``` -------------------------------- ### CLI Example Source: https://github.com/stdlib-js/stdlib/blob/develop/lib/node_modules/@stdlib/_tools/benchmarks/html/README.md Example of how to run the `benchmarks-html` CLI tool, providing the URL of the benchmarks bundle. ```bash $ benchmarks-html /foo/bar/beep.js ``` -------------------------------- ### CLI usage example Source: https://github.com/stdlib-js/stdlib/blob/develop/lib/node_modules/@stdlib/utils/type-min/README.md Example of using the typemin CLI to get the minimum value for 'int16'. ```bash $ typemin int16 -32768 ``` -------------------------------- ### Apply Float Callback to Strided Arrays (C) Source: https://github.com/stdlib-js/stdlib/blob/develop/lib/node_modules/@stdlib/strided/base/binary/README.md Applies a binary float callback to strided input arrays and assigns results to a strided output array. Requires setup for arrays, shape, strides, and the callback function. ```c #include // Create underlying byte arrays: uint8_t x[] = { 0, 0, 0 }; uint8_t y[] = { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 }; uint8_t out[] = { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 }; // Define a pointer to an array containing pointers to strided arrays: uint8_t *arrays[] = { x, y, out }; // Define the strides: int64_t strides[] = { 1, 4, 4 }; // Define the number of elements over which to iterate: int64_t shape[] = { 3 }; // Define a callback: static double fcn( double x, double y ) { return x + y; } // Apply the callback: stdlib_strided_bf_f_as_dd_d( arrays, shape, strides, (void *)fcn ); ``` ```c void stdlib_strided_bf_f_as_dd_d( uint8_t *arrays[], const int64_t *shape, const int64_t *strides, void *fcn ); ``` -------------------------------- ### Example Bundle Usage Source: https://github.com/stdlib-js/stdlib/blob/develop/lib/node_modules/@stdlib/_tools/tests/bundle/README.md An example demonstrating how to bundle files from a specific root directory with a custom pattern, logging the result. ```javascript var join = require( 'path' ).join; var bundle = require( '@stdlib/_tools/tests/bundle' ); var root = join( __dirname, 'fixtures' ); var opts = { 'pattern': '*.js' }; bundle( root, opts, onBundle ); function onBundle( error, bundle ) { if ( error ) { throw error; } console.log( bundle.toString() ); } ``` -------------------------------- ### CLI usage example Source: https://github.com/stdlib-js/stdlib/blob/develop/lib/node_modules/@stdlib/utils/type-max/README.md Example of using the `typemax` CLI to get the maximum value for int16. ```bash $ typemax int16 32767 ``` -------------------------------- ### Apply Callback to Strided Simple Arrays (int8) Source: https://github.com/stdlib-js/stdlib/blob/develop/lib/node_modules/@stdlib/strided/base/binary/README.md Applies a binary callback to strided input arrays and assigns results to a strided output array. Requires setup of input/output byte arrays, shape, strides, and a callback function. ```c #include // Create underlying byte arrays: uint8_t x[] = { 0, 0, 0 }; uint8_t y[] = { 0, 0, 0 }; uint8_t out[] = { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 }; // Define a pointer to an array containing pointers to strided arrays: uint8_t *arrays[] = { x, y, out }; // Define the strides: int64_t strides[] = { 1, 1, 8 }; // Define the number of elements over which to iterate: int64_t shape[] = { 3 }; // Define a callback: static int8_t fcn( int8_t x, int8_t y ) { return x + y; } // Apply the callback: stdlib_strided_ss_c( arrays, shape, strides, (void *)fcn ); ``` ```c void stdlib_strided_ss_c( uint8_t *arrays[], const int64_t *shape, const int64_t *strides, void *fcn ); ``` -------------------------------- ### Run Examples with Make Source: https://github.com/stdlib-js/stdlib/blob/develop/docs/contributing/FAQ.md Execute examples, optionally filtering them using EXAMPLES_FILTER. ```bash $ make EXAMPLES_FILTER=".*/math/base/special/abs/.*" examples ``` -------------------------------- ### CLI Usage Example Source: https://github.com/stdlib-js/stdlib/blob/develop/lib/node_modules/@stdlib/repl/signature/README.md Example of how to use the stdlib-alias-signature command-line interface to get the signature of an alias. ```bash $ stdlib-alias-signature 'base.sin' ``` -------------------------------- ### Start Tutorial Source: https://github.com/stdlib-js/stdlib/blob/develop/lib/node_modules/@stdlib/repl/docs/commands/tutorial.txt Starts an interactive tutorial. If no tutorial name is provided, a list of available tutorials is displayed. Existing workspaces are cleared unless a new workspace name is specified. ```APIDOC ## tutorial( [name, [options]] ) ### Description Starts a tutorial. When not provided a tutorial name, the function prints a list of available tutorials. If a specified workspace already exists, the workspace is silently cleared and a new tutorial presentation bound. In order to preserve an existing workspace, specify an alternative tutorial workspace name. ### Method [Function Call] ### Parameters #### Path Parameters None #### Query Parameters None #### Request Body None ### Parameters - **name** (string) - Optional - Tutorial name. - **options** (Object) - Optional - Tutorial options. - **options.borderTop** (string) - Optional - Top border character sequence. Default: '*'. - **options.borderBottom** (string) - Optional - Bottom border character sequence. Default: '*'. - **options.borderLeft** (string) - Optional - Left border character sequence. Default: '* '. - **options.borderRight** (string) - Optional - Right border character sequence. Default: ' *'. - **options.counter** (string|boolean) - Optional - Slide counter. If `true`, each tutorial slide displays a slide counter. If set to 'progress', each tutorial slide displays a progress counter. If `false`, no counter is displayed. Default: 'progress'. - **options.workspace** (string) - Optional - REPL workspace name. A tutorial presentation adds commands to the specified workspace, thus allowing tutorial navigation and interaction. Default: `'tutorial--'`, where `name` is the tutorial name and `n` is an assigned tutorial presentation identifier. - **options.autoClear** (boolean) - Optional - Boolean indicating whether to automatically clear the screen before writing a rendered tutorial slide to the REPL. Default: true. ### Request Example ```javascript tutorial( 'repl' ); ``` ### Response #### Success Response (200) - **out** (integer|void) - Tutorial presentation identifier. #### Response Example ```javascript // Returns an integer identifier for the tutorial presentation ``` ### See Also - presentationStart - presentationStop - workspace - workspaces ``` -------------------------------- ### Get an example for a known alias Source: https://github.com/stdlib-js/stdlib/blob/develop/lib/node_modules/@stdlib/repl/code-blocks/README.md Call the `example` function with a valid alias string (e.g., 'base.sin') to retrieve its associated code example. The function returns a string containing the example code. ```javascript var out = example( 'base.sin' ); // returns ``` -------------------------------- ### Apply Binary Callback to Strided Arrays (uint32) Source: https://github.com/stdlib-js/stdlib/blob/develop/lib/node_modules/@stdlib/strided/base/binary/README.md Applies a binary callback to strided input array elements and assigns results to elements in a strided output array. Requires setup of byte arrays, pointers, strides, shape, and a callback function. ```c #include // Create underlying byte arrays: uint8_t x[] = { 0, 0, 0, 0, 0, 0 }; uint8_t y[] = { 0, 0, 0 }; uint8_t out[] = { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 }; // Define a pointer to an array containing pointers to strided arrays: uint8_t *arrays[] = { x, y, out }; // Define the strides: int64_t strides[] = { 2, 1, 4 }; // Define the number of elements over which to iterate: int64_t shape[] = { 3 }; // Define a callback: static uint32_t fcn( uint32_t x, uint32_t y ) { return x + y; } // Apply the callback: stdlib_strided_tb_u_as_uu_u( arrays, shape, strides, (void *)fcn ); ``` ```c void stdlib_strided_tb_u_as_uu_u( uint8_t *arrays[], const int64_t *shape, const int64_t *strides, void *fcn ); ``` -------------------------------- ### Apply Binary Callback to Strided Arrays (uint16) Source: https://github.com/stdlib-js/stdlib/blob/develop/lib/node_modules/@stdlib/strided/base/binary/README.md Applies a binary callback to strided input array elements and assigns results to elements in a strided output array. Requires setup of byte arrays, pointers, strides, shape, and a callback function. ```c #include // Create underlying byte arrays: uint8_t x[] = { 0, 0, 0, 0, 0, 0 }; uint8_t y[] = { 0, 0, 0 }; uint8_t out[] = { 0, 0, 0, 0, 0, 0 }; // Define a pointer to an array containing pointers to strided arrays: uint8_t *arrays[] = { x, y, out }; // Define the strides: int64_t strides[] = { 2, 1, 2 }; // Define the number of elements over which to iterate: int64_t shape[] = { 3 }; // Define a callback: static uint16_t fcn( uint16_t x, uint16_t y ) { return x + y; } // Apply the callback: stdlib_strided_tb_t_as_tt_t( arrays, shape, strides, (void *)fcn ); ``` ```c void stdlib_strided_tb_t_as_tt_t( uint8_t *arrays[], const int64_t *shape, const int64_t *strides, void *fcn ); ``` -------------------------------- ### Apply Binary Callback to Strided Arrays (int32) Source: https://github.com/stdlib-js/stdlib/blob/develop/lib/node_modules/@stdlib/strided/base/binary/README.md Applies a binary callback to strided input array elements and assigns results to elements in a strided output array. Requires setup of byte arrays, pointers, strides, shape, and a callback function. ```c #include // Create underlying byte arrays: uint8_t x[] = { 0, 0, 0, 0, 0, 0 }; uint8_t y[] = { 0, 0, 0 }; uint8_t out[] = { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 }; // Define a pointer to an array containing pointers to strided arrays: uint8_t *arrays[] = { x, y, out }; // Define the strides: int64_t strides[] = { 2, 1, 4 }; // Define the number of elements over which to iterate: int64_t shape[] = { 3 }; // Define a callback: static int32_t fcn( int32_t x, int32_t y ) { return x + y; } // Apply the callback: stdlib_strided_tb_i_as_ii_i( arrays, shape, strides, (void *)fcn ); ``` ```c void stdlib_strided_tb_i_as_ii_i( uint8_t *arrays[], const int64_t *shape, const int64_t *strides, void *fcn ); ``` -------------------------------- ### Example: Bundle Fixture File Source: https://github.com/stdlib-js/stdlib/blob/develop/lib/node_modules/@stdlib/_tools/browserify/file-list/README.md An example demonstrating how to bundle a specific fixture file and log its content. Ensure the path to the fixture is correctly specified. ```javascript var join = require( 'path' ).join; var bundle = require( '@stdlib/_tools/browserify/file-list' ); var fpath = join( __dirname, 'examples', 'fixtures', 'index.js' ); var files = [ fpath ]; bundle( files, onBundle ); function onBundle( error, output ) { if ( error ) { throw error; } console.log( output.toString() ); } ``` -------------------------------- ### CLI Usage Example Source: https://github.com/stdlib-js/stdlib/blob/develop/lib/node_modules/@stdlib/repl/help/README.md Example of how to use the stdlib-alias-help command-line interface to get help text for a specific alias. ```bash $ stdlib-alias-help 'base.sin' ``` -------------------------------- ### Apply Callback to Strided Complex Arrays (float64) Source: https://github.com/stdlib-js/stdlib/blob/develop/lib/node_modules/@stdlib/strided/base/binary/README.md Applies a binary callback to strided input arrays and assigns results to a strided output array. Requires setup of input/output byte arrays, shape, strides, and a callback function. ```c #include "stdlib/complex/float64/ctor.h" #include // Create underlying byte arrays: uint8_t x[] = { 0, 0, 0 }; uint8_t y[] = { 0, 0, 0, 0, 0, 0 }; uint8_t out[] = { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 }; // Define a pointer to an array containing pointers to strided arrays: uint8_t *arrays[] = { x, y, out }; // Define the strides: int64_t strides[] = { 1, 2, 16 }; // Define the number of elements over which to iterate: int64_t shape[] = { 3 }; // Define a callback: static stdlib_complex128_t fcn( stdlib_complex128_t x, stdlib_complex128_t y ) { // ... } // Apply the callback: stdlib_strided_sk_z_as_zz_z( arrays, shape, strides, (void *)fcn ); ``` ```c void stdlib_strided_sk_z_as_zz_z( uint8_t *arrays[], const int64_t *shape, const int64_t *strides, void *fcn ); ``` -------------------------------- ### Verify Environment with Examples Source: https://github.com/stdlib-js/stdlib/blob/develop/docs/contributing/development.md Run project examples to verify the environment configuration. This example filters for examples related to the 'sin' function in math/base/special. ```bash $ make EXAMPLES_FILTER=".*/math/base/special/sin/.*" examples ``` -------------------------------- ### Get Example by Alias Source: https://github.com/stdlib-js/stdlib/blob/develop/lib/node_modules/@stdlib/repl/code-blocks/README.md Retrieves a code example string for a given stdlib alias. Returns null if the alias is not recognized. ```APIDOC ## GET /api/example ### Description Returns an example associated with a provided alias. ### Method GET ### Endpoint /api/example ### Parameters #### Query Parameters - **alias** (string) - Required - The alias for which to retrieve an example (e.g., 'base.sin'). ### Request Example ```json { "alias": "base.sin" } ``` ### Response #### Success Response (200) - **example** (string) - A string containing the code example for the alias, or null if the alias is not found. #### Response Example ```json { "example": "var sin = require('@stdlib/math/base/special/sin');\nvar y = sin( 3.141592653589793 );" } ``` #### Error Response (404) - **error** (string) - Indicates that the alias was not found. #### Response Example ```json { "error": "Alias not found." } ``` ``` -------------------------------- ### JavaScript Example with Random Input Source: https://github.com/stdlib-js/stdlib/blob/develop/lib/node_modules/@stdlib/math/base/special/sincosf/README.md This example demonstrates using sincosf with an array of random single-precision floats. Ensure necessary modules are installed. ```javascript var uniform = require( '@stdlib/random/array/uniform' ); var TWO_PI = require( '@stdlib/constants/float32/two-pi' ); var sincosf = require( '@stdlib/math/base/special/sincosf' ); var opts = { 'dtype': 'float32' }; var x = uniform( 100, 0.0, TWO_PI, opts ); var y; var i; for ( i = 0; i < x.length; i++ ) { y = sincosf( x[ i ] ); console.log( 'sincosf(%d) = [ %d, %d ]', x[ i ], y[ 0 ], y[ 1 ] ); } ``` -------------------------------- ### Example Usage with Path Resolution Source: https://github.com/stdlib-js/stdlib/blob/develop/lib/node_modules/@stdlib/_tools/pkgs/entry-points/README.md Example demonstrating how to resolve package entry points using an absolute path for one of the packages. ```javascript var resolve = require( 'path' ).resolve; var entryPoints = require( '@stdlib/_tools/pkgs/entry-points' ); var pkg = resolve( __dirname, '../' ); var pkgs = [ pkg, 'tape' ]; entryPoints( pkgs, onEntries ); function onEntries( error, results ) { if ( error ) { throw error; } console.dir( results ); } ``` -------------------------------- ### C Example with Header Inclusion Source: https://github.com/stdlib-js/stdlib/blob/develop/lib/node_modules/@stdlib/_tools/remark/plugins/remark-lint-expected-html-sections/test/fixtures/valid_complete.md.txt A basic C code example that includes a header file. This serves as a starting point for C implementations. ```c // C example #include "foo.h" ``` -------------------------------- ### Async Examples with Options Source: https://github.com/stdlib-js/stdlib/blob/develop/lib/node_modules/@stdlib/fs/resolve-parent-paths/README.md Demonstrates asynchronous path resolution with different options, including specifying a directory and handling non-existent paths. ```javascript var opts = { 'dir': __dirname }; resolveParentPaths( [ 'package.json', 'README.md' ], opts, onPaths ); resolveParentPaths( [ './../non_existent_path' ], onPaths ); function onPaths( error, paths ) { if ( error ) { throw error; } console.log( paths ); } ``` -------------------------------- ### Apply Binary Callback to Strided Complex Arrays (C) Source: https://github.com/stdlib-js/stdlib/blob/develop/lib/node_modules/@stdlib/strided/base/binary/README.md Applies a binary callback to strided input complex128 arrays and assigns results to a strided output array. Requires specific includes and careful setup of byte arrays, shape, and strides. ```c #include "stdlib/complex/float64/ctor.h" #include // Create underlying byte arrays: uint8_t x[] = { 0, 0, 0, 0, 0, 0 }; uint8_t y[] = { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 }; uint8_t out[] = { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 }; // Define a pointer to an array containing pointers to strided arrays: uint8_t *arrays[] = { x, y, out }; // Define the strides: int64_t strides[] = { 2, 4, 16 }; // Define the number of elements over which to iterate: int64_t shape[] = { 3 }; // Define a callback: static stdlib_complex128_t fcn( stdlib_complex128_t x, stdlib_complex128_t y ) { // ... } // Apply the callback: stdlib_strided_kf_z_as_zz_z( arrays, shape, strides, (void *)fcn ); ``` ```c void stdlib_strided_kf_z_as_zz_z( uint8_t *arrays[], const int64_t *shape, const int64_t *strides, void *fcn ); ``` -------------------------------- ### Get inherited properties of an array Source: https://github.com/stdlib-js/stdlib/blob/develop/lib/node_modules/@stdlib/utils/inherited-properties/README.md This example demonstrates how to get the inherited properties of an array. By default, the function traverses the entire prototype chain. ```javascript var props = inheritedProperties( [ 1, 2, 3 ] ); // returns [...] ``` -------------------------------- ### Example bundle usage with path join and pattern Source: https://github.com/stdlib-js/stdlib/blob/develop/lib/node_modules/@stdlib/_tools/benchmarks/bundle/README.md An example demonstrating how to bundle benchmark files from a specific root directory with a custom pattern, using `path.join` for path construction. ```javascript var join = require( 'path' ).join; var bundle = require( '@stdlib/_tools/benchmarks/bundle' ); var root = join( __dirname, 'fixtures' ); var opts = { 'pattern': '*.js' }; bundle( root, opts, onBundle ); function onBundle( error, bundle ) { if ( error ) { throw error; } console.log( bundle.toString() ); } ``` -------------------------------- ### Apply Complex Callback to Strided Arrays (C) Source: https://github.com/stdlib-js/stdlib/blob/develop/lib/node_modules/@stdlib/strided/base/binary/README.md Applies a binary complex callback to strided input arrays and assigns results to a strided output array. Requires specific includes and setup for arrays, shape, strides, and the callback function. ```c #include "stdlib/complex/float64/ctor.h" #include // Create underlying byte arrays: uint8_t x[] = { 0, 0, 0 }; uint8_t y[] = { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 }; uint8_t out[] = { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 }; // Define a pointer to an array containing pointers to strided arrays: uint8_t *arrays[] = { x, y, out }; // Define the strides: int64_t strides[] = { 1, 4, 8 }; // Define the number of elements over which to iterate: int64_t shape[] = { 3 }; // Define a callback: static stdlib_complex128_t fcn( stdlib_complex128_t x, stdlib_complex128_t y ) { // ... } // Apply the callback: stdlib_strided_bf_c_as_zz_z( arrays, shape, strides, (void *)fcn ); ``` ```c void stdlib_strided_bf_c_as_zz_z( uint8_t *arrays[], const int64_t *shape, const int64_t *strides, void *fcn ); ``` -------------------------------- ### Import get function from @stdlib/_tools/github/get Source: https://github.com/stdlib-js/stdlib/blob/develop/lib/node_modules/@stdlib/_tools/github/get/README.md Use this snippet to import the `get` function for retrieving GitHub API resources. Ensure the package is installed. ```javascript var get = require( '@stdlib/_tools/github/get' ); ``` -------------------------------- ### Full Example with Options Source: https://github.com/stdlib-js/stdlib/blob/develop/lib/node_modules/@stdlib/_tools/benchmarks/browser-build/README.md A comprehensive example demonstrating how to build browser benchmark assets with specific options for pattern, bundle, and HTML filenames. It also includes directory creation and error handling. ```javascript var join = require( 'path' ).join; var resolve = require( 'path' ).resolve; var mkdirp = require( 'mkdirp' ).sync; var build = require( '@stdlib/_tools/benchmarks/browser-build' ); var root = join( __dirname, 'fixtures' ); var out = resolve( __dirname, '../build' ); mkdirp( out ); var opts = { 'pattern': 'index.js', 'bundle': 'benchmark_bundle.js', 'html': 'benchmarks.html' }; build( root, out, opts, clbk ); function clbk( error, bool ) { if ( error ) { throw error; } if ( bool ) { console.log( 'Success!' ); } else { console.log( 'No generated assets.' ); } } ``` -------------------------------- ### Example: Star a repository with token and user agent Source: https://github.com/stdlib-js/stdlib/blob/develop/lib/node_modules/@stdlib/_tools/github/star-repo/README.md A complete example demonstrating how to star a repository, requiring a GitHub access token and optionally a user agent. Ensure to replace '' with your actual token. ```javascript var star = require( '@stdlib/_tools/github/star-repo' ); var opts = { 'token': '', 'useragent': 'beep-boop-bop' }; star( 'stdlib-js/stdlib', opts, clbk ); function clbk( error, info ) { if ( info ) { console.error( info ); } if ( error ) { if ( error instanceof Error ) { throw error; } console.error( error.message ); } else { console.log( 'Success!' ); } } ``` -------------------------------- ### Get next code point index from start Source: https://github.com/stdlib-js/stdlib/blob/develop/lib/node_modules/@stdlib/string/next-code-point-index/README.md Find the index of the next Unicode code point in a string, starting the search from the beginning. ```javascript var out = nextCodePointIndex( 'last man standing' ); // returns 1 ``` -------------------------------- ### Comprehensive file tree build example Source: https://github.com/stdlib-js/stdlib/blob/develop/lib/node_modules/@stdlib/_tools/docs/www/readme-fragment-file-tree/README.md A comprehensive example demonstrating how to build an HTML rendered package README file tree. It includes setting a custom directory, ignore patterns, and handling the build process with a callback. ```javascript var mkdir = require( 'fs' ).mkdirSync; var resolve = require( 'path' ).resolve; var exists = require( '@stdlib/fs/exists' ).sync; var build = require( '@stdlib/_tools/docs/www/readme-fragment-file-tree' ); var dpath = resolve( __dirname, 'build' ); var opts = { 'dir': './lib/node_modules', 'ignore': [ 'benchmark/**', 'bin/**', 'build/**', 'docs/**', 'etc/**', 'examples/**', 'reports/**', 'scripts/**', 'test/**' ] }; if ( !exists( dpath ) ) { mkdir( dpath ); } build( dpath, opts, done ); function done( error ) { if ( error ) { throw error; } console.log( 'Finished!' ); } ``` -------------------------------- ### Example usage of dapxsum.ndarray Source: https://github.com/stdlib-js/stdlib/blob/develop/lib/node_modules/@stdlib/blas/ext/base/wasm/dapxsum/README.md Demonstrates the usage of the dapxsum.ndarray function with randomly generated data. This example assumes the necessary @stdlib modules are installed and available. ```javascript var discreteUniform = require( '@stdlib/random/array/discrete-uniform' ); var dapxsum = require( '@stdlib/blas/ext/base/wasm/dapxsum' ); var opts = { 'dtype': 'float64' }; var x = discreteUniform( 10, 0, 100, opts ); console.log( x ); var sum = dapxsum.ndarray( x.length, 5.0, x, 1, 0 ); console.log( sum ); ``` -------------------------------- ### Run All Package Examples Source: https://github.com/stdlib-js/stdlib/blob/develop/tools/make/README.md Executes all example files for all packages in the project. This command is used to verify that examples are functioning correctly. ```bash $ make examples ``` -------------------------------- ### Get Float32 Size - JavaScript Source: https://github.com/stdlib-js/stdlib/blob/develop/lib/node_modules/@stdlib/constants/float32/num-bytes/docs/repl.txt Access the `float32` constant to get the size in bytes of a single-precision floating-point number. This value is fixed and does not require any setup. ```javascript const alias = require('@stdlib/constants-float32/size'); console.log(alias); // returns 4 ```