@stryke/hash 0.2.4 → 0.5.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 CHANGED
@@ -1,4 +1,47 @@
1
1
  <!-- START header -->
2
+ <!-- prettier-ignore-start -->
3
+ <!-- markdownlint-disable -->
4
+
5
+
6
+ <div align="center"><img src="https://pub-761b436209f44a4d886487c917806c08.r2.dev/storm-banner.gif" width="100%" alt="Storm Software" /></div>
7
+ <br />
8
+
9
+ <div align="center">
10
+ <b>
11
+ <a href="https://stormsoftware.com" target="_blank">Website</a> •
12
+ <a href="https://github.com/storm-software/stryke" target="_blank">GitHub</a> •
13
+ <a href="https://discord.gg/MQ6YVzakM5">Discord</a> • <a href="https://stormsoftware.com/projects/stryke/docs" target="_blank">Docs</a> • <a href="https://stormsoftware.com/contact" target="_blank">Contact</a> •
14
+ <a href="https://github.com/storm-software/stryke/issues/new?assignees=&labels=bug&template=bug-report.yml&title=Bug Report%3A+">Report a Bug</a>
15
+ </b>
16
+ </div>
17
+
18
+ <br />
19
+ This package is part of Storm Software's **🌩️ Stryke** monorepo. Stryke packages TypeScript utility packages with shared functionality common to many Storm Software applications.
20
+
21
+ <br />
22
+
23
+ <h3 align="center">💻 Visit <a href="https://stormsoftware.com" target="_blank">stormsoftware.com</a> to stay up to date with this developer</h3><br />
24
+
25
+ [![Version](https://img.shields.io/badge/version-0.2.4-1fb2a6.svg?style=for-the-badge&color=1fb2a6)](https://prettier.io/)&nbsp;[![Nx](https://img.shields.io/badge/Nx-17.0.2-lightgrey?style=for-the-badge&logo=nx&logoWidth=20&&color=1fb2a6)](http://nx.dev/)&nbsp;[![NextJs](https://img.shields.io/badge/Next.js-14.0.2-lightgrey?style=for-the-badge&logo=nextdotjs&logoWidth=20&color=1fb2a6)](https://nextjs.org/)&nbsp;[![Commitizen friendly](https://img.shields.io/badge/commitizen-friendly-brightgreen.svg?style=for-the-badge&logo=commitlint&color=1fb2a6)](http://commitizen.github.io/cz-cli/)&nbsp;![Semantic-Release](https://img.shields.io/badge/%20%20%F0%9F%93%A6%F0%9F%9A%80-semantic--release-e10079.svg?style=for-the-badge&color=1fb2a6)&nbsp;[![documented with Fumadocs](https://img.shields.io/badge/documented_with-fumadocs-success.svg?style=for-the-badge&logo=readthedocs&color=1fb2a6)](https://fumadocs.vercel.app/)&nbsp;![GitHub Workflow Status (with event)](https://img.shields.io/github/actions/workflow/status/storm-software/stryke/cr.yml?style=for-the-badge&logo=github-actions&color=1fb2a6)
26
+
27
+ > [!IMPORTANT] This repository, and the apps, libraries, and tools contained
28
+ > within, is still in it's initial development phase. As a result, bugs and
29
+ > issues are expected with it's usage. When the main development phase
30
+ > completes, a proper release will be performed, the packages will be availible
31
+ > through NPM (and other distributions), and this message will be removed.
32
+ > However, in the meantime, please feel free to report any issues you may come
33
+ > across.
34
+
35
+ <div align="center">
36
+ <b>Be sure to ⭐ this repository on <a href="https://github.com/storm-software/stryke" target="_blank">GitHub</a> so you can keep up to date on any daily progress!</b>
37
+ </div>
38
+
39
+ <br />
40
+
41
+
42
+ <!-- markdownlint-restore -->
43
+ <!-- prettier-ignore-end -->
44
+
2
45
  <!-- END header -->
3
46
 
4
47
  # Stryke - Hashing Utiltites
@@ -7,6 +50,24 @@ A package containing various functions that given a certain parameter will
7
50
  generate a hash string
8
51
 
9
52
  <!-- START doctoc -->
53
+ <!-- DON'T EDIT THIS SECTION, INSTEAD RE-RUN doctoc TO UPDATE -->
54
+
55
+ ## Table of Contents
56
+
57
+ - [Installing](#installing)
58
+ - [Reduced Package Size](#reduced-package-size)
59
+ - [Development](#development)
60
+ - [Building](#building)
61
+ - [Running unit tests](#running-unit-tests)
62
+ - [Linting](#linting)
63
+ - [Storm Workspaces](#storm-workspaces)
64
+ - [Roadmap](#roadmap)
65
+ - [Support](#support)
66
+ - [License](#license)
67
+ - [Changelog](#changelog)
68
+ - [Contributing](#contributing)
69
+ - [Contributors](#contributors)
70
+
10
71
  <!-- END doctoc -->
11
72
 
12
73
  ## Installing
@@ -60,4 +121,173 @@ Run `nx test hash` to execute the unit tests via [Jest](https://jestjs.io).
60
121
  Run `nx lint hash` to run [ESLint](https://eslint.org/) on the package.
61
122
 
62
123
  <!-- START footer -->
124
+ <!-- prettier-ignore-start -->
125
+ <!-- markdownlint-disable -->
126
+
127
+
128
+ ## Storm Workspaces
129
+
130
+ Storm workspaces are built using
131
+ <a href="https://nx.dev/" target="_blank">Nx</a>, a set of extensible dev tools
132
+ for monorepos, which helps you develop like Google, Facebook, and Microsoft.
133
+ Building on top of Nx, the Open System provides a set of tools and patterns that
134
+ help you scale your monorepo to many teams while keeping the codebase
135
+ maintainable.
136
+
137
+ <div align="right">[ <a href="#table-of-contents">Back to top ▲</a> ]</div>
138
+ <br />
139
+
140
+ ## Roadmap
141
+
142
+ See the [open issues](https://github.com/storm-software/stryke/issues) for a
143
+ list of proposed features (and known issues).
144
+
145
+ - [Top Feature Requests](https://github.com/storm-software/stryke/issues?q=label%3Aenhancement+is%3Aopen+sort%3Areactions-%2B1-desc)
146
+ (Add your votes using the 👍 reaction)
147
+ - [Top Bugs](https://github.com/storm-software/stryke/issues?q=is%3Aissue+is%3Aopen+label%3Abug+sort%3Areactions-%2B1-desc)
148
+ (Add your votes using the 👍 reaction)
149
+ - [Newest Bugs](https://github.com/storm-software/stryke/issues?q=is%3Aopen+is%3Aissue+label%3Abug)
150
+
151
+ <div align="right">[ <a href="#table-of-contents">Back to top ▲</a> ]</div>
152
+ <br />
153
+
154
+ ## Support
155
+
156
+ Reach out to the maintainer at one of the following places:
157
+
158
+ - [Contact](https://stormsoftware.com/contact)
159
+ - [GitHub discussions](https://github.com/storm-software/stryke/discussions)
160
+ - <support@stormsoftware.com>
161
+
162
+ <div align="right">[ <a href="#table-of-contents">Back to top ▲</a> ]</div>
163
+ <br />
164
+
165
+ ## License
166
+
167
+ This project is licensed under the **Apache License 2.0**. Feel free to edit and
168
+ distribute this template as you like.
169
+
170
+ See [LICENSE](LICENSE) for more information.
171
+
172
+ <div align="right">[ <a href="#table-of-contents">Back to top ▲</a> ]</div>
173
+ <br />
174
+
175
+ ## Changelog
176
+
177
+ This project adheres to
178
+ [Semantic Versioning](https://semver.org/spec/v2.0.0.html). Every release, along
179
+ with the migration instructions, is documented in the [CHANGELOG](CHANGELOG.md)
180
+ file
181
+
182
+ <div align="right">[ <a href="#table-of-contents">Back to top ▲</a> ]</div>
183
+ <br />
184
+
185
+ ## Contributing
186
+
187
+ First off, thanks for taking the time to contribute! Contributions are what
188
+ makes the open-source community such an amazing place to learn, inspire, and
189
+ create. Any contributions you make will benefit everybody else and are **greatly
190
+ appreciated**.
191
+
192
+ Please try to create bug reports that are:
193
+
194
+ - _Reproducible._ Include steps to reproduce the problem.
195
+ - _Specific._ Include as much detail as possible: which version, what
196
+ environment, etc.
197
+ - _Unique._ Do not duplicate existing opened issues.
198
+ - _Scoped to a Single Bug._ One bug per report.
199
+
200
+ Please adhere to this project's [code of conduct](.github/CODE_OF_CONDUCT.md).
201
+
202
+ You can use
203
+ [markdownlint-cli](https://github.com/storm-software/stryke/markdownlint-cli) to
204
+ check for common markdown style inconsistency.
205
+
206
+ <div align="right">[ <a href="#table-of-contents">Back to top ▲</a> ]</div>
207
+ <br />
208
+
209
+ ## Contributors
210
+
211
+ Thanks goes to these wonderful people
212
+ ([emoji key](https://allcontributors.org/docs/en/emoji-key)):
213
+
214
+ <!-- ALL-CONTRIBUTORS-LIST:START - Do not remove or modify this section -->
215
+
216
+ <table>
217
+ <tbody>
218
+ <tr>
219
+ <td align="center" valign="top" width="14.28%"><a href="http://www.sullypat.com/"><img src="https://avatars.githubusercontent.com/u/99053093?v=4?s=100" width="100px;" alt="Patrick Sullivan"/><br /><sub><b>Patrick Sullivan</b></sub></a><br /><a href="#design-sullivanpj" title="Design">🎨</a> <a href="https://github.com/storm-software/stryke/commits?author=sullivanpj" title="Code">💻</a> <a href="#tool-sullivanpj" title="Tools">🔧</a> <a href="https://github.com/storm-software/stryke/commits?author=sullivanpj" title="Documentation">📖</a> <a href="https://github.com/storm-software/stryke/commits?author=sullivanpj" title="Tests">⚠️</a></td>
220
+ <td align="center" valign="top" width="14.28%"><a href="https://tylerbenning.com/"><img src="https://avatars.githubusercontent.com/u/7265547?v=4?s=100" width="100px;" alt="Tyler Benning"/><br /><sub><b>Tyler Benning</b></sub></a><br /><a href="#design-tbenning" title="Design">🎨</a></td>
221
+ <td align="center" valign="top" width="14.28%"><a href="http://stormsoftware.com"><img src="https://avatars.githubusercontent.com/u/149802440?v=4?s=100" width="100px;" alt="Stormie"/><br /><sub><b>Stormie</b></sub></a><br /><a href="#maintenance-stormie-bot" title="Maintenance">🚧</a></td>
222
+ </tr>
223
+ </tbody>
224
+ <tfoot>
225
+ <tr>
226
+ <td align="center" size="13px" colspan="7">
227
+ <img src="https://raw.githubusercontent.com/all-contributors/all-contributors-cli/1b8533af435da9854653492b1327a23a4dbd0a10/assets/logo-small.svg" alt="All Contributors">
228
+ <a href="https://all-contributors.js.org/docs/en/bot/usage">Add your contributions</a>
229
+ </img>
230
+ </td>
231
+ </tr>
232
+ </tfoot>
233
+ </table>
234
+
235
+ <!-- ALL-CONTRIBUTORS-LIST:END -->
236
+
237
+ This project follows the
238
+ [all-contributors](https://github.com/all-contributors/all-contributors)
239
+ specification. Contributions of any kind welcome!
240
+
241
+ <div align="right">[ <a href="#table-of-contents">Back to top ▲</a> ]</div>
242
+ <br />
243
+
244
+ <hr />
245
+ <br />
246
+
247
+ <div align="center">
248
+ <img src="https://pub-761b436209f44a4d886487c917806c08.r2.dev/logo-banner.png" width="100%" alt="Storm Software" />
249
+ </div>
250
+ <br />
251
+
252
+ <div align="center">
253
+ <a href="https://stormsoftware.com" target="_blank">Website</a> • <a href="https://stormsoftware.com/contact" target="_blank">Contact</a> • <a href="https://linkedin.com/in/patrick-sullivan-865526b0" target="_blank">LinkedIn</a> • <a href="https://medium.com/@pat.joseph.sullivan" target="_blank">Medium</a> • <a href="https://github.com/storm-software" target="_blank">GitHub</a> • <a href="https://keybase.io/sullivanp" target="_blank">OpenPGP Key</a>
254
+ </div>
255
+
256
+ <div align="center">
257
+ <b>Fingerprint:</b> 1BD2 7192 7770 2549 F4C9 F238 E6AD C420 DA5C 4C2D
258
+ </div>
259
+ <br />
260
+
261
+ Storm Software is an open source software development organization and creator
262
+ of Acidic, StormStack and StormCloud.
263
+
264
+ Our mission is to make software development more accessible. Our ideal future is
265
+ one where anyone can create software without years of prior development
266
+ experience serving as a barrier to entry. We hope to achieve this via LLMs,
267
+ Generative AI, and intuitive, high-level data modeling/programming languages.
268
+
269
+ Join us on [Discord](https://discord.gg/MQ6YVzakM5) to chat with the team,
270
+ receive release notifications, ask questions, and get involved.
271
+
272
+ If this sounds interesting, and you would like to help us in creating the next
273
+ generation of development tools, please reach out on our
274
+ [website](https://stormsoftware.com/contact) or join our
275
+ [Slack channel](https://join.slack.com/t/storm-software/shared_invite/zt-2gsmk04hs-i6yhK_r6urq0dkZYAwq2pA)!
276
+
277
+ <br />
278
+
279
+ <div align="center"><a href="https://stormsoftware.com" target="_blank"><img src="https://pub-761b436209f44a4d886487c917806c08.r2.dev/icon-fill.png" alt="Storm Software" width="200px"/></a></div>
280
+ <br />
281
+ <div align="center"><a href="https://stormsoftware.com" target="_blank"><img src="https://pub-761b436209f44a4d886487c917806c08.r2.dev/visit-us-text.svg" alt="Visit us at stormsoftware.com" height="90px"/></a></div>
282
+
283
+ <br />
284
+
285
+ <div align="right">[ <a href="#table-of-contents">Back to top ▲</a> ]</div>
286
+ <br />
287
+ <br />
288
+
289
+
290
+ <!-- markdownlint-restore -->
291
+ <!-- prettier-ignore-end -->
292
+
63
293
  <!-- END footer -->
@@ -0,0 +1,19 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.hashDirectory = hashDirectory;
7
+ exports.hashFiles = hashFiles;
8
+ var _promises = require("node:fs/promises");
9
+ var _listFiles = require("@stryke/fs/files/list-files");
10
+ var _hash = require("./hash.cjs");
11
+ async function hashFiles(r, s) {
12
+ const t = {};
13
+ return await Promise.all(r.map(async i => {
14
+ t[i] = await (0, _promises.readFile)(i, "utf8");
15
+ })), (0, _hash.hash)(t, s);
16
+ }
17
+ async function hashDirectory(r, s) {
18
+ return hashFiles(await (0, _listFiles.listFiles)(r), s);
19
+ }
@@ -0,0 +1,17 @@
1
+ import type { HashOptions } from "./hash";
2
+ /**
3
+ * Hash a list of file paths into a string based on the file content
4
+ *
5
+ * @param files - The list of file paths to hash
6
+ * @param options - Hashing options
7
+ * @returns A hashed string value
8
+ */
9
+ export declare function hashFiles(files: string[], options?: HashOptions): Promise<string>;
10
+ /**
11
+ * Hash a folder path into a string based on the file content
12
+ *
13
+ * @param directoryPath - The folder path to hash
14
+ * @param options - Hashing options
15
+ * @returns A hashed string value
16
+ */
17
+ export declare function hashDirectory(directoryPath: string, options?: HashOptions): Promise<string>;
@@ -0,0 +1 @@
1
+ import{readFile as o}from"node:fs/promises";import{listFiles as a}from"@stryke/fs/files/list-files";import{hash as n}from"./hash";export async function hashFiles(r,s){const t={};return await Promise.all(r.map(async i=>{t[i]=await o(i,"utf8")})),n(t,s)}export async function hashDirectory(r,s){return hashFiles(await a(r),s)}
package/dist/hash.cjs CHANGED
@@ -7,8 +7,8 @@ exports.hash = hash;
7
7
  var _isString = require("@stryke/types/type-checks/is-string");
8
8
  var _hashObject = require("./hash-object.cjs");
9
9
  var _sha = require("./sha-256.cjs");
10
- function hash(t, s) {
11
- const n = (0, _sha.sha256base64)((0, _isString.isString)(t) ? t : (0, _hashObject.hashObject)(t, s)),
12
- e = s?.maxLength ?? 32;
13
- return n.length > e ? n.slice(0, e) : n;
10
+ function hash(t, e) {
11
+ const s = (0, _sha.sha256base64)((0, _isString.isString)(t) ? t : (0, _hashObject.hashObject)(t, e)),
12
+ n = e?.maxLength ?? 32;
13
+ return s.length > n ? s.slice(0, n) : s;
14
14
  }
package/dist/hash.d.ts CHANGED
@@ -1,4 +1,4 @@
1
- import { type HashObjectOptions } from "./hash-object";
1
+ import type { HashObjectOptions } from "./hash-object";
2
2
  export interface HashOptions extends HashObjectOptions {
3
3
  /**
4
4
  * The maximum length of the hash
package/dist/hash.mjs CHANGED
@@ -1 +1 @@
1
- import{isString as r}from"@stryke/types/type-checks/is-string";import{hashObject as a}from"./hash-object";import{sha256base64 as h}from"./sha-256";export function hash(t,s){const n=h(r(t)?t:a(t,s)),e=s?.maxLength??32;return n.length>e?n.slice(0,e):n}
1
+ import{isString as r}from"@stryke/types/type-checks/is-string";import{hashObject as h}from"./hash-object";import{sha256base64 as a}from"./sha-256";export function hash(t,e){const s=a(r(t)?t:h(t,e)),n=e?.maxLength??32;return s.length>n?s.slice(0,n):s}
package/dist/index.cjs CHANGED
@@ -14,6 +14,17 @@ Object.keys(_hash).forEach(function (key) {
14
14
  }
15
15
  });
16
16
  });
17
+ var _hashFiles = require("./hash-files.cjs");
18
+ Object.keys(_hashFiles).forEach(function (key) {
19
+ if (key === "default" || key === "__esModule") return;
20
+ if (key in exports && exports[key] === _hashFiles[key]) return;
21
+ Object.defineProperty(exports, key, {
22
+ enumerable: true,
23
+ get: function () {
24
+ return _hashFiles[key];
25
+ }
26
+ });
27
+ });
17
28
  var _sha = require("./sha-256.cjs");
18
29
  Object.keys(_sha).forEach(function (key) {
19
30
  if (key === "default" || key === "__esModule") return;
package/dist/index.d.ts CHANGED
@@ -7,5 +7,6 @@
7
7
  * @packageDocumentation
8
8
  */
9
9
  export * from "./hash";
10
+ export * from "./hash-files";
10
11
  export * from "./sha-256";
11
12
  export * from "./xx-hash";
package/dist/index.mjs CHANGED
@@ -1 +1 @@
1
- export*from"./hash";export*from"./sha-256";export*from"./xx-hash";
1
+ export*from"./hash";export*from"./hash-files";export*from"./sha-256";export*from"./xx-hash";
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@stryke/hash",
3
- "version": "0.2.4",
3
+ "version": "0.5.0",
4
4
  "type": "module",
5
5
  "description": "A package containing utility functions that hash data using various algorithms.",
6
6
  "repository": {
@@ -9,7 +9,11 @@
9
9
  "directory": "packages/hash"
10
10
  },
11
11
  "private": false,
12
- "dependencies": { "js-xxhash": "^4.0.0", "@stryke/types": ">=0.2.1" },
12
+ "dependencies": {
13
+ "js-xxhash": "^4.0.0",
14
+ "@stryke/fs": ">=0.5.0",
15
+ "@stryke/types": ">=0.5.0"
16
+ },
13
17
  "publishConfig": { "access": "public" },
14
18
  "devDependencies": {},
15
19
  "sideEffects": false,
@@ -125,6 +129,20 @@
125
129
  "default": "./dist/hash-object.mjs"
126
130
  }
127
131
  },
132
+ "./hash-files": {
133
+ "import": {
134
+ "types": "./dist/hash-files.d.ts",
135
+ "default": "./dist/hash-files.mjs"
136
+ },
137
+ "require": {
138
+ "types": "./dist/hash-files.d.ts",
139
+ "default": "./dist/hash-files.cjs"
140
+ },
141
+ "default": {
142
+ "types": "./dist/hash-files.d.ts",
143
+ "default": "./dist/hash-files.mjs"
144
+ }
145
+ },
128
146
  ".": {
129
147
  "import": { "types": "./dist/index.d.ts", "default": "./dist/index.mjs" },
130
148
  "require": {