@ts-utilities/core 1.0.7 → 1.0.8
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 +12 -13
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
# @ts-
|
|
1
|
+
# @ts-utilities/core
|
|
2
2
|
|
|
3
3
|

|
|
4
4
|

|
|
@@ -7,7 +7,7 @@
|
|
|
7
7
|
|
|
8
8
|
## Description
|
|
9
9
|
|
|
10
|
-
`@ts-
|
|
10
|
+
`@ts-utilities/core` is a collection of core utility functions and advanced TypeScript types designed for JavaScript/TypeScript projects. It provides essential utilities for object manipulation, async operations, data transformation, and type-level programming. The library is built with TypeScript and is fully typed, ensuring a smooth and error-free development experience.
|
|
11
11
|
|
|
12
12
|
## Features
|
|
13
13
|
|
|
@@ -20,16 +20,16 @@
|
|
|
20
20
|
|
|
21
21
|
## Installation
|
|
22
22
|
|
|
23
|
-
You can install `@ts-
|
|
23
|
+
You can install `@ts-utilities/core` using npm or yarn:
|
|
24
24
|
|
|
25
25
|
```bash
|
|
26
|
-
npm install @ts-
|
|
26
|
+
npm install @ts-utilities/core
|
|
27
27
|
```
|
|
28
28
|
|
|
29
29
|
or
|
|
30
30
|
|
|
31
31
|
```bash
|
|
32
|
-
yarn add @ts-
|
|
32
|
+
yarn add @ts-utilities/core
|
|
33
33
|
```
|
|
34
34
|
|
|
35
35
|
## Usage
|
|
@@ -39,9 +39,8 @@ yarn add @ts-collection/core
|
|
|
39
39
|
You can import individual utilities or types as needed:
|
|
40
40
|
|
|
41
41
|
```typescript
|
|
42
|
-
import { deepmerge, poll, shield, sleep, debounce, throttle } from '@ts-
|
|
43
|
-
import {
|
|
44
|
-
import type { DeepPartial, Primitive, KeysOfType } from '@ts-collection/core/types';
|
|
42
|
+
import { deepmerge, poll, shield, sleep, debounce, throttle, getObjectValue, extendProps, hydrate } from '@ts-utilities/core';
|
|
43
|
+
import type { DeepPartial, Primitive, KeysOfType } from '@ts-utilities/core';
|
|
45
44
|
```
|
|
46
45
|
|
|
47
46
|
### Examples
|
|
@@ -49,7 +48,7 @@ import type { DeepPartial, Primitive, KeysOfType } from '@ts-collection/core/typ
|
|
|
49
48
|
#### Object Utilities
|
|
50
49
|
|
|
51
50
|
```typescript
|
|
52
|
-
import { getObjectValue, extendProps } from '@ts-
|
|
51
|
+
import { getObjectValue, extendProps } from '@ts-utilities/core';
|
|
53
52
|
|
|
54
53
|
const obj = { a: { b: { c: 1 } } };
|
|
55
54
|
const value = getObjectValue(obj, 'a.b.c'); // 1
|
|
@@ -60,7 +59,7 @@ const extended = extendProps({ a: 1 }, { b: 'hello' }); // { a: 1, b: 'hello' }
|
|
|
60
59
|
#### Data Transformation
|
|
61
60
|
|
|
62
61
|
```typescript
|
|
63
|
-
import { hydrate, deepmerge } from '@ts-
|
|
62
|
+
import { hydrate, deepmerge } from '@ts-utilities/core';
|
|
64
63
|
|
|
65
64
|
const cleaned = hydrate({ a: null, b: { c: null } }); // { a: undefined, b: { c: undefined } }
|
|
66
65
|
|
|
@@ -95,7 +94,7 @@ const combined = deepmerge(
|
|
|
95
94
|
#### Async Operations
|
|
96
95
|
|
|
97
96
|
```typescript
|
|
98
|
-
import { poll, shield, sleep } from '@ts-
|
|
97
|
+
import { poll, shield, sleep } from '@ts-utilities/core';
|
|
99
98
|
|
|
100
99
|
const result = await poll(async () => {
|
|
101
100
|
const status = await checkStatus();
|
|
@@ -108,7 +107,7 @@ const [error, data] = await shield(fetchData());
|
|
|
108
107
|
#### Debounce and Throttle
|
|
109
108
|
|
|
110
109
|
```typescript
|
|
111
|
-
import { debounce, throttle } from '@ts-
|
|
110
|
+
import { debounce, throttle } from '@ts-utilities/core';
|
|
112
111
|
|
|
113
112
|
const debouncedFunction = debounce(() => console.log('Debounced!'), 300);
|
|
114
113
|
const throttledFunction = throttle(() => console.log('Throttled!'), 300);
|
|
@@ -117,7 +116,7 @@ const throttledFunction = throttle(() => console.log('Throttled!'), 300);
|
|
|
117
116
|
#### TypeScript Types
|
|
118
117
|
|
|
119
118
|
```typescript
|
|
120
|
-
import type { DeepPartial, Nullable, KeysOfType, Primitive } from '@ts-
|
|
119
|
+
import type { DeepPartial, Nullable, KeysOfType, Primitive } from '@ts-utilities/core';
|
|
121
120
|
|
|
122
121
|
type PartialUser = DeepPartial<User>;
|
|
123
122
|
type NullableUser = Nullable<User>;
|