udirpdeprecated

A library that facilitates the use of many things that Node.js includes and including new functions and methods. (And recycle libraries)

Usage no npm install needed!

<script type="module">
  import udirp from 'https://cdn.skypack.dev/udirp';
</script>

README

Installation

npm install udirp
Stable versions that are not without bugs: 1.0.14 and 1.1.2

Import

Typescript

import dirp from "udirp";
//Or you can also get the properties independently.

Javascript

const dirp = require("udirp");
//Or you can also get the properties independently.

How to use 🤔

Example to get information from a file in typescript.

/*
Suppose this is my folder where my project is:

- node_modules
- src
    + index.ts
    - schools
        - json
            + students.json
            + schools.json


And I want to get my JSON where is the information of my students (students.json). Im in index.ts and the content of the json is

{
    "luis":{
        "math":10,
        "science":8
    },
    "tom":{
        "math":7,
        "science":9
    }
}

*/
//The first parameter will be the name of our file to obtain information, in this case it will be "students". Then open options in the form of an object, these options will be, the file extension, if it is outside the directory, and if it is inside other directories. Finally, this method expects a promise, so we will use .then to obtain the read data.
import { file } from "udirp";
file
  .getContent("students", { extension: "json", directory: "src/schools/json" })
  .then((response) => {
    response.data;
    //This return <Buffer 7b 0d 0a 20 20 20 20 22 6c 75 69 73 22 3a 7b 0d 0a 20 20 20 20 20 20 20 20 22 6d 61 74 68 22 3a 31 30 2c 0d 0a 20 20 20 20 20 20 20 20 22 73 63 69 65 ... 77 more bytes>
    response.data.toString();
    /*This return {
    "luis":{
        "math":10,
        "science":8
    },
    "tom":{
        "math":7,
        "science":9
    }
}
*/
  });

Example of how to get total ram, use ram and free ram in megabytes.

import { ram } from "udirp";
ram.get().then((res) => {
  console.log(`
It is in use ${res.ram_usage_mb} MB
There is free ${res.free_ram_mb} MB
There are in total ${res.total_ram_mb} MB
    `);
});
/*
This return 

It is in use 7029.5 MB
There is free 9286.88 MB
There are in total 16316.38 MB
*/

Example to obtain the active time in hours, minutes and seconds.

import { computer, utils } from "./lib/index";

computer.uptime().then((res) => {
  utils.getTime(res.data).then((res) => {
    console.log(res.date);
  });
});

//This return 7 Hours, 23 Minutes And 19 Seconds

Computer

Property Function Result in object
getAllInfo { }
name_gpu
vram
temperature_gpu
total_memory_mb_gpu
free_memory_mb_gpu
use_memory_mb_gpu
system_info
cpu_model
cores
cpu_usage
ram_usage
total_ram
free_ram_mb
free_ram_porcent
ip
max_temperature_cpu
uptime
voltage
platform
max_speed_cpu
min_speed_cpu
speed_cpu
temperature_cpu
getIp ip:string
uptime uptime:number

Ram

Property Function Result in object
get { }
free_ram_mb
free_ram_porcent
total_ram_mb

Gpu

Property Function Result in object
get { }
name
use_memory_md
free_memory_md
total_memory_md
temperature
vram

Cpu

Property Function Result in object
get { }
voltage
cpu_model
cpu_usage
max_temperature
max_speed
min_speed
speed
temperature

Utils

Property Function Result in object
getTime { }
data

File

Property Method Principal parameter and type Options parameters and type Promise ? Returns ?
getContent name_file:string directory: string; thisDirectory: boolean; extension: string Yes object: data
create name_file:string filename_extension: string; content: string; directory: string; thisDirectory: boolean; No Nothing
delete name_file: string, directory: string; thisDirectory: boolean; No Nothing
clone name_file: string directory: string; filename_extension: string; thisDirectory: boolean; No Nothing
getInfo name_file:string extension: string, directory: string, thisDirectory: boolean Yes object:content, extension, name and directory

Dir

Property Method Principal parameter and type Options parameters and type Promise ? Returns ?
create name_folder: string Dont have No Nothing
delete name_folder: string Dont have No Nothing

This library is in beta phase, new methods and functions will be added little by little.