Socket
Socket
Sign inDemoInstall

kaven-utils

Package Overview
Dependencies
Maintainers
1
Versions
102
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

kaven-utils

Utils for Node.js.


Version published
Weekly downloads
6
decreased by-64.71%
Maintainers
1
Weekly downloads
 
Created
Source

Kaven-Utils

Installation

npm i kaven-utils --save

or

yarn add kaven-utils

Usage

import KavenUtility from "kaven-utils";

KavenUtility.MethodName();
// ...
// Your own utility.js

import { KavenUtility } from "kaven-utils";

export default new class Utility extends KavenUtility {
    // ...
}();

KavenUtility Methods List

export declare class KavenUtility extends KavenBasic {
    readonly Platform: NodeJS.Platform;
    readonly IsWin32: boolean;
    ExternalIPRules: IExternalIPRule[];
    protected isInitialized: boolean;
    protected readonly ansiUp: Au;
    protected readonly chalkInstance: Chalk;
    constructor();
    Initialize(): void;
    BuildLogString(level?: LogLevel, ...args: any[]): string;
    BuildError(...param: any[]): string;
    OverrideConsole(): this;
    GetColoredStatus(code: string | number): string | number;
    CopyFileSync(dest: string, src: string): any;
    FindLogFile(): Promise<string>;
    ResetLogFile(fileName: string, backupFolder?: string): boolean;
    GetLogContent(file?: string, html?: boolean): Promise<any>;
    GetFileContent(fileName: string, html?: boolean): Promise<string>;
    IsDirectory(strPath: string): boolean;
    GetFileExtension(fileName: string, trimDot?: boolean, toLowerCase?: boolean): string;
    GetFileName(fileName: string): string;
    ZipFolder(folderPath: string, fileName: string, topFolderName?: string): Promise<string>;
    SevenZipFolder(folderPath: string, fileName: string, password?: string): Promise<string>;
    Run7zCommand(command: string, switches?: any): Promise<string>;
    SevenZipFiles(files: string[], fileName: string, password?: string): Promise<string>;
    BackupMongoDB(outputDir: string, databaseName?: string, host?: string, databaseUser?: string, databasePassword?: string): Promise<string>;
    DeleteFolder(folderPath: string): Promise<string[]>;
    DeleteFileOrDirectory(...paths: string[]): Promise<string[]>;
    UploadFileToFTPServer(fileName: string, serverHost?: string, serverPort?: number, serverUserName?: string, serverUserPassword?: string): Promise<string>;
    SendEmail(config: MailConfig, option: MailOption): Promise<{}>;
    GenerateQRCode(data: string, version?: number, errorCorrectionLevel?: "low" | "medium" | "quartile" | "high" | "L" | "M" | "Q" | "H", toSJISFunc?: (codePoint: string) => number): Promise<any>;
    StartSchedule(func: () => void, year?: number | number[], month?: number | number[], date?: number | number[], dayOfWeek?: number | number[], hour?: number | number[], minute?: number | number[], second?: number | number[]): schedule.Job;
    StartScheduleLikeCron(func: () => void, rule: string): schedule.Job;
    Base64Encode(data: string, encoding?: string): string;
    Base64Decode(base64Data: string, encoding?: string): string;
    CreateCertificate(options?: pem.CertificateCreationOptions): Promise<pem.CertificateCreationResult>;
    SaveStringToFile(str: string, savePath: string): Promise<string>;
    WriteStringToClipboard(text: string): void;
    WriteStringToClipboardAsync(text: string): Promise<void>;
    ReadStringFromClipboard(): string;
    ReadStringFromClipboardAsync(): Promise<string>;
    DownloadFile(url: string, savePath: string): Promise<string>;
    GetFileSizeInBytes(filePath: string): Promise<number>;
    ResetLogFileIf(overBytes?: number): Promise<boolean>;
    MakeDirectory(dir: string): Promise<string>;
    MakeDirectorySync(dir: string): string;
    LoadJsonFile(filePath: string): Promise<IndexObject>;
    HMAC_SHA1(stringToSign: string, secret: string): Buffer;
    GetAllFilesRecursively(dir: string, extensions?: string[], ignorePaths?: string[]): string[];
    GetAllFiles(dir: string): string[];
    FindAndReplaceInFiles(dirOrFiles: string | string[], conditions?: string[][], newStrMethod?: (str: string) => string, extensions?: string[], showLog?: boolean): Promise<void>;
    GetFileType(buf: Buffer | Uint8Array): FileType.FileTypeResult;
    GetFileTypeFromFile(file: string): Promise<FileType.FileTypeResult>;
    GetFileList(filesOrFolders: string[], excludeFilesOrFolders?: string[], fileTypes?: string[]): string[];
    RunCommand(command: string, options?: {
        encoding: BufferEncoding;
    } & ExecOptions): Promise<{
        stdout: string;
        stderr: string;
    }>;
    RunCommandAndDecode(command: string, decodeEncoding?: string): Promise<{
        stdout: string;
        stderr: string;
    }>;
    Exec(command: string, options?: IExecOptions, autoDecode?: boolean): import("child_process").ChildProcess;
    Spawn(command: string, args?: ReadonlyArray<string>, options?: SpawnOptions, autoDecode?: boolean): import("child_process").ChildProcess;
    CopyFileOrDirectory(src: string, dest: string, options?: ncpOptions): Promise<string>;
    CreateJWT(payload: string | object | Buffer, secret: string, options: JWT.SignOptions): Promise<string>;
    VerifyJWT(token: string, secret: string, options?: JWT.SignOptions): Promise<{
        [key: string]: any;
    }>;
    DecodeJWT(token: string, options?: JWT.DecodeOptions): string | {
        [key: string]: any;
    };
    ReadFileBytes(file: string, length: number, offset?: number): Promise<Buffer>;
    IsFileOrDirectoryExist(...paths: string[]): boolean[];
    GetProtocolFromURL(url: string): string;
    HTTPGet<T>(url: string): Promise<IHTTPResponse<T>>;
    HTTPPost<T>(url: string, data: any): Promise<IHTTPResponse<T>>;
    GetExternalIP(): Promise<string>;
    InitializeTextLogger(stdoutFile: string, stderrFile: string): void;
}

