@avstantso/std-ext 1.0.2 → 1.2.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/CHANGELOG.md CHANGED
@@ -1,7 +1,29 @@
1
1
  # Changelog
2
2
 
3
+
4
+ ## [1.2.1] - 2026-01-18
5
+
6
+ ### Changed
7
+
8
+ - Fix publishing
9
+
3
10
  All notable changes to this project will be documented in this file.
4
11
 
12
+ ## [1.1.0] - 2026-01-18
13
+
14
+ ### Added
15
+
16
+ - `Object.definePropertyOnce` - adds property only if not exists
17
+ - `Object.definePropertiesOnce` - adds multiple properties only if not exist
18
+ - `RegExp.escape` - escape all RegExp special characters in a string (TC39 proposal polyfill)
19
+ - `Symbol.Has` - factory function to check and cast symbol in object
20
+
21
+ ### Changed
22
+
23
+ - Reorganized extensions to `_std-ext/` directory structure
24
+ - `Array.prototype` and `String.prototype` extensions now use `definePropertiesOnce`
25
+ - `toCapitalized()` and `toUncapitalized()` now preserve string literal types
26
+
5
27
  ## [1.0.2] - 2026-01-15
6
28
 
7
29
  ### Fixed
package/README.md CHANGED
@@ -3,7 +3,7 @@
3
3
  [![npm version](https://img.shields.io/npm/v/@avstantso/std-ext.svg)](https://www.npmjs.com/package/@avstantso/std-ext)
4
4
  [![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](https://opensource.org/licenses/MIT)
5
5
 
6
- Standard JavaScript objects extension with zero dependencies. Adds useful methods to native String and Array prototypes with full TypeScript support.
6
+ Standard JavaScript objects extension with zero dependencies. Adds useful methods to native String, Array, RegExp, Object, and Symbol with full TypeScript support.
7
7
 
8
8
  ## Features
9
9
 
@@ -32,39 +32,173 @@ Simply import the package once in your application entry point to enable all ext
32
32
  ```typescript
33
33
  import '@avstantso/std-ext';
34
34
 
35
- // Now all String and Array methods are available
35
+ // Now all extensions are available
36
36
  const greeting = "hello".toCapitalized(); // "Hello"
37
37
  const items = [1, 0, 2, null, 3, false, 4].pack(); // [1, 2, 3, 4]
38
+ const escaped = RegExp.escape("file[1].txt"); // "file\\[1\\]\\.txt"
38
39
  ```
39
40
 
40
41
  ## API Reference
41
42
 
43
+ ### RegExp Extensions
44
+
45
+ #### `RegExp.escape(str)`
46
+
47
+ Escapes all RegExp special characters in a string, making it safe to use in `new RegExp()`. This is a polyfill for the [TC39 RegExp.escape proposal](https://tc39.es/proposal-regex-escaping/).
48
+
49
+ **Parameters:**
50
+ - `str: string` - The string to escape
51
+
52
+ **Returns:** `string` - New string with escaped RegExp characters
53
+
54
+ **Escaped characters:** `\ ^ $ . * + ? ( ) [ ] { } |`
55
+
56
+ **Example:**
57
+ ```typescript
58
+ RegExp.escape("file[1].txt"); // "file\\[1\\]\\.txt"
59
+ RegExp.escape("price: $10.00"); // "price: \\$10\\.00"
60
+ RegExp.escape("a+b=c?"); // "a\\+b=c\\?"
61
+
62
+ // Safe dynamic RegExp creation
63
+ const userInput = "test.file[1]";
64
+ const regex = new RegExp(RegExp.escape(userInput));
65
+ regex.test("test.file[1]"); // true
66
+ regex.test("testXfile11"); // false
67
+ ```
68
+
69
+ ### Object Extensions
70
+
71
+ #### `Object.definePropertyOnce(o, p, attributes)`
72
+
73
+ Adds a property to an object only if it doesn't already exist. Useful for polyfills and non-intrusive extensions. Especially handy for hot module replacement (HMR) environments like Vite, Webpack, or Parcel where modules may be re-executed multiple times.
74
+
75
+ **Parameters:**
76
+ - `o: T` - Object on which to add the property
77
+ - `p: PropertyKey` - The property name
78
+ - `attributes: PropertyDescriptor` - Descriptor for the property
79
+
80
+ **Returns:** `T` - The object passed in
81
+
82
+ **Example:**
83
+ ```typescript
84
+ const obj = { existing: 1 };
85
+
86
+ Object.definePropertyOnce(obj, 'existing', { value: 999 });
87
+ Object.definePropertyOnce(obj, 'newProp', { value: 2 });
88
+
89
+ console.log(obj.existing); // 1 (unchanged)
90
+ console.log(obj.newProp); // 2 (added)
91
+
92
+ // Useful for polyfills
93
+ Object.definePropertyOnce(String.prototype, 'myMethod', {
94
+ value() { return this.toUpperCase(); }
95
+ });
96
+ ```
97
+
98
+ #### `Object.definePropertiesOnce(o, properties)`
99
+
100
+ Adds multiple properties to an object, skipping any that already exist. Same HMR benefits as `definePropertyOnce`.
101
+
102
+ **Parameters:**
103
+ - `o: T` - Object on which to add the properties
104
+ - `properties: PropertyDescriptorMap` - Object containing property descriptors
105
+
106
+ **Returns:** `T` - The object passed in
107
+
108
+ **Example:**
109
+ ```typescript
110
+ const obj = { a: 1 };
111
+
112
+ Object.definePropertiesOnce(obj, {
113
+ a: { value: 999 }, // skipped - already exists
114
+ b: { value: 2 }, // added
115
+ c: { value: 3 } // added
116
+ });
117
+
118
+ console.log(obj); // { a: 1, b: 2, c: 3 }
119
+ ```
120
+
121
+ ### Symbol Extensions
122
+
123
+ #### `Symbol.Has(symb, resultTemplate?)`
124
+
125
+ Creates a type guard function that checks if an object has a specific symbol property. Returns a reusable checker function with proper TypeScript type narrowing.
126
+
127
+ **Parameters:**
128
+ - `symb: symbol` - The symbol to check for
129
+ - `resultTemplate?: R` - Optional type-only argument to infer the symbol's value type (not used at runtime)
130
+
131
+ **Returns:** `(obj: unknown) => obj is { [K in Symb]: R }` - Type guard function
132
+
133
+ **Example:**
134
+ ```typescript
135
+ const mySymbol = Symbol('mySymbol');
136
+ const hasMySymbol = Symbol.Has(mySymbol);
137
+
138
+ const obj1 = { [mySymbol]: 'value' };
139
+ const obj2 = { foo: 'bar' };
140
+
141
+ hasMySymbol(obj1); // true
142
+ hasMySymbol(obj2); // false
143
+ hasMySymbol(null); // false (safe with nullish values)
144
+
145
+ // Works great with well-known symbols
146
+ const hasIterator = Symbol.Has(Symbol.iterator);
147
+
148
+ hasIterator([]); // true
149
+ hasIterator('string'); // true
150
+ hasIterator(new Map()); // true
151
+ hasIterator({}); // false
152
+
153
+ // Type narrowing in conditionals
154
+ const data: unknown = getExternalData();
155
+ if (hasIterator(data)) {
156
+ for (const item of data) { ... } // TypeScript knows data is iterable
157
+ }
158
+
159
+ // With typed value using resultTemplate
160
+ const symbolFreeze = Symbol('freeze');
161
+ const hasFreeze = Symbol.Has(symbolFreeze, () => {});
162
+
163
+ if (hasFreeze(obj)) {
164
+ obj[symbolFreeze](); // TypeScript knows it's () => void
165
+ }
166
+ ```
167
+
42
168
  ### String Extensions
43
169
 
44
170
  #### `toCapitalized()`
45
171
 
46
172
  Capitalizes the first character of the string.
47
173
 
48
- **Returns:** `Capitalize<string>`
174
+ **Returns:** `Capitalize<S>` where `S` is the string literal type
49
175
 
50
176
  **Example:**
51
177
  ```typescript
52
178
  "hello".toCapitalized(); // "Hello"
53
179
  "world".toCapitalized(); // "World"
54
180
  "".toCapitalized(); // ""
181
+
182
+ // Preserves literal types
183
+ const a = 'foo' as const;
184
+ const b = a.toCapitalized(); // type is 'Foo', not string
55
185
  ```
56
186
 
57
187
  #### `toUncapitalized()`
58
188
 
59
189
  Uncapitalizes the first character of the string.
60
190
 
61
- **Returns:** `Uncapitalize<string>`
191
+ **Returns:** `Uncapitalize<S>` where `S` is the string literal type
62
192
 
63
193
  **Example:**
64
194
  ```typescript
65
195
  "Hello".toUncapitalized(); // "hello"
66
196
  "World".toUncapitalized(); // "world"
67
197
  "".toUncapitalized(); // ""
198
+
199
+ // Preserves literal types
200
+ const a = 'FOO' as const;
201
+ const b = a.toUncapitalized(); // type is 'fOO', not string
68
202
  ```
69
203
 
70
204
  ### Array Extensions
@@ -82,6 +216,39 @@ Filters out all falsy values from the array (false, 0, "", null, undefined, NaN)
82
216
  [1, 0, 2, null, 3, false, 4].pack(); // [1, 2, 3, 4]
83
217
  ["a", "", "b", null, "c"].pack(); // ["a", "b", "c"]
84
218
  [true, false, true, undefined].pack(); // [true, true]
219
+
220
+ // Real world example: React conditional CSS classes
221
+ function Button({ isActive, isDisabled, isLoading }) {
222
+ return (
223
+ <button
224
+ className={[
225
+ 'btn',
226
+ isActive && 'btn--active',
227
+ isDisabled && 'btn--disabled',
228
+ isLoading && 'btn--loading'
229
+ ].pack().join(' ')}
230
+ >
231
+ Click me
232
+ </button>
233
+ );
234
+ }
235
+
236
+ // Compare to the alternative without pack():
237
+ function Button({ isActive, isDisabled, isLoading }) {
238
+ return (
239
+ <button
240
+ className={`btn${
241
+ isActive ? ' btn--active' : ''
242
+ }${
243
+ isDisabled ? ' btn--disabled' : ''
244
+ }${
245
+ isLoading ? ' btn--loading' : ''
246
+ }`}
247
+ >
248
+ Click me
249
+ </button>
250
+ );
251
+ }
85
252
  ```
86
253
 
87
254
  #### `peek()`
@@ -0,0 +1,5 @@
1
+ import './object';
2
+ import './symbol';
3
+ import './array';
4
+ import './string';
5
+ import './reg-exp';
@@ -0,0 +1,17 @@
1
+ interface ObjectConstructor {
2
+ /**
3
+ * Adds a property to an object (if it's not exists).
4
+ * @param o Object on which to add the property.\
5
+ * This can be a native JavaScript object (that is, a user-defined object or a built in object) or a DOM object.
6
+ * @param p The property name.
7
+ * @param attributes Descriptor for the property. It can be for a data property or an accessor property.
8
+ */
9
+ definePropertyOnce: ObjectConstructor['defineProperty'];
10
+ /**
11
+ * Adds one or more properties to an object (if it's not exists).
12
+ * @param o Object on which to add or modify the properties. This can be a native JavaScript object or a DOM object.
13
+ * @param properties JavaScript object that contains one or more descriptor objects.\
14
+ * Each descriptor object describes a data property or an accessor property.
15
+ */
16
+ definePropertiesOnce: ObjectConstructor['defineProperties'];
17
+ }
@@ -0,0 +1,9 @@
1
+ interface RegExpConstructor {
2
+ /**
3
+ * @summary Escape all `RegExp` special characters in a string
4
+ * @returns New string with escaped `RegExp` characters
5
+ * @see https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/RegExp/escape
6
+ * @see https://tc39.es/proposal-regex-escaping/
7
+ */
8
+ escape(str: string): string;
9
+ }
@@ -0,0 +1,4 @@
1
+ declare interface String {
2
+ toCapitalized<S extends string = string>(this: S): Capitalize<S>;
3
+ toUncapitalized<S extends string = string>(this: S): Uncapitalize<S>;
4
+ }
@@ -0,0 +1,14 @@
1
+ interface SymbolConstructor {
2
+ /**
3
+ * @summary Has `symbol` factory function
4
+ * @template Symb Symbol type for checks
5
+ * @template R Symbol field type
6
+ * @param resultTemplate Type-only argument to infer `R` template (not used at runtime)
7
+ * @return Function for check and cast symbol in object
8
+ */
9
+ Has<Symb extends symbol, R = unknown>(symb: Symb, resultTemplate?: R): {
10
+ (obj: unknown): obj is {
11
+ [K in Symb]: R;
12
+ };
13
+ };
14
+ }
package/dist/index.d.ts CHANGED
@@ -1,2 +1 @@
1
- import './array';
2
- import './string';
1
+ import './_std-ext';
package/dist/index.js CHANGED
@@ -1,6 +1,38 @@
1
1
  'use strict';
2
2
 
3
- Object.defineProperties(Array.prototype, {
3
+ if (!Object.definePropertyOnce)
4
+ Object.defineProperty(Object, 'definePropertyOnce', {
5
+ value(o, p, attributes) {
6
+ if (!(p in o))
7
+ Object.defineProperty(o, p, attributes);
8
+ return o;
9
+ },
10
+ writable: false,
11
+ configurable: true
12
+ });
13
+ if (!Object.definePropertiesOnce)
14
+ Object.defineProperty(Object, 'definePropertiesOnce', {
15
+ value(o, properties) {
16
+ for (const p in properties)
17
+ if (!(p in o))
18
+ Object.defineProperty(o, p, properties[p]);
19
+ return o;
20
+ },
21
+ writable: false,
22
+ configurable: true
23
+ });
24
+
25
+ Object.definePropertiesOnce(Symbol, {
26
+ Has: {
27
+ value(symb) {
28
+ return (obj) => obj != null && symb in Object(obj);
29
+ },
30
+ writable: false,
31
+ configurable: true
32
+ }
33
+ });
34
+
35
+ Object.definePropertiesOnce(Array.prototype, {
4
36
  pack: {
5
37
  value() {
6
38
  return this && this.filter((item) => item);
@@ -13,14 +45,26 @@ Object.defineProperties(Array.prototype, {
13
45
  }
14
46
  });
15
47
 
16
- Object.defineProperty(String.prototype, 'toCapitalized', {
17
- value() {
18
- return this && this.charAt(0).toLocaleUpperCase() + this.slice(1);
48
+ Object.definePropertiesOnce(String.prototype, {
49
+ toCapitalized: {
50
+ value() {
51
+ return this && this.charAt(0).toLocaleUpperCase() + this.slice(1);
52
+ }
53
+ },
54
+ toUncapitalized: {
55
+ value() {
56
+ return this && this.charAt(0).toLocaleLowerCase() + this.slice(1);
57
+ }
19
58
  }
20
59
  });
21
- Object.defineProperty(String.prototype, 'toUncapitalized', {
22
- value() {
23
- return this && this.charAt(0).toLocaleLowerCase() + this.slice(1);
60
+
61
+ Object.definePropertiesOnce(RegExp, {
62
+ escape: {
63
+ value(str) {
64
+ return str.replace(/[\\^$.*+?()[\]{}|]/g, '\\$&');
65
+ },
66
+ writable: false,
67
+ configurable: true
24
68
  }
25
69
  });
26
70
  //# sourceMappingURL=index.js.map
package/dist/index.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sources":["../src/array.ts","../src/string.ts"],"sourcesContent":["namespace AVStantso.Array {\n /**\n * @summary Select `Array<T>` or `ReadonlyArray<T>` by `[W]ritable`\n */\n export type RW<W extends boolean, T = unknown> = W extends true\n ? Array<T>\n : ReadonlyArray<T>;\n\n /**\n * @summary Key of `AVStantso.Array.RW<W>`\n */\n export type Key<W extends boolean> = keyof {\n [K in keyof RW<W> as `${Extract<K, string>}`]: 0;\n };\n\n export namespace Key {\n /**\n * @summary Immutable array key\n */\n export type R = Key<false>;\n\n /**\n * @summary Mutable array key\n */\n export type RW = Key<true>;\n\n /**\n * @summary Mutation key only\n */\n export type W = Exclude<RW, R>;\n }\n\n // eslint-disable-next-line @typescript-eslint/no-unused-vars\n export interface Ex<W extends boolean, T> {\n /**\n * @summary Filter all not `falsy` items\n * @returns New array with all not `falsy` items\n */\n pack(): Array<T>;\n\n /**\n * @summary Get last item. Array not changes\n * @returns Last item or `undefined`, if array empty. Array not changes\n */\n peek(): T;\n }\n}\n\n// eslint-disable-next-line @typescript-eslint/no-empty-object-type\ndeclare interface ReadonlyArray<T> extends AVStantso.Array.Ex<false, T> { }\n// eslint-disable-next-line @typescript-eslint/no-empty-object-type\ndeclare interface Array<T> extends AVStantso.Array.Ex<true, T> { }\n\nObject.defineProperties(Array.prototype, {\n pack: {\n value() {\n return this && this.filter((item: unknown) => item);\n }\n },\n peek: {\n value() {\n return this && this.at(-1);\n }\n }\n});\n","// eslint-disable-next-line @typescript-eslint/no-unused-vars\ndeclare interface String {\n toCapitalized(): Capitalize<string>;\n toUncapitalized(): Uncapitalize<string>;\n}\n\nObject.defineProperty(String.prototype, 'toCapitalized', {\n value() {\n return this && this.charAt(0).toLocaleUpperCase() + this.slice(1);\n }\n});\n\nObject.defineProperty(String.prototype, 'toUncapitalized', {\n value() {\n return this && this.charAt(0).toLocaleLowerCase() + this.slice(1);\n }\n});\n"],"names":[],"mappings":";;AAqDA,MAAM,CAAC,gBAAgB,CAAC,KAAK,CAAC,SAAS,EAAE;AACvC,IAAA,IAAI,EAAE;QACJ,KAAK,GAAA;AACH,YAAA,OAAO,IAAI,IAAI,IAAI,CAAC,MAAM,CAAC,CAAC,IAAa,KAAK,IAAI,CAAC;QACrD;AACD,KAAA;AACD,IAAA,IAAI,EAAE;QACJ,KAAK,GAAA;YACH,OAAO,IAAI,IAAI,IAAI,CAAC,EAAE,CAAC,EAAE,CAAC;QAC5B;AACD;AACF,CAAA,CAAC;;AC1DF,MAAM,CAAC,cAAc,CAAC,MAAM,CAAC,SAAS,EAAE,eAAe,EAAE;IACvD,KAAK,GAAA;AACH,QAAA,OAAO,IAAI,IAAI,IAAI,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC,iBAAiB,EAAE,GAAG,IAAI,CAAC,KAAK,CAAC,CAAC,CAAC;IACnE;AACD,CAAA,CAAC;AAEF,MAAM,CAAC,cAAc,CAAC,MAAM,CAAC,SAAS,EAAE,iBAAiB,EAAE;IACzD,KAAK,GAAA;AACH,QAAA,OAAO,IAAI,IAAI,IAAI,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC,iBAAiB,EAAE,GAAG,IAAI,CAAC,KAAK,CAAC,CAAC,CAAC;IACnE;AACD,CAAA,CAAC;;"}
1
+ {"version":3,"file":"index.js","sources":["../src/_std-ext/object.ts","../src/_std-ext/symbol.ts","../src/_std-ext/array.ts","../src/_std-ext/string.ts","../src/_std-ext/reg-exp.ts"],"sourcesContent":["// eslint-disable-next-line @typescript-eslint/no-unused-vars\ninterface ObjectConstructor {\n /**\n * Adds a property to an object (if it's not exists).\n * @param o Object on which to add the property.\\\n * This can be a native JavaScript object (that is, a user-defined object or a built in object) or a DOM object.\n * @param p The property name.\n * @param attributes Descriptor for the property. It can be for a data property or an accessor property.\n */\n definePropertyOnce: ObjectConstructor['defineProperty'];\n\n /**\n * Adds one or more properties to an object (if it's not exists).\n * @param o Object on which to add or modify the properties. This can be a native JavaScript object or a DOM object.\n * @param properties JavaScript object that contains one or more descriptor objects.\\\n * Each descriptor object describes a data property or an accessor property.\n */\n definePropertiesOnce: ObjectConstructor['defineProperties'];\n}\n\nif (!Object.definePropertyOnce)\n Object.defineProperty(Object, 'definePropertyOnce', {\n value<T>(o: T, p: PropertyKey, attributes: PropertyDescriptor): T {\n if (!(p in (o as object))) Object.defineProperty(o, p, attributes);\n return o;\n },\n writable: false,\n configurable: true\n });\n\nif (!Object.definePropertiesOnce)\n Object.defineProperty(Object, 'definePropertiesOnce', {\n value<T>(o: T, properties: PropertyDescriptorMap): T {\n for (const p in properties)\n if (!(p in (o as object))) Object.defineProperty(o, p, properties[p]);\n return o;\n },\n writable: false,\n configurable: true\n });\n","// eslint-disable-next-line @typescript-eslint/no-unused-vars\ninterface SymbolConstructor {\n /**\n * @summary Has `symbol` factory function\n * @template Symb Symbol type for checks\n * @template R Symbol field type\n * @param resultTemplate Type-only argument to infer `R` template (not used at runtime)\n * @return Function for check and cast symbol in object\n */\n Has<\n Symb extends symbol,\n R = unknown\n >(symb: Symb, resultTemplate?: R): {\n (obj: unknown): obj is { [K in Symb]: R };\n }\n}\n\nObject.definePropertiesOnce(Symbol, {\n Has: {\n value(symb: symbol) {\n return (obj: unknown) => obj != null && symb in Object(obj);\n },\n writable: false,\n configurable: true\n }\n});\n","namespace AVStantso.Array {\n /**\n * @summary Select `Array<T>` or `ReadonlyArray<T>` by `[W]ritable`\n */\n export type RW<W extends boolean, T = unknown> = W extends true\n ? Array<T>\n : ReadonlyArray<T>;\n\n /**\n * @summary Key of `AVStantso.Array.RW<W>`\n */\n export type Key<W extends boolean> = keyof {\n [K in keyof RW<W> as `${Extract<K, string>}`]: 0;\n };\n\n export namespace Key {\n /**\n * @summary Immutable array key\n */\n export type R = Key<false>;\n\n /**\n * @summary Mutable array key\n */\n export type RW = Key<true>;\n\n /**\n * @summary Mutation key only\n */\n export type W = Exclude<RW, R>;\n }\n\n // eslint-disable-next-line @typescript-eslint/no-unused-vars\n export interface Ex<W extends boolean, T> {\n /**\n * @summary Filter all not `falsy` items\n * @returns New array with all not `falsy` items\n */\n pack(): Array<T>;\n\n /**\n * @summary Get last item. Array not changes\n * @returns Last item or `undefined`, if array empty. Array not changes\n */\n peek(): T;\n }\n}\n\n// eslint-disable-next-line @typescript-eslint/no-empty-object-type\ndeclare interface ReadonlyArray<T> extends AVStantso.Array.Ex<false, T> { }\n// eslint-disable-next-line @typescript-eslint/no-empty-object-type\ndeclare interface Array<T> extends AVStantso.Array.Ex<true, T> { }\n\nObject.definePropertiesOnce(Array.prototype, {\n pack: {\n value() {\n return this && this.filter((item: unknown) => item);\n }\n },\n peek: {\n value() {\n return this && this.at(-1);\n }\n }\n});\n","// eslint-disable-next-line @typescript-eslint/no-unused-vars\ndeclare interface String {\n toCapitalized<S extends string = string>(this: S): Capitalize<S>;\n toUncapitalized<S extends string = string>(this: S): Uncapitalize<S>;\n}\n\nObject.definePropertiesOnce(String.prototype, {\n toCapitalized: {\n value() {\n return this && this.charAt(0).toLocaleUpperCase() + this.slice(1);\n }\n },\n toUncapitalized: {\n value() {\n return this && this.charAt(0).toLocaleLowerCase() + this.slice(1);\n }\n }\n});\n","// eslint-disable-next-line @typescript-eslint/no-unused-vars\ninterface RegExpConstructor {\n /**\n * @summary Escape all `RegExp` special characters in a string\n * @returns New string with escaped `RegExp` characters\n * @see https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/RegExp/escape\n * @see https://tc39.es/proposal-regex-escaping/\n */\n escape(str: string): string;\n}\n\nObject.definePropertiesOnce(RegExp, {\n escape: {\n value(str: string) {\n return str.replace(/[\\\\^$.*+?()[\\]{}|]/g, '\\\\$&');\n },\n writable: false,\n configurable: true\n }\n});\n"],"names":[],"mappings":";;AAoBA,IAAI,CAAC,MAAM,CAAC,kBAAkB;AAC5B,IAAA,MAAM,CAAC,cAAc,CAAC,MAAM,EAAE,oBAAoB,EAAE;AAClD,QAAA,KAAK,CAAI,CAAI,EAAE,CAAc,EAAE,UAA8B,EAAA;AAC3D,YAAA,IAAI,EAAE,CAAC,IAAK,CAAY,CAAC;gBAAE,MAAM,CAAC,cAAc,CAAC,CAAC,EAAE,CAAC,EAAE,UAAU,CAAC;AAClE,YAAA,OAAO,CAAC;QACV,CAAC;AACD,QAAA,QAAQ,EAAE,KAAK;AACf,QAAA,YAAY,EAAE;AACf,KAAA,CAAC;AAEJ,IAAI,CAAC,MAAM,CAAC,oBAAoB;AAC9B,IAAA,MAAM,CAAC,cAAc,CAAC,MAAM,EAAE,sBAAsB,EAAE;QACpD,KAAK,CAAI,CAAI,EAAE,UAAiC,EAAA;YAC9C,KAAK,MAAM,CAAC,IAAI,UAAU;AACxB,gBAAA,IAAI,EAAE,CAAC,IAAK,CAAY,CAAC;AAAE,oBAAA,MAAM,CAAC,cAAc,CAAC,CAAC,EAAE,CAAC,EAAE,UAAU,CAAC,CAAC,CAAC,CAAC;AACvE,YAAA,OAAO,CAAC;QACV,CAAC;AACD,QAAA,QAAQ,EAAE,KAAK;AACf,QAAA,YAAY,EAAE;AACf,KAAA,CAAC;;ACtBJ,MAAM,CAAC,oBAAoB,CAAC,MAAM,EAAE;AAClC,IAAA,GAAG,EAAE;AACH,QAAA,KAAK,CAAC,IAAY,EAAA;AAChB,YAAA,OAAO,CAAC,GAAY,KAAK,GAAG,IAAI,IAAI,IAAI,IAAI,IAAI,MAAM,CAAC,GAAG,CAAC;QAC7D,CAAC;AACD,QAAA,QAAQ,EAAE,KAAK;AACf,QAAA,YAAY,EAAE;AACf;AACF,CAAA,CAAC;;AC4BF,MAAM,CAAC,oBAAoB,CAAC,KAAK,CAAC,SAAS,EAAE;AAC3C,IAAA,IAAI,EAAE;QACJ,KAAK,GAAA;AACH,YAAA,OAAO,IAAI,IAAI,IAAI,CAAC,MAAM,CAAC,CAAC,IAAa,KAAK,IAAI,CAAC;QACrD;AACD,KAAA;AACD,IAAA,IAAI,EAAE;QACJ,KAAK,GAAA;YACH,OAAO,IAAI,IAAI,IAAI,CAAC,EAAE,CAAC,EAAE,CAAC;QAC5B;AACD;AACF,CAAA,CAAC;;AC1DF,MAAM,CAAC,oBAAoB,CAAC,MAAM,CAAC,SAAS,EAAE;AAC5C,IAAA,aAAa,EAAE;QACb,KAAK,GAAA;AACH,YAAA,OAAO,IAAI,IAAI,IAAI,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC,iBAAiB,EAAE,GAAG,IAAI,CAAC,KAAK,CAAC,CAAC,CAAC;QACnE;AACD,KAAA;AACD,IAAA,eAAe,EAAE;QACf,KAAK,GAAA;AACH,YAAA,OAAO,IAAI,IAAI,IAAI,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC,iBAAiB,EAAE,GAAG,IAAI,CAAC,KAAK,CAAC,CAAC,CAAC;QACnE;AACD;AACF,CAAA,CAAC;;ACNF,MAAM,CAAC,oBAAoB,CAAC,MAAM,EAAE;AAClC,IAAA,MAAM,EAAE;AACN,QAAA,KAAK,CAAC,GAAW,EAAA;YACf,OAAO,GAAG,CAAC,OAAO,CAAC,qBAAqB,EAAE,MAAM,CAAC;QACnD,CAAC;AACD,QAAA,QAAQ,EAAE,KAAK;AACf,QAAA,YAAY,EAAE;AACf;AACF,CAAA,CAAC;;"}
package/package.json CHANGED
@@ -2,7 +2,7 @@
2
2
  "name": "@avstantso/std-ext",
3
3
  "license": "MIT",
4
4
  "author": "avstantso",
5
- "version": "1.0.2",
5
+ "version": "1.2.1",
6
6
  "description": "Standard JS objects extension. Zero-dependencies",
7
7
  "keywords": [
8
8
  "String",
package/dist/string.d.ts DELETED
@@ -1,4 +0,0 @@
1
- declare interface String {
2
- toCapitalized(): Capitalize<string>;
3
- toUncapitalized(): Uncapitalize<string>;
4
- }
File without changes