@stryke/path 0.20.0 → 0.21.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/is-type.cjs CHANGED
@@ -5,6 +5,8 @@ Object.defineProperty(exports, "__esModule", {
5
5
  });
6
6
  exports.isAbsolute = isAbsolute;
7
7
  exports.isAbsolutePath = isAbsolutePath;
8
+ exports.isNpmScopedPackage = isNpmScopedPackage;
9
+ exports.isNpmScopedPackagePath = isNpmScopedPackagePath;
8
10
  exports.isRelative = isRelative;
9
11
  exports.isRelativePath = isRelativePath;
10
12
  var _regex = require("./regex.cjs");
@@ -20,4 +22,10 @@ function isRelativePath(t) {
20
22
  }
21
23
  function isRelative(t) {
22
24
  return isRelativePath(t);
25
+ }
26
+ function isNpmScopedPackagePath(t) {
27
+ return _regex.NPM_SCOPED_PACKAGE_REGEX.test((0, _slash.slash)(t));
28
+ }
29
+ function isNpmScopedPackage(t) {
30
+ return isNpmScopedPackagePath(t);
23
31
  }
package/dist/is-type.d.ts CHANGED
@@ -32,3 +32,37 @@ export declare function isRelativePath(path: string): boolean;
32
32
  * @returns An indicator specifying if the path is a relative path
33
33
  */
34
34
  export declare function isRelative(path: string): boolean;
35
+ /**
36
+ * Check if the path is a npm package path.
37
+ *
38
+ * @remarks
39
+ * This only checks if the path matches the npm namespace scoped package naming convention such as `@scope/package-name`. This is an alias for {@link isNpmScopedPackage}.
40
+ *
41
+ * @example
42
+ * ```ts
43
+ * isNpmScopedPackage("@stryke/path"); // returns true
44
+ * isNpmScopedPackage("lodash"); // returns false
45
+ * isNpmNamespacePackage("./src/index.ts"); // returns false
46
+ * ```
47
+ *
48
+ * @param path - The path to check
49
+ * @returns An indicator specifying if the path is a npm package path
50
+ */
51
+ export declare function isNpmScopedPackagePath(path: string): boolean;
52
+ /**
53
+ * Check if the path is a npm package path.
54
+ *
55
+ * @remarks
56
+ * This only checks if the path matches the npm namespace scoped package naming convention such as `@scope/package-name`. This is an alias for {@link isNpmScopedPackagePath}.
57
+ *
58
+ * @example
59
+ * ```ts
60
+ * isNpmScopedPackagePath("@stryke/path"); // returns true
61
+ * isNpmScopedPackagePath("lodash"); // returns false
62
+ * isNpmScopedPackagePath("./src/index.ts"); // returns false
63
+ * ```
64
+ *
65
+ * @param path - The path to check
66
+ * @returns An indicator specifying if the path is a npm package path
67
+ */
68
+ export declare function isNpmScopedPackage(path: string): boolean;
package/dist/is-type.mjs CHANGED
@@ -1 +1 @@
1
- import{ABSOLUTE_PATH_REGEX as o}from"./regex";import{slash as n}from"./slash";export function isAbsolutePath(t){return o.test(n(t))}export function isAbsolute(t){return isAbsolutePath(t)}export function isRelativePath(t){return!isAbsolutePath(t)}export function isRelative(t){return isRelativePath(t)}
1
+ import{ABSOLUTE_PATH_REGEX as e,NPM_SCOPED_PACKAGE_REGEX as n}from"./regex";import{slash as o}from"./slash";export function isAbsolutePath(t){return e.test(o(t))}export function isAbsolute(t){return isAbsolutePath(t)}export function isRelativePath(t){return!isAbsolutePath(t)}export function isRelative(t){return isRelativePath(t)}export function isNpmScopedPackagePath(t){return n.test(o(t))}export function isNpmScopedPackage(t){return isNpmScopedPackagePath(t)}
package/dist/regex.cjs CHANGED
@@ -3,10 +3,12 @@
3
3
  Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
- exports.UNC_REGEX = exports.ROOT_FOLDER_REGEX = exports.FILE_EXTENSION_REGEX = exports.DRIVE_LETTER_START_REGEX = exports.DRIVE_LETTER_REGEX = exports.ABSOLUTE_PATH_REGEX = void 0;
6
+ exports.UNC_REGEX = exports.ROOT_FOLDER_REGEX = exports.PACKAGE_PATH_REGEX = exports.NPM_SCOPED_PACKAGE_REGEX = exports.FILE_EXTENSION_REGEX = exports.DRIVE_LETTER_START_REGEX = exports.DRIVE_LETTER_REGEX = exports.ABSOLUTE_PATH_REGEX = void 0;
7
7
  const DRIVE_LETTER_START_REGEX = exports.DRIVE_LETTER_START_REGEX = /^[A-Z]:\//i,
