@avstantso/std-ext 1.1.0 → 1.2.2

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,5 +1,19 @@
1
1
  # Changelog
2
2
 
3
+
4
+ ## [1.2.2] - 2026-02-04
5
+
6
+ ### Changed
7
+
8
+ - Removed `dev-basic` workspace dependency (dev deps now resolved via `.yarnrc.yml` packageExtensions)
9
+
10
+
11
+ ## [1.2.1] - 2026-01-18
12
+
13
+ ### Changed
14
+
15
+ - Fix publishing
16
+
3
17
  All notable changes to this project will be documented in this file.
4
18
 
5
19
  ## [1.1.0] - 2026-01-18
@@ -0,0 +1,42 @@
1
+ declare namespace AVStantso.Array {
2
+ /**
3
+ * @summary Select `Array<T>` or `ReadonlyArray<T>` by `[W]ritable`
4
+ */
5
+ type RW<W extends boolean, T = unknown> = W extends true ? Array<T> : ReadonlyArray<T>;
6
+ /**
7
+ * @summary Key of `AVStantso.Array.RW<W>`
8
+ */
9
+ type Key<W extends boolean> = keyof {
10
+ [K in keyof RW<W> as `${Extract<K, string>}`]: 0;
11
+ };
12
+ namespace Key {
13
+ /**
14
+ * @summary Immutable array key
15
+ */
16
+ type R = Key<false>;
17
+ /**
18
+ * @summary Mutable array key
19
+ */
20
+ type RW = Key<true>;
21
+ /**
22
+ * @summary Mutation key only
23
+ */
24
+ type W = Exclude<RW, R>;
25
+ }
26
+ interface Ex<W extends boolean, T> {
27
+ /**
28
+ * @summary Filter all not `falsy` items
29
+ * @returns New array with all not `falsy` items
30
+ */
31
+ pack(): Array<T>;
32
+ /**
33
+ * @summary Get last item. Array not changes
34
+ * @returns Last item or `undefined`, if array empty. Array not changes
35
+ */
36
+ peek(): T;
37
+ }
38
+ }
39
+ declare interface ReadonlyArray<T> extends AVStantso.Array.Ex<false, T> {
40
+ }
41
+ declare interface Array<T> extends AVStantso.Array.Ex<true, T> {
42
+ }
@@ -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
+ }
@@ -0,0 +1 @@
1
+ import './_std-ext';
package/dist/index.js ADDED
@@ -0,0 +1,70 @@
1
+ 'use strict';
2
+
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, {
36
+ pack: {
37
+ value() {
38
+ return this && this.filter((item) => item);
39
+ }
40
+ },
41
+ peek: {
42
+ value() {
43
+ return this && this.at(-1);
44
+ }
45
+ }
46
+ });
47
+
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
+ }
58
+ }
59
+ });
60
+
61
+ Object.definePropertiesOnce(RegExp, {
62
+ escape: {
63
+ value(str) {
64
+ return str.replace(/[\\^$.*+?()[\]{}|]/g, '\\$&');
65
+ },
66
+ writable: false,
67
+ configurable: true
68
+ }
69
+ });
70
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
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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C,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.1.0",
5
+ "version": "1.2.2",
6
6
  "description": "Standard JS objects extension. Zero-dependencies",
7
7
  "keywords": [
8
8
  "String",
@@ -24,8 +24,5 @@
24
24
  "build:tsc": "tsc -p tsconfig-build.json",
25
25
  "build": "node ../rollup",
26
26
  "test": "NODE_ENV=test jest --coverage"
27
- },
28
- "devDependencies": {
29
- "@avstantso/dev-basic": "1.0.0"
30
27
  }
31
28
  }