npm package: @rosinfo.tech/node
Description: [![rosinfo.tech](https://cdn.rosinfo.tech/id/logo/id_logo_width_160.svg "rosinfo.tech")](https://rosinfo.tech)
Latest version: 0.0.8

[![rosinfo.tech](https://cdn.rosinfo.tech/id/logo/id_logo_width_160.svg "rosinfo.tech")](https://rosinfo.tech)

# @rosinfo.tech/node

## Installation

```shell
npm i @rosinfo.tech/node
```

## Usage

ES6:

```typescript
import { isExists } from "@rosinfo.tech/node/isExists";

// or
// import { isExists } from "@rosinfo.tech/node";

// ...
if ( isExists( "/path/to/file/or/directory" ) ) {
// ...
}
// ...
```

CommonJS:

```typescript
const { isExists } = require( "@rosinfo.tech/node/isExists" );

// or
// const { isExists } = require( "@rosinfo.tech/node" );

// ...
if ( isExists( "/path/to/file/or/directory" ) ) {
// ...
}
// ...
```

## Functions

```typescript
import { Stats, copyFile, readFile, writeFile } from "fs";

import { inspect as inspectUtil } from "util";

export declare const FILE_SYSTEM_ENCODING_DEFAULT = "utf8";

export declare const FILE_SYSTEM_INDENT_WHITE_SPACES = 4;

export declare const FILE_SYSTEM_MAP_AFTER_KEY = "__AFTER__";

export declare const SEP: "\\" | "/";

export declare const FILE_SYSTEM_EXCEPT_FILES: string[];

export interface IDirectoryReadThenableCallbackOptions {
    directoryFile: string;
    isDirectory: boolean;
    lstatDirectoryFile: Stats;
}

export interface IDirectoryReadOptions {
    accept?: string | RegExp | Array<string | RegExp>;
    except?: string | RegExp | Array<string | RegExp>;
    isAddDirectories?: boolean;
    isAddFiles?: boolean;
    isAddPath?: boolean;
    isLink?: boolean;
    isRecursive?: boolean;
    isRecursiveDependsOnTest?: boolean;
    isReturnDirectoryFiles?: boolean;
    isTestPath?: boolean;
    thenableCallback?: (options: IDirectoryReadThenableCallbackOptions) => Promise<unknown>;
}

export declare const directoryReadOptions: (options: any) => IDirectoryReadOptions;

export declare const directoryRead: (path: string, options?: IDirectoryReadOptions | boolean, returnInternal?: Array<string>) => Promise<Array<string>>;

interface IArchiveCreateOptions {
    encoding?: string;
    format: "zip" | "tar";
    logStandard?: boolean;
    mode?: number | string;
    onLog?: (...logData: Array<string | number>) => unknown;
}

export declare const ARCHIVE_CREATE_LOG_INITIAL = "ARCHIVE_CREATE_LOG_INITIAL";

export declare const ARCHIVE_CREATE_LOG_PATH_FILE_ADD = "ARCHIVE_CREATE_LOG_PATH_FILE_ADD";

export declare const ARCHIVE_CREATE_LOG_ON_ERROR = "ARCHIVE_CREATE_LOG_ON_ERROR";

export declare const ARCHIVE_CREATE_LOG_ON_WARNING = "ARCHIVE_CREATE_LOG_ON_WARNING";

export declare const ARCHIVE_CREATE_LOG_ON_SUCCESS = "ARCHIVE_CREATE_LOG_ON_SUCCESS";

export declare const archiveCreate: (pathFileArchive: string, pathOrPathFiles: string | Array<string>, pathRelative?: string | boolean, options?: Partial<IArchiveCreateOptions> & IDirectoryReadOptions) => Promise<unknown>;

export declare const archiveExtract: (pathFileArchive: any, pathExtract: any) => Promise<void>;

interface IDirectoryCopyOptions {
    isForce?: boolean;
    isReturnCopiedFiles?: false;
    modeCopyFile?: number;
    modeMkDir?: number | string;
}

export declare const directoryCopy: (directorySource: string, directoryDestination: string, options?: IDirectoryCopyOptions & IDirectoryReadOptions) => Promise<boolean | Array<string>>;

interface IDirectoryCreateOptions {
    mode?: number | string;
    recursive?: boolean;
}

export declare const directoryCreate: (path: any, options?: IDirectoryCreateOptions) => Promise<boolean>;

export declare const directoryEmptyUnlink: (path: string, options: IDirectoryReadOptions) => Promise<boolean>;

export declare const fileCopy: typeof copyFile.__promisify__;

export interface IFileJsonOptions {
    createIfDoesNotExist?: boolean;
    encoding?: BufferEncoding;
    indent?: number;
}

export declare const fileJsonRead: (pathFile: string, options?: IFileJsonOptions) => Promise<any>;

export declare const fileJsonFilter: (pathFile: string, filterPropertiesName: Array<string>, options?: IFileJsonOptions) => Promise<any>;

export declare const fileJsonWrite: (pathFile: string, data: any, options?: IFileJsonOptions) => Promise<boolean>;

interface IDirectoryFileCopyOptions {
    suppressErrors?: boolean;
}

export declare const filePathCopy: (sourcePathFile: string, destinationPathFile: string, options?: IDirectoryFileCopyOptions) => Promise<boolean>;

export declare const fileRead: typeof readFile.__promisify__;

export declare const fileWrite: typeof writeFile.__promisify__;

export declare const inspect: typeof inspectUtil;

export declare const isDirectory: (directoryArg: string) => boolean;

export declare const isExists: (pathFile: string) => boolean;

type TInspectParameters = Parameters<typeof inspect>;

export declare const logInspect: (inspected: TInspectParameters[0], options?: TInspectParameters[1]) => void;

interface IMapCopyOptions {
    context?: string;
    map?: Record<string, string>;
    suppressErrors?: boolean;
}

export declare const mapCopy: ({ context, map, suppressErrors }: IMapCopyOptions) => Promise<void>;

interface IMapJsonOptions {
    context?: string;
    map?: any;
    suppressErrors?: boolean;
}

export declare const mapJson: ({ context, map, suppressErrors }: IMapJsonOptions) => Promise<void>;

interface IMapUnlinkOptions {
    context?: string;
    map?: any;
    suppressErrors?: boolean;
}

export declare const mapUnlink: ({ context, map, suppressErrors }: IMapUnlinkOptions) => Promise<void>;

interface IMapWriteOptions {
    context?: string;
    map?: any;
    suppressErrors?: boolean;
}

export declare const mapWrite: ({ context, map }: IMapWriteOptions) => Promise<void>;

export declare const normalize: (pathFile: string) => string;

export declare const resolve: (...pathFiles: Array<string>) => string;

interface IUnlinkOptions {
    contentOnly?: boolean;
}

export declare const unlink: (pathFile: string, options?: IUnlinkOptions & IDirectoryReadOptions) => Promise<boolean>;
```