unplugin-utils
Advanced tools
+18
-4
@@ -1,2 +0,1 @@ | ||
| "use strict"; | ||
| //#region rolldown:runtime | ||
@@ -29,2 +28,5 @@ var __create = Object.create; | ||
| //#region src/path.ts | ||
| /** | ||
| * Converts path separators to forward slash. | ||
| */ | ||
| function normalizePath(filename) { | ||
@@ -51,2 +53,14 @@ return filename.replaceAll("\\", "/"); | ||
| } | ||
| /** | ||
| * Constructs a filter function which can be used to determine whether or not | ||
| * certain modules should be operated upon. | ||
| * @param include If `include` is omitted or has zero length, filter will return `true` by default. | ||
| * @param exclude ID must not match any of the `exclude` patterns. | ||
| * @param options Additional options. | ||
| * @param options.resolve Optionally resolves the patterns against a directory other than `process.cwd()`. | ||
| * If a `string` is specified, then the value will be used as the base directory. | ||
| * Relative paths will be resolved against `process.cwd()` first. | ||
| * If `false`, then the patterns will not be resolved against any directory. | ||
| * This can be useful if you want to create a filter for virtual module names. | ||
| */ | ||
| function createFilter(include, exclude, options) { | ||
@@ -80,4 +94,4 @@ const resolutionBase = options && options.resolve; | ||
| //#endregion | ||
| exports.createFilter = createFilter | ||
| exports.normalizePath = normalizePath | ||
| exports.toArray = toArray | ||
| exports.createFilter = createFilter; | ||
| exports.normalizePath = normalizePath; | ||
| exports.toArray = toArray; |
+8
-5
@@ -0,1 +1,2 @@ | ||
| //#region src/filter.d.ts | ||
| /** | ||
@@ -18,5 +19,6 @@ * A valid `picomatch` glob pattern, or array of patterns. | ||
| declare function createFilter(include?: FilterPattern, exclude?: FilterPattern, options?: { | ||
| resolve?: string | false | null | ||
| resolve?: string | false | null; | ||
| }): (id: string | unknown) => boolean; | ||
| //#endregion | ||
| //#region src/path.d.ts | ||
| /** | ||
@@ -26,5 +28,6 @@ * Converts path separators to forward slash. | ||
| declare function normalizePath(filename: string): string; | ||
| //#endregion | ||
| //#region src/utils.d.ts | ||
| declare function toArray<T>(thing: readonly T[] | T | undefined | null): readonly T[]; | ||
| export { type FilterPattern, createFilter, normalizePath, toArray }; | ||
| //#endregion | ||
| export { FilterPattern, createFilter, normalizePath, toArray }; |
+8
-5
@@ -0,1 +1,2 @@ | ||
| //#region src/filter.d.ts | ||
| /** | ||
@@ -18,5 +19,6 @@ * A valid `picomatch` glob pattern, or array of patterns. | ||
| declare function createFilter(include?: FilterPattern, exclude?: FilterPattern, options?: { | ||
| resolve?: string | false | null | ||
| resolve?: string | false | null; | ||
| }): (id: string | unknown) => boolean; | ||
| //#endregion | ||
| //#region src/path.d.ts | ||
| /** | ||
@@ -26,5 +28,6 @@ * Converts path separators to forward slash. | ||
| declare function normalizePath(filename: string): string; | ||
| //#endregion | ||
| //#region src/utils.d.ts | ||
| declare function toArray<T>(thing: readonly T[] | T | undefined | null): readonly T[]; | ||
| export { type FilterPattern, createFilter, normalizePath, toArray }; | ||
| //#endregion | ||
| export { FilterPattern, createFilter, normalizePath, toArray }; |
+15
-0
@@ -5,2 +5,5 @@ import { isAbsolute, join, resolve } from "pathe"; | ||
| //#region src/path.ts | ||
| /** | ||
| * Converts path separators to forward slash. | ||
| */ | ||
| function normalizePath(filename) { | ||
@@ -27,2 +30,14 @@ return filename.replaceAll("\\", "/"); | ||
| } | ||
| /** | ||
| * Constructs a filter function which can be used to determine whether or not | ||
| * certain modules should be operated upon. | ||
| * @param include If `include` is omitted or has zero length, filter will return `true` by default. | ||
| * @param exclude ID must not match any of the `exclude` patterns. | ||
| * @param options Additional options. | ||
| * @param options.resolve Optionally resolves the patterns against a directory other than `process.cwd()`. | ||
| * If a `string` is specified, then the value will be used as the base directory. | ||
| * Relative paths will be resolved against `process.cwd()` first. | ||
| * If `false`, then the patterns will not be resolved against any directory. | ||
| * This can be useful if you want to create a filter for virtual module names. | ||
| */ | ||
| function createFilter(include, exclude, options) { | ||
@@ -29,0 +44,0 @@ const resolutionBase = options && options.resolve; |
+17
-16
| { | ||
| "name": "unplugin-utils", | ||
| "version": "0.2.4", | ||
| "version": "0.2.5", | ||
| "description": "A set of utility functions commonly used by unplugins.", | ||
@@ -34,18 +34,19 @@ "type": "module", | ||
| "dependencies": { | ||
| "pathe": "^2.0.2", | ||
| "picomatch": "^4.0.2" | ||
| "pathe": "^2.0.3", | ||
| "picomatch": "^4.0.3" | ||
| }, | ||
| "devDependencies": { | ||
| "@sxzz/eslint-config": "^5.0.1", | ||
| "@sxzz/prettier-config": "^2.1.1", | ||
| "@types/node": "^22.13.1", | ||
| "@types/picomatch": "^3.0.2", | ||
| "bumpp": "^10.0.2", | ||
| "eslint": "^9.19.0", | ||
| "oxc-transform": "^0.48.2", | ||
| "prettier": "^3.4.2", | ||
| "tsdown": "^0.5.7", | ||
| "tsx": "^4.19.2", | ||
| "typescript": "^5.7.3", | ||
| "vitest": "^3.0.5" | ||
| "@sxzz/eslint-config": "^7.1.2", | ||
| "@sxzz/prettier-config": "^2.2.3", | ||
| "@types/node": "^24.2.0", | ||
| "@types/picomatch": "^4.0.2", | ||
| "@vitest/coverage-v8": "3.2.4", | ||
| "bumpp": "^10.2.2", | ||
| "eslint": "^9.32.0", | ||
| "oxc-transform": "^0.80.0", | ||
| "prettier": "^3.6.2", | ||
| "tsdown": "^0.13.3", | ||
| "tsx": "^4.20.3", | ||
| "typescript": "^5.9.2", | ||
| "vitest": "^3.2.4" | ||
| }, | ||
@@ -64,4 +65,4 @@ "engines": { | ||
| "format": "prettier --cache --write .", | ||
| "release": "bumpp && pnpm publish" | ||
| "release": "bumpp" | ||
| } | ||
| } |
+2
-1
@@ -1,2 +0,2 @@ | ||
| # unplugin-utils [](https://npmjs.com/package/unplugin-utils) | ||
| # unplugin-utils [](https://npmjs.com/package/unplugin-utils) [](https://codecov.io/gh/sxzz/unplugin-utils) | ||
@@ -13,2 +13,3 @@ [](https://github.com/sxzz/unplugin-utils/actions/workflows/unit-test.yml) | ||
| - ✂️ Subset, smaller bundle size. | ||
| - **💯 Coverage**: 100% test coverage. | ||
@@ -15,0 +16,0 @@ ## Install |
14853
15.29%182
22.97%61
1.67%13
8.33%Updated
Updated