Release Notes

1.0.8

Add clipboard support base on clipboardy

Add following functions:

export declare function WriteStringToClipboard(text: string): void;
export declare function WriteStringToClipboardAsync(text: string): Promise<void>;
export declare function ReadStringFromClipboard(): string;
export declare function ReadStringFromClipboardAsync(): Promise<string>;
export declare function SplitStringByNewline(str: string): string[];

1.0.9

Add following functions:

export declare function RemoveInvalidCharactersForPath(path: string): string;
export declare function DownloadFile(url: string, path: string): Promise<string>;
export declare function GetFileSizeInBytes(path: string): Promise<number>;
export declare function ResetLogFileIf(overBytes?: number): Promise<boolean>;
export declare function MakeDirectory(dir: string): Promise<string>;
export declare function MakeDirectorySync(dir: string): string;

1.0.10

Add following functions:

interface String {
    GetIndent(): string;
}

1.0.11

Add:

export declare let IsDebugMode: boolean;

Improve:

export declare function CopyFileSync(dest: string, src: string): any;

1.0.12

1.0.13

1.0.14 (republish)

Add:

interface String {
    OnlyContains(...characters: string[]): boolean;
    ToArray(): string[];
    Distinct(): string;
}

interface Array < T > {
    Distinct(): Array < T > ;
    First(): T;
    Last(): T;
}

export declare let IsDebugMode: boolean;
export declare function LoadJsonFile(path: string): Promise<{[index: string]: any;}>;
export declare function GetNextVersion(version: string): string | number;

1.1.0

Add:

export declare namespace KavenCommon
export declare namespace KavenUtility
export default KavenUtility;

1.1.1

Code Improve

1.1.14

Add:

static RunCommand(command: string, options?: {
    encoding: BufferEncoding;
} & ExecOptions): Promise<{
    stdout: string;
    stderr: string;
}>;

static RunCommandAndDecode(command: string, decodeEncoding?: string): Promise<{
    stdout: string;
    stderr: string;
}>;

static CopyFileOrDirectory(src: string, dest: string, options?: ncpOptions): Promise<boolean>;

1.1.18

Add:

static ReadFileBytes(file: string, length: number, offset?: number): Promise<Buffer>;
static GetFileTypeFromFile(file: string): Promise<FileType.FileTypeResult>;

1.1.19

Improve:

static GetFileExtension(fileName: string, trimDot = false, toLowerCase = false)

1.1.20

Fix #5, #6

1.1.21

1.1.22

Add CLI support

1.2.0

1.2.1

Code Refactoring

Dependencies

Example

Keywords

FAQs

Package last updated on 22 Jan 2020

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