@webdeveric/utils 0.77.0 → 0.79.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,12 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.countCharCode = countCharCode;
4
+ function countCharCode(input, charCode) {
5
+ let count = 0;
6
+ for (let index = 0, length = input.length; index < length; ++index) {
7
+ if (input.charCodeAt(index) === charCode) {
8
+ ++count;
9
+ }
10
+ }
11
+ return count;
12
+ }
@@ -0,0 +1,10 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.countCharacter = countCharacter;
4
+ const countCharCode_js_1 = require("./countCharCode.js");
5
+ function countCharacter(input, char) {
6
+ if (char.length !== 1) {
7
+ throw new Error('Expected a single character');
8
+ }
9
+ return (0, countCharCode_js_1.countCharCode)(input, char.charCodeAt(0));
10
+ }
@@ -0,0 +1,17 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.getSortedObject = getSortedObject;
4
+ const isAnyObject_js_1 = require("./predicate/isAnyObject.js");
5
+ const defaultCompareFunction = (left, right) => typeof left === 'symbol' || typeof right === 'symbol' ? 0 : left.localeCompare(right);
6
+ function getSortedObject(data, compareFunction = defaultCompareFunction) {
7
+ if (Array.isArray(data)) {
8
+ return data.map((item) => getSortedObject(item, compareFunction));
9
+ }
10
+ const entries = Reflect.ownKeys(data)
11
+ .sort(compareFunction)
12
+ .map((key) => {
13
+ const value = data[key];
14
+ return [key, (0, isAnyObject_js_1.isAnyObject)(value) ? getSortedObject(value, compareFunction) : value];
15
+ });
16
+ return Object.fromEntries(entries);
17
+ }
package/dist/cjs/index.js CHANGED
@@ -28,6 +28,8 @@ __exportStar(require("./combinations.js"), exports);
28
28
  __exportStar(require("./comment.js"), exports);
29
29
  __exportStar(require("./compose.js"), exports);
30
30
  __exportStar(require("./convert.js"), exports);
31
+ __exportStar(require("./countCharacter.js"), exports);
32
+ __exportStar(require("./countCharCode.js"), exports);
31
33
  __exportStar(require("./counter.js"), exports);
32
34
  __exportStar(require("./deepDecodeURI.js"), exports);
33
35
  __exportStar(require("./deepFreeze.js"), exports);
@@ -48,6 +50,7 @@ __exportStar(require("./getOwnProperties.js"), exports);
48
50
  __exportStar(require("./getPackageName.js"), exports);
49
51
  __exportStar(require("./getPaths.js"), exports);
50
52
  __exportStar(require("./getRandomItem.js"), exports);
53
+ __exportStar(require("./getSortedObject.js"), exports);
51
54
  __exportStar(require("./getType.js"), exports);
52
55
  __exportStar(require("./has.js"), exports);
53
56
  __exportStar(require("./hasAdditionalProperties.js"), exports);
@@ -57,6 +60,7 @@ __exportStar(require("./iterateForever.js"), exports);
57
60
  __exportStar(require("./joinStrings.js"), exports);
58
61
  __exportStar(require("./jsonParse.js"), exports);
59
62
  __exportStar(require("./looksLikeURL.js"), exports);
63
+ __exportStar(require("./memo.js"), exports);
60
64
  __exportStar(require("./normalize.js"), exports);
61
65
  __exportStar(require("./numbers.js"), exports);
62
66
  __exportStar(require("./parseNumber.js"), exports);
@@ -29,6 +29,7 @@ __exportStar(require("./nullish.js"), exports);
29
29
  __exportStar(require("./optional.js"), exports);
30
30
  __exportStar(require("./range.js"), exports);
31
31
  __exportStar(require("./shape.js"), exports);
32
+ __exportStar(require("./simple.js"), exports);
32
33
  __exportStar(require("./stringLength.js"), exports);
33
34
  __exportStar(require("./tuple.js"), exports);
34
35
  __exportStar(require("./typeOf.js"), exports);
@@ -2,4 +2,4 @@
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.isAny = void 0;
4
4
  const assume_js_1 = require("./assume.js");
5
- exports.isAny = (assume_js_1.assume);
5
+ exports.isAny = assume_js_1.assume;
@@ -2,4 +2,4 @@
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.isUnknown = void 0;
4
4
  const assume_js_1 = require("./assume.js");
