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

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.

  • 1.2.0
  • npm
  • Socket score

Version published
Weekly downloads
7
decreased by-12.5%
Maintainers
1
Weekly downloads
 
Created
Source

Kaven-Utils

Installation

npm i kaven-utils --save

or

yarn add kaven-utils

Usage

import { KavenCommon, KavenUtility, ... } from "kaven-utils";

// Create Express server
const app = express();
app.use(KavenCommon.Logger);

KavenUtility.MethodName();
...

KavenUtility Methods List

    static Initialize(): void;
    static BuildLogString(level?: LogLevel, ...args: any[]): string;
    static BuildError(...param: any[]): string;
    static OverrideConsole(): typeof KavenUtility;
    static GetColoredStatus(code: string | number): string | number;
    static CopyFileSync(dest: string, src: string): any;
    static FindLogFile(): Promise<string>;
    static ResetLogFile(fileName: string, backupFolder?: string): boolean;
    static GetLogContent(file?: string, html?: boolean): Promise<any>;
    static GetFileContent(fileName: string, html?: boolean): Promise<string>;
    static IsDirectory(strPath: string): boolean;
    static GetFileExtension(fileName: string, trimDot?: boolean, toLowerCase?: boolean): string;
    static GetFileName(fileName: string): string;
    static ZipFolder(folderPath: string, fileName: string, topFolderName?: string): Promise<string>;
    static SevenZipFolder(folderPath: string, fileName: string, password?: string): Promise<string>;
    static Run7zCommand(command: string, switches?: any): Promise<string>;
    static SevenZipFiles(files: string[], fileName: string, password?: string): Promise<string>;
    static BackupMongoDB(outputDir: string, databaseName?: string, host?: string, databaseUser?: string, databasePassword?: string): Promise<string>;
    static DeleteFolder(folderPath: string): Promise<string[]>;
    static UploadFileToFTPServer(fileName: string, serverHost?: string, serverPort?: number, serverUserName?: string, serverUserPassword?: string): Promise<string>;
    static SendEmail(config: MailConfig, option: MailOption): Promise<{}>;
    static GenerateQRCode(data: string, version?: number, errorCorrectionLevel?: "low" | "medium" | "quartile" | "high" | "L" | "M" | "Q" | "H", toSJISFunc?: (codePoint: string) => number): Promise<any>;
    static 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;
    static StartScheduleLikeCron(func: () => void, rule: string): schedule.Job;
    static Base64Encode(data: string, encoding?: string): string;
    static Base64Decode(base64Data: string, encoding?: string): string;
    static CreateCertificate(options?: pem.CertificateCreationOptions): Promise<pem.CertificateCreationResult>;
    static SaveStringToFile(str: string, savePath: string): Promise<string>;
    static WriteStringToClipboard(text: string): void;
    static WriteStringToClipboardAsync(text: string): Promise<void>;
    static ReadStringFromClipboard(): string;
    static ReadStringFromClipboardAsync(): Promise<string>;
    static DownloadFile(url: string, savePath: string): Promise<string>;
    static GetFileSizeInBytes(filePath: string): Promise<number>;
    static ResetLogFileIf(overBytes?: number): Promise<boolean>;
    static MakeDirectory(dir: string): Promise<string>;
    static MakeDirectorySync(dir: string): string;
    static LoadJsonFile(filePath: string): Promise<IndexObject>;
    static HMAC_SHA1(stringToSign: string, secret: string): Buffer;
    static GetAllFilesRecursively(dir: string, extensions?: string[], ignorePaths?: string[]): string[];
    static GetAllFiles(dir: string): string[];
    static FindAndReplaceInFiles(dirOrFiles: string | string[], conditions?: string[][], newStrMethod?: (str: string) => string, extensions?: string[], showLog?: boolean): Promise<void>;
    static GetFileType(buf: Buffer | Uint8Array): FileType.FileTypeResult;
    static GetFileTypeFromFile(file: string): Promise<FileType.FileTypeResult>;
    static GetFileList(filesOrFolders: string[], excludeFilesOrFolders?: string[], fileTypes?: string[]): string[];
    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>;
    static CreateJWT(payload: string | object | Buffer, secret: string, options: JWT.SignOptions): Promise<string>;
    static VerifyJWT(token: string, secret: string, options?: JWT.SignOptions): Promise<{
        [key: string]: any;
    }>;
    static DecodeJWT(token: string, options?: JWT.DecodeOptions): string | {
        [key: string]: any;
    };
    static ReadFileBytes(file: string, length: number, offset?: number): Promise<Buffer>;

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

Code Refactoring

Dependencies

Example

Keywords

FAQs

Package last updated on 03 Aug 2019

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