Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
96 changes: 96 additions & 0 deletions lib/node_modules/@stdlib/_tools/repl-txt/wrap-text/bin/cli
Original file line number Diff line number Diff line change
@@ -0,0 +1,96 @@
#!/usr/bin/env node

/**
* @license Apache-2.0
*
* Copyright (c) 2026 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 readFileSync = require( '@stdlib/fs/read-file' ).sync;
var stdin = require( '@stdlib/process/read-stdin' );
var stdinStream = require( '@stdlib/streams/node/stdin' );
var CLI = require( '@stdlib/cli/ctor' );
var wrap = require( './../lib' );


// MAIN //

/**
* Main execution sequence.
*
* @private
* @returns {void}
*/
function main() {
var flags;
var args;
var opts;
var cli;

// Create a command-line interface:
cli = new CLI({
'pkg': require( './../package.json' ),
'options': require( './../etc/cli_opts.json' ),
'help': readFileSync( resolve( __dirname, '..', 'docs', 'usage.txt' ), {
'encoding': 'utf8'
})
});

// Get any provided command-line options:
flags = cli.flags();
if ( flags.help || flags.version ) {
return;
}

// Get any provided command-line arguments:
args = cli.args();

// Build options...
opts = {};
if ( flags.indent !== void 0 ) {
opts.indent = flags.indent;
}
if ( flags[ 'max-width' ] !== void 0 ) {
opts.maxWidth = flags[ 'max-width' ];
}

// Check if we are receiving data from `stdin`...
if ( !stdinStream.isTTY ) {
return stdin( onRead );
}
console.log( wrap( args[ 0 ], opts ) ); // eslint-disable-line no-console

/**
* Callback invoked upon reading from `stdin`.
*
* @private
* @param {(Error|null)} error - error object
* @param {Buffer} data - data
* @returns {void}
*/
function onRead( error, data ) {
if ( error ) {
return cli.error( error );
}
console.log( wrap( data.toString(), opts ) ); // eslint-disable-line no-console
}
}

main();
10 changes: 10 additions & 0 deletions lib/node_modules/@stdlib/_tools/repl-txt/wrap-text/docs/usage.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@

Usage: wrap-text [options] [str]

Options:

-h, --help Print this message.
-V, --version Print the package version.
-i, --indent indent Number of leading spaces per line. Default: 4.
-w, --max-width width Total line width limit. Default: 80.

Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
{
"boolean": [
"help",
"version"
],
"integer": [
"indent",
"max-width"
],
"alias": {
"help": [
"h"
],
"version": [
"V"
]
}
}
106 changes: 106 additions & 0 deletions lib/node_modules/@stdlib/_tools/repl-txt/wrap-text/examples/index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,106 @@
/**
* @license Apache-2.0
*
* Copyright (c) 2026 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';

var wrap = require( './../lib' );

var txt = 'Beep boop foo bar.';
var out = wrap( txt );
console.log( out+'\n' );

txt = 'Rounds each element in a single-precision floating-point strided array `x` toward zero and assigns the results to elements in a single-precision floating-point strided array `y`.';
out = wrap( txt );
console.log( out+'\n' );

txt = 'Rounds each element in a single-precision floating-point strided array `x` toward positive infinity and assigns the results to elements in a single-precision floating-point strided array `y`.';
out = wrap( txt );
console.log( out+'\n' );

txt = 'Evaluates the ramp function for each element in a double-precision floating-point strided array `x` and assigns the results to elements in a double-precision floating-point strided array `y`.';
out = wrap( txt );
console.log( out+'\n' );

txt = [
'Generates a double-precision floating-point Vandermonde matrix.',
'',
'When the mode is positive, the matrix is generated such that',
'',
' [',
' 1 x_0^1 x_0^2 ... x_0^(N-1)',
' 1 x_1^1 x_1^2 ... x_1^(N-1)',
' ...',
' ]',
'',
'with increasing powers along the rows.'
].join( '\n' );
out = wrap( txt );
console.log( out+'\n' );

txt = [
'Initializes a single-precision floating-point workspace array for performing a real-valued Fourier transform.',
'',
'The workspace array is divided into three sections:',
'',
'1. scratch/workspace: the section ranges from indices 0 to N-1 and is used while performing transforms. This section is not updated during initialization.',
'',
'2. twiddle factors: the section ranges from indices N to 2N-1 and stores a table of reusable complex exponential constants as cosine/sine pairs.'
].join( '\n' );
out = wrap( txt );
console.log( out+'\n' );

txt = [
'Converts an array to an object supporting fancy indexing.',
'',
'Fancy arrays support broadcasting in which assigned scalars and single-element arrays are repeated (without additional memory allocation) to match the length of a target array instance.'
].join( '\n' );
out = wrap( txt );
console.log( out+'\n' );

txt = [
'In octal representation, a mask is a four digit number, e.g., 0077, comprised as follows:',
'',
'- 0: special permissions (setuid, setgid, sticky bit)',
'- 0: (u)ser/owner permissions',
'- 7: (g)roup permissions',
'- 7: (o)thers/non-group permissions',
'',
'Permissions can be represented using the following symbolic form:',
'',
' u=rwx,g=rwx,o=rwx'
].join( '\n' );
out = wrap( txt );
console.log( out+'\n' );

txt = [
'Applies a real elementary reflector `H = I - tau * v * v^T` to a real M by N matrix `C`.',
'',
'If `side = \'left\'`,',
'',
'- `work` should have `N` indexed elements.',
'- `V` should have `1 + (M-1) * abs(strideV)` indexed elements.',
'- `C` is overwritten by `H * C`.',
'',
'If `side = \'right\'`,',
'',
'- `work` should have `M` indexed elements.',
'- `V` should have `1 + (N-1) * abs(strideV)` indexed elements.',
'- `C` is overwritten by `C * H`.'
].join( '\n' );
out = wrap( txt );
console.log( out+'\n' );
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
{
" ": "SP",
"-": "HY",
"(": "OP",
"[": "OP",
"{": "OP",
")": "CL",
"]": "CL",
"}": "CL",
"`": "QU",
".": "IS",
",": "IS",
":": "IS",
";": "IS"
}
40 changes: 40 additions & 0 deletions lib/node_modules/@stdlib/_tools/repl-txt/wrap-text/lib/index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
/**
* @license Apache-2.0
*
* Copyright (c) 2026 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';

/**
* Wrap text using a forward greedy algorithm with UAX #14-inspired break classes.
*
* @module @stdlib/_tools/repl-txt/wrap-text
*
* @example
* var wrap = require( '@stdlib/_tools/repl-txt/wrap-text' );
*
* var out = wrap( 'This is a short line.' );
* // returns ' This is a short line.'
*/

// MODULES //

var main = require( './main.js' );


// EXPORTS //

module.exports = main;
Loading
Loading