@stryke/string-format 0.9.2 → 0.10.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/index.cjs +11 -0
- package/dist/index.d.ts +1 -0
- package/dist/index.mjs +1 -1
- package/dist/package.cjs +21 -0
- package/dist/package.d.ts +108 -0
- package/dist/package.mjs +1 -0
- package/package.json +16 -2
package/dist/index.cjs
CHANGED
|
@@ -102,6 +102,17 @@ Object.keys(_normalizeEmail).forEach(function (key) {
|
|
|
102
102
|
}
|
|
103
103
|
});
|
|
104
104
|
});
|
|
105
|
+
var _package = require("./package.cjs");
|
|
106
|
+
Object.keys(_package).forEach(function (key) {
|
|
107
|
+
if (key === "default" || key === "__esModule") return;
|
|
108
|
+
if (key in exports && exports[key] === _package[key]) return;
|
|
109
|
+
Object.defineProperty(exports, key, {
|
|
110
|
+
enumerable: true,
|
|
111
|
+
get: function () {
|
|
112
|
+
return _package[key];
|
|
113
|
+
}
|
|
114
|
+
});
|
|
115
|
+
});
|
|
105
116
|
var _pad = require("./pad.cjs");
|
|
106
117
|
Object.keys(_pad).forEach(function (key) {
|
|
107
118
|
if (key === "default" || key === "__esModule") return;
|
package/dist/index.d.ts
CHANGED
|
@@ -15,6 +15,7 @@ export * from "./get-words";
|
|
|
15
15
|
export * from "./kebab-case";
|
|
16
16
|
export * from "./lower-case-first";
|
|
17
17
|
export * from "./normalize-email";
|
|
18
|
+
export * from "./package";
|
|
18
19
|
export * from "./pad";
|
|
19
20
|
export * from "./pascal-case";
|
|
20
21
|
export * from "./period-split";
|
package/dist/index.mjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export*from"./acronyms";export*from"./camel-case";export*from"./constant-case";export*from"./deburr";export*from"./escape";export*from"./get-words";export*from"./kebab-case";export*from"./lower-case-first";export*from"./normalize-email";export*from"./pad";export*from"./pascal-case";export*from"./period-split";export*from"./pretty-bytes";export*from"./snake-case";export*from"./start-case";export*from"./strip-indents";export*from"./title-case";export*from"./unescape";export*from"./upper-case-first";
|
|
1
|
+
export*from"./acronyms";export*from"./camel-case";export*from"./constant-case";export*from"./deburr";export*from"./escape";export*from"./get-words";export*from"./kebab-case";export*from"./lower-case-first";export*from"./normalize-email";export*from"./package";export*from"./pad";export*from"./pascal-case";export*from"./period-split";export*from"./pretty-bytes";export*from"./snake-case";export*from"./start-case";export*from"./strip-indents";export*from"./title-case";export*from"./unescape";export*from"./upper-case-first";
|
package/dist/package.cjs
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.getPackageName = getPackageName;
|
|
7
|
+
exports.getPackageVersion = getPackageVersion;
|
|
8
|
+
exports.hasPackageVersion = hasPackageVersion;
|
|
9
|
+
exports.removePackageVersion = removePackageVersion;
|
|
10
|
+
function hasPackageVersion(n) {
|
|
11
|
+
return /^.[^\n\r@\u2028\u2029]*@.*$/.test(n);
|
|
12
|
+
}
|
|
13
|
+
function removePackageVersion(n) {
|
|
14
|
+
return hasPackageVersion(n) ? n.substring(0, n.lastIndexOf("@")) : n;
|
|
15
|
+
}
|
|
16
|
+
function getPackageName(n) {
|
|
17
|
+
return /^[^\n\r/\u2028\u2029]*\/.[^\n\r/\u2028\u2029]*\/.*$/.test(n) ? n.substring(0, n.lastIndexOf("/")) : removePackageVersion(n);
|
|
18
|
+
}
|
|
19
|
+
function getPackageVersion(n) {
|
|
20
|
+
return hasPackageVersion(n) ? n.replace(/^.+@/, "") : void 0;
|
|
21
|
+
}
|
|
@@ -0,0 +1,108 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Check if a package name has a version
|
|
3
|
+
*
|
|
4
|
+
* @example
|
|
5
|
+
* ```typescript
|
|
6
|
+
* hasPackageVersion("lodash@4.17.21");
|
|
7
|
+
* // => true
|
|
8
|
+
* hasPackageVersion("@stryke/core@4.17.21");
|
|
9
|
+
* // => true
|
|
10
|
+
* hasPackageVersion("lodash");
|
|
11
|
+
* // => false
|
|
12
|
+
* hasPackageVersion("@stryke/core");
|
|
13
|
+
* // => false
|
|
14
|
+
* hasPackageVersion("lodash/module");
|
|
15
|
+
* // => false
|
|
16
|
+
* hasPackageVersion("@stryke/core/module");
|
|
17
|
+
* // => false
|
|
18
|
+
* hasPackageVersion("lodash/module@4.17.21");
|
|
19
|
+
* // => true
|
|
20
|
+
* hasPackageVersion("@stryke/core/module@4.17.21");
|
|
21
|
+
* // => true
|
|
22
|
+
* ```
|
|
23
|
+
*
|
|
24
|
+
* @param value - The package name with version
|
|
25
|
+
* @returns Whether the package name has a version
|
|
26
|
+
*/
|
|
27
|
+
export declare function hasPackageVersion(value: string): boolean;
|
|
28
|
+
/**
|
|
29
|
+
* Remove the version from a package name (if it exists)
|
|
30
|
+
*
|
|
31
|
+
* @example
|
|
32
|
+
* ```typescript
|
|
33
|
+
* removePackageVersion("lodash@4.17.21");
|
|
34
|
+
* // => "lodash"
|
|
35
|
+
* removePackageVersion("@stryke/core@4.17.21");
|
|
36
|
+
* // => "@stryke/core"
|
|
37
|
+
* removePackageVersion("lodash");
|
|
38
|
+
* // => "lodash"
|
|
39
|
+
* removePackageVersion("@stryke/core");
|
|
40
|
+
* // => "@stryke/core"
|
|
41
|
+
* getPackageName("lodash/module");
|
|
42
|
+
* // => "lodash/module"
|
|
43
|
+
* getPackageName("@stryke/core/module");
|
|
44
|
+
* // => "@stryke/core/module"
|
|
45
|
+
* getPackageName("lodash/module@4.17.21");
|
|
46
|
+
* // => "lodash/module"
|
|
47
|
+
* getPackageName("@stryke/core/module@4.17.21");
|
|
48
|
+
* // => "@stryke/core/module"
|
|
49
|
+
* ```
|
|
50
|
+
*
|
|
51
|
+
* @param value - The package name with version
|
|
52
|
+
* @returns The package name without version
|
|
53
|
+
*/
|
|
54
|
+
export declare function removePackageVersion(value: string): string;
|
|
55
|
+
/**
|
|
56
|
+
* Get the package name from a scoped package string
|
|
57
|
+
*
|
|
58
|
+
* @example
|
|
59
|
+
* ```typescript
|
|
60
|
+
* getPackageName("lodash@4.17.21");
|
|
61
|
+
* // => "lodash"
|
|
62
|
+
* getPackageName("@stryke/core@4.17.21");
|
|
63
|
+
* // => "@stryke/core"
|
|
64
|
+
* getPackageName("lodash");
|
|
65
|
+
* // => "lodash"
|
|
66
|
+
* getPackageName("@stryke/core");
|
|
67
|
+
* // => "@stryke/core"
|
|
68
|
+
* getPackageName("lodash/module");
|
|
69
|
+
* // => "lodash"
|
|
70
|
+
* getPackageName("@stryke/core/module");
|
|
71
|
+
* // => "@stryke/core"
|
|
72
|
+
* getPackageName("lodash/module@4.17.21");
|
|
73
|
+
* // => "lodash"
|
|
74
|
+
* getPackageName("@stryke/core/module@4.17.21");
|
|
75
|
+
* // => "@stryke/core"
|
|
76
|
+
* ```
|
|
77
|
+
*
|
|
78
|
+
* @param value - The scoped package string
|
|
79
|
+
* @returns The package name without the scope
|
|
80
|
+
*/
|
|
81
|
+
export declare function getPackageName(value: string): string;
|
|
82
|
+
/**
|
|
83
|
+
* Get the package version from a scoped package string
|
|
84
|
+
*
|
|
85
|
+
* @example
|
|
86
|
+
* ```typescript
|
|
87
|
+
* getPackageName("lodash@4.17.21");
|
|
88
|
+
* // => "4.17.21"
|
|
89
|
+
* getPackageName("@stryke/core@4.17.21");
|
|
90
|
+
* // => "4.17.21"
|
|
91
|
+
* getPackageName("lodash");
|
|
92
|
+
* // => undefined
|
|
93
|
+
* getPackageName("@stryke/core");
|
|
94
|
+
* // => undefined
|
|
95
|
+
* getPackageName("lodash/module");
|
|
96
|
+
* // => undefined
|
|
97
|
+
* getPackageName("@stryke/core/module");
|
|
98
|
+
* // => undefined
|
|
99
|
+
* getPackageName("lodash/module@4.17.21");
|
|
100
|
+
* // => "4.17.21"
|
|
101
|
+
* getPackageName("@stryke/core/module@4.17.21");
|
|
102
|
+
* // => "4.17.21"
|
|
103
|
+
* ```
|
|
104
|
+
*
|
|
105
|
+
* @param value - The scoped package string
|
|
106
|
+
* @returns The package version without the package name if it exists. If not, returns undefined.
|
|
107
|
+
*/
|
|
108
|
+
export declare function getPackageVersion(value: string): string | undefined;
|
package/dist/package.mjs
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export function hasPackageVersion(n){return/^.[^\n\r@\u2028\u2029]*@.*$/.test(n)}export function removePackageVersion(n){return hasPackageVersion(n)?n.substring(0,n.lastIndexOf("@")):n}export function getPackageName(n){return/^[^\n\r/\u2028\u2029]*\/.[^\n\r/\u2028\u2029]*\/.*$/.test(n)?n.substring(0,n.lastIndexOf("/")):removePackageVersion(n)}export function getPackageVersion(n){return hasPackageVersion(n)?n.replace(/^.+@/,""):void 0}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@stryke/string-format",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.10.0",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"description": "A package containing utility functions to transform strings into various formats.",
|
|
6
6
|
"repository": {
|
|
@@ -186,6 +186,20 @@
|
|
|
186
186
|
"require": { "types": "./dist/pad.d.ts", "default": "./dist/pad.cjs" },
|
|
187
187
|
"default": { "types": "./dist/pad.d.ts", "default": "./dist/pad.mjs" }
|
|
188
188
|
},
|
|
189
|
+
"./package": {
|
|
190
|
+
"import": {
|
|
191
|
+
"types": "./dist/package.d.ts",
|
|
192
|
+
"default": "./dist/package.mjs"
|
|
193
|
+
},
|
|
194
|
+
"require": {
|
|
195
|
+
"types": "./dist/package.d.ts",
|
|
196
|
+
"default": "./dist/package.cjs"
|
|
197
|
+
},
|
|
198
|
+
"default": {
|
|
199
|
+
"types": "./dist/package.d.ts",
|
|
200
|
+
"default": "./dist/package.mjs"
|
|
201
|
+
}
|
|
202
|
+
},
|
|
189
203
|
"./normalize-email": {
|
|
190
204
|
"import": {
|
|
191
205
|
"types": "./dist/normalize-email.d.ts",
|
|
@@ -333,5 +347,5 @@
|
|
|
333
347
|
"main": "./dist/index.cjs",
|
|
334
348
|
"module": "./dist/index.mjs",
|
|
335
349
|
"types": "./dist/index.d.ts",
|
|
336
|
-
"gitHead": "
|
|
350
|
+
"gitHead": "b6c7dec04a3f5c6aa82f13ccba8a096c2da2519c"
|
|
337
351
|
}
|