Skip to content

Collection of basic node utilities, errors, terminal input, output, filesystem and more.

License

Notifications You must be signed in to change notification settings

squirrel-forge/node-util

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

80 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

@squirrel-forge/node-util

Collection of basic node utilities, errors, terminal input, output, filesystem and more.

Installation

npm i @squirrel-forge/node-util

Usage

const { Class, function } = require( '@squirrel-forge/node-util' );

Notes

In prepareation of node version support changes, dependencies are softened and must be specified and/or documented by packages requiring them. [Breaking changes] since version ^1.4.0 all external dependencies were removed and made optional peer dependencies and therefore must be installed manually when required.

Optional dependencies

These dependencies are optional and only required when using the mentioned methods or classes. All of these must be installed manually, since they have been removed as direct dependencies.

Classes

  • CliInput( cfx, args, trimQuotes, false, true )
    • trimQuotes : boolean
    • hasArgs()
    • hasFlags()
    • flag( flag, default )
    • arg( index )
    • setArg( arg )
    • setFlag( flag )
    • getFlagsOptions( src )
    • eraseLastLine()
    • question( options )
    • ask( questions )
  • Exception( message, previous, options )
    • name : string
    • previous : *
    • stack : string
    • toString()
  • FsInterface : static
    • remote( url )*
    • remoteText( url )*
    • remoteJSON( url )*
    • read( file, enc )
    • readText( file )
    • readJSON( file )
    • exists( file, access )
    • write( file, content )
    • copy( source, target )
    • dir( dir )
    • isDir( dir )
    • unlink( file )
    • relative2root( dir, root )
    • filterOptions( options )
    • filterFiles( files, options )
    • files( dir, filter )
    • fileList( dir, options )*
    • fileListRecursive2Flat( tree, result )
    • treeWalker( tree, callback )
  • OutputBuffer()*
    • length : number
    • allowIntercept : boolean
    • flush()
    • reduce()
    • contents()
    • start()
    • end()
    • onIntercept( handler )
    • offIntercept( handler )
  • Progress()*
    • start( text, loop, safemode )
    • stop( keep )
  • StatsDisplay( cfx )
    • constructor
      • StatsDisplayException : StatsDisplayException constructor
      • StatsDisplayType : StatsDisplayType constructor
    • hasStyle( name )
    • styleAs( string, style, no-reset )
    • is_simple( value )
    • is_display_type( value )
    • show( value, result, level, heading )
    • parse( source, result )
    • display( source, output )
  • Timer
    • start( name )
    • get( name )
    • measure( name )
    • end( name )
  • Warning( message, previous, options ) extends Exception
    • name : string
    • previous : *
    • stack : string
    • toString()
    • toLocaleString()

Functions

  • callback( name, context, args )
  • cmd( command )
  • convertBytes( bytes, decimals, style, return, unit )
  • convertHrtime( time, seconds_suffix_separrator, milliseconds_suffix, return )
  • isPojo( obj )
  • isUrl( string )
  • leadingZeros( number, length, char, reverse )
  • parseInput( args )
  • prompt( once )
  • rand( min, max )
  • requireOptional( name, version, fatal )
  • round( value, decimals )
  • simpleReplace( template, data, prefix, suffix )
  • strand()
  • strSlug( string )
  • trimChar( string, remove, limit )
  • updateNotice( pkg, cfx, verbose )
  • wait( ms )

Issues and docs

If you encounter any issues, please report here.


Check the sourcecode on github for detailed comments.

About

Collection of basic node utilities, errors, terminal input, output, filesystem and more.

Topics

Resources

License

Stars

Watchers

Forks

Packages

No packages published