anthelpers 0.0.0 → 0.0.1
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/.idea/workspace.xml +50 -17
- package/index.js +56 -0
- package/index.ts +25 -3
- package/package.json +1 -1
package/.idea/workspace.xml
CHANGED
|
@@ -1,9 +1,11 @@
|
|
|
1
1
|
<?xml version="1.0" encoding="UTF-8"?>
|
|
2
2
|
<project version="4">
|
|
3
|
+
<component name="AutoImportSettings">
|
|
4
|
+
<option name="autoReloadType" value="SELECTIVE" />
|
|
5
|
+
</component>
|
|
3
6
|
<component name="ChangeListManager">
|
|
4
|
-
<list default="true" id="cbb82d94-0dbd-445b-8adb-15f10cc25fd5" name="Changes" comment="">
|
|
5
|
-
<change afterPath="$PROJECT_DIR$/.idea/
|
|
6
|
-
<change afterPath="$PROJECT_DIR$/.idea/workspace.xml" afterDir="false" />
|
|
7
|
+
<list default="true" id="cbb82d94-0dbd-445b-8adb-15f10cc25fd5" name="Changes" comment="git add ,">
|
|
8
|
+
<change beforePath="$PROJECT_DIR$/.idea/workspace.xml" beforeDir="false" afterPath="$PROJECT_DIR$/.idea/workspace.xml" afterDir="false" />
|
|
7
9
|
</list>
|
|
8
10
|
<option name="SHOW_DIALOG" value="false" />
|
|
9
11
|
<option name="HIGHLIGHT_CONFLICTS" value="true" />
|
|
@@ -13,6 +15,13 @@
|
|
|
13
15
|
<component name="ComposerSettings">
|
|
14
16
|
<execution />
|
|
15
17
|
</component>
|
|
18
|
+
<component name="FileTemplateManagerImpl">
|
|
19
|
+
<option name="RECENT_TEMPLATES">
|
|
20
|
+
<list>
|
|
21
|
+
<option value="JavaScript File" />
|
|
22
|
+
</list>
|
|
23
|
+
</option>
|
|
24
|
+
</component>
|
|
16
25
|
<component name="Git.Settings">
|
|
17
26
|
<option name="RECENT_GIT_ROOT_PATH" value="$PROJECT_DIR$" />
|
|
18
27
|
</component>
|
|
@@ -25,26 +34,31 @@
|
|
|
25
34
|
<path value="$PROJECT_DIR$/../modulesphp" />
|
|
26
35
|
</include_path>
|
|
27
36
|
</component>
|
|
28
|
-
<component name="ProjectColorInfo"
|
|
29
|
-
|
|
30
|
-
}
|
|
37
|
+
<component name="ProjectColorInfo">{
|
|
38
|
+
"associatedIndex": 2
|
|
39
|
+
}</component>
|
|
31
40
|
<component name="ProjectId" id="2yugxZZijGwAT9eK4yBkv7xnQCB" />
|
|
32
41
|
<component name="ProjectLevelVcsManager" settingsEditedManually="true" />
|
|
33
42
|
<component name="ProjectViewState">
|
|
34
43
|
<option name="hideEmptyMiddlePackages" value="true" />
|
|
35
44
|
<option name="showLibraryContents" value="true" />
|
|
36
45
|
</component>
|
|
37
|
-
<component name="PropertiesComponent"
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
+
<component name="PropertiesComponent">{
|
|
47
|
+
"keyToString": {
|
|
48
|
+
"RunOnceActivity.OpenProjectViewOnStart": "true",
|
|
49
|
+
"RunOnceActivity.ShowReadmeOnStart": "true",
|
|
50
|
+
"kotlin-language-version-configured": "true",
|
|
51
|
+
"last_opened_file_path": "D:/var/www/BOTs/dollmaker1",
|
|
52
|
+
"node.js.detected.package.eslint": "true",
|
|
53
|
+
"node.js.detected.package.tslint": "true",
|
|
54
|
+
"node.js.selected.package.eslint": "(autodetect)",
|
|
55
|
+
"node.js.selected.package.tslint": "(autodetect)",
|
|
56
|
+
"nodejs_package_manager_path": "npm",
|
|
57
|
+
"settings.editor.selected.configurable": "reference.webide.settings.project.settings.php",
|
|
58
|
+
"ts.external.directory.path": "D:\\intellij-idea\\IntelliJ IDEA 2023.3.4\\plugins\\javascript-impl\\jsLanguageServicesImpl\\external",
|
|
59
|
+
"vue.rearranger.settings.migration": "true"
|
|
46
60
|
}
|
|
47
|
-
}
|
|
61
|
+
}</component>
|
|
48
62
|
<component name="SpellCheckerSettings" RuntimeDictionaries="0" Folders="0" CustomDictionaries="0" DefaultDictionary="application-level" UseSingleDictionary="true" transferred="true" />
|
|
49
63
|
<component name="TaskManager">
|
|
50
64
|
<task active="true" id="Default" summary="Default task">
|
|
@@ -53,11 +67,30 @@
|
|
|
53
67
|
<option name="number" value="Default" />
|
|
54
68
|
<option name="presentableId" value="Default" />
|
|
55
69
|
<updated>1750690124782</updated>
|
|
56
|
-
<workItem from="1750690125892" duration="
|
|
70
|
+
<workItem from="1750690125892" duration="677000" />
|
|
71
|
+
<workItem from="1750701696645" duration="1183000" />
|
|
57
72
|
</task>
|
|
73
|
+
<task id="LOCAL-00001" summary="git add ,">
|
|
74
|
+
<option name="closed" value="true" />
|
|
75
|
+
<created>1750701889682</created>
|
|
76
|
+
<option name="number" value="00001" />
|
|
77
|
+
<option name="presentableId" value="LOCAL-00001" />
|
|
78
|
+
<option name="project" value="LOCAL" />
|
|
79
|
+
<updated>1750701889682</updated>
|
|
80
|
+
</task>
|
|
81
|
+
<option name="localTasksCounter" value="2" />
|
|
58
82
|
<servers />
|
|
59
83
|
</component>
|
|
60
84
|
<component name="TypeScriptGeneratedFilesManager">
|
|
61
85
|
<option name="version" value="3" />
|
|
86
|
+
<option name="exactExcludedFiles">
|
|
87
|
+
<list>
|
|
88
|
+
<option value="$PROJECT_DIR$/index.js" />
|
|
89
|
+
</list>
|
|
90
|
+
</option>
|
|
91
|
+
</component>
|
|
92
|
+
<component name="VcsManagerConfiguration">
|
|
93
|
+
<MESSAGE value="git add ," />
|
|
94
|
+
<option name="LAST_COMMIT_MESSAGE" value="git add ," />
|
|
62
95
|
</component>
|
|
63
96
|
</project>
|
package/index.js
ADDED
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
// antHelpers
|
|
2
|
+
/**
|
|
3
|
+
* transform '\r\n' and '\r' to '\n'
|
|
4
|
+
* @param string
|
|
5
|
+
*/
|
|
6
|
+
export function normalize_newlines(string) {
|
|
7
|
+
return String(string).replace(/\r\n/g, '\n').replace(/\r/g, '\n');
|
|
8
|
+
}
|
|
9
|
+
/**
|
|
10
|
+
* adds 4 spaces to all '\n'
|
|
11
|
+
* @param string
|
|
12
|
+
*/
|
|
13
|
+
export function indent_codeblock(string) {
|
|
14
|
+
return ' ' + normalize_newlines(string).replace(/\n/g, '\n ');
|
|
15
|
+
}
|
|
16
|
+
/**
|
|
17
|
+
* Formats a string into a blockquote suitable for Markdown.
|
|
18
|
+
* Each line of the string is prefixed with `> `, as per Markdown blockquote syntax.
|
|
19
|
+
*
|
|
20
|
+
* @param {string} string - The input string to format as a Markdown quote.
|
|
21
|
+
* @returns {string} A string formatted as a Markdown blockquote.
|
|
22
|
+
*/
|
|
23
|
+
function quoteMarkdown(string) {
|
|
24
|
+
return '> ' + normalize_newlines(string).replace(/\n/g, '\n> ');
|
|
25
|
+
}
|
|
26
|
+
/**
|
|
27
|
+
* Escapes special Markdown characters in a string to prevent formatting.
|
|
28
|
+
* Characters escaped include: ~ ` > - \ [ ] ( ) # ^ & * _ ! <
|
|
29
|
+
*
|
|
30
|
+
* @param {string} string - The input string to escape for Markdown.
|
|
31
|
+
* @returns {string} The escaped string, safe for Markdown rendering.
|
|
32
|
+
*/
|
|
33
|
+
function markdown_escape(string) {
|
|
34
|
+
return normalize_newlines(string).replace(/[~`>\-\\\[\]()#^&*_!<]/g, '\\$&');
|
|
35
|
+
}
|
|
36
|
+
/**
|
|
37
|
+
* encodes a json with an indent
|
|
38
|
+
* @param jsonicItem the item you want to jsonify
|
|
39
|
+
* @param indent a number corresponding to indent, use true for 2
|
|
40
|
+
* @param replacer JSON.stringify's replacer
|
|
41
|
+
*/
|
|
42
|
+
export function jsonEncode(jsonicItem, indent = false, replacer) {
|
|
43
|
+
if (indent === false)
|
|
44
|
+
return JSON.stringify(jsonicItem, replacer);
|
|
45
|
+
else
|
|
46
|
+
return JSON.stringify(jsonicItem, replacer, indent === true ? 2 : +indent);
|
|
47
|
+
}
|
|
48
|
+
/**
|
|
49
|
+
* like jsonEncode but also adds 4 spaces to it
|
|
50
|
+
* @param jsonicItem the json item to convert
|
|
51
|
+
* @param indent a number corresponding to indent, use true for 2
|
|
52
|
+
* @param replacer JSON.stringify's replacer
|
|
53
|
+
*/
|
|
54
|
+
export function jsonEncodeIndent(jsonicItem, indent = true, replacer) {
|
|
55
|
+
return indent_codeblock(jsonEncode(jsonicItem, indent, replacer));
|
|
56
|
+
}
|
package/index.ts
CHANGED
|
@@ -16,6 +16,28 @@ export function indent_codeblock(string: string): string {
|
|
|
16
16
|
return ' ' + normalize_newlines(string).replace(/\n/g, '\n ');
|
|
17
17
|
}
|
|
18
18
|
|
|
19
|
+
/**
|
|
20
|
+
* Formats a string into a blockquote suitable for Markdown.
|
|
21
|
+
* Each line of the string is prefixed with `> `, as per Markdown blockquote syntax.
|
|
22
|
+
*
|
|
23
|
+
* @param {string} string - The input string to format as a Markdown quote.
|
|
24
|
+
* @returns {string} A string formatted as a Markdown blockquote.
|
|
25
|
+
*/
|
|
26
|
+
function quoteMarkdown(string: string): string {
|
|
27
|
+
return '> ' + normalize_newlines(string).replace(/\n/g, '\n> ');
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
/**
|
|
31
|
+
* Escapes special Markdown characters in a string to prevent formatting.
|
|
32
|
+
* Characters escaped include: ~ ` > - \ [ ] ( ) # ^ & * _ ! <
|
|
33
|
+
*
|
|
34
|
+
* @param {string} string - The input string to escape for Markdown.
|
|
35
|
+
* @returns {string} The escaped string, safe for Markdown rendering.
|
|
36
|
+
*/
|
|
37
|
+
function markdown_escape(string: string): string {
|
|
38
|
+
return normalize_newlines(string).replace(/[~`>\-\\\[\]()#^&*_!<]/g, '\\$&');
|
|
39
|
+
}
|
|
40
|
+
|
|
19
41
|
/**
|
|
20
42
|
* encodes a json with an indent
|
|
21
43
|
* @param jsonicItem the item you want to jsonify
|
|
@@ -29,9 +51,9 @@ export function jsonEncode(jsonicItem: any, indent: boolean | number = false, re
|
|
|
29
51
|
|
|
30
52
|
/**
|
|
31
53
|
* like jsonEncode but also adds 4 spaces to it
|
|
32
|
-
* @param jsonicItem
|
|
33
|
-
* @param indent
|
|
34
|
-
* @param replacer
|
|
54
|
+
* @param jsonicItem the json item to convert
|
|
55
|
+
* @param indent a number corresponding to indent, use true for 2
|
|
56
|
+
* @param replacer JSON.stringify's replacer
|
|
35
57
|
*/
|
|
36
58
|
export function jsonEncodeIndent(jsonicItem: any, indent: boolean | number = true, replacer?: (this: any, key: string, value: any) => any): string {
|
|
37
59
|
return indent_codeblock(jsonEncode(jsonicItem, indent, replacer));
|