Skip to content

Commit c681a73

Browse files
committed
docs: update md files
1 parent c6c0b98 commit c681a73

File tree

4 files changed

+55
-18
lines changed

4 files changed

+55
-18
lines changed

CHANGELOG.md

Lines changed: 20 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,22 @@
1+
# @sv443-network/coreutils
2+
3+
## 1.0.0
4+
5+
This is the initial release of CoreUtils. Most features have been originally ported from [version 9.4.1 of `@sv443-network/userutils`](https://github.com/Sv443-Network/UserUtils/tree/v9.4.1)
6+
Parts of the code have been overhauled, and some features have been added:
17
- Additions:
2-
- array:
3-
- Added `takeRandomItemIndex()`
4-
- BREAKING CHANGES:
8+
- Added [`capitalize()`](https://github.com/Sv443-Network/CoreUtils/blob/main/docs.md#function-capitalize) to capitalize the first letter of a string.
9+
- Added [`setImmediateInterval()`](https://github.com/Sv443-Network/CoreUtils/blob/main/docs.md#function-setimmediateinterval) to set an interval that runs immediately, then again on a fixed *interval.*
10+
- Added [`setImmediateTimeoutLoop()`](https://github.com/Sv443-Network/CoreUtils/blob/main/docs.md#function-setimmediatetimeoutloop) to set a recursive `setTimeout()` loop with a fixed *delay.*
11+
- Added [`takeRandomItemIndex()`](https://github.com/Sv443-Network/CoreUtils/blob/main/docs.md#function-takerandomitemindex), as a mutating counterpart to [`randomItemIndex()`](https://github.com/Sv443-Network/CoreUtils/blob/main/docs.md#function-randomitemindex)
12+
- Added [`truncStr()`](https://github.com/Sv443-Network/CoreUtils/blob/main/docs.md#function-truncstr) to truncate a string to a given length, optionally adding an ellipsis.
13+
- Added [`valsWithin()`](https://github.com/Sv443-Network/CoreUtils/blob/main/docs.md#function-valswithin) to check if two values, rounded at the given decimal, are within a certain range of each other.
14+
- **BREAKING CHANGES:**
515
- Reworked DataStore
6-
- Encoding with `deflate-raw` will now be enabled by default. Set `compressionFormat: null` to disable it.
7-
- Added `DataStoreEngine` base class to create a persistent storage engine
8-
- Added `FileStorageEngine` for file-based storage in the backend and `BrowserStorageEngine` for browser API based storage
9-
- The global key `__ds_fmt_ver` will now contain a global version number for DataStore-internal format integrity
10-
- crypto:
11-
- renamed `ab2str()` to `abtoa()` and `str2ab()` to `atoab()` to match `btoa()` and `atob()`
16+
- The constructor now needs an `engine` property that is an instance of a [`DataStoreEngine`](https://github.com/Sv443-Network/CoreUtils/blob/main/docs.md#class-datastoreengine.)
17+
- Encoding with `deflate-raw` will now be enabled by default. Set `compressionFormat: null` to disable it and restore the previous behavior.
18+
- Added [`DataStoreEngine` class](https://github.com/Sv443-Network/CoreUtils/blob/main/docs.md#class-datastoreengine) with two implementations available out-of-the-box; [`FileStorageEngine`](https://github.com/Sv443-Network/CoreUtils/blob/main/docs.md#class-filestorageengine) and [`BrowserStorageEngine`](https://github.com/Sv443-Network/CoreUtils/blob/main/docs.md#class-browserstorageengine), for Node/Deno and browser environments respectively. Userscripts need to use [`BrowserStorageEngine`.](https://github.com/Sv443-Network/CoreUtils/blob/main/docs.md#class-browserstorageengine)
19+
- Added shorthand property `compressionFormat` as an alternative to the properties `encodeData` and `decodeData`
20+
- The global key `__ds_fmt_ver` will now contain a global version number for DataStore-internal format integrity.
21+
- Renamed `ab2str()` to `abtoa()` and `str2ab()` to `atoab()` to match `btoa()` and `atob()`
22+
- Renamed `purifyObj()` to `pureObj()`

README.md

Lines changed: 33 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,10 @@
1-
> [!IMPORTANT]
2-
> This library is not ready to be used yet. Please check back in a couple weeks.
3-
4-
<br><br>
5-
61
<div align="center" style="text-align: center;">
72

83
# CoreUtils
94
Cross-platform, general-purpose, JavaScript core library for Node, Deno and the browser.
105
Intended to be used in conjunction with [`@sv443-network/userutils`](https://github.com/Sv443-Network/UserUtils) and [`@sv443-network/djsutils`](https://github.com/Sv443-Network/DJSUtils), but can be used independently as well.
116

12-
### [Documentation](./docs.md#readme) &bull; [Features](#features) &bull; [Installation](#installation) &bull; [License](#license)
7+
### [Documentation](./docs.md#readme) &bull; [Features](#features) &bull; [Installation](#installation) &bull; [License](#license) &bull; [Changelog](./CHANGELOG.md)
138

149
</div>
1510
<br>
@@ -138,4 +133,35 @@ pnpm i @sv443-network/coreutils
138133
yarn add @sv443-network/coreutils
139134
npx jsr install @sv443-network/coreutils
140135
deno add jsr:@sv443-network/coreutils
141-
```
136+
```
137+
- If you are in a DOM environment, you can include the UMD bundle using your favorite CDN:
138+
```html
139+
<script src="https://cdn.jsdelivr.net/npm/@sv443-network/coreutils@latest/dist/CoreUtils.min.umd.js"></script>
140+
<script src="https://unpkg.com/@sv443-network/coreutils@latest/dist/CoreUtils.min.umd.js"></script>
141+
<script src="https://esm.sh/@sv443-network/coreutils@latest/dist/CoreUtils.min.umd.js"></script>
142+
```
143+
- Then, import parts of the library as needed:
144+
```ts
145+
// >> EcmaScript Modules (ESM):
146+
147+
// - import parts of the library:
148+
import { randomItem } from "@sv443-network/coreutils";
149+
// - or import the full library:
150+
import * as CoreUtils from "@sv443-network/coreutils";
151+
// - or import raw TS files, after installing via JSR:
152+
import { DataStore } from "jsr:@sv443-network/coreutils/lib/DataStore.ts";
153+
154+
// >> CommonJS (CJS):
155+
156+
// - import parts of the library:
157+
const { debounce } = require("@sv443-network/coreutils");
158+
// - or import the full library:
159+
const CoreUtils = require("@sv443-network/coreutils");
160+
161+
// >> Universal Module Definition (UMD):
162+
163+
// - to make the global variable `CoreUtils` available, import this file:
164+
// "@sv443-network/coreutils/dist/CoreUtils.min.umd.js"
165+
// - or import the library on your HTML page:
166+
// <script src="https://cdn.jsdelivr.net/npm/@sv443-network/coreutils@latest/dist/CoreUtils.min.umd.js"></script>
167+
```

docs.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1399,7 +1399,7 @@ const engine = new FileStorageEngine(options?: FileStorageEngineOptions);
13991399
14001400
Storage engine for the [`DataStore` class](#class-datastore) that uses a file to store data.
14011401
1402-
⚠️ Requires Node.js or Deno with Node compatibility
1402+
⚠️ Requires Node.js or Deno with Node compatibility (v1.31+)
14031403
⚠️ Don't reuse this engine across multiple [`DataStore`](#class-datastore) instances
14041404
14051405
<details><summary>Example - click to view</summary>

jsr.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
{
22
"$schema": "https://jsr.io/schema/config-file.v1.json",
33
"name": "@sv443-network/coreutils",
4-
"version": "0.0.1",
4+
"version": "1.0.0",
55
"exports": {
66
".": "./lib/index.ts"
77
},

0 commit comments

Comments
 (0)