@opfr/utils-lang 0.2.2 → 0.3.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/dist/string.js ADDED
@@ -0,0 +1,62 @@
1
+ export const TIGHT_SPACE = String.fromCharCode(8202);
2
+ export const WIDE_SPACE = String.fromCharCode(8201);
3
+ export const fillWithTightSpaces = (str, separator = '') => {
4
+ return str.split(separator).join(TIGHT_SPACE);
5
+ };
6
+ export const fillWithWideSpaces = (str, separator = '') => {
7
+ return str.split(separator).join(WIDE_SPACE);
8
+ };
9
+ export const ellipsis = (str, limit) => {
10
+ if (str.length > limit)
11
+ return str.slice(0, limit - 3) + '...';
12
+ return str;
13
+ };
14
+ export const capitalize = (str) => {
15
+ return str && str[0].toUpperCase() + str.slice(1);
16
+ };
17
+ export const capitalizeAllWords = (str) => {
18
+ return str.split(' ').map(capitalize).join(' ');
19
+ };
20
+ export const isPositiveInteger = (str) => {
21
+ return /^\d+$/.test(str);
22
+ };
23
+ export const numberToOrdinal = (nb) => {
24
+ if (nb !== Math.round(nb) || nb < 1 || nb === Infinity || nb === -Infinity) {
25
+ return null;
26
+ }
27
+ return nb === 1 ? '1er' : `${nb}ème`;
28
+ };
29
+ export const trim = (str) => {
30
+ return str.trim().replace(/\s+/gi, ' ');
31
+ };
32
+ export const breakWords = (str) => {
33
+ const words = str.split(' ');
34
+ const splitByBetterSize = (words) => {
35
+ let bestDiff = Infinity;
36
+ for (let i = 0; i < words.length; i++) {
37
+ const diff = Math.abs(words.slice(0, i + 1).join(' ').length -
38
+ words.slice(i + 1).join(' ').length);
39
+ if (diff <= bestDiff)
40
+ bestDiff = diff;
41
+ else
42
+ return i - 1;
43
+ }
44
+ return bestDiff;
45
+ };
46
+ const bestSplit = splitByBetterSize(words);
47
+ if (words.length === 1)
48
+ return [words[0]];
49
+ return [words.slice(0, bestSplit + 1), words.slice(bestSplit + 1)].map(v => v.join(' '));
50
+ };
51
+ export const isString = (str) => {
52
+ return typeof str === 'string';
53
+ };
54
+ export const camelcase = (str) => {
55
+ const newString = str.replace(/[^a-zA-Z0-9]+(.)/g, (m, chr) => chr.toUpperCase());
56
+ return `${newString.charAt(0).toLowerCase()}${newString.slice(1)}`;
57
+ };
58
+ export const pascalCase = (str) => {
59
+ const camelCased = camelcase(str);
60
+ return `${camelCased.charAt(0).toUpperCase()}${camelCased.slice(1)}`;
61
+ };
62
+ //# sourceMappingURL=string.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"string.js","sourceRoot":"","sources":["../src/string.ts"],"names":[],"mappings":"AAAA,MAAM,CAAC,MAAM,WAAW,GAAG,MAAM,CAAC,YAAY,CAAC,IAAI,CAAC,CAAC;AACrD,MAAM,CAAC,MAAM,UAAU,GAAG,MAAM,CAAC,YAAY,CAAC,IAAI,CAAC,CAAC;AAEpD,MAAM,CAAC,MAAM,mBAAmB,GAAG,CAAC,GAAW,EAAE,YAAoB,EAAE,EAAE,EAAE;IACzE,OAAO,GAAG,CAAC,KAAK,CAAC,SAAS,CAAC,CAAC,IAAI,CAAC,WAAW,CAAC,CAAC;AAChD,CAAC,CAAC;AAEF,MAAM,CAAC,MAAM,kBAAkB,GAAG,CAAC,GAAW,EAAE,YAAoB,EAAE,EAAE,EAAE;IACxE,OAAO,GAAG,CAAC,KAAK,CAAC,SAAS,CAAC,CAAC,IAAI,CAAC,UAAU,CAAC,CAAC;AAC/C,CAAC,CAAC;AAEF,MAAM,CAAC,MAAM,QAAQ,GAAG,CAAC,GAAW,EAAE,KAAa,EAAE,EAAE;IACrD,IAAI,GAAG,CAAC,MAAM,GAAG,KAAK;QAAE,OAAO,GAAG,CAAC,KAAK,CAAC,CAAC,EAAE,KAAK,GAAG,CAAC,CAAC,GAAG,KAAK,CAAC;IAC/D,OAAO,GAAG,CAAC;AACb,CAAC,CAAC;AAEF,MAAM,CAAC,MAAM,UAAU,GAAG,CAAC,GAAW,EAAE,EAAE;IACxC,OAAO,GAAG,IAAI,GAAG,CAAC,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AC,CAAC,CAAC,WAAW,EAAE,GAAG,SAAS,CAAC,KAAK,CAAC,CAAC,CAAC,EAAE,CAAC;AACrE,CAAC,CAAC;AAEF,MAAM,CAAC,MAAM,UAAU,GAAG,CAAC,GAAW,EAAU,EAAE;IAChD,MAAM,UAAU,GAAG,SAAS,CAAC,GAAG,CAAC,CAAC;IAClC,OAAO,GAAG,UAAU,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC,WAAW,EAAE,GAAG,UAAU,CAAC,KAAK,CAAC,CAAC,CAAC,EAAE,CAAC;AACvE,CAAC,CAAC"}
package/package.json CHANGED
@@ -1,12 +1,12 @@
1
1
  {
2
2
  "name": "@opfr/utils-lang",
3
- "version": "0.2.2",
3
+ "version": "0.3.0",
4
4
  "private": false,
5
5
  "description": "OPFR utils-lang",
6
6
  "author": "Matthieu VEIGA",
7
7
  "scripts": {
8
8
  "prepublish": "npm run build",
9
- "build": "tsc && vite build",
9
+ "build": " vite build && tsc",
10
10
  "test": "vitest",
11
11
  "test:ci": "vitest run",
12
12
  "coverage": "vitest run --coverage"
@@ -31,5 +31,5 @@
31
31
  "node_modules",
32
32
  "dist"
33
33
  ],
34
- "gitHead": "fe9443a984bbe149017ff43c417416607caacefc"
34
+ "gitHead": "4791181e365e6da6515343437a8cbba1daa945c9"
35
35
  }
