@js-bits/typedef-utils
Advanced tools
Comparing version 1.0.0 to 1.0.1
{ | ||
"name": "@js-bits/typedef-utils", | ||
"version": "1.0.0", | ||
"version": "1.0.1", | ||
"description": "Utility types for TypeScript", | ||
@@ -5,0 +5,0 @@ "keywords": [ |
@@ -5,13 +5,2 @@ # Utility types for TypeScript | ||
```typescript | ||
const parse: MathUtils.Parse<'-56.78'> = -56.78; | ||
const add: MathUtils.Add<9999999, 9999999> = 19999998; | ||
const multiply: MathUtils.Multiply<78, 63> = 4914; | ||
const trim: StringUtils.Trim<' abc '> = 'abc'; | ||
const split: StringUtils.Split<'a b c', ' '> = ['a', 'b', 'c']; | ||
const length: TupleUtils.Length<[1, 2, 3, 4, 5]> = 5; | ||
const longest: TupleUtils.Longest<[1], [1, 2, 3]> = [1, 2, 3]; | ||
const append: TupleUtils.Append<[1, 2, 3, 4], 5> = [1, 2, 3, 4, 5]; | ||
``` | ||
## Installation | ||
@@ -31,4 +20,33 @@ | ||
Add `"./node_modules/@js-bits"` to `"typeRoots"` of your _tsconfig.json_, add `"typedef-utils"` to `"types"` array. | ||
## Examples | ||
String utilities: | ||
```typescript | ||
import type { Split, Trim } from '@js-bits/typedef-utils/string'; | ||
const trim: Trim<' abc '> = 'abc'; | ||
const split: Split<'a b c', ' '> = ['a', 'b', 'c']; | ||
``` | ||
Math utilities: | ||
```typescript | ||
import type { Add, Multiply, Parse } from '@js-bits/typedef-utils/math'; | ||
const parse: Parse<'-56.78'> = -56.78; | ||
const add: Add<9999999, 9999999> = 19999998; | ||
const multiply: Multiply<78, 63> = 4914; | ||
``` | ||
Tuple utilities: | ||
```typescript | ||
import type { Append, Length, Longest } from '@js-bits/typedef-utils/tuple'; | ||
const length: Length<[1, 2, 3, 4, 5]> = 5; | ||
const longest: Longest<[1], [1, 2, 3]> = [1, 2, 3]; | ||
const append: Append<[1, 2, 3, 4], 5> = [1, 2, 3, 4, 5]; | ||
``` | ||
## Documentation | ||
@@ -38,4 +56,4 @@ | ||
- [String utilities](docs/modules/string.StringUtils.md) | ||
- [Math utilities](docs/modules/math.MathUtils.md) | ||
- [Tuple utilities](docs/modules/tuple.TupleUtils.md) | ||
- [String utilities](docs/modules/string.md) | ||
- [Math utilities](docs/modules/math.md) | ||
- [Tuple utilities](docs/modules/tuple.md) |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
58585
57