5
- exports.isUnknown = (assume_js_1.assume);
5
+ exports.isUnknown = assume_js_1.assume;
@@ -0,0 +1,9 @@
1
+ export function countCharCode(input, charCode) {
2
+ let count = 0;
3
+ for (let index = 0, length = input.length; index < length; ++index) {
4
+ if (input.charCodeAt(index) === charCode) {
5
+ ++count;
6
+ }
7
+ }
8
+ return count;
9
+ }
@@ -0,0 +1,7 @@
1
+ import { countCharCode } from './countCharCode.js';
2
+ export function countCharacter(input, char) {
3
+ if (char.length !== 1) {
4
+ throw new Error('Expected a single character');
5
+ }
6
+ return countCharCode(input, char.charCodeAt(0));
7
+ }
@@ -0,0 +1,14 @@
1
+ import { isAnyObject } from './predicate/isAnyObject.js';
2
+ const defaultCompareFunction = (left, right) => typeof left === 'symbol' || typeof right === 'symbol' ? 0 : left.localeCompare(right);
3
+ export function getSortedObject(data, compareFunction = defaultCompareFunction) {
4
+ if (Array.isArray(data)) {
5
+ return data.map((item) => getSortedObject(item, compareFunction));
6
+ }
7
+ const entries = Reflect.ownKeys(data)
8
+ .sort(compareFunction)
9
+ .map((key) => {
10
+ const value = data[key];
11
+ return [key, isAnyObject(value) ? getSortedObject(value, compareFunction) : value];
12
+ });
13
+ return Object.fromEntries(entries);
14
+ }
package/dist/mjs/index.js CHANGED
@@ -12,6 +12,8 @@ export * from './combinations.js';
12
12
  export * from './comment.js';
13
13
  export * from './compose.js';
14
14
  export * from './convert.js';
15
+ export * from './countCharacter.js';
16
+ export * from './countCharCode.js';
15
17
  export * from './counter.js';
16
18
  export * from './deepDecodeURI.js';
17
19
  export * from './deepFreeze.js';
@@ -32,6 +34,7 @@ export * from './getOwnProperties.js';
32
34
  export * from './getPackageName.js';
33
35
  export * from './getPaths.js';
34
36
  export * from './getRandomItem.js';
37
+ export * from './getSortedObject.js';
35
38
  export * from './getType.js';
36
39
  export * from './has.js';
37
40
  export * from './hasAdditionalProperties.js';
@@ -41,6 +44,7 @@ export * from './iterateForever.js';
41
44
  export * from './joinStrings.js';
42
45
  export * from './jsonParse.js';
43
46
  export * from './looksLikeURL.js';
47
+ export * from './memo.js';
44
48
  export * from './normalize.js';
45
49
  export * from './numbers.js';
46
50
  export * from './parseNumber.js';
@@ -13,6 +13,7 @@ export * from './nullish.js';
13
13
  export * from './optional.js';
14
14
  export * from './range.js';
15
15
  export * from './shape.js';
16
+ export * from './simple.js';
16
17
  export * from './stringLength.js';
17
18
  export * from './tuple.js';
18
19
  export * from './typeOf.js';
@@ -1,2 +1,2 @@
1
1
  import { assume } from './assume.js';
2
- export const isAny = (assume);
2
+ export const isAny = assume;
@@ -1,2 +1,2 @@
1
1
  import { assume } from './assume.js';
2
- export const isUnknown = (assume);
2
+ export const isUnknown = assume;
@@ -0,0 +1 @@
1
+ export declare function countCharCode(input: string, charCode: number): number;
@@ -0,0 +1 @@
1
+ export declare function countCharacter(input: string, char: string): number;
@@ -0,0 +1,3 @@
1
+ import type { CompareFn } from './types/functions.js';
2
+ export declare function getSortedObject<Data extends object>(data: Data, compareFunction?: CompareFn<string | symbol>): Data;
3
+ export declare function getSortedObject<Data extends object>(data: Data[], compareFunction?: CompareFn<string | symbol>): Data[];
@@ -12,6 +12,8 @@ export * from './combinations.js';
12
12
  export * from './comment.js';
13
13
  export * from './compose.js';
14
14
  export * from './convert.js';
15
+ export * from './countCharacter.js';
16
+ export * from './countCharCode.js';
15
17
  export * from './counter.js';
16
18
  export * from './deepDecodeURI.js';
17
19
  export * from './deepFreeze.js';
@@ -32,6 +34,7 @@ export * from './getOwnProperties.js';
32
34
  export * from './getPackageName.js';
33
35
  export * from './getPaths.js';
34
36
  export * from './getRandomItem.js';
37
+ export * from './getSortedObject.js';
35
38
  export * from './getType.js';
36
39
  export * from './has.js';
37
40
  export * from './hasAdditionalProperties.js';
@@ -41,6 +44,7 @@ export * from './iterateForever.js';
41
44
  export * from './joinStrings.js';
42
45
  export * from './jsonParse.js';
