Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Separate the lsTypes enum to other module, reorganizing codebase #1

Merged
merged 2 commits into from
Apr 18, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions src/index.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,12 @@
/**
* Main entry of `lsfnd` package.
*
* Copyright (c) 2024 Ryuu Mitsuki. All rights reserved.
*
* @author Ryuu Mitsuki (https://github.com/mitsuki31)
* @since 0.1.0
* @license MIT
*/

export * from './lsTypes';
export * from './lsfnd';
49 changes: 49 additions & 0 deletions src/lsTypes.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
/**
* A module contains only a {@link lsTypes} enum, which is used by {@link !lsfnd~ls ls}
* function to specify type of the returned results.
*
* Copyright (c) 2024 Ryuu Mitsuki. All rights reserved.
*
* @module lsTypes
* @author Ryuu Mitsuki (https://github.com/mitsuki31)
* @since 0.1.0
* @license MIT
* @see {@link lsTypes}
*/

/**
* This enumeration defines the different types of listings supported by
* the {@link !lsfnd~ls ls} function. It specifies which file system entries should be
* included in the results.
*
* @readonly
* @public
* @since 0.1.0
* @see {@link !lsfnd~ls ls}
*/
export enum lsTypes {
/**
* This option lists both regular files and directories in the output.
* You can also use other number types for alias, like:
* ```ts
* LS_A: 0b01 | 0o01 | 0x01 // Each equivalent to 1
* ```
*/
LS_A = 0b01 << 0b00, // ALL
/**
* This option filters the output to include only directory entries.
* You can also use other number types for alias, like:
* ```ts
* LS_D: 0b10 | 0o02 | 0x02 // Each equivalent to 2
* ```
*/
LS_D = 0b01 << 0b01, // DIRECTORY
/**
* This option filters the output to include only regular files (non-directories).
* You can also use other number types for alias, like:
* ```ts
* LS_F: 0b100 | 0o04 | 0x04 // Each equivalent to 4
* ```
*/
LS_F = 0b01 << 0b10 // FILE
}
42 changes: 3 additions & 39 deletions src/lsfnd.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,7 @@
* A module that offers some functions to read and list files and/or directories
* in a specified directory with support filtering using regular expression pattern.
*
* Copyright (c) 2024 Ryuu Mitsuki.
* Licensed under the MIT license.
* Copyright (c) 2024 Ryuu Mitsuki. All rights reserved.
*
* @module lsfnd
* @author Ryuu Mitsuki (https://github.com/mitsuki31)
Expand All @@ -14,6 +13,7 @@
import * as fs from 'node:fs';
import * as path from 'node:path';
import { isRegExp } from 'node:util';
import { lsTypes } from './lsTypes';
import type {
LsEntries,
LsResult,
Expand All @@ -22,42 +22,6 @@ import type {
LsTypesValues
} from '../types';

/**
* This enumeration defines the different types of listings supported by
* the {@link ls} function. It specifies which file system entries should be
* included in the results.
*
* @readonly
* @since 0.1.0
* @see {@link ls}
*/
export enum lsTypes {
/**
* This option lists both regular files and directories in the output.
* You can also use other number types for alias, like:
* ```ts
* LS_A: 0b01 | 0o01 | 0x01 // Each equivalent to 1
* ```
*/
LS_A = 0b01 << 0b00, // ALL
/**
* This option filters the output to include only directory entries.
* You can also use other number types for alias, like:
* ```ts
* LS_D: 0b10 | 0o02 | 0x02 // Each equivalent to 2
* ```
*/
LS_D = 0b01 << 0b01, // DIRECTORY
/**
* This option filters the output to include only regular files (non-directories).
* You can also use other number types for alias, like:
* ```ts
* LS_F: 0b100 | 0o04 | 0x04 // Each equivalent to 4
* ```
*/
LS_F = 0b01 << 0b10 // FILE
}

/**
* Lists files and/or directories in a specified directory path, filtering by a
* regular expression pattern.
Expand Down Expand Up @@ -86,7 +50,7 @@ export enum lsTypes {
* @param type - A type to specify the returned file system type to be included.
* If not specified or set to `0`, then it will includes all types
* (including regular files and directories).
* See {@link lsTypes} to check all supported types.
* See {@link !lsTypes~lsTypes lsTypes} to check all supported types.
*
* @returns A promise that resolves with an array of string representing the
* entries result or an empty array if any files and directories doesn't
Expand Down
1 change: 1 addition & 0 deletions typedoc.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ module.exports = {
titleLink: pkg.repository.url.replace(/^git\+/, ''),
entryPoints: [
'src/lsfnd.ts',
'src/lsTypes.ts',
'types/index.d.ts',
'types/build.prop.d.ts'
],
Expand Down
Loading