@stryke/hash 0.7.1 → 0.7.2

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.
@@ -15,5 +15,5 @@ async function hashFiles(i, s) {
15
15
  })), (0, _hash.hash)(t, s);
16
16
  }
17
17
  async function hashDirectory(i, s = {}) {
18
- return s.ignored = s.ignored ?? ["**/node_modules/**", "**/.git/**", "**/.nx/**", "**/.cache/**", "**/tmp/**"], hashFiles(await (0, _listFiles.listFiles)(i, s), s);
18
+ return s.ignored = s.ignored ?? ["**/node_modules/**", "**/.git/**", "**/.nx/**", "**/.cache/**", "**/.storm/**", "**/tmp/**"], hashFiles(await (0, _listFiles.listFiles)(i, s), s);
19
19
  }
@@ -1 +1 @@
1
- import{listFiles as e}from"@stryke/fs/files/list-files";import{readFile as o}from"@stryke/fs/files/read-file";import{hash as n}from"./hash";export async function hashFiles(i,s){const t={};return await Promise.all(i.map(async r=>{t[r]=await o(r)})),n(t,s)}export async function hashDirectory(i,s={}){return s.ignored=s.ignored??["**/node_modules/**","**/.git/**","**/.nx/**","**/.cache/**","**/tmp/**"],hashFiles(await e(i,s),s)}
1
+ import{listFiles as e}from"@stryke/fs/files/list-files";import{readFile as o}from"@stryke/fs/files/read-file";import{hash as n}from"./hash";export async function hashFiles(i,s){const t={};return await Promise.all(i.map(async r=>{t[r]=await o(r)})),n(t,s)}export async function hashDirectory(i,s={}){return s.ignored=s.ignored??["**/node_modules/**","**/.git/**","**/.nx/**","**/.cache/**","**/.storm/**","**/tmp/**"],hashFiles(await e(i,s),s)}
@@ -46,15 +46,15 @@ function p(t) {
46
46
  const n = Object.prototype.toString.call(e);
47
47
  let a = "";
48
48
  const y = n.length;
49
- y < 10 ? a = "unknown:[" + n + "]" : a = n.slice(8, y - 1), a = a.toLowerCase();
49
+ y < 10 ? a = `unknown:[${n}]` : a = n.slice(8, y - 1), a = a.toLowerCase();
50
50
  let l = null;
51
- if ((l = u.get(e)) === void 0) u.set(e, u.size);else return this.dispatch("[CIRCULAR:" + l + "]");
51
+ if ((l = u.get(e)) === void 0) u.set(e, u.size);else return this.dispatch(`[CIRCULAR:${l}]`);
52
52
  if (typeof Buffer < "u" && Buffer.isBuffer && Buffer.isBuffer(e)) return r("buffer:"), r(e.toString("utf8"));
53
53
  if (a !== "object" && a !== "function" && a !== "asyncfunction") this[a] ? this[a](e) : t.ignoreUnknown || this.unknown(e, a);else {
54
54
  let i = Object.keys(e);
55
55
  t.unorderedObjects && (i = i.sort());
56
56
  let c = [];
57
- t.respectType !== !1 && !g(e) && (c = b), t.excludeKeys && (i = i.filter(s => !t.excludeKeys(s)), c = c.filter(s => !t.excludeKeys(s))), r("object:" + (i.length + c.length) + ":");
57
+ t.respectType !== !1 && !g(e) && (c = b), t.excludeKeys && (i = i.filter(s => !t.excludeKeys(s)), c = c.filter(s => !t.excludeKeys(s))), r(`object:${i.length + c.length}:`);
58
58
  const d = s => {
59
59
  this.dispatch(s), r(":"), t.excludeValues || this.dispatch(e[s]), r(",");
60
60
  };
@@ -63,7 +63,7 @@ function p(t) {
63
63
  }
64
64
  },
65
65
  array(e, n) {
66
- if (n = n === void 0 ? t.unorderedArrays !== !1 : n, r("array:" + e.length + ":"), !n || e.length <= 1) {
66
+ if (n = n === void 0 ? t.unorderedArrays !== !1 : n, r(`array:${e.length}:`), !n || e.length <= 1) {
67
67
  for (const l of e) this.dispatch(l);
68
68
  return;
69
69
  }
@@ -77,31 +77,31 @@ function p(t) {
77
77
  return u = a, y.sort(), this.array(y, !1);
78
78
  },
79
79
  date(e) {
80
- return r("date:" + e.toJSON());
80
+ return r(`date:${e.toJSON()}`);
81
81
  },
82
82
  symbol(e) {
83
- return r("symbol:" + e.toString());
83
+ return r(`symbol:${e.toString()}`);
84
84
  },
85
85
  unknown(e, n) {
86
86
  if (r(n), !!e && (r(":"), e && typeof e.entries == "function")) return this.array(Array.from(e.entries()), !0);
87
87
  },
88
88
  error(e) {
89
- return r("error:" + e.toString());
89
+ return r(`error:${e.toString()}`);
90
90
  },
91
91
  boolean(e) {
92
- return r("bool:" + e);
92
+ return r(`bool:${e}`);
93
93
  },
94
94
  string(e) {
95
- r("string:" + e.length + ":"), r(e);
95
+ r(`string:${e.length}:`), r(e);
96
96
  },
97
97
  function(e) {
98
- r("fn:"), g(e) ? this.dispatch("[native]") : this.dispatch(e.toString()), t.respectFunctionNames !== !1 && this.dispatch("function-name:" + String(e.name)), t.respectFunctionProperties && this.object(e);
98
+ r("fn:"), g(e) ? this.dispatch("[native]") : this.dispatch(e.toString()), t.respectFunctionNames !== !1 && this.dispatch(`function-name:${String(e.name)}`), t.respectFunctionProperties && this.object(e);
99
99
  },
100
100
  number(e) {
101
- return r("number:" + e);
101
+ return r(`number:${e}`);
102
102
  },
103
103
  xml(e) {
104
- return r("xml:" + e.toString());
104
+ return r(`xml:${e.toString()}`);
105
105
  },
106
106
  null() {
107
107
  return r("Null");
@@ -110,7 +110,7 @@ function p(t) {
110
110
  return r("Undefined");
111
111
  },
112
112
  regexp(e) {
113
- return r("regex:" + e.toString());
113
+ return r(`regex:${e.toString()}`);
114
114
  },
115
115
  uint8array(e) {
116
116
  return r("uint8array:"), this.dispatch(Array.prototype.slice.call(e));
@@ -143,7 +143,7 @@ function p(t) {
143
143
  return r("arraybuffer:"), this.dispatch(new Uint8Array(e));
144
144
  },
145
145
  url(e) {
146
- return r("url:" + e.toString());
146
+ return r(`url:${e.toString()}`);
147
147
  },
148
148
  map(e) {
149
149
  r("map:");
@@ -168,7 +168,7 @@ Use "options.replacer" or "options.ignoreUnknown"
168
168
  return r("domwindow");
169
169
  },
170
170
  bigint(e) {
171
- return r("bigint:" + e.toString());
171
+ return r(`bigint:${e.toString()}`);
172
172
  },
173
173
  process() {
174
174
  return r("process");
@@ -1,3 +1,3 @@
1
- const f=Object.freeze({ignoreUnknown:!1,respectType:!1,respectFunctionNames:!1,respectFunctionProperties:!1,unorderedObjects:!0,unorderedArrays:!1,unorderedSets:!1,excludeKeys:void 0,excludeValues:void 0,replacer:void 0});export function hashObject(t,o){o?o={...f,...o}:o=f;const u=p(o);return u.dispatch(t),u.toString()}const b=Object.freeze(["prototype","__proto__","constructor"]);function p(t){let o="",u=new Map;const r=e=>{o+=e};return{toString(){return o},getContext(){return u},dispatch(e){return t.replacer&&(e=t.replacer(e)),this[e===null?"null":typeof e](e)},object(e){if(e&&typeof e.toJSON=="function")return this.object(e.toJSON());const n=Object.prototype.toString.call(e);let a="";const y=n.length;y<10?a="unknown:["+n+"]":a=n.slice(8,y-1),a=a.toLowerCase();let l=null;if((l=u.get(e))===void 0)u.set(e,u.size);else return this.dispatch("[CIRCULAR:"+l+"]");if(typeof Buffer<"u"&&Buffer.isBuffer&&Buffer.isBuffer(e))return r("buffer:"),r(e.toString("utf8"));if(a!=="object"&&a!=="function"&&a!=="asyncfunction")this[a]?this[a](e):t.ignoreUnknown||this.unknown(e,a);else{let i=Object.keys(e);t.unorderedObjects&&(i=i.sort());let c=[];t.respectType!==!1&&!g(e)&&(c=b),t.excludeKeys&&(i=i.filter(s=>!t.excludeKeys(s)),c=c.filter(s=>!t.excludeKeys(s))),r("object:"+(i.length+c.length)+":");const d=s=>{this.dispatch(s),r(":"),t.excludeValues||this.dispatch(e[s]),r(",")};for(const s of i)d(s);for(const s of c)d(s)}},array(e,n){if(n=n===void 0?t.unorderedArrays!==!1:n,r("array:"+e.length+":"),!n||e.length<=1){for(const l of e)this.dispatch(l);return}const a=new Map,y=e.map(l=>{const i=p(t);i.dispatch(l);for(const[c,d]of i.getContext())a.set(c,d);return i.toString()});return u=a,y.sort(),this.array(y,!1)},date(e){return r("date:"+e.toJSON())},symbol(e){return r("symbol:"+e.toString())},unknown(e,n){if(r(n),!!e&&(r(":"),e&&typeof e.entries=="function"))return this.array(Array.from(e.entries()),!0)},error(e){return r("error:"+e.toString())},boolean(e){return r("bool:"+e)},string(e){r("string:"+e.length+":"),r(e)},function(e){r("fn:"),g(e)?this.dispatch("[native]"):this.dispatch(e.toString()),t.respectFunctionNames!==!1&&this.dispatch("function-name:"+String(e.name)),t.respectFunctionProperties&&this.object(e)},number(e){return r("number:"+e)},xml(e){return r("xml:"+e.toString())},null(){return r("Null")},undefined(){return r("Undefined")},regexp(e){return r("regex:"+e.toString())},uint8array(e){return r("uint8array:"),this.dispatch(Array.prototype.slice.call(e))},uint8clampedarray(e){return r("uint8clampedarray:"),this.dispatch(Array.prototype.slice.call(e))},int8array(e){return r("int8array:"),this.dispatch(Array.prototype.slice.call(e))},uint16array(e){return r("uint16array:"),this.dispatch(Array.prototype.slice.call(e))},int16array(e){return r("int16array:"),this.dispatch(Array.prototype.slice.call(e))},uint32array(e){return r("uint32array:"),this.dispatch(Array.prototype.slice.call(e))},int32array(e){return r("int32array:"),this.dispatch(Array.prototype.slice.call(e))},float32array(e){return r("float32array:"),this.dispatch(Array.prototype.slice.call(e))},float64array(e){return r("float64array:"),this.dispatch(Array.prototype.slice.call(e))},arraybuffer(e){return r("arraybuffer:"),this.dispatch(new Uint8Array(e))},url(e){return r("url:"+e.toString())},map(e){r("map:");const n=[...e];return this.array(n,t.unorderedSets!==!1)},set(e){r("set:");const n=[...e];return this.array(n,t.unorderedSets!==!1)},file(e){return r("file:"),this.dispatch([e.name,e.size,e.type,e.lastModfied])},blob(){if(t.ignoreUnknown)return r("[blob]");throw new Error(`Hashing Blob objects is currently not supported
1
+ const f=Object.freeze({ignoreUnknown:!1,respectType:!1,respectFunctionNames:!1,respectFunctionProperties:!1,unorderedObjects:!0,unorderedArrays:!1,unorderedSets:!1,excludeKeys:void 0,excludeValues:void 0,replacer:void 0});export function hashObject(t,o){o?o={...f,...o}:o=f;const u=p(o);return u.dispatch(t),u.toString()}const b=Object.freeze(["prototype","__proto__","constructor"]);function p(t){let o="",u=new Map;const r=e=>{o+=e};return{toString(){return o},getContext(){return u},dispatch(e){return t.replacer&&(e=t.replacer(e)),this[e===null?"null":typeof e](e)},object(e){if(e&&typeof e.toJSON=="function")return this.object(e.toJSON());const n=Object.prototype.toString.call(e);let a="";const y=n.length;y<10?a=`unknown:[${n}]`:a=n.slice(8,y-1),a=a.toLowerCase();let l=null;if((l=u.get(e))===void 0)u.set(e,u.size);else return this.dispatch(`[CIRCULAR:${l}]`);if(typeof Buffer<"u"&&Buffer.isBuffer&&Buffer.isBuffer(e))return r("buffer:"),r(e.toString("utf8"));if(a!=="object"&&a!=="function"&&a!=="asyncfunction")this[a]?this[a](e):t.ignoreUnknown||this.unknown(e,a);else{let i=Object.keys(e);t.unorderedObjects&&(i=i.sort());let c=[];t.respectType!==!1&&!g(e)&&(c=b),t.excludeKeys&&(i=i.filter(s=>!t.excludeKeys(s)),c=c.filter(s=>!t.excludeKeys(s))),r(`object:${i.length+c.length}:`);const d=s=>{this.dispatch(s),r(":"),t.excludeValues||this.dispatch(e[s]),r(",")};for(const s of i)d(s);for(const s of c)d(s)}},array(e,n){if(n=n===void 0?t.unorderedArrays!==!1:n,r(`array:${e.length}:`),!n||e.length<=1){for(const l of e)this.dispatch(l);return}const a=new Map,y=e.map(l=>{const i=p(t);i.dispatch(l);for(const[c,d]of i.getContext())a.set(c,d);return i.toString()});return u=a,y.sort(),this.array(y,!1)},date(e){return r(`date:${e.toJSON()}`)},symbol(e){return r(`symbol:${e.toString()}`)},unknown(e,n){if(r(n),!!e&&(r(":"),e&&typeof e.entries=="function"))return this.array(Array.from(e.entries()),!0)},error(e){return r(`error:${e.toString()}`)},boolean(e){return r(`bool:${e}`)},string(e){r(`string:${e.length}:`),r(e)},function(e){r("fn:"),g(e)?this.dispatch("[native]"):this.dispatch(e.toString()),t.respectFunctionNames!==!1&&this.dispatch(`function-name:${String(e.name)}`),t.respectFunctionProperties&&this.object(e)},number(e){return r(`number:${e}`)},xml(e){return r(`xml:${e.toString()}`)},null(){return r("Null")},undefined(){return r("Undefined")},regexp(e){return r(`regex:${e.toString()}`)},uint8array(e){return r("uint8array:"),this.dispatch(Array.prototype.slice.call(e))},uint8clampedarray(e){return r("uint8clampedarray:"),this.dispatch(Array.prototype.slice.call(e))},int8array(e){return r("int8array:"),this.dispatch(Array.prototype.slice.call(e))},uint16array(e){return r("uint16array:"),this.dispatch(Array.prototype.slice.call(e))},int16array(e){return r("int16array:"),this.dispatch(Array.prototype.slice.call(e))},uint32array(e){return r("uint32array:"),this.dispatch(Array.prototype.slice.call(e))},int32array(e){return r("int32array:"),this.dispatch(Array.prototype.slice.call(e))},float32array(e){return r("float32array:"),this.dispatch(Array.prototype.slice.call(e))},float64array(e){return r("float64array:"),this.dispatch(Array.prototype.slice.call(e))},arraybuffer(e){return r("arraybuffer:"),this.dispatch(new Uint8Array(e))},url(e){return r(`url:${e.toString()}`)},map(e){r("map:");const n=[...e];return this.array(n,t.unorderedSets!==!1)},set(e){r("set:");const n=[...e];return this.array(n,t.unorderedSets!==!1)},file(e){return r("file:"),this.dispatch([e.name,e.size,e.type,e.lastModfied])},blob(){if(t.ignoreUnknown)return r("[blob]");throw new Error(`Hashing Blob objects is currently not supported
2
2
  Use "options.replacer" or "options.ignoreUnknown"
3
- `)},domwindow(){return r("domwindow")},bigint(e){return r("bigint:"+e.toString())},process(){return r("process")},timer(){return r("timer")},pipe(){return r("pipe")},tcp(){return r("tcp")},udp(){return r("udp")},tty(){return r("tty")},statwatcher(){return r("statwatcher")},securecontext(){return r("securecontext")},connection(){return r("connection")},zlib(){return r("zlib")},context(){return r("context")},nodescript(){return r("nodescript")},httpparser(){return r("httpparser")},dataview(){return r("dataview")},signal(){return r("signal")},fsevent(){return r("fsevent")},tlswrap(){return r("tlswrap")}}}const h="[native code] }",w=h.length;function g(t){return typeof t!="function"?!1:Function.prototype.toString.call(t).slice(-w)===h}
3
+ `)},domwindow(){return r("domwindow")},bigint(e){return r(`bigint:${e.toString()}`)},process(){return r("process")},timer(){return r("timer")},pipe(){return r("pipe")},tcp(){return r("tcp")},udp(){return r("udp")},tty(){return r("tty")},statwatcher(){return r("statwatcher")},securecontext(){return r("securecontext")},connection(){return r("connection")},zlib(){return r("zlib")},context(){return r("context")},nodescript(){return r("nodescript")},httpparser(){return r("httpparser")},dataview(){return r("dataview")},signal(){return r("signal")},fsevent(){return r("fsevent")},tlswrap(){return r("tlswrap")}}}const h="[native code] }",w=h.length;function g(t){return typeof t!="function"?!1:Function.prototype.toString.call(t).slice(-w)===h}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@stryke/hash",
3
- "version": "0.7.1",
3
+ "version": "0.7.2",
4
4
  "type": "module",
5
5
  "description": "A package containing utility functions that hash data using various algorithms.",
6
6
  "repository": {
@@ -11,7 +11,7 @@
11
11
  "private": false,
12
12
  "dependencies": {
13
13
  "js-xxhash": "^4.0.0",
14
- "@stryke/fs": ">=0.8.0",
14
+ "@stryke/fs": ">=0.9.1",
15
15
  "@stryke/types": ">=0.5.1"
16
16
  },
17
17
  "publishConfig": { "access": "public" },
@@ -28,7 +28,6 @@
28
28
  "stryke",
29
29
  "typescript",
30
30
  "utilities",
31
- "storm-stack",
32
31
  "storm-software",
33
32
  "storm",
34
33
  "storm-ops",