From 326ea632219d10f3a65d4697e995f829cc4368c3 Mon Sep 17 00:00:00 2001 From: Ryuu Mitsuki Date: Thu, 18 Apr 2024 16:23:18 +0700 Subject: [PATCH 1/2] refactor: Move the `lsTypes` to separate file The module has also correctly re-exported from main entry package, and update some documentations. --- src/index.ts | 3 +++ src/lsTypes.ts | 49 +++++++++++++++++++++++++++++++++++++++++++++++++ src/lsfnd.ts | 42 +++--------------------------------------- 3 files changed, 55 insertions(+), 39 deletions(-) create mode 100644 src/lsTypes.ts diff --git a/src/index.ts b/src/index.ts index 4f4f0b6..28b617f 100644 --- a/src/index.ts +++ b/src/index.ts @@ -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'; diff --git a/src/lsTypes.ts b/src/lsTypes.ts new file mode 100644 index 0000000..ab1d152 --- /dev/null +++ b/src/lsTypes.ts @@ -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 +} diff --git a/src/lsfnd.ts b/src/lsfnd.ts index 780c9f6..9b76275 100644 --- a/src/lsfnd.ts +++ b/src/lsfnd.ts @@ -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) @@ -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, @@ -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. @@ -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 From 32681d7615012edf2cc69bd872e0ff099f359d3b Mon Sep 17 00:00:00 2001 From: Ryuu Mitsuki Date: Thu, 18 Apr 2024 16:44:16 +0700 Subject: [PATCH 2/2] chore(typedoc): Update the `entryPoints` field Included the `lsTypes.ts` module to the `entryPoints` field. --- typedoc.config.js | 1 + 1 file changed, 1 insertion(+) diff --git a/typedoc.config.js b/typedoc.config.js index 0799d98..04b02df 100644 --- a/typedoc.config.js +++ b/typedoc.config.js @@ -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' ],