@poppinss/utils 6.8.3 → 6.9.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/README.md +1 -1
- package/build/chunk-2KG3PWR4.js +17 -0
- package/build/chunk-4V5ON6P7.js +7 -0
- package/build/chunk-EJKUJ44Y.js +12 -0
- package/build/chunk-H54AK3PI.js +7 -0
- package/build/{chunk-IOBSMUFC.js → chunk-XHQBV7AF.js} +0 -1
- package/build/index.d.ts +1 -2
- package/build/index.js +67 -68
- package/build/src/assert.js +2 -1
- package/build/src/base64.d.ts +2 -2
- package/build/src/exception.d.ts +1 -52
- package/build/src/exception.js +2 -2
- package/build/src/exceptions/main.d.ts +1 -2
- package/build/src/exceptions/main.js +2 -3
- package/build/src/json/main.js +2 -2
- package/build/src/object_builder.d.ts +1 -58
- package/build/src/slash.d.ts +24 -1
- package/build/src/slash.js +4 -4
- package/build/src/string/main.d.ts +1 -49
- package/build/src/string/main.js +2 -8
- package/build/src/string/string_builder.d.ts +1 -0
- package/build/src/string/string_builder.js +2 -0
- package/build/src/types.js +0 -1
- package/package.json +21 -26
- package/build/chunk-GGIWJLUJ.js +0 -55
- package/build/chunk-GGIWJLUJ.js.map +0 -1
- package/build/chunk-IOBSMUFC.js.map +0 -1
- package/build/chunk-K76IL3UP.js +0 -270
- package/build/chunk-K76IL3UP.js.map +0 -1
- package/build/chunk-NKGAOHNN.js +0 -64
- package/build/chunk-NKGAOHNN.js.map +0 -1
- package/build/chunk-PNT36FCE.js +0 -21
- package/build/chunk-PNT36FCE.js.map +0 -1
- package/build/chunk-RRTFLKKC.js +0 -7
- package/build/chunk-RRTFLKKC.js.map +0 -1
- package/build/index.js.map +0 -1
- package/build/src/assert.js.map +0 -1
- package/build/src/exception.js.map +0 -1
- package/build/src/exceptions/invalid_arguments_exception.d.ts +0 -5
- package/build/src/exceptions/main.js.map +0 -1
- package/build/src/exceptions/runtime_exception.d.ts +0 -5
- package/build/src/json/main.js.map +0 -1
- package/build/src/slash.js.map +0 -1
- package/build/src/string/bytes.d.ts +0 -11
- package/build/src/string/change_case.d.ts +0 -42
- package/build/src/string/excerpt.d.ts +0 -11
- package/build/src/string/interpolate.d.ts +0 -8
- package/build/src/string/main.js.map +0 -1
- package/build/src/string/milliseconds.d.ts +0 -9
- package/build/src/string/ordinal.d.ts +0 -4
- package/build/src/string/pluralize.d.ts +0 -16
- package/build/src/string/random.d.ts +0 -4
- package/build/src/string/seconds.d.ts +0 -9
- package/build/src/string/sentence.d.ts +0 -8
- package/build/src/string/slugify.d.ts +0 -6
- package/build/src/string/truncate.d.ts +0 -10
- package/build/src/string_builder.d.ts +0 -80
- package/build/src/string_builder.js +0 -149
- package/build/src/string_builder.js.map +0 -1
- package/build/src/types.js.map +0 -1
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@poppinss/utils",
|
|
3
|
-
"version": "6.
|
|
3
|
+
"version": "6.9.0",
|
|
4
4
|
"description": "Handy utilities for repetitive work",
|
|
5
5
|
"main": "build/index.js",
|
|
6
6
|
"type": "module",
|
|
@@ -20,7 +20,7 @@
|
|
|
20
20
|
},
|
|
21
21
|
"./assert": "./build/src/assert.js",
|
|
22
22
|
"./string": "./build/src/string/main.js",
|
|
23
|
-
"./string_builder": "./build/src/string_builder.js",
|
|
23
|
+
"./string_builder": "./build/src/string/string_builder.js",
|
|
24
24
|
"./json": "./build/src/json/main.js",
|
|
25
25
|
"./types": "./build/src/types.js",
|
|
26
26
|
"./exceptions": "./build/src/exceptions/main.js",
|
|
@@ -47,41 +47,35 @@
|
|
|
47
47
|
},
|
|
48
48
|
"devDependencies": {
|
|
49
49
|
"@adonisjs/eslint-config": "^2.0.0-beta.6",
|
|
50
|
-
"@adonisjs/logger": "^6.0.
|
|
50
|
+
"@adonisjs/logger": "^6.0.5",
|
|
51
51
|
"@adonisjs/prettier-config": "^1.4.0",
|
|
52
52
|
"@adonisjs/tsconfig": "^1.4.0",
|
|
53
|
-
"@japa/assert": "^
|
|
53
|
+
"@japa/assert": "^4.0.0",
|
|
54
54
|
"@japa/expect-type": "^2.0.2",
|
|
55
55
|
"@japa/runner": "^3.1.4",
|
|
56
|
-
"@release-it/conventional-changelog": "^
|
|
57
|
-
"@swc/core": "^1.
|
|
56
|
+
"@release-it/conventional-changelog": "^9.0.4",
|
|
57
|
+
"@swc/core": "^1.10.4",
|
|
58
58
|
"@types/fs-extra": "^11.0.4",
|
|
59
|
-
"@types/node": "^22.
|
|
60
|
-
"c8": "^10.1.
|
|
61
|
-
"eslint": "^9.
|
|
59
|
+
"@types/node": "^22.10.2",
|
|
60
|
+
"c8": "^10.1.3",
|
|
61
|
+
"eslint": "^9.17.0",
|
|
62
62
|
"fs-extra": "^11.2.0",
|
|
63
63
|
"lodash": "^4.17.21",
|
|
64
64
|
"lodash-cli": "^4.17.5",
|
|
65
65
|
"move-file-cli": "^3.0.0",
|
|
66
|
-
"prettier": "^3.
|
|
67
|
-
"release-it": "^17.
|
|
66
|
+
"prettier": "^3.4.2",
|
|
67
|
+
"release-it": "^17.11.0",
|
|
68
68
|
"ts-node-maintained": "^10.9.4",
|
|
69
|
-
"tsup": "^8.
|
|
70
|
-
"typescript": "^5.
|
|
69
|
+
"tsup": "^8.3.5",
|
|
70
|
+
"typescript": "^5.7.2"
|
|
71
71
|
},
|
|
72
72
|
"dependencies": {
|
|
73
|
-
"@
|
|
74
|
-
"@
|
|
75
|
-
"@
|
|
76
|
-
"bytes": "^3.1.2",
|
|
77
|
-
"case-anything": "^3.1.0",
|
|
73
|
+
"@poppinss/exception": "^1.2.0",
|
|
74
|
+
"@poppinss/object-builder": "^1.1.0",
|
|
75
|
+
"@poppinss/string": "^1.1.0",
|
|
78
76
|
"flattie": "^1.1.1",
|
|
79
|
-
"pluralize": "^8.0.0",
|
|
80
77
|
"safe-stable-stringify": "^2.5.0",
|
|
81
|
-
"secure-json-parse": "^
|
|
82
|
-
"slash": "^5.1.0",
|
|
83
|
-
"slugify": "^1.6.6",
|
|
84
|
-
"truncatise": "^0.0.8"
|
|
78
|
+
"secure-json-parse": "^3.0.1"
|
|
85
79
|
},
|
|
86
80
|
"homepage": "https://github.com/poppinss/utils#readme",
|
|
87
81
|
"repository": {
|
|
@@ -95,9 +89,10 @@
|
|
|
95
89
|
"toolkit",
|
|
96
90
|
"utilities"
|
|
97
91
|
],
|
|
98
|
-
"author": "virk
|
|
92
|
+
"author": "Harminder Virk <virk@adonisjs.com>",
|
|
99
93
|
"license": "MIT",
|
|
100
94
|
"publishConfig": {
|
|
95
|
+
"access": "public",
|
|
101
96
|
"provenance": true
|
|
102
97
|
},
|
|
103
98
|
"tsup": {
|
|
@@ -105,7 +100,7 @@
|
|
|
105
100
|
"./index.ts",
|
|
106
101
|
"./src/assert.ts",
|
|
107
102
|
"./src/string/main.ts",
|
|
108
|
-
"./src/string_builder.ts",
|
|
103
|
+
"./src/string/string_builder.ts",
|
|
109
104
|
"./src/json/main.ts",
|
|
110
105
|
"./src/types.ts",
|
|
111
106
|
"./src/slash.ts",
|
|
@@ -116,7 +111,7 @@
|
|
|
116
111
|
"clean": true,
|
|
117
112
|
"format": "esm",
|
|
118
113
|
"dts": false,
|
|
119
|
-
"sourcemap":
|
|
114
|
+
"sourcemap": false,
|
|
120
115
|
"target": "esnext"
|
|
121
116
|
},
|
|
122
117
|
"release-it": {
|
package/build/chunk-GGIWJLUJ.js
DELETED
|
@@ -1,55 +0,0 @@
|
|
|
1
|
-
// src/exception.ts
|
|
2
|
-
import { format } from "node:util";
|
|
3
|
-
var Exception = class extends Error {
|
|
4
|
-
/**
|
|
5
|
-
* Name of the class that raised the exception.
|
|
6
|
-
*/
|
|
7
|
-
name;
|
|
8
|
-
/**
|
|
9
|
-
* A status code for the error. Usually helpful when converting errors
|
|
10
|
-
* to HTTP responses.
|
|
11
|
-
*/
|
|
12
|
-
status;
|
|
13
|
-
constructor(message, options) {
|
|
14
|
-
super(message, options);
|
|
15
|
-
const ErrorConstructor = this.constructor;
|
|
16
|
-
this.name = ErrorConstructor.name;
|
|
17
|
-
this.message = message || ErrorConstructor.message || "";
|
|
18
|
-
this.status = options?.status || ErrorConstructor.status || 500;
|
|
19
|
-
const code = options?.code || ErrorConstructor.code;
|
|
20
|
-
if (code !== void 0) {
|
|
21
|
-
this.code = code;
|
|
22
|
-
}
|
|
23
|
-
const help = ErrorConstructor.help;
|
|
24
|
-
if (help !== void 0) {
|
|
25
|
-
this.help = help;
|
|
26
|
-
}
|
|
27
|
-
Error.captureStackTrace(this, ErrorConstructor);
|
|
28
|
-
}
|
|
29
|
-
get [Symbol.toStringTag]() {
|
|
30
|
-
return this.constructor.name;
|
|
31
|
-
}
|
|
32
|
-
toString() {
|
|
33
|
-
if (this.code) {
|
|
34
|
-
return `${this.name} [${this.code}]: ${this.message}`;
|
|
35
|
-
}
|
|
36
|
-
return `${this.name}: ${this.message}`;
|
|
37
|
-
}
|
|
38
|
-
};
|
|
39
|
-
function createError(message, code, status) {
|
|
40
|
-
return class extends Exception {
|
|
41
|
-
static message = message;
|
|
42
|
-
static code = code;
|
|
43
|
-
static status = status;
|
|
44
|
-
constructor(args, options) {
|
|
45
|
-
super(format(message, ...args || []), options);
|
|
46
|
-
this.name = "Exception";
|
|
47
|
-
}
|
|
48
|
-
};
|
|
49
|
-
}
|
|
50
|
-
|
|
51
|
-
export {
|
|
52
|
-
Exception,
|
|
53
|
-
createError
|
|
54
|
-
};
|
|
55
|
-
//# sourceMappingURL=chunk-GGIWJLUJ.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/exception.ts"],"sourcesContent":["/*\n * @poppinss/utils\n *\n * (c) Poppinss\n *\n * For the full copyright and license information, please view the LICENSE\n * file that was distributed with this source code.\n */\n\nimport { format } from 'node:util'\n\n/**\n * Extended Error object with the option to set error `status` and `code`.\n * At AdonisJs, we prefer exceptions with proper error codes to handle\n * them without relying on message pattern matching.\n *\n * ```js\n * new Exception('message', 500, 'E_RUNTIME_EXCEPTION')\n * ```\n */\nexport class Exception extends Error {\n /**\n * Static properties to defined on the exception once\n * and then re-use them\n */\n declare static help?: string\n declare static code?: string\n declare static status?: number\n declare static message?: string\n\n /**\n * Name of the class that raised the exception.\n */\n name: string\n\n /**\n * Optional help description for the error. You can use it to define additional\n * human readable information for the error.\n */\n declare help?: string\n\n /**\n * A machine readable error code. This will allow the error handling logic\n * to narrow down exceptions based upon the error code.\n */\n declare code?: string\n\n /**\n * A status code for the error. Usually helpful when converting errors\n * to HTTP responses.\n */\n status: number\n\n constructor(message?: string, options?: ErrorOptions & { code?: string; status?: number }) {\n super(message, options)\n\n const ErrorConstructor = this.constructor as typeof Exception\n\n this.name = ErrorConstructor.name\n this.message = message || ErrorConstructor.message || ''\n this.status = options?.status || ErrorConstructor.status || 500\n\n const code = options?.code || ErrorConstructor.code\n if (code !== undefined) {\n this.code = code\n }\n\n const help = ErrorConstructor.help\n if (help !== undefined) {\n this.help = help\n }\n\n Error.captureStackTrace(this, ErrorConstructor)\n }\n\n get [Symbol.toStringTag]() {\n return this.constructor.name\n }\n\n toString() {\n if (this.code) {\n return `${this.name} [${this.code}]: ${this.message}`\n }\n return `${this.name}: ${this.message}`\n }\n}\n\n/**\n * Helper to create anonymous error classes\n */\nexport function createError<T extends any[] = never>(\n message: string,\n code: string,\n status?: number\n): typeof Exception & T extends never\n ? { new (args?: any, options?: ErrorOptions): Exception }\n : { new (args: T, options?: ErrorOptions): Exception } {\n return class extends Exception {\n static message = message\n static code = code\n static status = status\n\n constructor(args: T, options?: ErrorOptions) {\n super(format(message, ...(args || [])), options)\n this.name = 'Exception'\n }\n }\n}\n"],"mappings":";AASA,SAAS,cAAc;AAWhB,IAAM,YAAN,cAAwB,MAAM;AAAA;AAAA;AAAA;AAAA,EAanC;AAAA;AAAA;AAAA;AAAA;AAAA,EAkBA;AAAA,EAEA,YAAY,SAAkB,SAA6D;AACzF,UAAM,SAAS,OAAO;AAEtB,UAAM,mBAAmB,KAAK;AAE9B,SAAK,OAAO,iBAAiB;AAC7B,SAAK,UAAU,WAAW,iBAAiB,WAAW;AACtD,SAAK,SAAS,SAAS,UAAU,iBAAiB,UAAU;AAE5D,UAAM,OAAO,SAAS,QAAQ,iBAAiB;AAC/C,QAAI,SAAS,QAAW;AACtB,WAAK,OAAO;AAAA,IACd;AAEA,UAAM,OAAO,iBAAiB;AAC9B,QAAI,SAAS,QAAW;AACtB,WAAK,OAAO;AAAA,IACd;AAEA,UAAM,kBAAkB,MAAM,gBAAgB;AAAA,EAChD;AAAA,EAEA,KAAK,OAAO,WAAW,IAAI;AACzB,WAAO,KAAK,YAAY;AAAA,EAC1B;AAAA,EAEA,WAAW;AACT,QAAI,KAAK,MAAM;AACb,aAAO,GAAG,KAAK,IAAI,KAAK,KAAK,IAAI,MAAM,KAAK,OAAO;AAAA,IACrD;AACA,WAAO,GAAG,KAAK,IAAI,KAAK,KAAK,OAAO;AAAA,EACtC;AACF;AAKO,SAAS,YACd,SACA,MACA,QAGuD;AACvD,SAAO,cAAc,UAAU;AAAA,IAC7B,OAAO,UAAU;AAAA,IACjB,OAAO,OAAO;AAAA,IACd,OAAO,SAAS;AAAA,IAEhB,YAAY,MAAS,SAAwB;AAC3C,YAAM,OAAO,SAAS,GAAI,QAAQ,CAAC,CAAE,GAAG,OAAO;AAC/C,WAAK,OAAO;AAAA,IACd;AAAA,EACF;AACF;","names":[]}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/json/safe_parse.ts","../src/json/safe_stringify.ts","../src/json/main.ts"],"sourcesContent":["/*\n * @poppinss/utils\n *\n * (c) Poppinss\n *\n * For the full copyright and license information, please view the LICENSE\n * file that was distributed with this source code.\n */\n\nimport { parse } from 'secure-json-parse'\nimport { JSONReviver } from '../types.js'\n\n/**\n * A drop-in replacement for JSON.parse with prototype poisoning protection.\n */\nexport function safeParse(jsonString: string, reviver?: JSONReviver): any {\n return parse(jsonString, reviver, {\n protoAction: 'remove',\n constructorAction: 'remove',\n })\n}\n","/*\n * @poppinss/utils\n *\n * (c) Poppinss\n *\n * For the full copyright and license information, please view the LICENSE\n * file that was distributed with this source code.\n */\n\nimport { configure } from 'safe-stable-stringify'\nimport { JSONReplacer } from '../types.js'\n\nconst stringify = configure({\n bigint: false,\n circularValue: undefined,\n deterministic: false,\n})\n\n/**\n * Replacer to handle custom data types.\n *\n * - Bigints are converted to string\n */\nfunction jsonStringifyReplacer(replacer?: JSONReplacer): JSONReplacer {\n return function (key, value) {\n const val = replacer ? replacer.call(this, key, value) : value\n\n if (typeof val === 'bigint') {\n return val.toString()\n }\n\n return val\n }\n}\n\n/**\n * String Javascript values to a JSON string. Handles circular\n * references and bigints\n */\nexport function safeStringify(\n value: any,\n replacer?: JSONReplacer,\n space?: string | number\n): string | undefined {\n return stringify(value, jsonStringifyReplacer(replacer), space)\n}\n","/*\n * @poppinss/utils\n *\n * (c) Poppinss\n *\n * For the full copyright and license information, please view the LICENSE\n * file that was distributed with this source code.\n */\n\nimport { safeParse } from './safe_parse.js'\nimport { safeStringify } from './safe_stringify.js'\n\nconst json = {\n safeParse,\n safeStringify,\n}\n\nexport default json\n"],"mappings":";AASA,SAAS,aAAa;AAMf,SAAS,UAAU,YAAoB,SAA4B;AACxE,SAAO,MAAM,YAAY,SAAS;AAAA,IAChC,aAAa;AAAA,IACb,mBAAmB;AAAA,EACrB,CAAC;AACH;;;ACXA,SAAS,iBAAiB;AAG1B,IAAM,YAAY,UAAU;AAAA,EAC1B,QAAQ;AAAA,EACR,eAAe;AAAA,EACf,eAAe;AACjB,CAAC;AAOD,SAAS,sBAAsB,UAAuC;AACpE,SAAO,SAAU,KAAK,OAAO;AAC3B,UAAM,MAAM,WAAW,SAAS,KAAK,MAAM,KAAK,KAAK,IAAI;AAEzD,QAAI,OAAO,QAAQ,UAAU;AAC3B,aAAO,IAAI,SAAS;AAAA,IACtB;AAEA,WAAO;AAAA,EACT;AACF;AAMO,SAAS,cACd,OACA,UACA,OACoB;AACpB,SAAO,UAAU,OAAO,sBAAsB,QAAQ,GAAG,KAAK;AAChE;;;ACjCA,IAAM,OAAO;AAAA,EACX;AAAA,EACA;AACF;AAEA,IAAO,eAAQ;","names":[]}
|
package/build/chunk-K76IL3UP.js
DELETED
|
@@ -1,270 +0,0 @@
|
|
|
1
|
-
import {
|
|
2
|
-
base64,
|
|
3
|
-
milliseconds_default
|
|
4
|
-
} from "./chunk-NKGAOHNN.js";
|
|
5
|
-
|
|
6
|
-
// src/string/bytes.ts
|
|
7
|
-
import bytes from "bytes";
|
|
8
|
-
var bytes_default = {
|
|
9
|
-
format(valueInBytes, options) {
|
|
10
|
-
return bytes.format(valueInBytes, options);
|
|
11
|
-
},
|
|
12
|
-
/**
|
|
13
|
-
* Parse the unit expression to bytes. If the unit value
|
|
14
|
-
* is a number, then it will be returned as it is considering
|
|
15
|
-
* it is already in bytes.
|
|
16
|
-
*/
|
|
17
|
-
parse(unit) {
|
|
18
|
-
if (typeof unit === "number") {
|
|
19
|
-
return unit;
|
|
20
|
-
}
|
|
21
|
-
return bytes.parse(unit);
|
|
22
|
-
}
|
|
23
|
-
};
|
|
24
|
-
|
|
25
|
-
// src/string/seconds.ts
|
|
26
|
-
import { parse, format } from "@lukeed/ms";
|
|
27
|
-
var seconds_default = {
|
|
28
|
-
format(seconds, long) {
|
|
29
|
-
return format(seconds * 1e3, long);
|
|
30
|
-
},
|
|
31
|
-
/**
|
|
32
|
-
* Parse time expression string to seconds. The number value
|
|
33
|
-
* is returned as it is, considering it is already in seconds
|
|
34
|
-
*/
|
|
35
|
-
parse(duration) {
|
|
36
|
-
if (typeof duration === "number") {
|
|
37
|
-
return duration;
|
|
38
|
-
}
|
|
39
|
-
const milliseconds = parse(duration);
|
|
40
|
-
if (milliseconds === void 0) {
|
|
41
|
-
throw new Error(`Invalid duration expression "${duration}"`);
|
|
42
|
-
}
|
|
43
|
-
return Math.floor(milliseconds / 1e3);
|
|
44
|
-
}
|
|
45
|
-
};
|
|
46
|
-
|
|
47
|
-
// src/string/slugify.ts
|
|
48
|
-
import { default as slugifyPkg } from "slugify";
|
|
49
|
-
var slug = slugifyPkg;
|
|
50
|
-
|
|
51
|
-
// src/string/random.ts
|
|
52
|
-
import { randomBytes } from "node:crypto";
|
|
53
|
-
function random(size) {
|
|
54
|
-
const bits = (size + 1) * 6;
|
|
55
|
-
const buffer = randomBytes(Math.ceil(bits / 8));
|
|
56
|
-
return base64.urlEncode(buffer).slice(0, size);
|
|
57
|
-
}
|
|
58
|
-
|
|
59
|
-
// src/string/excerpt.ts
|
|
60
|
-
import truncatise from "truncatise";
|
|
61
|
-
function excerpt(sentence2, charactersLimit, options) {
|
|
62
|
-
return truncatise(sentence2, {
|
|
63
|
-
TruncateLength: charactersLimit,
|
|
64
|
-
/**
|
|
65
|
-
* Do not complete words when "completeWords" is not explicitly set
|
|
66
|
-
* to true
|
|
67
|
-
*/
|
|
68
|
-
Strict: options && options.completeWords === true ? false : true,
|
|
69
|
-
StripHTML: true,
|
|
70
|
-
TruncateBy: "characters",
|
|
71
|
-
Suffix: options && options.suffix
|
|
72
|
-
});
|
|
73
|
-
}
|
|
74
|
-
|
|
75
|
-
// src/string/ordinal.ts
|
|
76
|
-
function ordinal(value) {
|
|
77
|
-
const transformedValue = Math.abs(typeof value === "string" ? Number.parseInt(value) : value);
|
|
78
|
-
if (!Number.isFinite(transformedValue) || Number.isNaN(transformedValue)) {
|
|
79
|
-
throw new Error("Cannot ordinalize invalid or infinite numbers");
|
|
80
|
-
}
|
|
81
|
-
const percent = transformedValue % 100;
|
|
82
|
-
if (percent >= 10 && percent <= 20) {
|
|
83
|
-
return `${value}th`;
|
|
84
|
-
}
|
|
85
|
-
const decimal = transformedValue % 10;
|
|
86
|
-
switch (decimal) {
|
|
87
|
-
case 1:
|
|
88
|
-
return `${value}st`;
|
|
89
|
-
case 2:
|
|
90
|
-
return `${value}nd`;
|
|
91
|
-
case 3:
|
|
92
|
-
return `${value}rd`;
|
|
93
|
-
default:
|
|
94
|
-
return `${value}th`;
|
|
95
|
-
}
|
|
96
|
-
}
|
|
97
|
-
|
|
98
|
-
// src/string/truncate.ts
|
|
99
|
-
import truncatise2 from "truncatise";
|
|
100
|
-
function truncate(sentence2, charactersLimit, options) {
|
|
101
|
-
return truncatise2(sentence2, {
|
|
102
|
-
TruncateLength: charactersLimit,
|
|
103
|
-
/**
|
|
104
|
-
* Do not complete words when "completeWords" is not explicitly set
|
|
105
|
-
* to true
|
|
106
|
-
*/
|
|
107
|
-
Strict: options && options.completeWords === true ? false : true,
|
|
108
|
-
StripHTML: false,
|
|
109
|
-
TruncateBy: "characters",
|
|
110
|
-
Suffix: options && options.suffix
|
|
111
|
-
});
|
|
112
|
-
}
|
|
113
|
-
|
|
114
|
-
// src/string/sentence.ts
|
|
115
|
-
function sentence(values, options) {
|
|
116
|
-
if (values.length === 0) {
|
|
117
|
-
return "";
|
|
118
|
-
}
|
|
119
|
-
if (values.length === 1) {
|
|
120
|
-
return values[0];
|
|
121
|
-
}
|
|
122
|
-
if (values.length === 2) {
|
|
123
|
-
return `${values[0]}${options?.pairSeparator || " and "}${values[1]}`;
|
|
124
|
-
}
|
|
125
|
-
const normalized = Object.assign({ separator: ", ", lastSeparator: ", and " }, options);
|
|
126
|
-
return `${values.slice(0, -1).join(normalized.separator)}${normalized.lastSeparator}${values[values.length - 1]}`;
|
|
127
|
-
}
|
|
128
|
-
|
|
129
|
-
// src/string/interpolate.ts
|
|
130
|
-
function parseProp(data, key) {
|
|
131
|
-
const tokens = key.split(".");
|
|
132
|
-
while (tokens.length) {
|
|
133
|
-
if (data === null || typeof data !== "object") {
|
|
134
|
-
return;
|
|
135
|
-
}
|
|
136
|
-
const token = tokens.shift();
|
|
137
|
-
data = Object.hasOwn(data, token) ? data[token] : void 0;
|
|
138
|
-
}
|
|
139
|
-
return data;
|
|
140
|
-
}
|
|
141
|
-
function interpolate(input, data) {
|
|
142
|
-
return input.replace(/(\\)?{{(.*?)}}/g, (_, escapeChar, key) => {
|
|
143
|
-
if (escapeChar) {
|
|
144
|
-
return `{{${key}}}`;
|
|
145
|
-
}
|
|
146
|
-
return parseProp(data, key.trim());
|
|
147
|
-
});
|
|
148
|
-
}
|
|
149
|
-
|
|
150
|
-
// src/string/pluralize.ts
|
|
151
|
-
import { default as pluralizePkg } from "pluralize";
|
|
152
|
-
function pluralize(word, count, inclusive) {
|
|
153
|
-
return pluralizePkg(word, count, inclusive);
|
|
154
|
-
}
|
|
155
|
-
pluralize.addPluralRule = pluralizePkg.addPluralRule;
|
|
156
|
-
pluralize.addSingularRule = pluralizePkg.addSingularRule;
|
|
157
|
-
pluralize.addIrregularRule = pluralizePkg.addIrregularRule;
|
|
158
|
-
pluralize.addUncountableRule = pluralizePkg.addUncountableRule;
|
|
159
|
-
var plural = pluralizePkg.plural;
|
|
160
|
-
var singular = pluralizePkg.singular;
|
|
161
|
-
var isPlural = pluralizePkg.isPlural;
|
|
162
|
-
var isSingular = pluralizePkg.isSingular;
|
|
163
|
-
|
|
164
|
-
// src/string/change_case.ts
|
|
165
|
-
import * as changeCase from "case-anything";
|
|
166
|
-
var NO_CASE_SPLIT_REGEXP = [/([a-z0-9])([A-Z])/g, /([A-Z])([A-Z][a-z])/g];
|
|
167
|
-
var NO_CASE_STRIP_REGEXP = /[^A-Z0-9]+/gi;
|
|
168
|
-
var SMALL_WORDS = /\b(?:an?d?|a[st]|because|but|by|en|for|i[fn]|neither|nor|o[fnr]|only|over|per|so|some|tha[tn]|the|to|up|upon|vs?\.?|versus|via|when|with|without|yet)\b/i;
|
|
169
|
-
var TOKENS = /[^\s:–—-]+|./g;
|
|
170
|
-
var WHITESPACE = /\s/;
|
|
171
|
-
var IS_MANUAL_CASE = /.(?=[A-Z]|\..)/;
|
|
172
|
-
var ALPHANUMERIC_PATTERN = /[A-Za-z0-9\u00C0-\u00FF]/;
|
|
173
|
-
function titleCase(input) {
|
|
174
|
-
let output = "";
|
|
175
|
-
let result;
|
|
176
|
-
while ((result = TOKENS.exec(input)) !== null) {
|
|
177
|
-
const { 0: token, index } = result;
|
|
178
|
-
if (!IS_MANUAL_CASE.test(token) && (!SMALL_WORDS.test(token) || index === 0 || index + token.length === input.length) && (input.charAt(index + token.length) !== ":" || WHITESPACE.test(input.charAt(index + token.length + 1)))) {
|
|
179
|
-
output += token.replace(ALPHANUMERIC_PATTERN, (char) => char.toUpperCase());
|
|
180
|
-
continue;
|
|
181
|
-
}
|
|
182
|
-
output += token;
|
|
183
|
-
}
|
|
184
|
-
return output;
|
|
185
|
-
}
|
|
186
|
-
function camelCase2(value) {
|
|
187
|
-
return changeCase.camelCase(value);
|
|
188
|
-
}
|
|
189
|
-
function snakeCase2(value) {
|
|
190
|
-
return changeCase.snakeCase(value);
|
|
191
|
-
}
|
|
192
|
-
function dashCase(value, options) {
|
|
193
|
-
if (options && options.capitalize) {
|
|
194
|
-
return changeCase.trainCase(value);
|
|
195
|
-
}
|
|
196
|
-
return changeCase.kebabCase(value);
|
|
197
|
-
}
|
|
198
|
-
function pascalCase2(value) {
|
|
199
|
-
return changeCase.pascalCase(value);
|
|
200
|
-
}
|
|
201
|
-
function capitalCase2(value) {
|
|
202
|
-
return changeCase.capitalCase(value);
|
|
203
|
-
}
|
|
204
|
-
function sentenceCase(value) {
|
|
205
|
-
return noCase(value, (input, index) => {
|
|
206
|
-
const result = input.toLowerCase();
|
|
207
|
-
if (index === 0) {
|
|
208
|
-
return input.charAt(0).toUpperCase() + input.substring(1);
|
|
209
|
-
}
|
|
210
|
-
return result;
|
|
211
|
-
});
|
|
212
|
-
}
|
|
213
|
-
function dotCase(value, options) {
|
|
214
|
-
const transformedValue = changeCase.dotNotation(value);
|
|
215
|
-
if (options && options.lowerCase) {
|
|
216
|
-
return transformedValue.toLowerCase();
|
|
217
|
-
}
|
|
218
|
-
return transformedValue;
|
|
219
|
-
}
|
|
220
|
-
function noCase(value, transform) {
|
|
221
|
-
let result = NO_CASE_SPLIT_REGEXP.reduce((input, regex) => input.replace(regex, "$1\0$2"), value);
|
|
222
|
-
result = result.replace(NO_CASE_STRIP_REGEXP, "\0");
|
|
223
|
-
let start = 0;
|
|
224
|
-
let end = result.length;
|
|
225
|
-
while (result.charAt(start) === "\0") {
|
|
226
|
-
start++;
|
|
227
|
-
}
|
|
228
|
-
while (result.charAt(end - 1) === "\0") {
|
|
229
|
-
end--;
|
|
230
|
-
}
|
|
231
|
-
return result.slice(start, end).split("\0").map(transform || ((input) => input.toLowerCase())).join(" ");
|
|
232
|
-
}
|
|
233
|
-
|
|
234
|
-
// src/string/main.ts
|
|
235
|
-
function condenseWhitespace(value) {
|
|
236
|
-
return value.trim().replace(/\s{2,}/g, " ");
|
|
237
|
-
}
|
|
238
|
-
var string = {
|
|
239
|
-
excerpt,
|
|
240
|
-
truncate,
|
|
241
|
-
slug,
|
|
242
|
-
interpolate,
|
|
243
|
-
plural,
|
|
244
|
-
pluralize,
|
|
245
|
-
singular,
|
|
246
|
-
isPlural,
|
|
247
|
-
isSingular,
|
|
248
|
-
camelCase: camelCase2,
|
|
249
|
-
capitalCase: capitalCase2,
|
|
250
|
-
dashCase,
|
|
251
|
-
dotCase,
|
|
252
|
-
noCase,
|
|
253
|
-
pascalCase: pascalCase2,
|
|
254
|
-
sentenceCase,
|
|
255
|
-
snakeCase: snakeCase2,
|
|
256
|
-
titleCase,
|
|
257
|
-
random,
|
|
258
|
-
sentence,
|
|
259
|
-
condenseWhitespace,
|
|
260
|
-
seconds: seconds_default,
|
|
261
|
-
milliseconds: milliseconds_default,
|
|
262
|
-
bytes: bytes_default,
|
|
263
|
-
ordinal
|
|
264
|
-
};
|
|
265
|
-
var main_default = string;
|
|
266
|
-
|
|
267
|
-
export {
|
|
268
|
-
main_default
|
|
269
|
-
};
|
|
270
|
-
//# sourceMappingURL=chunk-K76IL3UP.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/string/bytes.ts","../src/string/seconds.ts","../src/string/slugify.ts","../src/string/random.ts","../src/string/excerpt.ts","../src/string/ordinal.ts","../src/string/truncate.ts","../src/string/sentence.ts","../src/string/interpolate.ts","../src/string/pluralize.ts","../src/string/change_case.ts","../src/string/main.ts"],"sourcesContent":["/*\n * @poppinss/utils\n *\n * (c) Poppinss\n *\n * For the full copyright and license information, please view the LICENSE\n * file that was distributed with this source code.\n */\n\nimport bytes, { BytesOptions } from 'bytes'\n\nexport default {\n format(valueInBytes: number, options?: BytesOptions): string {\n return bytes.format(valueInBytes, options)\n },\n\n /**\n * Parse the unit expression to bytes. If the unit value\n * is a number, then it will be returned as it is considering\n * it is already in bytes.\n */\n parse(unit: string | number): number {\n if (typeof unit === 'number') {\n return unit\n }\n\n return bytes.parse(unit)\n },\n}\n","/*\n * @poppinss/utils\n *\n * (c) Poppinss\n *\n * For the full copyright and license information, please view the LICENSE\n * file that was distributed with this source code.\n */\n\nimport { parse, format } from '@lukeed/ms'\n\nexport default {\n format(seconds: number, long?: boolean): string {\n return format(seconds * 1000, long)\n },\n\n /**\n * Parse time expression string to seconds. The number value\n * is returned as it is, considering it is already in seconds\n */\n parse(duration: string | number): number {\n if (typeof duration === 'number') {\n return duration\n }\n\n const milliseconds = parse(duration)\n if (milliseconds === undefined) {\n throw new Error(`Invalid duration expression \"${duration}\"`)\n }\n\n return Math.floor(milliseconds / 1000)\n },\n}\n","/*\n * @poppinss/utils\n *\n * (c) Poppinss\n *\n * For the full copyright and license information, please view the LICENSE\n * file that was distributed with this source code.\n */\n\nimport { default as slugifyPkg } from 'slugify'\n\n/**\n * Typings of the slugify package are a bit off and therefore we have\n * to do this manual dance of re-assigning types\n */\nexport const slug = slugifyPkg as unknown as (typeof slugifyPkg)['default']\n","/*\n * @poppinss/utils\n *\n * (c) Poppinss\n *\n * For the full copyright and license information, please view the LICENSE\n * file that was distributed with this source code.\n */\n\nimport { randomBytes } from 'node:crypto'\nimport { base64 } from '../base64.js'\n\n/**\n * Generates a random string of a given size\n */\nexport function random(size: number): string {\n const bits = (size + 1) * 6\n const buffer = randomBytes(Math.ceil(bits / 8))\n return base64.urlEncode(buffer).slice(0, size)\n}\n","/*\n * @poppinss/utils\n *\n * (c) Poppinss\n *\n * For the full copyright and license information, please view the LICENSE\n * file that was distributed with this source code.\n */\n\n// @ts-expect-error (Package has no types)\nimport truncatise from 'truncatise'\n\n/**\n * Truncate a sentence to be under a certain characters limit and strip\n * out HTML tags from it.\n *\n * Optionally, you can force the truncate logic to complete words, which\n * may exceed the defined characters limit.\n */\nexport function excerpt(\n sentence: string,\n charactersLimit: number,\n options?: {\n completeWords?: boolean\n suffix?: string\n }\n): string {\n return truncatise(sentence, {\n TruncateLength: charactersLimit,\n /**\n * Do not complete words when \"completeWords\" is not explicitly set\n * to true\n */\n Strict: options && options.completeWords === true ? false : true,\n StripHTML: true,\n TruncateBy: 'characters',\n Suffix: options && options.suffix,\n })\n}\n","/*\n * @poppinss/utils\n *\n * (c) Poppinss\n *\n * For the full copyright and license information, please view the LICENSE\n * file that was distributed with this source code.\n */\n\n/**\n * Ordinalize a give number or string\n */\nexport function ordinal(value: string | number): string {\n const transformedValue = Math.abs(typeof value === 'string' ? Number.parseInt(value) : value)\n if (!Number.isFinite(transformedValue) || Number.isNaN(transformedValue)) {\n throw new Error('Cannot ordinalize invalid or infinite numbers')\n }\n\n const percent = transformedValue % 100\n if (percent >= 10 && percent <= 20) {\n return `${value}th`\n }\n\n const decimal = transformedValue % 10\n switch (decimal) {\n case 1:\n return `${value}st`\n case 2:\n return `${value}nd`\n case 3:\n return `${value}rd`\n default:\n return `${value}th`\n }\n}\n","/*\n * @poppinss/utils\n *\n * (c) Poppinss\n *\n * For the full copyright and license information, please view the LICENSE\n * file that was distributed with this source code.\n */\n\n// @ts-expect-error (Package has no types)\nimport truncatise from 'truncatise'\n\n/**\n * Truncate a sentence to be under a certain characters limit.\n *\n * Optionally, you can force the truncate logic to complete words, which\n * may exceed the defined characters limit.\n */\nexport function truncate(\n sentence: string,\n charactersLimit: number,\n options?: {\n completeWords?: boolean\n suffix?: string\n }\n): string {\n return truncatise(sentence, {\n TruncateLength: charactersLimit,\n /**\n * Do not complete words when \"completeWords\" is not explicitly set\n * to true\n */\n Strict: options && options.completeWords === true ? false : true,\n StripHTML: false,\n TruncateBy: 'characters',\n Suffix: options && options.suffix,\n })\n}\n","/*\n * @poppinss/utils\n *\n * (c) Poppinss\n *\n * For the full copyright and license information, please view the LICENSE\n * file that was distributed with this source code.\n */\n\n/**\n * Convert an array of values to a sentence.\n */\nexport function sentence(\n values: any[],\n options?: {\n separator?: string\n pairSeparator?: string\n lastSeparator?: string\n }\n): string {\n /**\n * Empty array\n */\n if (values.length === 0) {\n return ''\n }\n\n /**\n * Just one item\n */\n if (values.length === 1) {\n return values[0]\n }\n\n /**\n * Giving some love to two items, so that one can ditch comma with two items\n */\n if (values.length === 2) {\n return `${values[0]}${options?.pairSeparator || ' and '}${values[1]}`\n }\n\n const normalized = Object.assign({ separator: ', ', lastSeparator: ', and ' }, options)\n\n /**\n * Make sentence\n */\n return `${values.slice(0, -1).join(normalized.separator)}${normalized.lastSeparator}${\n values[values.length - 1]\n }`\n}\n","/*\n * @poppinss/utils\n *\n * (c) Poppinss\n *\n * For the full copyright and license information, please view the LICENSE\n * file that was distributed with this source code.\n */\n\n/**\n * Parses prop\n */\nfunction parseProp(data: any, key: string) {\n const tokens = key.split('.')\n while (tokens.length) {\n if (data === null || typeof data !== 'object') {\n return\n }\n const token = tokens.shift()!\n data = Object.hasOwn(data, token) ? data[token] : undefined\n }\n return data\n}\n\n/**\n * A simple function interpolate values inside curly braces.\n *\n * ```\n * interpolate('hello {{ username }}', { username: 'virk' })\n * ```\n */\nexport function interpolate(input: string, data: any) {\n return input.replace(/(\\\\)?{{(.*?)}}/g, (_, escapeChar, key) => {\n if (escapeChar) {\n return `{{${key}}}`\n }\n\n return parseProp(data, key.trim())\n })\n}\n","/*\n * @poppinss/utils\n *\n * (c) Poppinss\n *\n * For the full copyright and license information, please view the LICENSE\n * file that was distributed with this source code.\n */\n\nimport { default as pluralizePkg } from 'pluralize'\n\n/**\n * Pluralize a word based upon the count. The method returns the\n * singular form when count is 1.\n */\nexport function pluralize(word: string, count?: number, inclusive?: boolean): string {\n return pluralizePkg(word, count, inclusive)\n}\npluralize.addPluralRule = pluralizePkg.addPluralRule\npluralize.addSingularRule = pluralizePkg.addSingularRule\npluralize.addIrregularRule = pluralizePkg.addIrregularRule\npluralize.addUncountableRule = pluralizePkg.addUncountableRule\n\nexport const plural = pluralizePkg.plural\nexport const singular = pluralizePkg.singular\nexport const isPlural = pluralizePkg.isPlural\nexport const isSingular = pluralizePkg.isSingular\n","/*\n * @poppinss/utils\n *\n * (c) Poppinss\n *\n * For the full copyright and license information, please view the LICENSE\n * file that was distributed with this source code.\n */\n\nimport * as changeCase from 'case-anything'\n\n// Support camel case (\"camelCase\" -> \"camel Case\" and \"CAMELCase\" -> \"CAMEL Case\").\nconst NO_CASE_SPLIT_REGEXP = [/([a-z0-9])([A-Z])/g, /([A-Z])([A-Z][a-z])/g]\n\n// Remove all non-word characters.\nconst NO_CASE_STRIP_REGEXP = /[^A-Z0-9]+/gi\n\nconst SMALL_WORDS =\n /\\b(?:an?d?|a[st]|because|but|by|en|for|i[fn]|neither|nor|o[fnr]|only|over|per|so|some|tha[tn]|the|to|up|upon|vs?\\.?|versus|via|when|with|without|yet)\\b/i\nconst TOKENS = /[^\\s:–—-]+|./g\nconst WHITESPACE = /\\s/\nconst IS_MANUAL_CASE = /.(?=[A-Z]|\\..)/\nconst ALPHANUMERIC_PATTERN = /[A-Za-z0-9\\u00C0-\\u00FF]/\n\n/**\n * The method is a copy/paste from the \"title-case\" package. They have\n * a dependency on \"tslib\", which I don't want.\n */\nexport function titleCase(input: string) {\n let output = ''\n let result: RegExpExecArray | null\n\n while ((result = TOKENS.exec(input)) !== null) {\n const { 0: token, index } = result\n\n if (\n !IS_MANUAL_CASE.test(token) &&\n (!SMALL_WORDS.test(token) || index === 0 || index + token.length === input.length) &&\n (input.charAt(index + token.length) !== ':' ||\n WHITESPACE.test(input.charAt(index + token.length + 1)))\n ) {\n output += token.replace(ALPHANUMERIC_PATTERN, (char) => char.toUpperCase())\n continue\n }\n\n output += token\n }\n\n return output\n}\n\n/**\n * Convert string to camelcase\n */\nexport function camelCase(value: string): string {\n return changeCase.camelCase(value)\n}\n\n/**\n * Convert string to snakecase\n */\nexport function snakeCase(value: string): string {\n return changeCase.snakeCase(value)\n}\n\n/**\n * Convert string to dashcase\n */\nexport function dashCase(value: string, options?: { capitalize?: boolean }): string {\n if (options && options.capitalize) {\n return changeCase.trainCase(value)\n }\n\n return changeCase.kebabCase(value)\n}\n\n/**\n * Convert string to pascal case\n */\nexport function pascalCase(value: string): string {\n return changeCase.pascalCase(value)\n}\n\n/**\n * Convert string to capital case\n */\nexport function capitalCase(value: string): string {\n return changeCase.capitalCase(value)\n}\n\n/**\n * Convert string to sentence case\n */\nexport function sentenceCase(value: string): string {\n return noCase(value, (input, index) => {\n const result = input.toLowerCase()\n if (index === 0) {\n return input.charAt(0).toUpperCase() + input.substring(1)\n }\n return result\n })\n}\n\n/**\n * Convert string to dot case\n */\nexport function dotCase(value: string, options?: { lowerCase?: boolean }): string {\n const transformedValue = changeCase.dotNotation(value)\n if (options && options.lowerCase) {\n return transformedValue.toLowerCase()\n }\n\n return transformedValue\n}\n\n/**\n * Remove all sort of casing from the string. Copy-pasted from\n * \"no-case\" package with slight modifications.\n */\nexport function noCase(\n value: string,\n transform?: (part: string, index: number, parts: string[]) => string\n): string {\n let result = NO_CASE_SPLIT_REGEXP.reduce((input, regex) => input.replace(regex, '$1\\0$2'), value)\n result = result.replace(NO_CASE_STRIP_REGEXP, '\\0')\n\n let start = 0\n let end = result.length\n\n // Trim the delimiter from around the output string.\n while (result.charAt(start) === '\\0') {\n start++\n }\n while (result.charAt(end - 1) === '\\0') {\n end--\n }\n\n return result\n .slice(start, end)\n .split('\\0')\n .map(transform || ((input) => input.toLowerCase()))\n .join(' ')\n}\n","/*\n * @poppinss/utils\n *\n * (c) Poppinss\n *\n * For the full copyright and license information, please view the LICENSE\n * file that was distributed with this source code.\n */\n\nimport bytes from './bytes.js'\nimport seconds from './seconds.js'\nimport { slug } from './slugify.js'\nimport { random } from './random.js'\nimport { excerpt } from './excerpt.js'\nimport { ordinal } from './ordinal.js'\nimport { truncate } from './truncate.js'\nimport milliseconds from './milliseconds.js'\nimport { sentence } from './sentence.js'\nimport { interpolate } from './interpolate.js'\nimport { plural, pluralize, singular, isPlural, isSingular } from './pluralize.js'\nimport {\n noCase,\n dotCase,\n dashCase,\n camelCase,\n snakeCase,\n titleCase,\n pascalCase,\n capitalCase,\n sentenceCase,\n} from './change_case.js'\n\n/**\n * Condense multiple whitespaces from a string\n */\nfunction condenseWhitespace(value: string): string {\n return value.trim().replace(/\\s{2,}/g, ' ')\n}\n\nconst string = {\n excerpt,\n truncate,\n slug,\n interpolate,\n plural,\n pluralize,\n singular,\n isPlural,\n isSingular,\n camelCase,\n capitalCase,\n dashCase,\n dotCase,\n noCase,\n pascalCase,\n sentenceCase,\n snakeCase,\n titleCase,\n random,\n sentence,\n condenseWhitespace,\n seconds,\n milliseconds,\n bytes,\n ordinal,\n}\n\nexport default string\n"],"mappings":";;;;;;AASA,OAAO,WAA6B;AAEpC,IAAO,gBAAQ;AAAA,EACb,OAAO,cAAsB,SAAgC;AAC3D,WAAO,MAAM,OAAO,cAAc,OAAO;AAAA,EAC3C;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAOA,MAAM,MAA+B;AACnC,QAAI,OAAO,SAAS,UAAU;AAC5B,aAAO;AAAA,IACT;AAEA,WAAO,MAAM,MAAM,IAAI;AAAA,EACzB;AACF;;;ACnBA,SAAS,OAAO,cAAc;AAE9B,IAAO,kBAAQ;AAAA,EACb,OAAO,SAAiB,MAAwB;AAC9C,WAAO,OAAO,UAAU,KAAM,IAAI;AAAA,EACpC;AAAA;AAAA;AAAA;AAAA;AAAA,EAMA,MAAM,UAAmC;AACvC,QAAI,OAAO,aAAa,UAAU;AAChC,aAAO;AAAA,IACT;AAEA,UAAM,eAAe,M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A;AAAA,EACA;AAAA,EACA,YAAAC;AAAA,EACA;AAAA,EACA,WAAAC;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AACF;AAEA,IAAO,eAAQ;","names":["sentence","truncatise","sentence","camelCase","snakeCase","pascalCase","capitalCase","camelCase","capitalCase","pascalCase","snakeCase"]}
|
package/build/chunk-NKGAOHNN.js
DELETED
|
@@ -1,64 +0,0 @@
|
|
|
1
|
-
// src/base64.ts
|
|
2
|
-
var Base64 = class {
|
|
3
|
-
encode(data, encoding) {
|
|
4
|
-
if (typeof data === "string") {
|
|
5
|
-
return Buffer.from(data, encoding).toString("base64");
|
|
6
|
-
}
|
|
7
|
-
return Buffer.from(data).toString("base64");
|
|
8
|
-
}
|
|
9
|
-
decode(encoded, encoding = "utf-8", strict = false) {
|
|
10
|
-
if (Buffer.isBuffer(encoded)) {
|
|
11
|
-
return encoded.toString(encoding);
|
|
12
|
-
}
|
|
13
|
-
const decoded = Buffer.from(encoded, "base64").toString(encoding);
|
|
14
|
-
const isInvalid = this.encode(decoded, encoding) !== encoded;
|
|
15
|
-
if (strict && isInvalid) {
|
|
16
|
-
throw new Error("Cannot decode malformed value");
|
|
17
|
-
}
|
|
18
|
-
return isInvalid ? null : decoded;
|
|
19
|
-
}
|
|
20
|
-
urlEncode(data, encoding) {
|
|
21
|
-
const encoded = typeof data === "string" ? this.encode(data, encoding) : this.encode(data);
|
|
22
|
-
return encoded.replace(/\+/g, "-").replace(/\//g, "_").replace(/\=/g, "");
|
|
23
|
-
}
|
|
24
|
-
urlDecode(encoded, encoding = "utf-8", strict = false) {
|
|
25
|
-
if (Buffer.isBuffer(encoded)) {
|
|
26
|
-
return encoded.toString(encoding);
|
|
27
|
-
}
|
|
28
|
-
const decoded = Buffer.from(encoded, "base64").toString(encoding);
|
|
29
|
-
const isInvalid = this.urlEncode(decoded, encoding) !== encoded;
|
|
30
|
-
if (strict && isInvalid) {
|
|
31
|
-
throw new Error("Cannot urlDecode malformed value");
|
|
32
|
-
}
|
|
33
|
-
return isInvalid ? null : decoded;
|
|
34
|
-
}
|
|
35
|
-
};
|
|
36
|
-
var base64 = new Base64();
|
|
37
|
-
|
|
38
|
-
// src/string/milliseconds.ts
|
|
39
|
-
import { parse, format } from "@lukeed/ms";
|
|
40
|
-
var milliseconds_default = {
|
|
41
|
-
format(milliseconds, long) {
|
|
42
|
-
return format(milliseconds, long);
|
|
43
|
-
},
|
|
44
|
-
/**
|
|
45
|
-
* Parse time expression string to milliseconds. The number value
|
|
46
|
-
* is returned as it is, considering it is already in milliseconds
|
|
47
|
-
*/
|
|
48
|
-
parse(duration) {
|
|
49
|
-
if (typeof duration === "number") {
|
|
50
|
-
return duration;
|
|
51
|
-
}
|
|
52
|
-
const milliseconds = parse(duration);
|
|
53
|
-
if (milliseconds === void 0) {
|
|
54
|
-
throw new Error(`Invalid duration expression "${duration}"`);
|
|
55
|
-
}
|
|
56
|
-
return milliseconds;
|
|
57
|
-
}
|
|
58
|
-
};
|
|
59
|
-
|
|
60
|
-
export {
|
|
61
|
-
base64,
|
|
62
|
-
milliseconds_default
|
|
63
|
-
};
|
|
64
|
-
//# sourceMappingURL=chunk-NKGAOHNN.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/base64.ts","../src/string/milliseconds.ts"],"sourcesContent":["/*\n * @poppinss/utils\n *\n * (c) Poppinss\n *\n * For the full copyright and license information, please view the LICENSE\n * file that was distributed with this source code.\n */\n\n/**\n * Helper class to base64 encode/decode values with option\n * for url encoding and decoding\n */\nclass Base64 {\n /**\n * Base64 encode Buffer or string\n */\n encode(arrayBuffer: ArrayBuffer | SharedArrayBuffer): string\n encode(data: string, encoding?: BufferEncoding): string\n encode(data: ArrayBuffer | SharedArrayBuffer | string, encoding?: BufferEncoding): string {\n if (typeof data === 'string') {\n return Buffer.from(data, encoding).toString('base64')\n }\n return Buffer.from(data).toString('base64')\n }\n\n /**\n * Base64 decode a previously encoded string or Buffer.\n */\n decode(encode: string, encoding: BufferEncoding, strict: true): string\n decode(encode: string, encoding: undefined, strict: true): string\n decode(encode: string, encoding?: BufferEncoding, strict?: false): string | null\n decode(encode: Buffer, encoding?: BufferEncoding): string\n decode(\n encoded: string | Buffer,\n encoding: BufferEncoding = 'utf-8',\n strict: boolean = false\n ): string | null {\n if (Buffer.isBuffer(encoded)) {\n return encoded.toString(encoding)\n }\n\n const decoded = Buffer.from(encoded, 'base64').toString(encoding)\n const isInvalid = this.encode(decoded, encoding) !== encoded\n\n if (strict && isInvalid) {\n throw new Error('Cannot decode malformed value')\n }\n\n return isInvalid ? null : decoded\n }\n\n /**\n * Base64 encode Buffer or string to be URL safe. (RFC 4648)\n */\n urlEncode(arrayBuffer: ArrayBuffer | SharedArrayBuffer): string\n urlEncode(data: string, encoding?: BufferEncoding): string\n urlEncode(data: ArrayBuffer | SharedArrayBuffer | string, encoding?: BufferEncoding): string {\n const encoded = typeof data === 'string' ? this.encode(data, encoding) : this.encode(data)\n return encoded.replace(/\\+/g, '-').replace(/\\//g, '_').replace(/\\=/g, '')\n }\n\n /**\n * Base64 URL decode a previously encoded string or Buffer. (RFC 4648)\n */\n urlDecode(encode: string, encoding: BufferEncoding, strict: true): string\n urlDecode(encode: string, encoding: undefined, strict: true): string\n urlDecode(encode: string, encoding?: BufferEncoding, strict?: false): string | null\n urlDecode(encode: Buffer, encoding?: BufferEncoding): string\n urlDecode(\n encoded: string | Buffer,\n encoding: BufferEncoding = 'utf-8',\n strict: boolean = false\n ): string | null {\n if (Buffer.isBuffer(encoded)) {\n return encoded.toString(encoding)\n }\n\n const decoded = Buffer.from(encoded, 'base64').toString(encoding)\n const isInvalid = this.urlEncode(decoded, encoding) !== encoded\n\n if (strict && isInvalid) {\n throw new Error('Cannot urlDecode malformed value')\n }\n\n return isInvalid ? null : decoded\n }\n}\n\nexport const base64 = new Base64()\n","/*\n * @poppinss/utils\n *\n * (c) Poppinss\n *\n * For the full copyright and license information, please view the LICENSE\n * file that was distributed with this source code.\n */\n\nimport { parse, format } from '@lukeed/ms'\n\nexport default {\n format(milliseconds: number, long?: boolean): string {\n return format(milliseconds, long)\n },\n\n /**\n * Parse time expression string to milliseconds. The number value\n * is returned as it is, considering it is already in milliseconds\n */\n parse(duration: string | number): number {\n if (typeof duration === 'number') {\n return duration\n }\n\n const milliseconds = parse(duration)\n if (milliseconds === undefined) {\n throw new Error(`Invalid duration expression \"${duration}\"`)\n }\n\n return milliseconds\n },\n}\n"],"mappings":";AAaA,IAAM,SAAN,MAAa;AAAA,EAMX,OAAO,MAAgD,UAAmC;AACxF,QAAI,OAAO,SAAS,UAAU;AAC5B,aAAO,OAAO,KAAK,MAAM,QAAQ,EAAE,SAAS,QAAQ;AAAA,IACtD;AACA,WAAO,OAAO,KAAK,IAAI,EAAE,SAAS,QAAQ;AAAA,EAC5C;AAAA,EASA,OACE,SACA,WAA2B,SAC3B,SAAkB,OACH;AACf,QAAI,OAAO,SAAS,OAAO,GAAG;AAC5B,aAAO,QAAQ,SAAS,QAAQ;AAAA,IAClC;AAEA,UAAM,UAAU,OAAO,KAAK,SAAS,QAAQ,EAAE,SAAS,QAAQ;AAChE,UAAM,YAAY,KAAK,OAAO,SAAS,QAAQ,MAAM;AAErD,QAAI,UAAU,WAAW;AACvB,YAAM,IAAI,MAAM,+BAA+B;AAAA,IACjD;AAEA,WAAO,YAAY,OAAO;AAAA,EAC5B;AAAA,EAOA,UAAU,MAAgD,UAAmC;AAC3F,UAAM,UAAU,OAAO,SAAS,WAAW,KAAK,OAAO,MAAM,QAAQ,IAAI,KAAK,OAAO,IAAI;AACzF,WAAO,QAAQ,QAAQ,OAAO,GAAG,EAAE,QAAQ,OAAO,GAAG,EAAE,QAAQ,OAAO,EAAE;AAAA,EAC1E;AAAA,EASA,UACE,SACA,WAA2B,SAC3B,SAAkB,OACH;AACf,QAAI,OAAO,SAAS,OAAO,GAAG;AAC5B,aAAO,QAAQ,SAAS,QAAQ;AAAA,IAClC;AAEA,UAAM,UAAU,OAAO,KAAK,SAAS,QAAQ,EAAE,SAAS,QAAQ;AAChE,UAAM,YAAY,KAAK,UAAU,SAAS,QAAQ,MAAM;AAExD,QAAI,UAAU,WAAW;AACvB,YAAM,IAAI,MAAM,kCAAkC;AAAA,IACpD;AAEA,WAAO,YAAY,OAAO;AAAA,EAC5B;AACF;AAEO,IAAM,SAAS,IAAI,OAAO;;;AChFjC,SAAS,OAAO,cAAc;AAE9B,IAAO,uBAAQ;AAAA,EACb,OAAO,cAAsB,MAAwB;AACnD,WAAO,OAAO,cAAc,IAAI;AAAA,EAClC;AAAA;AAAA;AAAA;AAAA;AAAA,EAMA,MAAM,UAAmC;AACvC,QAAI,OAAO,aAAa,UAAU;AAChC,aAAO;AAAA,IACT;AAEA,UAAM,eAAe,MAAM,QAAQ;AACnC,QAAI,iBAAiB,QAAW;AAC9B,YAAM,IAAI,MAAM,gCAAgC,QAAQ,GAAG;AAAA,IAC7D;AAEA,WAAO;AAAA,EACT;AACF;","names":[]}
|
package/build/chunk-PNT36FCE.js
DELETED
|
@@ -1,21 +0,0 @@
|
|
|
1
|
-
import {
|
|
2
|
-
Exception
|
|
3
|
-
} from "./chunk-GGIWJLUJ.js";
|
|
4
|
-
|
|
5
|
-
// src/exceptions/runtime_exception.ts
|
|
6
|
-
var RuntimeException = class extends Exception {
|
|
7
|
-
static code = "E_RUNTIME_EXCEPTION";
|
|
8
|
-
static status = 500;
|
|
9
|
-
};
|
|
10
|
-
|
|
11
|
-
// src/exceptions/invalid_arguments_exception.ts
|
|
12
|
-
var InvalidArgumentsException = class extends Exception {
|
|
13
|
-
static code = "E_INVALID_ARGUMENTS_EXCEPTION";
|
|
14
|
-
static status = 500;
|
|
15
|
-
};
|
|
16
|
-
|
|
17
|
-
export {
|
|
18
|
-
RuntimeException,
|
|
19
|
-
InvalidArgumentsException
|
|
20
|
-
};
|
|
21
|
-
//# sourceMappingURL=chunk-PNT36FCE.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/exceptions/runtime_exception.ts","../src/exceptions/invalid_arguments_exception.ts"],"sourcesContent":["/*\n * @poppinss/utils\n *\n * (c) Poppinss\n *\n * For the full copyright and license information, please view the LICENSE\n * file that was distributed with this source code.\n */\n\nimport { Exception } from '../exception.js'\n\nexport class RuntimeException extends Exception {\n static code = 'E_RUNTIME_EXCEPTION'\n static status = 500\n}\n","/*\n * @poppinss/utils\n *\n * (c) Poppinss\n *\n * For the full copyright and license information, please view the LICENSE\n * file that was distributed with this source code.\n */\n\nimport { Exception } from '../exception.js'\n\nexport class InvalidArgumentsException extends Exception {\n static code = 'E_INVALID_ARGUMENTS_EXCEPTION'\n static status = 500\n}\n"],"mappings":";;;;;AAWO,IAAM,mBAAN,cAA+B,UAAU;AAAA,EAC9C,OAAO,OAAO;AAAA,EACd,OAAO,SAAS;AAClB;;;ACHO,IAAM,4BAAN,cAAwC,UAAU;AAAA,EACvD,OAAO,OAAO;AAAA,EACd,OAAO,SAAS;AAClB;","names":[]}
|
package/build/chunk-RRTFLKKC.js
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/slash.ts"],"sourcesContent":["/*\n * @poppinss/utils\n *\n * (c) Poppinss\n *\n * For the full copyright and license information, please view the LICENSE\n * file that was distributed with this source code.\n */\n\nexport { default as slash } from 'slash'\n"],"mappings":";AASA,SAAoB,WAAXA,gBAAwB;","names":["default"]}
|