43
46
  export * from './looksLikeURL.js';
47
+ export * from './memo.js';
44
48
  export * from './normalize.js';
45
49
  export * from './numbers.js';
46
50
  export * from './parseNumber.js';
@@ -13,6 +13,7 @@ export * from './nullish.js';
13
13
  export * from './optional.js';
14
14
  export * from './range.js';
15
15
  export * from './shape.js';
16
+ export * from './simple.js';
16
17
  export * from './stringLength.js';
17
18
  export * from './tuple.js';
18
19
  export * from './typeOf.js';
@@ -1,5 +1,5 @@
1
1
  export declare const isTimeoutError: import("../index.js").TypePredicateFn<{
2
- stack?: string | undefined;
2
+ stack?: string;
3
3
  readonly code: number;
4
4
  readonly message: string;
5
5
  name: "TimeoutError";
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@webdeveric/utils",
3
3
  "description": "Just another collection of utilities.",
4
- "version": "0.77.0",
4
+ "version": "0.79.0",
5
5
  "publishConfig": {
6
6
  "access": "public"
7
7
  },
@@ -66,13 +66,13 @@
66
66
  "url": "https://github.com/webdeveric/utils/issues"
67
67
  },
68
68
  "homepage": "https://github.com/webdeveric/utils/#readme",
69
- "packageManager": "pnpm@10.33.0+sha512.10568bb4a6afb58c9eb3630da90cc9516417abebd3fabbe6739f0ae795728da1491e9db5a544c76ad8eb7570f5c4bb3d6c637b2cb41bfdcdb47fa823c8649319",
69
+ "packageManager": "pnpm@10.33.2+sha512.a90faf6feeab71ad6c6e57f94e0fe1a12f5dcc22cd754db40ae9593eb6a3e0b6b12e3540218bb37ae083404b1f2ce6db2a4121e979829b4aff94b99f49da1cf8",
70
70
  "scripts": {
71
71
  "clean": "rimraf ./dist/",
72
72
  "prebuild": "pnpm clean",
73
- "build": "tsc --build tsconfig.cjs.json tsconfig.mjs.json --force",
73
+ "build": "tsgo --build tsconfig.cjs.json tsconfig.mjs.json --force",
74
74
  "postbuild": "echo '{\"type\":\"commonjs\"}' > ./dist/cjs/package.json && echo '{\"type\":\"module\"}' > ./dist/mjs/package.json && pnpm validate",
75
- "typecheck": "tsc --build --verbose --noEmit",
75
+ "typecheck": "tsgo --build --verbose --noEmit",
76
76
  "lint": "eslint ./*.{js,cjs,mjs,ts,cts,mts} ./src/ ./bench/ ./test/ --ext .ts,.mjs,.cjs",
77
77
  "bench": "vitest bench",
78
78
  "test": "vitest --typecheck",
@@ -85,13 +85,14 @@
85
85
  },
86
86
  "prettier": "@webdeveric/prettier-config",
87
87
  "devDependencies": {
88
- "@commitlint/config-conventional": "^20.5.0",
88
+ "@commitlint/config-conventional": "^20.5.3",
89
89
  "@commitlint/types": "^20.5.0",
90
90
  "@types/node": "^24.12.2",
91
- "@vitest/coverage-v8": "^4.1.4",
91
+ "@typescript/native-preview": "7.0.0-dev.20260502.1",
92
+ "@vitest/coverage-v8": "^4.1.5",
92
93
  "@webdeveric/eslint-config-ts": "^0.12.0",
93
94
  "@webdeveric/prettier-config": "^0.4.0",
94
- "commitlint": "^20.5.0",
95
+ "commitlint": "^20.5.3",
95
96
  "commitlint-plugin-cspell": "^0.8.0",
96
97
  "conventional-changelog-conventionalcommits": "^9.3.1",
97
98
  "cspell": "^10.0.0",
@@ -100,13 +101,12 @@
100
101
  "eslint-import-resolver-typescript": "^4.4.4",
101
102
  "eslint-plugin-import": "^2.32.0",
102
103
  "husky": "^9.1.7",
103
- "jsdom": "^29.0.2",
104
+ "jsdom": "^29.1.1",
104
105
  "lint-staged": "^16.4.0",
105
106
  "prettier": "^3.8.3",
106
107
  "rimraf": "^6.1.3",
107
108
  "semantic-release": "^25.0.3",
108
- "typescript": "^6.0.3",
109
- "validate-package-exports": "^0.23.0",
110
- "vitest": "^4.1.4"
109
+ "validate-package-exports": "^0.24.0",
110
+ "vitest": "^4.1.5"
111
111
  }
112
112
  }