vcardtool 0.1.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.
@@ -0,0 +1,36 @@
1
+ interface vCardProperty {
2
+ getValue(): string;
3
+ toString(): string;
4
+ setValue(value: string): void;
5
+ }
6
+
7
+ declare class vCardEmailProperty implements vCardProperty {
8
+ value: string;
9
+ value_param?: string;
10
+ type?: "work" | "home";
11
+ pref?: number;
12
+ getValue(): string;
13
+ setValue(value: string): void;
14
+ setType(type: "work" | "home"): void;
15
+ toString(): string;
16
+ constructor(value: string);
17
+ }
18
+
19
+ declare class vCardPhoneProperty implements vCardProperty {
20
+ value: string;
21
+ constructor(value: string);
22
+ setValue(value: string): void;
23
+ getValue(): string;
24
+ toString(): string;
25
+ }
26
+
27
+ declare class vCard {
28
+ version: string;
29
+ fn: string;
30
+ properties: vCardProperty[];
31
+ constructor(fn: string);
32
+ private format;
33
+ toString(): string;
34
+ }
35
+
36
+ export { vCard, vCardEmailProperty, vCardPhoneProperty };
package/dist/index.js ADDED
@@ -0,0 +1,111 @@
1
+ var __defProp = Object.defineProperty;
2
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
3
+ var __getOwnPropNames = Object.getOwnPropertyNames;
4
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
5
+ var __export = (target, all) => {
6
+ for (var name in all)
7
+ __defProp(target, name, { get: all[name], enumerable: true });
8
+ };
9
+ var __copyProps = (to, from, except, desc) => {
10
+ if (from && typeof from === "object" || typeof from === "function") {
11
+ for (let key of __getOwnPropNames(from))
12
+ if (!__hasOwnProp.call(to, key) && key !== except)
13
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
14
+ }
15
+ return to;
16
+ };
17
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
18
+
19
+ // src/index.ts
20
+ var index_exports = {};
21
+ __export(index_exports, {
22
+ vCard: () => vCard,
23
+ vCardEmailProperty: () => vCardEmailProperty,
24
+ vCardPhoneProperty: () => vCardPhoneProperty
25
+ });
26
+ module.exports = __toCommonJS(index_exports);
27
+
28
+ // src/properties/emailproperty.ts
29
+ var vCardEmailProperty = class {
30
+ value;
31
+ value_param;
32
+ type;
33
+ pref;
34
+ // To change to integers 1 and 100
35
+ getValue() {
36
+ return this.value || "";
37
+ }
38
+ setValue(value) {
39
+ this.value = value;
40
+ }
41
+ setType(type) {
42
+ this.type = type;
43
+ }
44
+ toString() {
45
+ let segment = ["EMAIL"];
46
+ if (this.value_param) {
47
+ segment.push(`VALUE=${this.value_param}`);
48
+ }
49
+ if (this.type) {
50
+ segment.push(`TYPE=${this.type}`);
51
+ } else {
52
+ segment.push(`TYPE=work`);
53
+ }
54
+ if (this.pref) {
55
+ segment.push(`PREF=${this.pref}`);
56
+ }
57
+ return `${segment.join(";")}:${this.getValue()}`;
58
+ }
59
+ constructor(value) {
60
+ this.value = value;
61
+ }
62
+ };
63
+
64
+ // src/properties/phoneproperty.ts
65
+ var vCardPhoneProperty = class {
66
+ value;
67
+ constructor(value) {
68
+ this.value = value;
69
+ }
70
+ setValue(value) {
71
+ this.value = value;
72
+ }
73
+ getValue() {
74
+ return this.value || "";
75
+ }
76
+ toString() {
77
+ return `TEL:${this.getValue()}`;
78
+ }
79
+ };
80
+
81
+ // src/index.ts
82
+ var vCard = class {
83
+ version;
84
+ fn;
85
+ properties = [];
86
+ constructor(fn) {
87
+ this.version = "4.0";
88
+ this.fn = fn;
89
+ }
90
+ format() {
91
+ let lines = [
92
+ "BEGIN:VCARD",
93
+ `VERSION:${this.version}`,
94
+ `FN:${this.fn}`
95
+ ];
96
+ for (let prop of this.properties) {
97
+ lines.push(prop.toString());
98
+ }
99
+ lines.push("END:VCARD");
100
+ return lines.join("\n");
101
+ }
102
+ toString() {
103
+ return this.format();
104
+ }
105
+ };
106
+ // Annotate the CommonJS export names for ESM import in node:
107
+ 0 && (module.exports = {
108
+ vCard,
109
+ vCardEmailProperty,
110
+ vCardPhoneProperty
111
+ });
package/package.json ADDED
@@ -0,0 +1,24 @@
1
+ {
2
+ "name": "vcardtool",
3
+ "version": "0.1.0",
4
+ "description": "",
5
+ "main": "./dist/index.js",
6
+ "types": "./dist/index.d.ts",
7
+ "files": [
8
+ "dist"
9
+ ],
10
+ "scripts": {
11
+ "build" : "tsup src/index.ts --format cjs --dts",
12
+ "dev" : "tsup src/index.ts --format cjs --dts --watch",
13
+ "test": "vitest"
14
+ },
15
+ "keywords": [],
16
+ "author": "",
17
+ "license": "ISC",
18
+ "type": "commonjs",
19
+ "devDependencies": {
20
+ "tsup": "^8.5.1",
21
+ "typescript": "^5.9.3",
22
+ "vitest": "^4.0.18"
23
+ }
24
+ }