adaptive-extender 0.2.5
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/CHANGELOG.md +2 -0
- package/README.md +1 -0
- package/dist/core/array.d.ts +42 -0
- package/dist/core/array.js +40 -0
- package/dist/core/array.js.map +1 -0
- package/dist/core/boolean.d.ts +14 -0
- package/dist/core/boolean.js +8 -0
- package/dist/core/boolean.js.map +1 -0
- package/dist/core/color.d.ts +369 -0
- package/dist/core/color.js +541 -0
- package/dist/core/color.js.map +1 -0
- package/dist/core/date.d.ts +27 -0
- package/dist/core/date.js +18 -0
- package/dist/core/date.js.map +1 -0
- package/dist/core/error.d.ts +20 -0
- package/dist/core/error.js +20 -0
- package/dist/core/error.js.map +1 -0
- package/dist/core/global.d.ts +14 -0
- package/dist/core/global.js +13 -0
- package/dist/core/global.js.map +1 -0
- package/dist/core/index.d.ts +17 -0
- package/dist/core/index.js +16 -0
- package/dist/core/index.js.map +1 -0
- package/dist/core/math.d.ts +44 -0
- package/dist/core/math.js +43 -0
- package/dist/core/math.js.map +1 -0
- package/dist/core/number.d.ts +59 -0
- package/dist/core/number.js +51 -0
- package/dist/core/number.js.map +1 -0
- package/dist/core/object.d.ts +30 -0
- package/dist/core/object.js +21 -0
- package/dist/core/object.js.map +1 -0
- package/dist/core/primitives.d.ts +10 -0
- package/dist/core/primitives.js +3 -0
- package/dist/core/primitives.js.map +1 -0
- package/dist/core/promise.d.ts +28 -0
- package/dist/core/promise.js +58 -0
- package/dist/core/promise.js.map +1 -0
- package/dist/core/random.d.ts +103 -0
- package/dist/core/random.js +114 -0
- package/dist/core/random.js.map +1 -0
- package/dist/core/string.d.ts +67 -0
- package/dist/core/string.js +44 -0
- package/dist/core/string.js.map +1 -0
- package/package.json +42 -0
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"random.js","sourceRoot":"","sources":["../../src/core/random.ts"],"names":[],"mappings":"AAAA,YAAY,CAAC;AAEb,MA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G,GAAG;gBAAE,OAAO,IAAI,CAAC;YACjD,KAAK,GAAG,GAAG,CAAC;QACb,CAAC;QACD,MAAM,IAAI,KAAK,CAAC,uCAAuC,MAAM,EAAE,CAAC,CAAC;IAClE,CAAC;IAAA,CAAC;;AAEH,YAAY;AAEZ,OAAO,EAAE,MAAM,EAAE,CAAC"}
|
|
@@ -0,0 +1,67 @@
|
|
|
1
|
+
import "./global.js";
|
|
2
|
+
declare global {
|
|
3
|
+
interface StringConstructor {
|
|
4
|
+
/**
|
|
5
|
+
* Imports a string from a source.
|
|
6
|
+
* @param source The source value to import.
|
|
7
|
+
* @param name The name of the source value.
|
|
8
|
+
* @returns The imported string value.
|
|
9
|
+
* @throws {TypeError} If the source is not a string.
|
|
10
|
+
*/
|
|
11
|
+
import(source: any, name?: string): string;
|
|
12
|
+
/**
|
|
13
|
+
* A constant empty string.
|
|
14
|
+
* @readonly
|
|
15
|
+
*/
|
|
16
|
+
empty: string;
|
|
17
|
+
/**
|
|
18
|
+
* Checks if a string is empty.
|
|
19
|
+
* @param text The string to check.
|
|
20
|
+
* @returns True if the string is empty, otherwise false.
|
|
21
|
+
*/
|
|
22
|
+
isEmpty(text: string): boolean;
|
|
23
|
+
/**
|
|
24
|
+
* Checks if a string contains only whitespace characters.
|
|
25
|
+
* @param text The string to check.
|
|
26
|
+
* @returns True if the string is empty or contains only whitespace, otherwise false.
|
|
27
|
+
*/
|
|
28
|
+
isWhitespace(text: string): boolean;
|
|
29
|
+
}
|
|
30
|
+
interface String {
|
|
31
|
+
/**
|
|
32
|
+
* Returns the current string unless it is empty, replacing it with the provided value.
|
|
33
|
+
* @param value The fallback value.
|
|
34
|
+
* @returns The original string or the fallback.
|
|
35
|
+
*/
|
|
36
|
+
insteadEmpty<T>(value: T): string | T;
|
|
37
|
+
/**
|
|
38
|
+
* Returns the current string unless it consists only of whitespace, replacing it with the provided value.
|
|
39
|
+
* @param value The fallback value.
|
|
40
|
+
* @returns The original string or the fallback.
|
|
41
|
+
*/
|
|
42
|
+
insteadWhitespace<T>(value: T): string | T;
|
|
43
|
+
/**
|
|
44
|
+
* Converts the string to title case, where the first letter of each word is capitalized.
|
|
45
|
+
* @returns The string converted to title case.
|
|
46
|
+
*/
|
|
47
|
+
toTitleCase(): string;
|
|
48
|
+
/**
|
|
49
|
+
* Converts the string to title case based on the specified locale(s), capitalizing the first letter of each word.
|
|
50
|
+
* @param locales A single locale or an array of locales for locale-aware case conversion.
|
|
51
|
+
* @returns The string converted to title case with locale-awareness.
|
|
52
|
+
*/
|
|
53
|
+
toLocalTitleCase(locales?: string | string[]): string;
|
|
54
|
+
/**
|
|
55
|
+
* Converts the string to title case based on the specified locale(s), capitalizing the first letter of each word.
|
|
56
|
+
* @param locales An argument supported by `Intl` for locale-aware case conversion.
|
|
57
|
+
* @returns The string converted to title case with locale-awareness.
|
|
58
|
+
*/
|
|
59
|
+
toLocalTitleCase(locales?: Intl.LocalesArgument): string;
|
|
60
|
+
/**
|
|
61
|
+
* Reverses the string.
|
|
62
|
+
* @returns The reversed string.
|
|
63
|
+
*/
|
|
64
|
+
reverse(): string;
|
|
65
|
+
}
|
|
66
|
+
}
|
|
67
|
+
export {};
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
import "./global.js";
|
|
3
|
+
String.import = function (source, name = "[source]") {
|
|
4
|
+
if (typeof (source) !== "string")
|
|
5
|
+
throw new TypeError(`Unable to import string from ${name} due its ${typename(source)} type`);
|
|
6
|
+
return source.valueOf();
|
|
7
|
+
};
|
|
8
|
+
Object.defineProperty(String, "empty", {
|
|
9
|
+
value: "",
|
|
10
|
+
writable: false,
|
|
11
|
+
});
|
|
12
|
+
String.isEmpty = function (text) {
|
|
13
|
+
return (text.length === 0);
|
|
14
|
+
};
|
|
15
|
+
String.isWhitespace = function (text) {
|
|
16
|
+
return String.isEmpty(text.trimStart());
|
|
17
|
+
};
|
|
18
|
+
String.prototype.insteadEmpty = function (value) {
|
|
19
|
+
const current = this.valueOf();
|
|
20
|
+
if (String.isEmpty(current))
|
|
21
|
+
return value;
|
|
22
|
+
return current;
|
|
23
|
+
};
|
|
24
|
+
String.prototype.insteadWhitespace = function (value) {
|
|
25
|
+
const current = this.valueOf();
|
|
26
|
+
if (String.isWhitespace(current))
|
|
27
|
+
return value;
|
|
28
|
+
return current;
|
|
29
|
+
};
|
|
30
|
+
const patternWordsFirstLetter = /\b\w/g;
|
|
31
|
+
String.prototype.toTitleCase = function () {
|
|
32
|
+
return this.toLowerCase().replace(patternWordsFirstLetter, char => char.toUpperCase());
|
|
33
|
+
};
|
|
34
|
+
String.prototype.toLocalTitleCase = function (locales) {
|
|
35
|
+
return this.toLocaleLowerCase(locales).replace(patternWordsFirstLetter, char => char.toLocaleUpperCase(locales));
|
|
36
|
+
};
|
|
37
|
+
String.prototype.reverse = function () {
|
|
38
|
+
let string = String.empty;
|
|
39
|
+
for (let index = this.length - 1; index >= 0; index--) {
|
|
40
|
+
string += this[index];
|
|
41
|
+
}
|
|
42
|
+
return string;
|
|
43
|
+
};
|
|
44
|
+
//# sourceMappingURL=string.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"string.js","sourceRoot":"","sources":["../../src/core/string.ts"],"names":[],"mappings":"AAAA,YAAY,CAAC;AAEb,OAAO,aAAa,CAAC;AAqErB,MAAM,CAAC,MAAM,GAAG,UAAU,MAAW,EAAE,OAAe,UAAU;IAC/D,IAAI,OAAO,CAAC,MAAM,CAAC,KAAK,QAAQ;QAAE,MAAM,IAAI,SAAS,CAAC,gCAAgC,IAAI,YAAY,QAAQ,CAAC,MAAM,CAAC,OAAO,CAAC,CAAC;IAC/H,OAAO,MAAM,CAAC,OAAO,EAAE,CAAC;AACzB,CAAC,CAAC;AAEF,MAAM,CAAC,cAAc,CAAC,MAAM,EAAE,OAAO,EAAE;IACtC,KAAK,EAAE,EAAE;IACT,QAAQ,EAAE,KAAK;CACf,CAAC,CAAC;AAEH,MAAM,CAAC,OAAO,GAA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AAC;IAC1B,KAAK,IAAI,KAAK,GAAG,IAAI,CAAC,MAAM,GAAG,CAAC,EAAE,KAAK,IAAI,CAAC,EAAE,KAAK,EAAE,EAAE,CAAC;QACvD,MAAM,IAAI,IAAI,CAAC,KAAK,CAAC,CAAC;IACvB,CAAC;IACD,OAAO,MAAM,CAAC;AACf,CAAC,CAAC"}
|
package/package.json
ADDED
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "adaptive-extender",
|
|
3
|
+
"version": "0.2.5",
|
|
4
|
+
"description": "Adaptive library for JS/TS development environments",
|
|
5
|
+
"type": "module",
|
|
6
|
+
"exports": {
|
|
7
|
+
"./core": {
|
|
8
|
+
"import": "./dist/core/index.js",
|
|
9
|
+
"types": "./dist/core/index.d.ts"
|
|
10
|
+
},
|
|
11
|
+
"./dom": {
|
|
12
|
+
"import": "./dist/dom/index.js",
|
|
13
|
+
"types": "./dist/dom/index.d.ts"
|
|
14
|
+
},
|
|
15
|
+
"./node": {
|
|
16
|
+
"import": "./dist/node/index.js",
|
|
17
|
+
"types": "./dist/node/index.d.ts"
|
|
18
|
+
}
|
|
19
|
+
},
|
|
20
|
+
"repository": {
|
|
21
|
+
"type": "git",
|
|
22
|
+
"url": "git+https://github.com/eccs0103/adaptive-extender.git"
|
|
23
|
+
},
|
|
24
|
+
"keywords": [ "javascript", "typescript", "extensions", "core", "dom", "node" ],
|
|
25
|
+
"author": "eccs0103",
|
|
26
|
+
"license": "MIT",
|
|
27
|
+
"bugs": {
|
|
28
|
+
"url": "https://github.com/eccs0103/adaptive-extender/issues"
|
|
29
|
+
},
|
|
30
|
+
"homepage": "https://github.com/eccs0103/adaptive-extender#readme",
|
|
31
|
+
"scripts": {
|
|
32
|
+
"build:core": "tsc -p ./src/core/tsconfig.json",
|
|
33
|
+
"build:dom": "tsc -p ./src/dom/tsconfig.json",
|
|
34
|
+
"build:node": "tsc -p ./src/node/tsconfig.json",
|
|
35
|
+
"build": "npm run build:core && npm run build:dom && npm run build:node",
|
|
36
|
+
|
|
37
|
+
"watch:core": "tsc -p ./src/core/tsconfig.json --watch",
|
|
38
|
+
"watch:dom": "tsc -p ./src/dom/tsconfig.json --watch",
|
|
39
|
+
"watch:node": "tsc -p ./src/node/tsconfig.json --watch",
|
|
40
|
+
"watch": "npm run watch:core && npm run watch:dom && npm run watch:node"
|
|
41
|
+
}
|
|
42
|
+
}
|