8
8
  DRIVE_LETTER_REGEX = exports.DRIVE_LETTER_REGEX = /^[A-Z]:$/i,
9
9
  UNC_REGEX = exports.UNC_REGEX = /^[/\\]{2}/,
10
10
  ABSOLUTE_PATH_REGEX = exports.ABSOLUTE_PATH_REGEX = /^[/\\](?![/\\])|^[/\\]{2}(?!\.)|^~[/\\]|^[A-Z]:[/\\]/i,
11
11
  ROOT_FOLDER_REGEX = exports.ROOT_FOLDER_REGEX = /^\/([A-Z]:)?$/i,
12
- FILE_EXTENSION_REGEX = exports.FILE_EXTENSION_REGEX = /\.[0-9a-z]+$/i;
12
+ FILE_EXTENSION_REGEX = exports.FILE_EXTENSION_REGEX = /\.[0-9a-z]+$/i,
13
+ PACKAGE_PATH_REGEX = exports.PACKAGE_PATH_REGEX = /^@\w+\/.*$/,
14
+ NPM_SCOPED_PACKAGE_REGEX = exports.NPM_SCOPED_PACKAGE_REGEX = /^(?:@[\w-]+\/)?[\w-]+$/;
package/dist/regex.d.ts CHANGED
@@ -4,3 +4,5 @@ export declare const UNC_REGEX: RegExp;
4
4
  export declare const ABSOLUTE_PATH_REGEX: RegExp;
5
5
  export declare const ROOT_FOLDER_REGEX: RegExp;
6
6
  export declare const FILE_EXTENSION_REGEX: RegExp;
7
+ export declare const PACKAGE_PATH_REGEX: RegExp;
8
+ export declare const NPM_SCOPED_PACKAGE_REGEX: RegExp;
package/dist/regex.mjs CHANGED
@@ -1 +1 @@
1
- export const DRIVE_LETTER_START_REGEX=/^[A-Z]:\//i,DRIVE_LETTER_REGEX=/^[A-Z]:$/i,UNC_REGEX=/^[/\\]{2}/,ABSOLUTE_PATH_REGEX=/^[/\\](?![/\\])|^[/\\]{2}(?!\.)|^~[/\\]|^[A-Z]:[/\\]/i,ROOT_FOLDER_REGEX=/^\/([A-Z]:)?$/i,FILE_EXTENSION_REGEX=/\.[0-9a-z]+$/i;
1
+ export const DRIVE_LETTER_START_REGEX=/^[A-Z]:\//i,DRIVE_LETTER_REGEX=/^[A-Z]:$/i,UNC_REGEX=/^[/\\]{2}/,ABSOLUTE_PATH_REGEX=/^[/\\](?![/\\])|^[/\\]{2}(?!\.)|^~[/\\]|^[A-Z]:[/\\]/i,ROOT_FOLDER_REGEX=/^\/([A-Z]:)?$/i,FILE_EXTENSION_REGEX=/\.[0-9a-z]+$/i,PACKAGE_PATH_REGEX=/^@\w+\/.*$/,NPM_SCOPED_PACKAGE_REGEX=/^(?:@[\w-]+\/)?[\w-]+$/;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@stryke/path",
3
- "version": "0.20.0",
3
+ "version": "0.21.0",
4
4
  "type": "module",
5
5
  "description": "A package containing various utilities that expand the functionality of NodeJs's built-in `path` module",
6
6
  "repository": {
@@ -11,9 +11,9 @@
11
11
  "private": false,
12
12
  "devDependencies": {
13
13
  "@storm-software/testing-tools": "^1.119.48",
14
- "@stryke/convert": "^0.6.5",
15
- "@stryke/type-checks": "^0.3.15",
16
- "@stryke/types": "^0.10.5"
14
+ "@stryke/convert": "^0.6.6",
15
+ "@stryke/type-checks": "^0.3.16",
16
+ "@stryke/types": "^0.10.6"
17
17
  },
18
18
  "publishConfig": { "access": "public" },
19
19
  "dependencies": {},
@@ -280,5 +280,5 @@
280
280
  "main": "./dist/index.cjs",
281
281
  "module": "./dist/index.mjs",
282
282
  "types": "./dist/index.d.ts",
283
- "gitHead": "2c99ef0e654a63299ca75104ec2e8a46d65997cc"
283
+ "gitHead": "fc3f6e2179191455ef4c9a8e7be4294a77228b07"
284
284
  }