Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

a-node-tools

Package Overview
Dependencies
Maintainers
0
Versions
7
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

a-node-tools

some about node

  • 0.0.5
  • latest
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
0
decreased by-100%
Maintainers
0
Weekly downloads
 
Created
Source

a-node-tools

A purely functional tool that includes

  • nodes use

language

English中文

install

npm install   a-node-tools  --save

file

  • readFileToJson read .json file and return JSON or null
  • readFileToJsonSync synchronous read .json file and return JSON or null
  • fileExist Does the file exist
  • dirEmpty Does the director is empty
  • writeJsonFilejson Write data to a blank file

runOtherCode section

  • runOtherCode Run other code
  • RunOtherCodeParam Declaration of parameter types for running other code

npmPkg section

  • npmPkgInfoType type of getNpmPkgInfo returns
  • getNpmPkgInfo get npm package info
  • testNpmPackageExist test a npm package is exist

path section

  • pathJoin File address concatenation
  • pathBasename Provide file path to obtain file name, without file type suffix
  • initializeFile Initialize the paths __filename and __dirname , as they can only be used in the cjs file. They are initialized here and are compatible
  • getCallerFilename Get the file that calls the function
  • isWindows Is it currently in a Windows environment, used to address the differences caused by different time separators when using 'path'
    • getDirectoryBy Find the parent directory of the target based on its file or file name

cursor section

You can use cursor to manipulate the cursor position:

MethodSchematicParameters
t\u001B--
_pon node environment printr print string; lineFeed line feed,default true
cursorHidecursor hide--
cursorShowcursor show--
cursorPositionSaveStore cursor position--
cursorPositionRestoreRestores cursor position--
cursorMoveUpcursor UpnumberOfUpwardMoves offset, default to 1
cursorMoveDowncursor DownnumberOfMovesDown offset, default to 1
cursorMoveLeftcursor LeftnumberOfLeftShifts offset, default to 1
cursorMoveRightcursor RightnumberOfRightShifts offset, default to 1
cursorAfterClearclear all after cursor--

readInput section

A function waiting for user input. Because it needs to wait, it is asynchronous, and when using it, wait should be used

import { readInput } from "a-node-tools";

const callBackFunction = (keyValue: string | undefined, key: any) => {
  if (key.name && key.name == "return") return true;
  else
    return console.log(
      `Try a different key, this key (${keyValue}) do not execute exit`
    );
};

Color section

The string color value of the terminal (meaning it cannot be used in a browser environment, (in fact, browsers have a simpler implementation method) :

Color static method

methodrgb 色值| Hexadecimal color value
fromHexadecimal------
fromRgb------
random------
darkBlackrgb(86 ,86 ,86)#565656
darkRedrgb(181 ,40 ,29)#b5281d
darkGreenrgb(50 ,181 ,32)#32b520
darkYellowrgb(160 ,160 ,29)#a0a01d
darkBluergb(64 ,10 ,217)#400ad9
darkMagentargb(201 ,24 ,201)#c918c9
darkCyanrgb(45 ,174 ,187)#2daebb
darkWhitergb(193 ,193 ,193)#c1c1c1
lightBlackrgb(111 ,111 ,111)#6f6f6f
redrgb(252 ,33 ,25)#fc2119
greenrgb(47 ,232 ,26)#2fe81a
yellowrgb(232 ,236 ,20)#e8ec14
bluergb(74 ,3 ,254)#4a03fe
magentargb(251 ,0 ,253)#fb00fa
cyanrgb(255 ,255 ,255)#ffffff

use Color

import { Color, _p } from 'a-node-tools';

/** `_Color` does not necessarily have to ce used together with `_p` ,`_p` is just the encapsulation of `process.stdout.write` */

_p(
  `${Color.red(
    `Red start${Color.yellow('The middle is yellow')} and the red ending`,
  )}`,
);

_p(Color.random('Randomly print a string of color values'));

If you have any questions, you can directly submit question

Keywords

FAQs

Package last updated on 27 Aug 2024

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc