litus 1.3.1 → 1.4.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/README.md +10 -12
- package/dist/cjs/arr/chunk.js +2 -2
- package/dist/cjs/arr/chunk.js.map +1 -1
- package/dist/cjs/arr/range.js +3 -3
- package/dist/cjs/arr/range.js.map +1 -1
- package/dist/cjs/arr/transpose.js +3 -0
- package/dist/cjs/arr/transpose.js.map +1 -1
- package/dist/cjs/arr/types.d.ts +1 -1
- package/dist/cjs/index.d.ts +2 -0
- package/dist/cjs/index.js +3 -1
- package/dist/cjs/index.js.map +1 -1
- package/dist/cjs/math/calc.d.ts +0 -2
- package/dist/cjs/math/calc.js +1 -1
- package/dist/cjs/math/calc.js.map +1 -1
- package/dist/cjs/math/mod.d.ts +1 -1
- package/dist/cjs/math/mod.js +4 -3
- package/dist/cjs/math/mod.js.map +1 -1
- package/dist/cjs/math/pow.d.ts +1 -1
- package/dist/cjs/math/pow.js +2 -4
- package/dist/cjs/math/pow.js.map +1 -1
- package/dist/cjs/str/_words.d.ts +1 -0
- package/dist/cjs/str/_words.js +13 -0
- package/dist/cjs/str/_words.js.map +1 -0
- package/dist/cjs/str/camel.d.ts +1 -0
- package/dist/cjs/str/camel.js +15 -0
- package/dist/cjs/str/camel.js.map +1 -0
- package/dist/cjs/str/capitalize.d.ts +1 -0
- package/dist/cjs/str/capitalize.js +8 -0
- package/dist/cjs/str/capitalize.js.map +1 -0
- package/dist/cjs/str/index.d.ts +7 -0
- package/dist/cjs/str/index.js +24 -0
- package/dist/cjs/str/index.js.map +1 -0
- package/dist/cjs/str/kebab.d.ts +1 -0
- package/dist/cjs/str/kebab.js +11 -0
- package/dist/cjs/str/kebab.js.map +1 -0
- package/dist/cjs/str/pascal.d.ts +1 -0
- package/dist/cjs/str/pascal.js +10 -0
- package/dist/cjs/str/pascal.js.map +1 -0
- package/dist/cjs/str/snake.d.ts +1 -0
- package/dist/cjs/str/snake.js +11 -0
- package/dist/cjs/str/snake.js.map +1 -0
- package/dist/cjs/str/template.d.ts +1 -0
- package/dist/cjs/str/template.js +11 -0
- package/dist/cjs/str/template.js.map +1 -0
- package/dist/cjs/str/trim.d.ts +1 -0
- package/dist/cjs/str/trim.js +9 -0
- package/dist/cjs/str/trim.js.map +1 -0
- package/dist/esm/arr/chunk.js +2 -2
- package/dist/esm/arr/chunk.js.map +1 -1
- package/dist/esm/arr/range.js +3 -3
- package/dist/esm/arr/range.js.map +1 -1
- package/dist/esm/arr/transpose.js +3 -0
- package/dist/esm/arr/transpose.js.map +1 -1
- package/dist/esm/arr/types.d.ts +1 -1
- package/dist/esm/index.d.ts +2 -0
- package/dist/esm/index.js +2 -0
- package/dist/esm/index.js.map +1 -1
- package/dist/esm/math/calc.d.ts +0 -2
- package/dist/esm/math/calc.js +1 -1
- package/dist/esm/math/calc.js.map +1 -1
- package/dist/esm/math/mod.d.ts +1 -1
- package/dist/esm/math/mod.js +4 -2
- package/dist/esm/math/mod.js.map +1 -1
- package/dist/esm/math/pow.d.ts +1 -1
- package/dist/esm/math/pow.js +2 -3
- package/dist/esm/math/pow.js.map +1 -1
- package/dist/esm/str/_words.d.ts +1 -0
- package/dist/esm/str/_words.js +9 -0
- package/dist/esm/str/_words.js.map +1 -0
- package/dist/esm/str/camel.d.ts +1 -0
- package/dist/esm/str/camel.js +11 -0
- package/dist/esm/str/camel.js.map +1 -0
- package/dist/esm/str/capitalize.d.ts +1 -0
- package/dist/esm/str/capitalize.js +4 -0
- package/dist/esm/str/capitalize.js.map +1 -0
- package/dist/esm/str/index.d.ts +7 -0
- package/dist/esm/str/index.js +8 -0
- package/dist/esm/str/index.js.map +1 -0
- package/dist/esm/str/kebab.d.ts +1 -0
- package/dist/esm/str/kebab.js +7 -0
- package/dist/esm/str/kebab.js.map +1 -0
- package/dist/esm/str/pascal.d.ts +1 -0
- package/dist/esm/str/pascal.js +6 -0
- package/dist/esm/str/pascal.js.map +1 -0
- package/dist/esm/str/snake.d.ts +1 -0
- package/dist/esm/str/snake.js +7 -0
- package/dist/esm/str/snake.js.map +1 -0
- package/dist/esm/str/template.d.ts +1 -0
- package/dist/esm/str/template.js +7 -0
- package/dist/esm/str/template.js.map +1 -0
- package/dist/esm/str/trim.d.ts +1 -0
- package/dist/esm/str/trim.js +5 -0
- package/dist/esm/str/trim.js.map +1 -0
- package/package.json +9 -3
package/README.md
CHANGED
|
@@ -1,21 +1,19 @@
|
|
|
1
1
|
<div align="center">
|
|
2
2
|
<img src="https://raw.githubusercontent.com/estidlore/litus/main/Logo.svg" alt="Logo" width="80" height="80">
|
|
3
3
|
|
|
4
|
-
<h2
|
|
4
|
+
<h2>Litus</h2>
|
|
5
5
|
|
|
6
|
-
<p
|
|
7
|
-
|
|
8
|
-
<br />
|
|
9
|
-
<a href="https://github.com/estidlore/litus/issues">Report Bug</a>
|
|
10
|
-
</p>
|
|
6
|
+
<p>Lightweight and powerful utils for Typescript with smart type inference</p>
|
|
7
|
+
<a href="https://github.com/estidlore/litus/blob/main/docs/docs.md">Docs</a>
|
|
11
8
|
</div>
|
|
12
9
|
|
|
13
10
|
Litus provides strongly-typed utils for:
|
|
14
11
|
|
|
15
|
-
-
|
|
16
|
-
-
|
|
17
|
-
-
|
|
18
|
-
-
|
|
12
|
+
- Arrays
|
|
13
|
+
- Functions
|
|
14
|
+
- Math
|
|
15
|
+
- Objects
|
|
16
|
+
- Strings
|
|
19
17
|
|
|
20
18
|
## Why Litus?
|
|
21
19
|
|
|
@@ -54,11 +52,11 @@ var _ = require("litus");
|
|
|
54
52
|
**Import only what you need**
|
|
55
53
|
|
|
56
54
|
```ts
|
|
57
|
-
import { arr, func, math, obj } from "litus";
|
|
55
|
+
import { arr, func, math, obj, str } from "litus";
|
|
58
56
|
```
|
|
59
57
|
|
|
60
58
|
```ts
|
|
61
|
-
import { aprox, copy, group, memo } from "litus";
|
|
59
|
+
import { aprox, copy, group, memo, template } from "litus";
|
|
62
60
|
```
|
|
63
61
|
|
|
64
62
|
## Contributing
|
package/dist/cjs/arr/chunk.js
CHANGED
|
@@ -3,8 +3,8 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
3
3
|
exports.chunk = void 0;
|
|
4
4
|
const range_1 = require("./range");
|
|
5
5
|
const chunk = (arr, size) => {
|
|
6
|
-
if (size
|
|
7
|
-
throw new Error("
|
|
6
|
+
if (!Number.isInteger(size)) {
|
|
7
|
+
throw new Error("Chunk size must be an integer");
|
|
8
8
|
}
|
|
9
9
|
return (0, range_1.range)(0, arr.length, size).map((i) => arr.slice(i, i + size));
|
|
10
10
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"chunk.js","sourceRoot":"","sources":["../../../src/arr/chunk.ts"],"names":[],"mappings":";;;AAAA,mCAAgC;AAEzB,MAAM,KAAK,GAAG,CAAI,GAAQ,EAAE,IAAY,EAAS,EAAE;IACxD,IAAI,
|
|
1
|
+
{"version":3,"file":"chunk.js","sourceRoot":"","sources":["../../../src/arr/chunk.ts"],"names":[],"mappings":";;;AAAA,mCAAgC;AAEzB,MAAM,KAAK,GAAG,CAAI,GAAQ,EAAE,IAAY,EAAS,EAAE;IACxD,IAAI,CAAC,MAAM,CAAC,SAAS,CAAC,IAAI,CAAC,EAAE;QAC3B,MAAM,IAAI,KAAK,CAAC,+BAA+B,CAAC,CAAC;KAClD;IACD,OAAO,IAAA,aAAK,EAAC,CAAC,EAAE,GAAG,CAAC,MAAM,EAAE,IAAI,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,GAAG,CAAC,KAAK,CAAC,CAAC,EAAE,CAAC,GAAG,IAAI,CAAC,CAAC,CAAC;AACvE,CAAC,CAAC;AALW,QAAA,KAAK,SAKhB"}
|
package/dist/cjs/arr/range.js
CHANGED
|
@@ -3,10 +3,10 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
3
3
|
exports.range = void 0;
|
|
4
4
|
const from_1 = require("./from");
|
|
5
5
|
const range = (a, b, step = 1) => {
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
throw Error("Invalid range");
|
|
6
|
+
if (step === 0) {
|
|
7
|
+
throw new Error("Step cannot be 0");
|
|
9
8
|
}
|
|
9
|
+
const n = Math.ceil((b - a) / step);
|
|
10
10
|
return (0, from_1.from)(n, (i) => a + step * i);
|
|
11
11
|
};
|
|
12
12
|
exports.range = range;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"range.js","sourceRoot":"","sources":["../../../src/arr/range.ts"],"names":[],"mappings":";;;AAAA,iCAA8B;AAEvB,MAAM,KAAK,GAAG,CAAC,CAAS,EAAE,CAAS,EAAE,IAAI,GAAG,CAAC,EAAY,EAAE;IAChE,
|
|
1
|
+
{"version":3,"file":"range.js","sourceRoot":"","sources":["../../../src/arr/range.ts"],"names":[],"mappings":";;;AAAA,iCAA8B;AAEvB,MAAM,KAAK,GAAG,CAAC,CAAS,EAAE,CAAS,EAAE,IAAI,GAAG,CAAC,EAAY,EAAE;IAChE,IAAI,IAAI,KAAK,CAAC,EAAE;QACd,MAAM,IAAI,KAAK,CAAC,kBAAkB,CAAC,CAAC;KACrC;IACD,MAAM,CAAC,GAAG,IAAI,CAAC,IAAI,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC,GAAG,IAAI,CAAC,CAAC;IACpC,OAAO,IAAA,WAAI,EAAC,CAAC,EAAE,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,GAAG,IAAI,GAAG,CAAC,CAAC,CAAC;AACtC,CAAC,CAAC;AANW,QAAA,KAAK,SAMhB"}
|
|
@@ -5,6 +5,9 @@ const from_1 = require("./from");
|
|
|
5
5
|
const transpose = (matrix) => {
|
|
6
6
|
const rows = matrix.length;
|
|
7
7
|
const cols = matrix[0].length;
|
|
8
|
+
if (matrix.some((row) => row.length !== cols)) {
|
|
9
|
+
throw new Error("Invalid matrix. Rows have different size");
|
|
10
|
+
}
|
|
8
11
|
const res = (0, from_1.from)(cols, (i) => (0, from_1.from)(rows, (j) => matrix[j][i]));
|
|
9
12
|
return res;
|
|
10
13
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"transpose.js","sourceRoot":"","sources":["../../../src/arr/transpose.ts"],"names":[],"mappings":";;;AAAA,iCAA8B;AAGvB,MAAM,SAAS,GAAG,CAAwB,MAAS,EAAgB,EAAE;IAC1E,MAAM,IAAI,GAAG,MAAM,CAAC,MAAM,CAAC;IAC3B,MAAM,IAAI,GAAG,MAAM,CAAC,CAAC,CAAC,CAAC,MAAM,CAAC;IAC9B,MAAM,GAAG,GAAG,IAAA,WAAI,EAAC,IAAI,EAAE,CAAC,CAAC,EAAE,EAAE,CAAC,IAAA,WAAI,EAAC,IAAI,EAAE,CAAC,CAAC,EAAE,EAAE,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC;IAC/D,OAAO,GAA8B,CAAC;AACxC,CAAC,CAAC;
|
|
1
|
+
{"version":3,"file":"transpose.js","sourceRoot":"","sources":["../../../src/arr/transpose.ts"],"names":[],"mappings":";;;AAAA,iCAA8B;AAGvB,MAAM,SAAS,GAAG,CAAwB,MAAS,EAAgB,EAAE;IAC1E,MAAM,IAAI,GAAG,MAAM,CAAC,MAAM,CAAC;IAC3B,MAAM,IAAI,GAAG,MAAM,CAAC,CAAC,CAAC,CAAC,MAAM,CAAC;IAC9B,IAAI,MAAM,CAAC,IAAI,CAAC,CAAC,GAAG,EAAE,EAAE,CAAC,GAAG,CAAC,MAAM,KAAK,IAAI,CAAC,EAAE;QAC7C,MAAM,IAAI,KAAK,CAAC,0CAA0C,CAAC,CAAC;KAC7D;IACD,MAAM,GAAG,GAAG,IAAA,WAAI,EAAC,IAAI,EAAE,CAAC,CAAC,EAAE,EAAE,CAAC,IAAA,WAAI,EAAC,IAAI,EAAE,CAAC,CAAC,EAAE,EAAE,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC;IAC/D,OAAO,GAA8B,CAAC;AACxC,CAAC,CAAC;AARW,QAAA,SAAS,aAQpB"}
|
package/dist/cjs/arr/types.d.ts
CHANGED
|
@@ -5,7 +5,7 @@ type Transpose<T extends unknown[][]> = T[number] extends infer U ? {
|
|
|
5
5
|
};
|
|
6
6
|
} : never;
|
|
7
7
|
type Tuple<T, N extends number, R extends T[] = []> = R["length"] extends N ? R : Tuple<T, N, [...R, T]>;
|
|
8
|
-
type ConvertTuple<T, ToType> = {
|
|
8
|
+
type ConvertTuple<T extends unknown[], ToType> = {
|
|
9
9
|
[K in keyof T]: ToType;
|
|
10
10
|
};
|
|
11
11
|
export type { ConvertTuple, Predicate, Transpose, Tuple };
|
package/dist/cjs/index.d.ts
CHANGED
|
@@ -2,10 +2,12 @@ export * as arr from "./arr";
|
|
|
2
2
|
export * as func from "./func";
|
|
3
3
|
export * as math from "./math";
|
|
4
4
|
export * as obj from "./obj";
|
|
5
|
+
export * as str from "./str";
|
|
5
6
|
export * from "./arr";
|
|
6
7
|
export * from "./func";
|
|
7
8
|
export * from "./math";
|
|
8
9
|
export * from "./obj";
|
|
10
|
+
export * from "./str";
|
|
9
11
|
export * from "./arr/types";
|
|
10
12
|
export * from "./obj/types";
|
|
11
13
|
export * from "./time";
|
package/dist/cjs/index.js
CHANGED
|
@@ -26,15 +26,17 @@ var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
|
26
26
|
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
27
27
|
};
|
|
28
28
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
29
|
-
exports.obj = exports.math = exports.func = exports.arr = void 0;
|
|
29
|
+
exports.str = exports.obj = exports.math = exports.func = exports.arr = void 0;
|
|
30
30
|
exports.arr = __importStar(require("./arr"));
|
|
31
31
|
exports.func = __importStar(require("./func"));
|
|
32
32
|
exports.math = __importStar(require("./math"));
|
|
33
33
|
exports.obj = __importStar(require("./obj"));
|
|
34
|
+
exports.str = __importStar(require("./str"));
|
|
34
35
|
__exportStar(require("./arr"), exports);
|
|
35
36
|
__exportStar(require("./func"), exports);
|
|
36
37
|
__exportStar(require("./math"), exports);
|
|
37
38
|
__exportStar(require("./obj"), exports);
|
|
39
|
+
__exportStar(require("./str"), exports);
|
|
38
40
|
__exportStar(require("./arr/types"), exports);
|
|
39
41
|
__exportStar(require("./obj/types"), exports);
|
|
40
42
|
__exportStar(require("./time"), exports);
|
package/dist/cjs/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,6CAA6B;AAC7B,+CAA+B;AAC/B,+CAA+B;AAC/B,6CAA6B;AAC7B,wCAAsB;AACtB,yCAAuB;AACvB,yCAAuB;AACvB,wCAAsB;AACtB,8CAA4B;AAC5B,8CAA4B;AAC5B,yCAAuB;AACvB,+CAA6B;AAC7B,0CAAwB"}
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,6CAA6B;AAC7B,+CAA+B;AAC/B,+CAA+B;AAC/B,6CAA6B;AAC7B,6CAA6B;AAC7B,wCAAsB;AACtB,yCAAuB;AACvB,yCAAuB;AACvB,wCAAsB;AACtB,wCAAsB;AACtB,8CAA4B;AAC5B,8CAA4B;AAC5B,yCAAuB;AACvB,+CAA6B;AAC7B,0CAAwB"}
|
package/dist/cjs/math/calc.d.ts
CHANGED
|
@@ -1,5 +1,3 @@
|
|
|
1
1
|
import type { ConvertTuple } from "../arr/types";
|
|
2
2
|
import type { Calc, Quantity } from "./types";
|
|
3
|
-
type Q<T> = ConvertTuple<T, Quantity>;
|
|
4
3
|
export declare const calc: <T extends number[]>(opFn: (...nums: T) => number) => <A extends ConvertTuple<T, Quantity>>(...q: A) => Calc<A>;
|
|
5
|
-
export {};
|
package/dist/cjs/math/calc.js
CHANGED
|
@@ -11,7 +11,7 @@ const calc = (opFn) => {
|
|
|
11
11
|
}
|
|
12
12
|
const size = vectors[0].length;
|
|
13
13
|
if (vectors.some((v) => v.length !== size)) {
|
|
14
|
-
throw Error("All vectors must have same length");
|
|
14
|
+
throw new Error("All vectors must have same length");
|
|
15
15
|
}
|
|
16
16
|
return (0, from_1.from)(size, (i) => {
|
|
17
17
|
const input = arr.map((el) => (typeof el === "number" ? el : el[i]));
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"calc.js","sourceRoot":"","sources":["../../../src/math/calc.ts"],"names":[],"mappings":";;;AAAA,oCAAiC;AAEjC,2CAAwC;
|
|
1
|
+
{"version":3,"file":"calc.js","sourceRoot":"","sources":["../../../src/math/calc.ts"],"names":[],"mappings":";;;AAAA,oCAAiC;AAEjC,2CAAwC;AAIjC,MAAM,IAAI,GAAG,CAClB,IAA4B,EACiC,EAAE;IAC/D,OAAO,IAAA,iBAAO,EAAC,CAAsC,GAAM,EAAE,EAAE;QAC7D,MAAM,OAAO,GAAG,GAAG,CAAC,MAAM,CAAC,CAAC,EAAE,EAAE,EAAE,CAAC,OAAO,EAAE,KAAK,QAAQ,CAAe,CAAC;QACzE,IAAI,OAAO,CAAC,MAAM,KAAK,CAAC,EAAE;YACxB,OAAO,IAAI,CAAC,KAAK,CAAC,SAAS,EAAE,GAAmB,CAAY,CAAC;SAC9D;QACD,MAAM,IAAI,GAAG,OAAO,CAAC,CAAC,CAAC,CAAC,MAAM,CAAC;QAC/B,IAAI,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,MAAM,KAAK,IAAI,CAAC,EAAE;YAC1C,MAAM,IAAI,KAAK,CAAC,mCAAmC,CAAC,CAAC;SACtD;QACD,OAAO,IAAA,WAAI,EAAC,IAAI,EAAE,CAAC,CAAC,EAAE,EAAE;YACtB,MAAM,KAAK,GAAG,GAAG,CAAC,GAAG,CAAC,CAAC,EAAE,EAAE,EAAE,CAAC,CAAC,OAAO,EAAE,KAAK,QAAQ,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC;YACrE,OAAO,IAAI,CAAC,KAAK,CAAC,SAAS,EAAE,KAAU,CAAC,CAAC;QAC3C,CAAC,CAAY,CAAC;IAChB,CAAC,CAAC,CAAC;AACL,CAAC,CAAC;AAjBW,QAAA,IAAI,QAiBf"}
|
package/dist/cjs/math/mod.d.ts
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export declare const mod:
|
|
1
|
+
export declare const mod: <A extends [x: import("./types").Quantity, modulo: import("./types").Quantity]>(...q: A) => import("./types").Calc<A>;
|
package/dist/cjs/math/mod.js
CHANGED
|
@@ -1,8 +1,9 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.mod = void 0;
|
|
4
|
-
const
|
|
4
|
+
const calc_1 = require("./calc");
|
|
5
|
+
exports.mod = (0, calc_1.calc)((x, modulo) => {
|
|
6
|
+
const m = Math.abs(modulo);
|
|
5
7
|
return ((x % m) + m) % m;
|
|
6
|
-
};
|
|
7
|
-
exports.mod = mod;
|
|
8
|
+
});
|
|
8
9
|
//# sourceMappingURL=mod.js.map
|
package/dist/cjs/math/mod.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"mod.js","sourceRoot":"","sources":["../../../src/math/mod.ts"],"names":[],"mappings":";;;
|
|
1
|
+
{"version":3,"file":"mod.js","sourceRoot":"","sources":["../../../src/math/mod.ts"],"names":[],"mappings":";;;AAAA,iCAA8B;AAEjB,QAAA,GAAG,GAAG,IAAA,WAAI,EAAC,CAAC,CAAC,EAAE,MAAM,EAAE,EAAE;IACpC,MAAM,CAAC,GAAG,IAAI,CAAC,GAAG,CAAC,MAAM,CAAC,CAAC;IAC3B,OAAO,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC,GAAG,CAAC,CAAC,GAAG,CAAC,CAAC;AAC3B,CAAC,CAAC,CAAC"}
|
package/dist/cjs/math/pow.d.ts
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export declare const pow:
|
|
1
|
+
export declare const pow: <A extends [base: import("./types").Quantity, exp: import("./types").Quantity]>(...q: A) => import("./types").Calc<A>;
|
package/dist/cjs/math/pow.js
CHANGED
|
@@ -1,8 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.pow = void 0;
|
|
4
|
-
const
|
|
5
|
-
|
|
6
|
-
};
|
|
7
|
-
exports.pow = pow;
|
|
4
|
+
const calc_1 = require("./calc");
|
|
5
|
+
exports.pow = (0, calc_1.calc)((base, exp) => Math.pow(base, exp));
|
|
8
6
|
//# sourceMappingURL=pow.js.map
|
package/dist/cjs/math/pow.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"pow.js","sourceRoot":"","sources":["../../../src/math/pow.ts"],"names":[],"mappings":";;;
|
|
1
|
+
{"version":3,"file":"pow.js","sourceRoot":"","sources":["../../../src/math/pow.ts"],"names":[],"mappings":";;;AAAA,iCAA8B;AAEjB,QAAA,GAAG,GAAG,IAAA,WAAI,EAAC,CAAC,IAAI,EAAE,GAAG,EAAE,EAAE,CAAC,IAAI,CAAC,GAAG,CAAC,IAAI,EAAE,GAAG,CAAC,CAAC,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare const words: (str: string) => string[];
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.words = void 0;
|
|
4
|
+
const words = (str) => {
|
|
5
|
+
return str
|
|
6
|
+
.replace(/([a-z])([A-Z])/g, "$1 $2")
|
|
7
|
+
.replace(/([A-Z])([A-Z][a-z])/g, "$1 $2")
|
|
8
|
+
.replace(/([0-9]+)/g, " $1 ")
|
|
9
|
+
.split(/[_-\s]+/)
|
|
10
|
+
.filter(Boolean);
|
|
11
|
+
};
|
|
12
|
+
exports.words = words;
|
|
13
|
+
//# sourceMappingURL=_words.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"_words.js","sourceRoot":"","sources":["../../../src/str/_words.ts"],"names":[],"mappings":";;;AAAO,MAAM,KAAK,GAAG,CAAC,GAAW,EAAY,EAAE;IAC7C,OAAO,GAAG;SACP,OAAO,CAAC,iBAAiB,EAAE,OAAO,CAAC;SACnC,OAAO,CAAC,sBAAsB,EAAE,OAAO,CAAC;SACxC,OAAO,CAAC,WAAW,EAAE,MAAM,CAAC;SAC5B,KAAK,CAAC,SAAS,CAAC;SAChB,MAAM,CAAC,OAAO,CAAC,CAAC;AACrB,CAAC,CAAC;AAPW,QAAA,KAAK,SAOhB"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare const camel: (str: string) => string;
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.camel = void 0;
|
|
4
|
+
const _words_1 = require("./_words");
|
|
5
|
+
const capitalize_1 = require("./capitalize");
|
|
6
|
+
const camel = (str) => {
|
|
7
|
+
const w = (0, _words_1.words)(str).map(capitalize_1.capitalize);
|
|
8
|
+
if (w.length === 0) {
|
|
9
|
+
return "";
|
|
10
|
+
}
|
|
11
|
+
w[0] = w[0].toLowerCase();
|
|
12
|
+
return w.join("");
|
|
13
|
+
};
|
|
14
|
+
exports.camel = camel;
|
|
15
|
+
//# sourceMappingURL=camel.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"camel.js","sourceRoot":"","sources":["../../../src/str/camel.ts"],"names":[],"mappings":";;;AAAA,qCAAiC;AACjC,6CAA0C;AAEnC,MAAM,KAAK,GAAG,CAAC,GAAW,EAAU,EAAE;IAC3C,MAAM,CAAC,GAAG,IAAA,cAAK,EAAC,GAAG,CAAC,CAAC,GAAG,CAAC,uBAAU,CAAC,CAAC;IACrC,IAAI,CAAC,CAAC,MAAM,KAAK,CAAC,EAAE;QAClB,OAAO,EAAE,CAAC;KACX;IACD,CAAC,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,CAAC,WAAW,EAAE,CAAC;IAC1B,OAAO,CAAC,CAAC,IAAI,CAAC,EAAE,CAAC,CAAC;AACpB,CAAC,CAAC;AAPW,QAAA,KAAK,SAOhB"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare const capitalize: (str: string) => string;
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.capitalize = void 0;
|
|
4
|
+
const capitalize = (str) => {
|
|
5
|
+
return str.charAt(0).toUpperCase() + str.slice(1).toLowerCase();
|
|
6
|
+
};
|
|
7
|
+
exports.capitalize = capitalize;
|
|
8
|
+
//# sourceMappingURL=capitalize.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"capitalize.js","sourceRoot":"","sources":["../../../src/str/capitalize.ts"],"names":[],"mappings":";;;AAAO,MAAM,UAAU,GAAG,CAAC,GAAW,EAAU,EAAE;IAChD,OAAO,GAAG,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC,WAAW,EAAE,GAAG,GAAG,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,WAAW,EAAE,CAAC;AAClE,CAAC,CAAC;AAFW,QAAA,UAAU,cAErB"}
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
14
|
+
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
15
|
+
};
|
|
16
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
+
__exportStar(require("./camel"), exports);
|
|
18
|
+
__exportStar(require("./capitalize"), exports);
|
|
19
|
+
__exportStar(require("./kebab"), exports);
|
|
20
|
+
__exportStar(require("./pascal"), exports);
|
|
21
|
+
__exportStar(require("./snake"), exports);
|
|
22
|
+
__exportStar(require("./template"), exports);
|
|
23
|
+
__exportStar(require("./trim"), exports);
|
|
24
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/str/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,0CAAwB;AACxB,+CAA6B;AAC7B,0CAAwB;AACxB,2CAAyB;AACzB,0CAAwB;AACxB,6CAA2B;AAC3B,yCAAuB"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare const kebab: (str: string) => string;
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.kebab = void 0;
|
|
4
|
+
const _words_1 = require("./_words");
|
|
5
|
+
const kebab = (str) => {
|
|
6
|
+
return (0, _words_1.words)(str)
|
|
7
|
+
.map((str) => str.toLowerCase())
|
|
8
|
+
.join("-");
|
|
9
|
+
};
|
|
10
|
+
exports.kebab = kebab;
|
|
11
|
+
//# sourceMappingURL=kebab.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"kebab.js","sourceRoot":"","sources":["../../../src/str/kebab.ts"],"names":[],"mappings":";;;AAAA,qCAAiC;AAE1B,MAAM,KAAK,GAAG,CAAC,GAAW,EAAU,EAAE;IAC3C,OAAO,IAAA,cAAK,EAAC,GAAG,CAAC;SACd,GAAG,CAAC,CAAC,GAAG,EAAE,EAAE,CAAC,GAAG,CAAC,WAAW,EAAE,CAAC;SAC/B,IAAI,CAAC,GAAG,CAAC,CAAC;AACf,CAAC,CAAC;AAJW,QAAA,KAAK,SAIhB"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare const pascal: (str: string) => string;
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.pascal = void 0;
|
|
4
|
+
const _words_1 = require("./_words");
|
|
5
|
+
const capitalize_1 = require("./capitalize");
|
|
6
|
+
const pascal = (str) => {
|
|
7
|
+
return (0, _words_1.words)(str).map(capitalize_1.capitalize).join("");
|
|
8
|
+
};
|
|
9
|
+
exports.pascal = pascal;
|
|
10
|
+
//# sourceMappingURL=pascal.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"pascal.js","sourceRoot":"","sources":["../../../src/str/pascal.ts"],"names":[],"mappings":";;;AAAA,qCAAiC;AACjC,6CAA0C;AAEnC,MAAM,MAAM,GAAG,CAAC,GAAW,EAAU,EAAE;IAC5C,OAAO,IAAA,cAAK,EAAC,GAAG,CAAC,CAAC,GAAG,CAAC,uBAAU,CAAC,CAAC,IAAI,CAAC,EAAE,CAAC,CAAC;AAC7C,CAAC,CAAC;AAFW,QAAA,MAAM,UAEjB"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare const snake: (str: string) => string;
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.snake = void 0;
|
|
4
|
+
const _words_1 = require("./_words");
|
|
5
|
+
const snake = (str) => {
|
|
6
|
+
return (0, _words_1.words)(str)
|
|
7
|
+
.map((str) => str.toLowerCase())
|
|
8
|
+
.join("_");
|
|
9
|
+
};
|
|
10
|
+
exports.snake = snake;
|
|
11
|
+
//# sourceMappingURL=snake.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"snake.js","sourceRoot":"","sources":["../../../src/str/snake.ts"],"names":[],"mappings":";;;AAAA,qCAAiC;AAE1B,MAAM,KAAK,GAAG,CAAC,GAAW,EAAU,EAAE;IAC3C,OAAO,IAAA,cAAK,EAAC,GAAG,CAAC;SACd,GAAG,CAAC,CAAC,GAAG,EAAE,EAAE,CAAC,GAAG,CAAC,WAAW,EAAE,CAAC;SAC/B,IAAI,CAAC,GAAG,CAAC,CAAC;AACf,CAAC,CAAC;AAJW,QAAA,KAAK,SAIhB"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare const template: (str: string, data: object) => string;
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.template = void 0;
|
|
4
|
+
const get_1 = require("../obj/get");
|
|
5
|
+
const template = (str, data) => {
|
|
6
|
+
return str.replace(/\{\{([a-zA-Z0-9._]+)\}\}/g, (_, path) => {
|
|
7
|
+
return (0, get_1.get)(data, path, "");
|
|
8
|
+
});
|
|
9
|
+
};
|
|
10
|
+
exports.template = template;
|
|
11
|
+
//# sourceMappingURL=template.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"template.js","sourceRoot":"","sources":["../../../src/str/template.ts"],"names":[],"mappings":";;;AAAA,kCAA+B;AAExB,MAAM,QAAQ,GAAG,CAAC,GAAW,EAAE,IAAY,EAAU,EAAE;IAC5D,OAAO,GAAG,CAAC,OAAO,CAAC,2BAA2B,EAAE,CAAC,CAAC,EAAE,IAAY,EAAE,EAAE;QAClE,OAAO,IAAA,SAAG,EAAC,IAAI,EAAE,IAAI,EAAE,EAAE,CAAC,CAAC;IAC7B,CAAC,CAAC,CAAC;AACL,CAAC,CAAC;AAJW,QAAA,QAAQ,YAInB"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare const trim: (str: string, chars?: string) => string;
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.trim = void 0;
|
|
4
|
+
const trim = (str, chars = " ") => {
|
|
5
|
+
const reg = new RegExp(`^[${chars}]+|[${chars}]+$`, "g");
|
|
6
|
+
return str.replace(reg, "");
|
|
7
|
+
};
|
|
8
|
+
exports.trim = trim;
|
|
9
|
+
//# sourceMappingURL=trim.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"trim.js","sourceRoot":"","sources":["../../../src/str/trim.ts"],"names":[],"mappings":";;;AAAO,MAAM,IAAI,GAAG,CAAC,GAAW,EAAE,KAAK,GAAG,GAAG,EAAU,EAAE;IACvD,MAAM,GAAG,GAAG,IAAI,MAAM,CAAC,KAAK,KAAK,OAAO,KAAK,KAAK,EAAE,GAAG,CAAC,CAAC;IACzD,OAAO,GAAG,CAAC,OAAO,CAAC,GAAG,EAAE,EAAE,CAAC,CAAC;AAC9B,CAAC,CAAC;AAHW,QAAA,IAAI,QAGf"}
|
package/dist/esm/arr/chunk.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { range } from "./range";
|
|
2
2
|
export const chunk = (arr, size) => {
|
|
3
|
-
if (size
|
|
4
|
-
throw new Error("
|
|
3
|
+
if (!Number.isInteger(size)) {
|
|
4
|
+
throw new Error("Chunk size must be an integer");
|
|
5
5
|
}
|
|
6
6
|
return range(0, arr.length, size).map((i) => arr.slice(i, i + size));
|
|
7
7
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"chunk.js","sourceRoot":"","sources":["../../../src/arr/chunk.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,EAAE,MAAM,SAAS,CAAC;AAEhC,MAAM,CAAC,MAAM,KAAK,GAAG,CAAI,GAAQ,EAAE,IAAY,EAAS,EAAE;IACxD,IAAI,
|
|
1
|
+
{"version":3,"file":"chunk.js","sourceRoot":"","sources":["../../../src/arr/chunk.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,EAAE,MAAM,SAAS,CAAC;AAEhC,MAAM,CAAC,MAAM,KAAK,GAAG,CAAI,GAAQ,EAAE,IAAY,EAAS,EAAE;IACxD,IAAI,CAAC,MAAM,CAAC,SAAS,CAAC,IAAI,CAAC,EAAE;QAC3B,MAAM,IAAI,KAAK,CAAC,+BAA+B,CAAC,CAAC;KAClD;IACD,OAAO,KAAK,CAAC,CAAC,EAAE,GAAG,CAAC,MAAM,EAAE,IAAI,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,GAAG,CAAC,KAAK,CAAC,CAAC,EAAE,CAAC,GAAG,IAAI,CAAC,CAAC,CAAC;AACvE,CAAC,CAAC"}
|
package/dist/esm/arr/range.js
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import { from } from "./from";
|
|
2
2
|
export const range = (a, b, step = 1) => {
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
throw Error("Invalid range");
|
|
3
|
+
if (step === 0) {
|
|
4
|
+
throw new Error("Step cannot be 0");
|
|
6
5
|
}
|
|
6
|
+
const n = Math.ceil((b - a) / step);
|
|
7
7
|
return from(n, (i) => a + step * i);
|
|
8
8
|
};
|
|
9
9
|
//# sourceMappingURL=range.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"range.js","sourceRoot":"","sources":["../../../src/arr/range.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,IAAI,EAAE,MAAM,QAAQ,CAAC;AAE9B,MAAM,CAAC,MAAM,KAAK,GAAG,CAAC,CAAS,EAAE,CAAS,EAAE,IAAI,GAAG,CAAC,EAAY,EAAE;IAChE,
|
|
1
|
+
{"version":3,"file":"range.js","sourceRoot":"","sources":["../../../src/arr/range.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,IAAI,EAAE,MAAM,QAAQ,CAAC;AAE9B,MAAM,CAAC,MAAM,KAAK,GAAG,CAAC,CAAS,EAAE,CAAS,EAAE,IAAI,GAAG,CAAC,EAAY,EAAE;IAChE,IAAI,IAAI,KAAK,CAAC,EAAE;QACd,MAAM,IAAI,KAAK,CAAC,kBAAkB,CAAC,CAAC;KACrC;IACD,MAAM,CAAC,GAAG,IAAI,CAAC,IAAI,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC,GAAG,IAAI,CAAC,CAAC;IACpC,OAAO,IAAI,CAAC,CAAC,EAAE,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,GAAG,IAAI,GAAG,CAAC,CAAC,CAAC;AACtC,CAAC,CAAC"}
|
|
@@ -2,6 +2,9 @@ import { from } from "./from";
|
|
|
2
2
|
export const transpose = (matrix) => {
|
|
3
3
|
const rows = matrix.length;
|
|
4
4
|
const cols = matrix[0].length;
|
|
5
|
+
if (matrix.some((row) => row.length !== cols)) {
|
|
6
|
+
throw new Error("Invalid matrix. Rows have different size");
|
|
7
|
+
}
|
|
5
8
|
const res = from(cols, (i) => from(rows, (j) => matrix[j][i]));
|
|
6
9
|
return res;
|
|
7
10
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"transpose.js","sourceRoot":"","sources":["../../../src/arr/transpose.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,IAAI,EAAE,MAAM,QAAQ,CAAC;AAG9B,MAAM,CAAC,MAAM,SAAS,GAAG,CAAwB,MAAS,EAAgB,EAAE;IAC1E,MAAM,IAAI,GAAG,MAAM,CAAC,MAAM,CAAC;IAC3B,MAAM,IAAI,GAAG,MAAM,CAAC,CAAC,CAAC,CAAC,MAAM,CAAC;IAC9B,MAAM,GAAG,GAAG,IAAI,CAAC,IAAI,EAAE,CAAC,CAAC,EAAE,EAAE,CAAC,IAAI,CAAC,IAAI,EAAE,CAAC,CAAC,EAAE,EAAE,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC;IAC/D,OAAO,GAA8B,CAAC;AACxC,CAAC,CAAC"}
|
|
1
|
+
{"version":3,"file":"transpose.js","sourceRoot":"","sources":["../../../src/arr/transpose.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,IAAI,EAAE,MAAM,QAAQ,CAAC;AAG9B,MAAM,CAAC,MAAM,SAAS,GAAG,CAAwB,MAAS,EAAgB,EAAE;IAC1E,MAAM,IAAI,GAAG,MAAM,CAAC,MAAM,CAAC;IAC3B,MAAM,IAAI,GAAG,MAAM,CAAC,CAAC,CAAC,CAAC,MAAM,CAAC;IAC9B,IAAI,MAAM,CAAC,IAAI,CAAC,CAAC,GAAG,EAAE,EAAE,CAAC,GAAG,CAAC,MAAM,KAAK,IAAI,CAAC,EAAE;QAC7C,MAAM,IAAI,KAAK,CAAC,0CAA0C,CAAC,CAAC;KAC7D;IACD,MAAM,GAAG,GAAG,IAAI,CAAC,IAAI,EAAE,CAAC,CAAC,EAAE,EAAE,CAAC,IAAI,CAAC,IAAI,EAAE,CAAC,CAAC,EAAE,EAAE,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC;IAC/D,OAAO,GAA8B,CAAC;AACxC,CAAC,CAAC"}
|
package/dist/esm/arr/types.d.ts
CHANGED
|
@@ -5,7 +5,7 @@ type Transpose<T extends unknown[][]> = T[number] extends infer U ? {
|
|
|
5
5
|
};
|
|
6
6
|
} : never;
|
|
7
7
|
type Tuple<T, N extends number, R extends T[] = []> = R["length"] extends N ? R : Tuple<T, N, [...R, T]>;
|
|
8
|
-
type ConvertTuple<T, ToType> = {
|
|
8
|
+
type ConvertTuple<T extends unknown[], ToType> = {
|
|
9
9
|
[K in keyof T]: ToType;
|
|
10
10
|
};
|
|
11
11
|
export type { ConvertTuple, Predicate, Transpose, Tuple };
|
package/dist/esm/index.d.ts
CHANGED
|
@@ -2,10 +2,12 @@ export * as arr from "./arr";
|
|
|
2
2
|
export * as func from "./func";
|
|
3
3
|
export * as math from "./math";
|
|
4
4
|
export * as obj from "./obj";
|
|
5
|
+
export * as str from "./str";
|
|
5
6
|
export * from "./arr";
|
|
6
7
|
export * from "./func";
|
|
7
8
|
export * from "./math";
|
|
8
9
|
export * from "./obj";
|
|
10
|
+
export * from "./str";
|
|
9
11
|
export * from "./arr/types";
|
|
10
12
|
export * from "./obj/types";
|
|
11
13
|
export * from "./time";
|
package/dist/esm/index.js
CHANGED
|
@@ -2,10 +2,12 @@ export * as arr from "./arr";
|
|
|
2
2
|
export * as func from "./func";
|
|
3
3
|
export * as math from "./math";
|
|
4
4
|
export * as obj from "./obj";
|
|
5
|
+
export * as str from "./str";
|
|
5
6
|
export * from "./arr";
|
|
6
7
|
export * from "./func";
|
|
7
8
|
export * from "./math";
|
|
8
9
|
export * from "./obj";
|
|
10
|
+
export * from "./str";
|
|
9
11
|
export * from "./arr/types";
|
|
10
12
|
export * from "./obj/types";
|
|
11
13
|
export * from "./time";
|
package/dist/esm/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,GAAG,MAAM,OAAO,CAAC;AAC7B,OAAO,KAAK,IAAI,MAAM,QAAQ,CAAC;AAC/B,OAAO,KAAK,IAAI,MAAM,QAAQ,CAAC;AAC/B,OAAO,KAAK,GAAG,MAAM,OAAO,CAAC;AAC7B,cAAc,OAAO,CAAC;AACtB,cAAc,QAAQ,CAAC;AACvB,cAAc,QAAQ,CAAC;AACvB,cAAc,OAAO,CAAC;AACtB,cAAc,aAAa,CAAC;AAC5B,cAAc,aAAa,CAAC;AAC5B,cAAc,QAAQ,CAAC;AACvB,cAAc,cAAc,CAAC;AAC7B,cAAc,SAAS,CAAC"}
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,GAAG,MAAM,OAAO,CAAC;AAC7B,OAAO,KAAK,IAAI,MAAM,QAAQ,CAAC;AAC/B,OAAO,KAAK,IAAI,MAAM,QAAQ,CAAC;AAC/B,OAAO,KAAK,GAAG,MAAM,OAAO,CAAC;AAC7B,OAAO,KAAK,GAAG,MAAM,OAAO,CAAC;AAC7B,cAAc,OAAO,CAAC;AACtB,cAAc,QAAQ,CAAC;AACvB,cAAc,QAAQ,CAAC;AACvB,cAAc,OAAO,CAAC;AACtB,cAAc,OAAO,CAAC;AACtB,cAAc,aAAa,CAAC;AAC5B,cAAc,aAAa,CAAC;AAC5B,cAAc,QAAQ,CAAC;AACvB,cAAc,cAAc,CAAC;AAC7B,cAAc,SAAS,CAAC"}
|
package/dist/esm/math/calc.d.ts
CHANGED
|
@@ -1,5 +1,3 @@
|
|
|
1
1
|
import type { ConvertTuple } from "../arr/types";
|
|
2
2
|
import type { Calc, Quantity } from "./types";
|
|
3
|
-
type Q<T> = ConvertTuple<T, Quantity>;
|
|
4
3
|
export declare const calc: <T extends number[]>(opFn: (...nums: T) => number) => <A extends ConvertTuple<T, Quantity>>(...q: A) => Calc<A>;
|
|
5
|
-
export {};
|
package/dist/esm/math/calc.js
CHANGED
|
@@ -8,7 +8,7 @@ export const calc = (opFn) => {
|
|
|
8
8
|
}
|
|
9
9
|
const size = vectors[0].length;
|
|
10
10
|
if (vectors.some((v) => v.length !== size)) {
|
|
11
|
-
throw Error("All vectors must have same length");
|
|
11
|
+
throw new Error("All vectors must have same length");
|
|
12
12
|
}
|
|
13
13
|
return from(size, (i) => {
|
|
14
14
|
const input = arr.map((el) => (typeof el === "number" ? el : el[i]));
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"calc.js","sourceRoot":"","sources":["../../../src/math/calc.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,IAAI,EAAE,MAAM,WAAW,CAAC;AAEjC,OAAO,EAAE,OAAO,EAAE,MAAM,eAAe,CAAC;
|
|
1
|
+
{"version":3,"file":"calc.js","sourceRoot":"","sources":["../../../src/math/calc.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,IAAI,EAAE,MAAM,WAAW,CAAC;AAEjC,OAAO,EAAE,OAAO,EAAE,MAAM,eAAe,CAAC;AAIxC,MAAM,CAAC,MAAM,IAAI,GAAG,CAClB,IAA4B,EACiC,EAAE;IAC/D,OAAO,OAAO,CAAC,CAAsC,GAAM,EAAE,EAAE;QAC7D,MAAM,OAAO,GAAG,GAAG,CAAC,MAAM,CAAC,CAAC,EAAE,EAAE,EAAE,CAAC,OAAO,EAAE,KAAK,QAAQ,CAAe,CAAC;QACzE,IAAI,OAAO,CAAC,MAAM,KAAK,CAAC,EAAE;YACxB,OAAO,IAAI,CAAC,KAAK,CAAC,SAAS,EAAE,GAAmB,CAAY,CAAC;SAC9D;QACD,MAAM,IAAI,GAAG,OAAO,CAAC,CAAC,CAAC,CAAC,MAAM,CAAC;QAC/B,IAAI,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,MAAM,KAAK,IAAI,CAAC,EAAE;YAC1C,MAAM,IAAI,KAAK,CAAC,mCAAmC,CAAC,CAAC;SACtD;QACD,OAAO,IAAI,CAAC,IAAI,EAAE,CAAC,CAAC,EAAE,EAAE;YACtB,MAAM,KAAK,GAAG,GAAG,CAAC,GAAG,CAAC,CAAC,EAAE,EAAE,EAAE,CAAC,CAAC,OAAO,EAAE,KAAK,QAAQ,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC;YACrE,OAAO,IAAI,CAAC,KAAK,CAAC,SAAS,EAAE,KAAU,CAAC,CAAC;QAC3C,CAAC,CAAY,CAAC;IAChB,CAAC,CAAC,CAAC;AACL,CAAC,CAAC"}
|
package/dist/esm/math/mod.d.ts
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export declare const mod:
|
|
1
|
+
export declare const mod: <A extends [x: import("./types").Quantity, modulo: import("./types").Quantity]>(...q: A) => import("./types").Calc<A>;
|
package/dist/esm/math/mod.js
CHANGED
package/dist/esm/math/mod.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"mod.js","sourceRoot":"","sources":["../../../src/math/mod.ts"],"names":[],"mappings":"AAAA,MAAM,CAAC,MAAM,GAAG,GAAG,CAAC,
|
|
1
|
+
{"version":3,"file":"mod.js","sourceRoot":"","sources":["../../../src/math/mod.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,IAAI,EAAE,MAAM,QAAQ,CAAC;AAE9B,MAAM,CAAC,MAAM,GAAG,GAAG,IAAI,CAAC,CAAC,CAAC,EAAE,MAAM,EAAE,EAAE;IACpC,MAAM,CAAC,GAAG,IAAI,CAAC,GAAG,CAAC,MAAM,CAAC,CAAC;IAC3B,OAAO,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC,GAAG,CAAC,CAAC,GAAG,CAAC,CAAC;AAC3B,CAAC,CAAC,CAAC"}
|
package/dist/esm/math/pow.d.ts
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export declare const pow:
|
|
1
|
+
export declare const pow: <A extends [base: import("./types").Quantity, exp: import("./types").Quantity]>(...q: A) => import("./types").Calc<A>;
|
package/dist/esm/math/pow.js
CHANGED
package/dist/esm/math/pow.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"pow.js","sourceRoot":"","sources":["../../../src/math/pow.ts"],"names":[],"mappings":"AAAA,
|
|
1
|
+
{"version":3,"file":"pow.js","sourceRoot":"","sources":["../../../src/math/pow.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,IAAI,EAAE,MAAM,QAAQ,CAAC;AAE9B,MAAM,CAAC,MAAM,GAAG,GAAG,IAAI,CAAC,CAAC,IAAI,EAAE,GAAG,EAAE,EAAE,CAAC,IAAI,CAAC,GAAG,CAAC,IAAI,EAAE,GAAG,CAAC,CAAC,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare const words: (str: string) => string[];
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"_words.js","sourceRoot":"","sources":["../../../src/str/_words.ts"],"names":[],"mappings":"AAAA,MAAM,CAAC,MAAM,KAAK,GAAG,CAAC,GAAW,EAAY,EAAE;IAC7C,OAAO,GAAG;SACP,OAAO,CAAC,iBAAiB,EAAE,OAAO,CAAC;SACnC,OAAO,CAAC,sBAAsB,EAAE,OAAO,CAAC;SACxC,OAAO,CAAC,WAAW,EAAE,MAAM,CAAC;SAC5B,KAAK,CAAC,SAAS,CAAC;SAChB,MAAM,CAAC,OAAO,CAAC,CAAC;AACrB,CAAC,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare const camel: (str: string) => string;
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { words } from "./_words";
|
|
2
|
+
import { capitalize } from "./capitalize";
|
|
3
|
+
export const camel = (str) => {
|
|
4
|
+
const w = words(str).map(capitalize);
|
|
5
|
+
if (w.length === 0) {
|
|
6
|
+
return "";
|
|
7
|
+
}
|
|
8
|
+
w[0] = w[0].toLowerCase();
|
|
9
|
+
return w.join("");
|
|
10
|
+
};
|
|
11
|
+
//# sourceMappingURL=camel.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"camel.js","sourceRoot":"","sources":["../../../src/str/camel.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,EAAE,MAAM,UAAU,CAAC;AACjC,OAAO,EAAE,UAAU,EAAE,MAAM,cAAc,CAAC;AAE1C,MAAM,CAAC,MAAM,KAAK,GAAG,CAAC,GAAW,EAAU,EAAE;IAC3C,MAAM,CAAC,GAAG,KAAK,CAAC,GAAG,CAAC,CAAC,GAAG,CAAC,UAAU,CAAC,CAAC;IACrC,IAAI,CAAC,CAAC,MAAM,KAAK,CAAC,EAAE;QAClB,OAAO,EAAE,CAAC;KACX;IACD,CAAC,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,CAAC,WAAW,EAAE,CAAC;IAC1B,OAAO,CAAC,CAAC,IAAI,CAAC,EAAE,CAAC,CAAC;AACpB,CAAC,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare const capitalize: (str: string) => string;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"capitalize.js","sourceRoot":"","sources":["../../../src/str/capitalize.ts"],"names":[],"mappings":"AAAA,MAAM,CAAC,MAAM,UAAU,GAAG,CAAC,GAAW,EAAU,EAAE;IAChD,OAAO,GAAG,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC,WAAW,EAAE,GAAG,GAAG,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,WAAW,EAAE,CAAC;AAClE,CAAC,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/str/index.ts"],"names":[],"mappings":"AAAA,cAAc,SAAS,CAAC;AACxB,cAAc,cAAc,CAAC;AAC7B,cAAc,SAAS,CAAC;AACxB,cAAc,UAAU,CAAC;AACzB,cAAc,SAAS,CAAC;AACxB,cAAc,YAAY,CAAC;AAC3B,cAAc,QAAQ,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare const kebab: (str: string) => string;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"kebab.js","sourceRoot":"","sources":["../../../src/str/kebab.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,EAAE,MAAM,UAAU,CAAC;AAEjC,MAAM,CAAC,MAAM,KAAK,GAAG,CAAC,GAAW,EAAU,EAAE;IAC3C,OAAO,KAAK,CAAC,GAAG,CAAC;SACd,GAAG,CAAC,CAAC,GAAG,EAAE,EAAE,CAAC,GAAG,CAAC,WAAW,EAAE,CAAC;SAC/B,IAAI,CAAC,GAAG,CAAC,CAAC;AACf,CAAC,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare const pascal: (str: string) => string;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"pascal.js","sourceRoot":"","sources":["../../../src/str/pascal.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,EAAE,MAAM,UAAU,CAAC;AACjC,OAAO,EAAE,UAAU,EAAE,MAAM,cAAc,CAAC;AAE1C,MAAM,CAAC,MAAM,MAAM,GAAG,CAAC,GAAW,EAAU,EAAE;IAC5C,OAAO,KAAK,CAAC,GAAG,CAAC,CAAC,GAAG,CAAC,UAAU,CAAC,CAAC,IAAI,CAAC,EAAE,CAAC,CAAC;AAC7C,CAAC,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare const snake: (str: string) => string;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"snake.js","sourceRoot":"","sources":["../../../src/str/snake.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,EAAE,MAAM,UAAU,CAAC;AAEjC,MAAM,CAAC,MAAM,KAAK,GAAG,CAAC,GAAW,EAAU,EAAE;IAC3C,OAAO,KAAK,CAAC,GAAG,CAAC;SACd,GAAG,CAAC,CAAC,GAAG,EAAE,EAAE,CAAC,GAAG,CAAC,WAAW,EAAE,CAAC;SAC/B,IAAI,CAAC,GAAG,CAAC,CAAC;AACf,CAAC,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare const template: (str: string, data: object) => string;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"template.js","sourceRoot":"","sources":["../../../src/str/template.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,GAAG,EAAE,MAAM,UAAU,CAAC;AAE/B,MAAM,CAAC,MAAM,QAAQ,GAAG,CAAC,GAAW,EAAE,IAAY,EAAU,EAAE;IAC5D,OAAO,GAAG,CAAC,OAAO,CAAC,2BAA2B,EAAE,CAAC,CAAC,EAAE,IAAY,EAAE,EAAE;QAClE,OAAO,GAAG,CAAC,IAAI,EAAE,IAAI,EAAE,EAAE,CAAC,CAAC;IAC7B,CAAC,CAAC,CAAC;AACL,CAAC,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare const trim: (str: string, chars?: string) => string;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"trim.js","sourceRoot":"","sources":["../../../src/str/trim.ts"],"names":[],"mappings":"AAAA,MAAM,CAAC,MAAM,IAAI,GAAG,CAAC,GAAW,EAAE,KAAK,GAAG,GAAG,EAAU,EAAE;IACvD,MAAM,GAAG,GAAG,IAAI,MAAM,CAAC,KAAK,KAAK,OAAO,KAAK,KAAK,EAAE,GAAG,CAAC,CAAC;IACzD,OAAO,GAAG,CAAC,OAAO,CAAC,GAAG,EAAE,EAAE,CAAC,CAAC;AAC9B,CAAC,CAAC"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "litus",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.4.0",
|
|
4
4
|
"description": "Commonly used utilities for JS and TS",
|
|
5
5
|
"author": {
|
|
6
6
|
"email": "estidlore@outlook.com",
|
|
@@ -16,12 +16,18 @@
|
|
|
16
16
|
"homepage": "https://github.com/estidlore/litus#readme",
|
|
17
17
|
"keywords": [
|
|
18
18
|
"array",
|
|
19
|
-
"date",
|
|
20
19
|
"javascript",
|
|
20
|
+
"js",
|
|
21
21
|
"math",
|
|
22
|
+
"number",
|
|
22
23
|
"object",
|
|
23
|
-
"
|
|
24
|
+
"stdlib",
|
|
25
|
+
"string",
|
|
26
|
+
"toolkit",
|
|
27
|
+
"ts",
|
|
28
|
+
"types",
|
|
24
29
|
"typescript",
|
|
30
|
+
"utilities",
|
|
25
31
|
"utils"
|
|
26
32
|
],
|
|
27
33
|
"license": "MIT",
|