@one-format/strings-plugin 0.0.0-stage → 1.0.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 +53 -3
- package/dist/index.d.ts +28 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +14 -0
- package/dist/index.js.map +1 -0
- package/package.json +22 -6
- package/src/index.ts +42 -0
- package/tsconfig.json +37 -0
package/README.md
CHANGED
|
@@ -1,3 +1,53 @@
|
|
|
1
|
-
#
|
|
2
|
-
|
|
3
|
-
|
|
1
|
+
# @one-format/strings-plugin
|
|
2
|
+
|
|
3
|
+
An official one-format plugin for common string transformations.
|
|
4
|
+
|
|
5
|
+
## Installation
|
|
6
|
+
|
|
7
|
+
```bash
|
|
8
|
+
npm install @one-format/strings-plugin
|
|
9
|
+
```
|
|
10
|
+
|
|
11
|
+
## Usage
|
|
12
|
+
|
|
13
|
+
The package exports a plugin object containing three tools:
|
|
14
|
+
|
|
15
|
+
```ts
|
|
16
|
+
import stringsPlugin from "@one-format/strings-plugin";
|
|
17
|
+
|
|
18
|
+
stringsPlugin.tools.uppercase("hello, world!");
|
|
19
|
+
// "HELLO, WORLD!"
|
|
20
|
+
|
|
21
|
+
stringsPlugin.tools.lowercase("Hello, World!");
|
|
22
|
+
// "hello, world!"
|
|
23
|
+
|
|
24
|
+
stringsPlugin.tools.urlencoded("hello world!");
|
|
25
|
+
// "hello%20world!"
|
|
26
|
+
```
|
|
27
|
+
|
|
28
|
+
Use the plugin with `@one-format/core` to expose its tools directly:
|
|
29
|
+
|
|
30
|
+
```ts
|
|
31
|
+
import adapter from "@one-format/core";
|
|
32
|
+
import stringsPlugin from "@one-format/strings-plugin";
|
|
33
|
+
|
|
34
|
+
const strings = adapter(stringsPlugin);
|
|
35
|
+
|
|
36
|
+
strings.uppercase("hello"); // "HELLO"
|
|
37
|
+
strings.lowercase("HELLO"); // "hello"
|
|
38
|
+
strings.urlencoded("hello world"); // "hello%20world"
|
|
39
|
+
```
|
|
40
|
+
|
|
41
|
+
## API
|
|
42
|
+
|
|
43
|
+
- `tools.uppercase(value)` - returns the string converted to uppercase.
|
|
44
|
+
- `tools.lowercase(value)` - returns the string converted to lowercase.
|
|
45
|
+
- `tools.urlencoded(value)` - returns the string encoded with
|
|
46
|
+
`encodeURIComponent`.
|
|
47
|
+
- `metadata` - identifies the plugin and its version.
|
|
48
|
+
|
|
49
|
+
All tools accept a string and return a string.
|
|
50
|
+
|
|
51
|
+
## License
|
|
52
|
+
|
|
53
|
+
EUPL-1.2
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
type PluginFn<Input = any, Output = any> = (input: Input) => Output;
|
|
2
|
+
interface PluginMetadata {
|
|
3
|
+
name: string;
|
|
4
|
+
author: string;
|
|
5
|
+
version?: string;
|
|
6
|
+
}
|
|
7
|
+
interface PluginType<Tools extends Record<string, any>> {
|
|
8
|
+
metadata: PluginMetadata;
|
|
9
|
+
tools: {
|
|
10
|
+
[K in keyof Tools]: PluginFn<Tools[K]['input'], Tools[K]['output']>;
|
|
11
|
+
};
|
|
12
|
+
}
|
|
13
|
+
declare const stringsPlugin: PluginType<{
|
|
14
|
+
uppercase: {
|
|
15
|
+
input: string;
|
|
16
|
+
output: string;
|
|
17
|
+
};
|
|
18
|
+
lowercase: {
|
|
19
|
+
input: string;
|
|
20
|
+
output: string;
|
|
21
|
+
};
|
|
22
|
+
urlencoded: {
|
|
23
|
+
input: string;
|
|
24
|
+
output: string;
|
|
25
|
+
};
|
|
26
|
+
}>;
|
|
27
|
+
export default stringsPlugin;
|
|
28
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,KAAK,QAAQ,CAAC,KAAK,GAAG,GAAG,EAAE,MAAM,GAAG,GAAG,IAAI,CAAC,KAAK,EAAE,KAAK,KAAK,MAAM,CAAC;AAEpE,UAAU,cAAc;IACpB,IAAI,EAAE,MAAM,CAAC;IACb,MAAM,EAAE,MAAM,CAAC;IACf,OAAO,CAAC,EAAE,MAAM,CAAC;CACpB;AACD,UAAU,UAAU,CAAC,KAAK,SAAS,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC;IAClD,QAAQ,EAAE,cAAc,CAAC;IACzB,KAAK,EAAE;SACF,CAAC,IAAI,MAAM,KAAK,GAAG,QAAQ,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,OAAO,CAAC,EAAE,KAAK,CAAC,CAAC,CAAC,CAAC,QAAQ,CAAC,CAAC;KACtE,CAAC;CACL;AAGD,QAAA,MAAM,aAAa,EAAE,UAAU,CAAC;IAC5B,SAAS,EAAE;QACP,KAAK,EAAE,MAAM,CAAC;QACd,MAAM,EAAE,MAAM,CAAA;KACjB,CAAC;IACF,SAAS,EAAE;QACP,KAAK,EAAE,MAAM,CAAC;QACd,MAAM,EAAE,MAAM,CAAA;KACjB,CAAC;IACF,UAAU,EAAE;QACR,KAAK,EAAE,MAAM,CAAC;QACd,MAAM,EAAE,MAAM,CAAA;KACjB,CAAA;CACA,CAWJ,CAAA;eAEc,aAAa"}
|
package/dist/index.js
ADDED
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
const stringsPlugin = {
|
|
2
|
+
"metadata": {
|
|
3
|
+
"author": "Vedansh Shetti <vedansh.shetti@gmail.com> - one-format Official Plugin",
|
|
4
|
+
"name": "One-Format Strings",
|
|
5
|
+
"version": "1.1.0"
|
|
6
|
+
},
|
|
7
|
+
tools: {
|
|
8
|
+
uppercase: (s) => s.toUpperCase(),
|
|
9
|
+
lowercase: (s) => s.toLowerCase(),
|
|
10
|
+
urlencoded: (s) => encodeURIComponent(s)
|
|
11
|
+
}
|
|
12
|
+
};
|
|
13
|
+
export default stringsPlugin;
|
|
14
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAeA,MAAM,aAAa,GAaV;IACL,UAAU,EAAE;QACR,QAAQ,EAAE,wEAAwE;QAClF,MAAM,EAAE,oBAAoB;QAC5B,SAAS,EAAE,OAAO;KACrB;IACD,KAAK,EAAE;QACH,SAAS,EAAE,CAAC,CAAS,EAAE,EAAE,CAAC,CAAC,CAAC,WAAW,EAAE;QACzC,SAAS,EAAE,CAAC,CAAS,EAAE,EAAE,CAAC,CAAC,CAAC,WAAW,EAAE;QACzC,UAAU,EAAE,CAAC,CAAS,EAAE,EAAE,CAAC,kBAAkB,CAAC,CAAC,CAAC;KACnD;CACJ,CAAA;AAED,eAAe,aAAa,CAAC"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,22 @@
|
|
|
1
|
-
{
|
|
2
|
-
"name": "@one-format/strings-plugin",
|
|
3
|
-
"version": "
|
|
4
|
-
"
|
|
5
|
-
"
|
|
6
|
-
|
|
1
|
+
{
|
|
2
|
+
"name": "@one-format/strings-plugin",
|
|
3
|
+
"version": "1.0.0",
|
|
4
|
+
"description": "",
|
|
5
|
+
"keywords": [
|
|
6
|
+
"http-formatting"
|
|
7
|
+
],
|
|
8
|
+
"license": "EUPL-1.2",
|
|
9
|
+
"author": "Vedansh Shetti <vedansh.shetti@gmail.com>",
|
|
10
|
+
"type": "module",
|
|
11
|
+
"main": "dist/index.js",
|
|
12
|
+
"scripts": {
|
|
13
|
+
"test": "echo \"I didnt feel like writing tests, its just more code to maintain\"",
|
|
14
|
+
"prepublishOnly": "tsc",
|
|
15
|
+
"postpublish": "rimraf dist"
|
|
16
|
+
},
|
|
17
|
+
"devDependencies": {
|
|
18
|
+
"@types/node": "^26.6.5",
|
|
19
|
+
"rimraf": "^6.1.3",
|
|
20
|
+
"typescript": "^7.0.2"
|
|
21
|
+
}
|
|
22
|
+
}
|
package/src/index.ts
ADDED
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
type PluginFn<Input = any, Output = any> = (input: Input) => Output;
|
|
2
|
+
|
|
3
|
+
interface PluginMetadata {
|
|
4
|
+
name: string; // Plugin Name
|
|
5
|
+
author: string; // Author
|
|
6
|
+
version?: string; // Version Number, preferably SemVer.
|
|
7
|
+
}
|
|
8
|
+
interface PluginType<Tools extends Record<string, any>> {
|
|
9
|
+
metadata: PluginMetadata;
|
|
10
|
+
tools: {
|
|
11
|
+
[K in keyof Tools]: PluginFn<Tools[K]['input'], Tools[K]['output']>;
|
|
12
|
+
};
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
|
|
16
|
+
const stringsPlugin: PluginType<{
|
|
17
|
+
uppercase: {
|
|
18
|
+
input: string,
|
|
19
|
+
output: string
|
|
20
|
+
},
|
|
21
|
+
lowercase: {
|
|
22
|
+
input: string,
|
|
23
|
+
output: string
|
|
24
|
+
},
|
|
25
|
+
urlencoded: {
|
|
26
|
+
input: string,
|
|
27
|
+
output: string
|
|
28
|
+
}
|
|
29
|
+
}> = {
|
|
30
|
+
"metadata": {
|
|
31
|
+
"author": "Vedansh Shetti <vedansh.shetti@gmail.com> - one-format Official Plugin",
|
|
32
|
+
"name": "One-Format Strings",
|
|
33
|
+
"version": "1.1.0"
|
|
34
|
+
},
|
|
35
|
+
tools: {
|
|
36
|
+
uppercase: (s: string) => s.toUpperCase(),
|
|
37
|
+
lowercase: (s: string) => s.toLowerCase(),
|
|
38
|
+
urlencoded: (s: string) => encodeURIComponent(s)
|
|
39
|
+
}
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
export default stringsPlugin;
|
package/tsconfig.json
ADDED
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
{
|
|
2
|
+
"compilerOptions": {
|
|
3
|
+
// Environment Settings
|
|
4
|
+
"module": "nodenext",
|
|
5
|
+
"target": "esnext",
|
|
6
|
+
"lib": ["esnext"],
|
|
7
|
+
"types": ["node"],
|
|
8
|
+
|
|
9
|
+
// Output Layout
|
|
10
|
+
"outDir": "./dist",
|
|
11
|
+
"rootDir": "./src",
|
|
12
|
+
"sourceMap": true,
|
|
13
|
+
"declaration": true,
|
|
14
|
+
"declarationMap": true,
|
|
15
|
+
|
|
16
|
+
// Stricter Typechecking
|
|
17
|
+
"strict": true,
|
|
18
|
+
"noUncheckedIndexedAccess": true,
|
|
19
|
+
"exactOptionalPropertyTypes": true,
|
|
20
|
+
"noImplicitReturns": true,
|
|
21
|
+
"noImplicitOverride": true,
|
|
22
|
+
"noUnusedLocals": true,
|
|
23
|
+
"noUnusedParameters": true,
|
|
24
|
+
"noFallthroughCasesInSwitch": true,
|
|
25
|
+
"noPropertyAccessFromIndexSignature": true,
|
|
26
|
+
|
|
27
|
+
// Module & Syntax
|
|
28
|
+
"verbatimModuleSyntax": true,
|
|
29
|
+
"isolatedModules": true,
|
|
30
|
+
"moduleDetection": "force",
|
|
31
|
+
"skipLibCheck": true,
|
|
32
|
+
"esModuleInterop": true,
|
|
33
|
+
"forceConsistentCasingInFileNames": true
|
|
34
|
+
},
|
|
35
|
+
"include": ["src/**/*"],
|
|
36
|
+
"exclude": ["node_modules", "dist"]
|
|
37
|
+
}
|