package/dist/emojis.d.ts DELETED
@@ -1,206 +0,0 @@
1
- export declare const emojis: {
2
- d1: string;
3
- d2: string;
4
- d3: string;
5
- d4: string;
6
- d5: string;
7
- d6: string;
8
- revolutionary: string;
9
- pirate: string;
10
- marine: string;
11
- berry: string;
12
- xp: string;
13
- success: string;
14
- hp: string;
15
- paper: string;
16
- rock: string;
17
- scissor: string;
18
- pray: string;
19
- gun: string;
20
- promise: string;
21
- love: string;
22
- note: string;
23
- watching: string;
24
- card: string;
25
- cards: {
26
- spades: {
27
- 1: string;
28
- 2: string;
29
- 3: string;
30
- 4: string;
31
- 5: string;
32
- 6: string;
33
- 7: string;
34
- 8: string;
35
- 9: string;
36
- 10: string;
37
- J: string;
38
- Q: string;
39
- K: string;
40
- };
41
- diamonds: {
42
- 1: string;
43
- 2: string;
44
- 3: string;
45
- 4: string;
46
- 5: string;
47
- 6: string;
48
- 7: string;
49
- 8: string;
50
- 9: string;
51
- 10: string;
52
- J: string;
53
- Q: string;
54
- K: string;
55
- };
56
- hearts: {
57
- 1: string;
58
- 2: string;
59
- 3: string;
60
- 4: string;
61
- 5: string;
62
- 6: string;
63
- 7: string;
64
- 8: string;
65
- 9: string;
66
- 10: string;
67
- J: string;
68
- Q: string;
69
- K: string;
70
- };
71
- clubs: {
72
- 1: string;
73
- 2: string;
74
- 3: string;
75
- 4: string;
76
- 5: string;
77
- 6: string;
78
- 7: string;
79
- 8: string;
80
- 9: string;
81
- 10: string;
82
- J: string;
83
- Q: string;
84
- K: string;
85
- };
86
- };
87
- factions: {
88
- b_citizen_Bronze: string;
89
- b_citizen_Silver: string;
90
- b_citizen_Gold: string;
91
- b_citizen_Platinum: string;
92
- b_citizen_Diamond: string;
93
- b_marine_Bronze: string;
94
- b_marine_Silver: string;
95
- b_marine_Gold: string;
96
- b_marine_Platinum: string;
97
- b_marine_Diamond: string;
98
- b_revolutionary_Bronze: string;
99
- b_revolutionary_Silver: string;
100
- b_revolutionary_Gold: string;
101
- b_revolutionary_Platinum: string;
102
- b_revolutionary_Diamond: string;
103
- b_pirate_Bronze: string;
104
- b_pirate_Silver: string;
105
- b_pirate_Gold: string;
106
- b_pirate_Platinum: string;
107
- b_pirate_Diamond: string;
108
- };
109
- characteristics: {
110
- vitality: string;
111
- strength: string;
112
- agility: string;
113
- intelligence: string;
114
- chance: string;
115
- wisdom: string;
116
- };
117
- item_background: string;
118
- item_title: string;
119
- item_lootbox1: string;
120
- item_lootbox2: string;
121
- item_lootbox3: string;
122
- item_lootbox4: string;
123
- item_bottle_xp_1: string;
124
- item_bottle_xp_2: string;
125
- item_bottle_xp_3: string;
126
- item_bottle_xp_4: string;
127
- item_boost_week: string;
128
- item_boost_day: string;
129
- item_repair_wood_plank: string;
130
- item_repair_nail: string;
131
- item_repair_glue: string;
132
- item_repair_rope: string;
133
- item_repair_kit: string;
134
- item_repair_tissue: string;
135
- item_ship_lock: string;
136
- item_ship_iron: string;
137
- item_ship_clover: string;
138
- item_ship_glass_bottle: string;
139
- item_ship_pure_water: string;
140
- item_ship_sea_salt: string;
141
- item_ship_ebony_poppy: string;
142
- item_ship_rose: string;
143
- item_ship_poppy: string;
144
- item_ship_manganese: string;
145
- item_ship_cursed_hawthorn: string;
146
- item_ship_mugwort: string;
147
- item_ship_mandrake: string;
148
- item_ship_obsidian: string;
149
- item_ship_saffron: string;
150
- item_ship_edelweiss: string;
151
- item_ship_emerald: string;
152
- item_ship_ruby: string;
153
- item_ship_sapphire: string;
154
- item_ship_siren_tear: string;
155
- item_ship_compass: string;
156
- item_ship_dragon_heart: string;
157
- item_ship_fairy_wing: string;
158
- item_ship_phoenix_feather: string;
159
- item_ship_mithril: string;
160
- item_craft_cereal: string;
161
- item_craft_cotton: string;
162
- item_craft_empty_box: string;
163
- item_craft_enchanted_emerald: string;
164
- item_craft_enchanted_ruby: string;
165
- item_craft_enchanted_sapphire: string;
166
- item_craft_enchanted_stone: string;
167
- item_craft_flour: string;
168
- item_craft_hemp: string;
169
- item_craft_scrap: string;
170
- item_craft_strange_gem: string;
171
- item_craft_strange_stone: string;
172
- item_craft_tools: string;
173
- item_craft_wood: string;
174
- item_craft_wine: string;
175
- item_craft_toy: string;
176
- item_craft_rhum: string;
177
- item_craft_milk: string;
178
- item_craft_fruit: string;
179
- item_craft_sugar: string;
180
- item_craft_egg: string;
181
- item_craft_bowl_cereal: string;
182
- item_craft_beer: string;
183
- item_craft_bowl: string;
184
- item_craft_rudder: string;
185
- item_craft_rescue_boat: string;
186
- item_craft_sailing_boat: string;
187
- item_craft_salt_water: string;
188
- item_craft_anchor: string;
189
- item_craft_hammock: string;
190
- item_craft_leather: string;
191
- item_craft_ancient_key: string;
192
- item_craft_iron_ore: string;
193
- item_scroll_agility: string;
194
- item_scroll_chance: string;
195
- item_scroll_intelligence: string;
196
- item_scroll_strength: string;
197
- item_scroll_vitality: string;
198
- item_scroll_wisdom: string;
199
- equipment_adventurer_strap: string;
200
- equipment_adventurer_collar: string;
201
- equipment_adventurer_boots: string;
202
- equipment_adventurer_helmet: string;
203
- equipment_adventurer_weapon: string;
204
- equipment_adventurer_belt: string;
205
- };
206
- //# sourceMappingURL=emojis.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"emojis.d.ts","sourceRoot":"","sources":["../src/emojis.ts"],"names":[],"mappings":"AAAA,eAAO,MAAM,MAAM;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CA4NlB,CAAC"}