Find WebAssembly

Find packages containing WebAssembly.

Usage

var findWASM = require( '@stdlib/_tools/pkgs/wasm' );

findWASM( [options,] clbk )

Asynchronously search for packages containing WebAssembly.

findWASM( onPkgs );

function onPkgs( error, pkgs ) {
    if ( error ) {
        throw error;
    }
    console.log( pkgs.join( '\n' ) );
}

The function accepts the following options:

  • dir: root directory from which to search for packages containing WebAssembly. May be either an absolute path or a path relative to the current working directory. Default: current working directory.
  • pattern: glob pattern used to find packages containing WebAssembly. Default: '**/package.json' (note: pattern must end with package.json).
  • ignore: list of glob patterns used to exclude matches.

To search from an alternative directory, set the dir option.

var opts = {
    'dir': '/foo/bar/baz'
};

findWASM( opts, onPkgs );

function onPkgs( error, pkgs ) {
    if ( error ) {
        throw error;
    }
    console.log( pkgs.join( '\n' ) );
}

To provide an alternative include filter, set the pattern option.

var opts = {
    'pattern': '**/foo/**/package.json'
};

findWASM( opts, onPkgs );

function onPkgs( error, pkgs ) {
    if ( error ) {
        throw error;
    }
    console.log( pkgs.join( '\n' ) );
}

To exclude matches, set the ignore option.

var opts = {
    'ignore': [
        'node_modules/**',
        'build/**',
        'reports/**'
    ]
};

findWASM( opts, onPkgs );

function onPkgs( error, pkgs ) {
    if ( error ) {
        throw error;
    }
    console.log( pkgs.join( '\n' ) );
}

findWASM.sync( [options] )

Synchronously searches for packages containing WebAssembly.

var pkgs = findWASM.sync();
// returns [...]

The function accepts the same options as findWASM() above.

Notes

  • The implementation resolves packages containing WebAssembly by checking for a WebAssembly flag in a package's package.json file.
  • No attempt is made to ensure that a WebAssembly implementation is actually exposed by the package.

Examples

var findWASM = require( '@stdlib/_tools/pkgs/wasm' );

findWASM( onPkgs );

function onPkgs( error, pkgs ) {
    if ( error ) {
        throw error;
    }
    console.log( pkgs.join( '\n' ) );
}

CLI

Usage

Usage: find-pkg-wasm [options] [<dir>]

Options:

  -h,    --help                Print this message.
  -V,    --version             Print the package version.
         --pattern pattern     Inclusion glob pattern.
         --ignore pattern      Exclusion glob pattern.

Notes

  • If not provided a dir argument, the current working directory is the search directory.

  • To provide multiple exclusion glob patterns, set multiple --ignore option arguments.

    $ find-pkg-wasm --ignore=node_modules/** --ignore=build/** --ignore=reports/**
    

Examples

$ find-pkg-wasm
<pkg>
<pkg>
...